Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add a link to open a folder explorer in notification #2498

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion react/src/components/FolderExplorerOpener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const FolderExplorerOpener = () => {
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isDataViewReady]); // don't need to watch `folderId` because this used only once right after the backend-ai-data-view is ready
}, [isDataViewReady, folderId]); // don't need to watch `folderId` because this used only once right after the backend-ai-data-view is ready

return null;
};
Expand Down
44 changes: 31 additions & 13 deletions src/components/backend-ai-storage-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,13 +1109,7 @@ export default class BackendAiStorageList extends BackendAIPage {
narrowLayout
scrimClickAction
@dialog-closed=${() => {
const queryParams = new URLSearchParams(window.location.search);
queryParams.delete('folder');
window.history.replaceState(
{},
'',
`${location.pathname}${queryParams.toString().length == 0 ? '' : '?' + queryParams}`,
);
this.triggerCloseFilebrowserToReact();
}}
>
<span slot="title" style="margin-right:1rem;">${this.explorer.id}</span>
Expand Down Expand Up @@ -1769,7 +1763,9 @@ export default class BackendAiStorageList extends BackendAIPage {
class="fg blue controls-running"
icon="folder_open"
title=${_t('data.folders.OpenAFolder')}
@click="${(e) => this._folderExplorer(rowData)}"
@click="${() => {
this.triggerOpenFilebrowserToReact(rowData);
}}"
?disabled="${this._isUncontrollableStatus(
rowData.item.status,
)}"
Expand All @@ -1780,7 +1776,7 @@ export default class BackendAiStorageList extends BackendAIPage {
<div
@click="${(e) =>
!this._isUncontrollableStatus(rowData.item.status) &&
this._folderExplorer(rowData)}"
this.triggerOpenFilebrowserToReact(rowData)}"
.folder-id="${rowData.item.name}"
style="cursor:${this._isUncontrollableStatus(rowData.item.status)
? 'default'
Expand Down Expand Up @@ -3381,6 +3377,32 @@ export default class BackendAiStorageList extends BackendAIPage {
}
}

triggerOpenFilebrowserToReact(rowData) {
const queryParams = new URLSearchParams(window.location.search);
queryParams.set('folder', rowData.item.id);
document.dispatchEvent(
new CustomEvent('react-navigate', {
detail: {
pathname: '/data',
search: queryParams.toString(),
},
}),
);
}

triggerCloseFilebrowserToReact() {
const queryParams = new URLSearchParams(window.location.search);
queryParams.delete('folder');
document.dispatchEvent(
new CustomEvent('react-navigate', {
detail: {
pathname: window.location.pathname,
search: queryParams.toString(),
},
}),
);
}

/**
* Set up the explorer of the folder and call the _clearExplorer() function.
*
Expand All @@ -3400,10 +3422,6 @@ export default class BackendAiStorageList extends BackendAIPage {
breadcrumb: ['.'],
};

const queryParams = new URLSearchParams(window.location.search);
queryParams.set('folder', rowData.item.id);
window.history.replaceState({}, '', `${location.pathname}?${queryParams}`);

/**
* NOTICE: If it's admin user and the folder type is group, It will have write permission.
*/
Expand Down
Loading