Skip to content

Commit

Permalink
feat(FR-372): support id based object resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 committed Jan 15, 2025
1 parent 529a225 commit ce97896
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
4 changes: 2 additions & 2 deletions react/src/components/ModelCardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
onClick={() => {
// const event = new CustomEvent('backend-ai-vfolder-cloning', {
// detail: {
// // TODO: change this to vfolder name
// name: mode_card?.name,
// // TODO: change this to vfolder id
// name: mode_card?.id,
// },
// });
// onRequestClose();
Expand Down
14 changes: 9 additions & 5 deletions src/components/backend-ai-data-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class BackendAIData extends BackendAIPage {
@property({ type: Object }) _helpDescriptionStorageProxyInfo = Object();
@property({ type: Object }) options;
@property({ type: Number }) capacity;
@property({ type: String }) cloneFolderName = '';
@property({ type: String }) cloneFolderID = '';
@property({ type: Object }) storageProxyInfo = Object();
@property({ type: String }) folderType = 'user';
@property({ type: Number }) currentGroupIdx = 0;
Expand Down Expand Up @@ -550,7 +550,7 @@ export default class BackendAIData extends BackendAIPage {
<mwc-textfield
id="clone-folder-src"
label="${_t('data.FolderToCopy')}"
value="${this.cloneFolderName}"
value="${this.cloneFolderID}"
disabled
></mwc-textfield>
<mwc-textfield
Expand Down Expand Up @@ -819,7 +819,11 @@ export default class BackendAIData extends BackendAIPage {
document.addEventListener('backend-ai-vfolder-cloning', (e: any) => {
if (e.detail) {
const selectedItems = e.detail;
this.cloneFolderName = selectedItems.name;
this.cloneFolderID = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? selectedItems.id
: selectedItems.name;
this._cloneFolderDialog();
}
});
Expand Down Expand Up @@ -976,7 +980,7 @@ export default class BackendAIData extends BackendAIPage {
this.allowedGroups = group_info.groups;
}
this.cloneFolderNameInput.value = await this._checkFolderNameAlreadyExists(
this.cloneFolderName,
this.cloneFolderID,
);
this.openDialog('clone-folder-dialog');
}
Expand Down Expand Up @@ -1267,7 +1271,7 @@ export default class BackendAIData extends BackendAIPage {
};
const job = globalThis.backendaiclient.vfolder.clone(
input,
this.cloneFolderName,
this.cloneFolderID,
);
job
.then(() => {
Expand Down
18 changes: 11 additions & 7 deletions src/components/backend-ai-folder-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
// [target vfolder information]
@property({ type: String }) vfolderID = '';
@property({ type: String }) vfolderName = '';
@property({ type: String }) vfolder = '';
@property({ type: Array }) vfolderFiles = [];
@property({ type: String }) vhost = '';
@property({ type: Boolean }) isWritable = false;
Expand Down Expand Up @@ -496,7 +497,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const path = this.breadcrumb.concat(fn).join('/');
const job = globalThis.backendaiclient.vfolder.request_download_token(
path,
this.vfolderName,
this.vfolder,
archive,
);
job
Expand Down Expand Up @@ -777,6 +778,9 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
return vfolder.id === this.vfolderID;
});
this.vfolderName = vfolder.name;
this.vfolder = globalThis.backendaiclient.supports('vfolder-id-based')
? vfolder.id
: vfolder.name;
this.vhost = vfolder.host;
this.isWritable = vfolder.permission.includes('w');

Expand All @@ -791,7 +795,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
this.fileListGrid.selectedItems = [];
const filesInfo = await globalThis.backendaiclient.vfolder.list_files(
this.breadcrumb.join('/'),
this.vfolderName,
this.vfolder,
);

const details = filesInfo.items;
Expand Down Expand Up @@ -968,7 +972,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.rename_file(
path,
newName,
this.vfolderName,
this.vfolder,
this.is_dir,
);
job
Expand Down Expand Up @@ -1034,7 +1038,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.delete_files(
filenames,
true,
this.vfolderName,
this.vfolder,
);
job.then((res) => {
this.notification.text =
Expand All @@ -1054,7 +1058,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.delete_files(
[path],
true,
this.vfolderName,
this.vfolder,
);
job
.then((res) => {
Expand Down Expand Up @@ -1121,7 +1125,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
this.mkdirNameInput.reportValidity();
if (this.mkdirNameInput.checkValidity()) {
const job = globalThis.backendaiclient.vfolder
.mkdir([...this.breadcrumb, newfolder].join('/'), this.vfolderName)
.mkdir([...this.breadcrumb, newfolder].join('/'), this.vfolder)
.catch((err) => {
if (err & err.message) {
this.notification.text = PainKiller.relieve(err.title);
Expand Down Expand Up @@ -1290,7 +1294,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.create_upload_session(
path,
fileObj,
this.vfolderName,
this.vfolder,
);
job.then((url) => {
const start_date = new Date().getTime();
Expand Down
23 changes: 18 additions & 5 deletions src/components/backend-ai-storage-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1932,8 +1932,10 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the info icon button
* */
_infoFolder(e) {
const folderName = this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(folderName);
const folder = globalThis.backendaiclient.supports('vfolder-id-based')
? this._getControlID(e)
: this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(folder);
job
.then((value) => {
this.folderInfo = value;
Expand All @@ -1955,7 +1957,10 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the settings icon button
* */
_modifyFolderOptionDialog(e) {
globalThis.backendaiclient.vfolder.name = this._getControlName(e);
globalThis.backendaiclient.vfolder.name =
globalThis.backendaiclient.supports('vfolder-id-based')
? this._getControlID(e)
: this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(
globalThis.backendaiclient.vfolder.name,
);
Expand Down Expand Up @@ -2101,7 +2106,11 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the
*/
_renameFolderDialog(e) {
this.renameFolderName = this._getControlName(e);
this.renameFolderName = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? this._getControlID(e)
: this._getControlName(e);
this.newFolderNameInput.value = '';
this.openDialog('modify-folder-name-dialog');
}
Expand Down Expand Up @@ -2427,7 +2436,11 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the share button
* */
_shareFolderDialog(e) {
this.selectedFolder = this._getControlName(e);
this.selectedFolder = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? this._getControlID(e)
: this._getControlName(e);
this.selectedFolderType = this._getControlType(e);
this._initializeSharingFolderDialogLayout();
this.openDialog('share-folder-dialog');
Expand Down
3 changes: 3 additions & 0 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ class Client {
this._features['max_network_count'] = true;
this._features['replicas'] = true;
}
if (this.isManagerVersionCompatibleWith(['25.1.0', '24.09.6', '24.03.12'])) {
this._features['vfolder-id-based'] = true;
}
}

/**
Expand Down

0 comments on commit ce97896

Please sign in to comment.