Skip to content

Commit

Permalink
refactor: add direct vfolder access link when accepting vfolder invit…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
lizable committed Jan 15, 2025
1 parent a1fcfda commit d9f89a1
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/components/backend-ai-summary-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,35 @@ export default class BackendAISummary extends BackendAIPage {
});
}

/**
* Returns tab according to vfolder information
*
* @param vfolderInfo
* @returns {string} - tab name of vfolder (model, general, data, automount)
*/
static getVFolderTabByVFolderInfo(vfolderInfo) {
if (
!vfolderInfo.name.startsWith('.') &&
vfolderInfo.usage_mode == 'model'
) {
return 'model';
} else if (
!vfolderInfo.name.startsWith('.') &&
vfolderInfo.usage_mode == 'general'
) {
return 'general';
} else if (
!vfolderInfo.name.startsWith('.') &&
vfolderInfo.usage_mode == 'data'
) {
return 'data';
} else if (vfolderInfo.name.startsWith('.')) {
return 'automount';
} else {
return 'general';
}
}

/**
* Accept invitation and make you can access vfolder.
*
Expand All @@ -400,9 +429,14 @@ export default class BackendAISummary extends BackendAIPage {
}
try {
await globalThis.backendaiclient.vfolder.accept_invitation(invitation.id);
const vfolderInfo = await globalThis.backendaiclient.vfolder.info(
invitation.vfolder_name,
);
const tabName = BackendAISummary.getVFolderTabByVFolderInfo(vfolderInfo);
this.notification.url = `/data?tab=${tabName}&folder=${invitation.vfolder_id.replace('-', '')}`;
this.notification.text =
_text('summary.AcceptSharedVFolder') + `${invitation.vfolder_name}`;
this.notification.show();
this.notification.show(true);
} catch (err) {
this.notification.text = PainKiller.relieve(err.title);
this.notification.detail = err.message;
Expand Down

0 comments on commit d9f89a1

Please sign in to comment.