Skip to content
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
5 changes: 4 additions & 1 deletion frontend/src/components/bucket/BucketConfigForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ const onSubmit = async (values: any) => {

const bucketChanges = differential(formBucket, initialValues);

props.bucket
const bucketModel = props.bucket
? await bucketStore.updateBucket(props.bucket?.bucketId, bucketChanges)
: await bucketStore.createBucket(formBucket);

// if successfully added a new configuration, do a recursive sync of this bucket
if(!props.bucket) await bucketStore.syncBucket(bucketModel.bucketId, true);
// refresh bucket list
await bucketStore.fetchBuckets({ userId: getUserId.value, objectPerms: true });

// trim trailing "//", if present
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/components/bucket/BucketTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ const confirmDeleteBucket = (bucketId: string) => {
confirm.require({
message:
'Are you sure you want to delete this folder in BCBox? \
This will drop all related objects and permissions from BCBox, \
This will drop all sub-folders and related objects and permissions from BCBox, \
but the files will still remain in the actual source storage location.',
header: 'Delete folder',
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
accept: () => deleteBucket(bucketId),
accept: () => deleteBucket(bucketId, true),
onHide: () => onDialogHide(),
reject: () => onDialogHide()
});
};

async function deleteBucket(bucketId: string) {
await bucketStore.deleteBucket(bucketId);
async function deleteBucket(bucketId: string, recursive=true) {
await bucketStore.deleteBucket(bucketId, recursive);
await bucketStore.fetchBuckets({ userId: getUserId.value, objectPerms: true });
}

Expand Down Expand Up @@ -240,8 +240,7 @@ watch(getBuckets, () => {
}
}

// Expand all nodes and set tree state
bucketTreeNodeMap.forEach((_v, k) => (expandedKeys.value[k] = true));
//set tree state
treeData.value = tree;
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/SyncButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const onSubmit = () => {
if (props.objectId) {
objectStore.syncObject(props.objectId);
} else if (props.bucketId) {
bucketStore.syncBucket(props.bucketId);
bucketStore.syncBucket(props.bucketId, false);
} else {
toast.error('', 'Unable to synchronize');
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/object/ObjectVersion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ const isDeleted: Ref<boolean> = computed(() => getIsDeleted.value(props.objectId
const tableData: Ref<Array<VersionDataSource>> = computed(() => {
return versions.value
.filter(v => !v.deleteMarker)
.sort((a, b) => {
return new Date(a.lastModifiedDate) < new Date(b.lastModifiedDate) ? 1 : -1;
})
.map((v: Version, index, arr) => ({
...v,
createdByName: getUser.value(v.createdBy)?.fullName,
versionNumber: arr.length - index,
isDeleted: isDeleted.value,

}));
});
// Highlight row for currently selected version
Expand Down
20 changes: 14 additions & 6 deletions frontend/src/services/bucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ export default {

/**
* @function deleteBucket
* Deletes a bucket
* This is a COMS DB delete only. The S3 bucket remains intact
* Deletes a bucket and optionally sub-folders
* This is a COMS DB delete only. The S3 bucket(s) remains intact
* @param {string} bucketId Bucket ID for the bucket to delete
* @returns {Promise} An axios response
*/
deleteBucket(bucketId: string) {
return comsAxios().delete(`${BUCKET_PATH}/${bucketId}`);
deleteBucket(bucketId: string, recursive: boolean ) {
return comsAxios().delete(`${BUCKET_PATH}/${bucketId}`, {
params: {
recursive: recursive,
}
});
},

/**
Expand All @@ -64,7 +68,11 @@ export default {
* @param {string} bucketId Bucket ID for the bucket to synchronize
* @returns {Promise} An axios response
*/
syncBucket(bucketId: string) {
return comsAxios().get(`${BUCKET_PATH}/${bucketId}/sync`);
syncBucket(bucketId: string, recursive: boolean ) {
return comsAxios().get(`${BUCKET_PATH}/${bucketId}/sync`, {
params: {
recursive: recursive,
}
});
}
};
8 changes: 4 additions & 4 deletions frontend/src/store/bucketStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export const useBucketStore = defineStore('bucket', () => {
}
}

async function deleteBucket(bucketId: string) {
async function deleteBucket(bucketId: string, recursive: boolean){
try {
appStore.beginIndeterminateLoading();

await bucketService.deleteBucket(bucketId);
await bucketService.deleteBucket(bucketId, recursive );
} finally {
appStore.endIndeterminateLoading();
}
Expand Down Expand Up @@ -112,11 +112,11 @@ export const useBucketStore = defineStore('bucket', () => {
}
}

async function syncBucket(bucketId: string) {
async function syncBucket(bucketId: string, recursive: boolean) {
try {
appStore.beginIndeterminateLoading();

await bucketService.syncBucket(bucketId);
await bucketService.syncBucket(bucketId, recursive );
toast.success('', 'Sync is in queue and will begin soon');
} catch (error: any) {
toast.error('Unable to sync', error);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type Version = {
mimeType: string;
objectId: string;
s3VersionId: string;
lastModifiedDate: string;
} & IAudit;
6 changes: 4 additions & 2 deletions frontend/tests/unit/store/versionStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const version: Version = {
objectId: '000',
s3VersionId: 's3123',
isLatest: true,
createdAt: '2023-05-01T22:18:12.553Z'
createdAt: '2023-05-01T22:18:12.553Z',
lastModifiedDate: '2023-05-01T22:18:12.553Z',
};

const versionOld: Version = {
Expand All @@ -41,7 +42,8 @@ const versionOld: Version = {
objectId: '000',
s3VersionId: 's2000',
isLatest: false,
createdAt: '2022-05-01T18:25:42.462Z'
createdAt: '2022-05-01T18:25:42.462Z',
lastModifiedDate: '2023-05-01T22:18:12.553Z',
};

const mockToast = vi.fn();
Expand Down
Loading