mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-04 13:03:37 +00:00
fix(dashboard): show a notified share past the people filter
Opening a "shared with you" notification, or a share link, while Shared was filtered to someone else picked out nothing: the item was filtered away. The filter now gives way to everyone's when it hides an item the notification or link names.
This commit is contained in:
1 parent
1d0784c13a
commit
ec261224a0
2 files changed
+37
-4
No files matched your search
@@ -5703,15 +5703,21 @@ const TabFiles = {
|
||||
* Selects the rows for the items a share link names, replacing the
|
||||
* current selection. Matched by uid — the link's `/<owner>/<uid>/<name>`
|
||||
* form carries it, and unlike the name it survives a rename. Values that
|
||||
* aren't shared paths, or items no longer shared, match nothing.
|
||||
* aren't shared paths, or items no longer shared, match nothing. A
|
||||
* people filter that hides one of the items gives way to everyone's.
|
||||
*
|
||||
* @param {string[]} sharedPaths - The link's `?shared=` values
|
||||
* @returns {void}
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
selectSharedRows (sharedPaths) {
|
||||
async selectSharedRows (sharedPaths) {
|
||||
const wanted = new Set(shared_uids_from_paths(sharedPaths));
|
||||
if ( wanted.size === 0 ) return;
|
||||
this.selectRowsWhere((row) => wanted.has(String(row.getAttribute('data-uid') ?? '').toLowerCase()));
|
||||
const uidOf = (row) => String(row.getAttribute('data-uid') ?? '').toLowerCase();
|
||||
if ( this.sharerFilter && this.currentPath === window.shared_path ) {
|
||||
const shown = new Set(this.$el_window.find('.files-tab .files .row').map((_, row) => uidOf(row)).get());
|
||||
if ( [...wanted].some((uid) => ! shown.has(uid)) ) await this.setSharerFilter(null);
|
||||
}
|
||||
this.selectRowsWhere((row) => wanted.has(uidOf(row)));
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -598,6 +598,8 @@ describe('TabFiles people filter across navigation', () => {
|
||||
TabFiles.renderingDirectory = false;
|
||||
TabFiles.trashedNames ??= new Map();
|
||||
TabFiles.sharerFilter = null;
|
||||
// jsdom has no layout to scroll.
|
||||
Element.prototype.scrollIntoView ??= () => {};
|
||||
vi.spyOn(TabFiles, 'listSharedView').mockImplementation(async () => [share('a', 'ann'), share('b', 'bob')]);
|
||||
vi.spyOn(TabFiles, 'applyColumnWidths').mockImplementation(() => {});
|
||||
vi.spyOn(TabFiles, 'renderItem').mockImplementation(async (file) => {
|
||||
@@ -620,6 +622,31 @@ describe('TabFiles people filter across navigation', () => {
|
||||
expect($('.sharer-chip.active').attr('data-sharer')).toBe('bob');
|
||||
});
|
||||
|
||||
it('gives way to show an item a share link or notification names', async () => {
|
||||
const uid = '5298098f-d8a2-41da-828f-867b9a7f0cce';
|
||||
TabFiles.listSharedView.mockImplementation(async () => [{ ...share('a', 'ann'), uid }, share('b', 'bob')]);
|
||||
await TabFiles.renderDirectory(SHARED);
|
||||
await TabFiles.setSharerFilter('bob');
|
||||
|
||||
await TabFiles.selectSharedRows([`/ann/${uid}/a`]);
|
||||
|
||||
expect(TabFiles.sharerFilter).toBeNull();
|
||||
expect(listed()).toEqual(['a', 'b']);
|
||||
expect($('.files .row.selected').attr('data-name')).toBe('a');
|
||||
});
|
||||
|
||||
it('stays put when the named item is already shown', async () => {
|
||||
const uid = '5298098f-d8a2-41da-828f-867b9a7f0cce';
|
||||
TabFiles.listSharedView.mockImplementation(async () => [share('a', 'ann'), { ...share('b', 'bob'), uid }]);
|
||||
await TabFiles.renderDirectory(SHARED);
|
||||
await TabFiles.setSharerFilter('bob');
|
||||
|
||||
await TabFiles.selectSharedRows([`/bob/${uid}/b`]);
|
||||
|
||||
expect(TabFiles.sharerFilter).toBe('bob');
|
||||
expect($('.files .row.selected').attr('data-name')).toBe('b');
|
||||
});
|
||||
|
||||
it("clears once the user goes back to their own files", async () => {
|
||||
await TabFiles.renderDirectory(SHARED);
|
||||
await TabFiles.setSharerFilter('bob');
|
||||
|
||||
Reference in new issue
Block a user