Skip to content

Commit c0136e5

Browse files
committed
trigger recursive sync when connecting a new storage location
1 parent 410ae8b commit c0136e5

File tree

8 files changed

+22
-11
lines changed

8 files changed

+22
-11
lines changed

frontend/src/components/bucket/BucketConfigForm.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ const onSubmit = async (values: any) => {
7878
7979
const bucketChanges = differential(formBucket, initialValues);
8080
81-
props.bucket
81+
const bucketModel = props.bucket
8282
? await bucketStore.updateBucket(props.bucket?.bucketId, bucketChanges)
8383
: await bucketStore.createBucket(formBucket);
8484
85+
// if successfully added a new configuration, do a recursive sync of this bucket
86+
if(!props.bucket) await bucketStore.syncBucket(bucketModel.bucketId, true);
87+
// refresh bucket list
8588
await bucketStore.fetchBuckets({ userId: getUserId.value, objectPerms: true });
8689
8790
// trim trailing "//", if present

frontend/src/components/bucket/BucketTable.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ watch(getBuckets, () => {
240240
}
241241
}
242242
243-
// Expand all nodes and set tree state
244-
bucketTreeNodeMap.forEach((_v, k) => (expandedKeys.value[k] = true));
243+
//set tree state
245244
treeData.value = tree;
246245
});
247246
</script>

frontend/src/components/common/SyncButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const onSubmit = () => {
4141
if (props.objectId) {
4242
objectStore.syncObject(props.objectId);
4343
} else if (props.bucketId) {
44-
bucketStore.syncBucket(props.bucketId);
44+
bucketStore.syncBucket(props.bucketId, false);
4545
} else {
4646
toast.error('', 'Unable to synchronize');
4747
}

frontend/src/components/object/ObjectVersion.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ const isDeleted: Ref<boolean> = computed(() => getIsDeleted.value(props.objectId
4747
const tableData: Ref<Array<VersionDataSource>> = computed(() => {
4848
return versions.value
4949
.filter(v => !v.deleteMarker)
50+
.sort((a, b) => {
51+
return new Date(a.lastModifiedDate) < new Date(b.lastModifiedDate) ? 1 : -1;
52+
})
5053
.map((v: Version, index, arr) => ({
5154
...v,
5255
createdByName: getUser.value(v.createdBy)?.fullName,
5356
versionNumber: arr.length - index,
5457
isDeleted: isDeleted.value,
55-
5658
}));
5759
});
5860
// Highlight row for currently selected version

frontend/src/services/bucketService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ export default {
6464
* @param {string} bucketId Bucket ID for the bucket to synchronize
6565
* @returns {Promise} An axios response
6666
*/
67-
syncBucket(bucketId: string) {
68-
return comsAxios().get(`${BUCKET_PATH}/${bucketId}/sync`);
67+
syncBucket(bucketId: string, recursive: boolean ) {
68+
return comsAxios().get(`${BUCKET_PATH}/${bucketId}/sync`, {
69+
params: {
70+
recursive: recursive,
71+
}
72+
});
6973
}
7074
};

frontend/src/store/bucketStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ export const useBucketStore = defineStore('bucket', () => {
112112
}
113113
}
114114

115-
async function syncBucket(bucketId: string) {
115+
async function syncBucket(bucketId: string, recursive: boolean) {
116116
try {
117117
appStore.beginIndeterminateLoading();
118118

119-
await bucketService.syncBucket(bucketId);
119+
await bucketService.syncBucket(bucketId, recursive );
120120
toast.success('', 'Sync is in queue and will begin soon');
121121
} catch (error: any) {
122122
toast.error('Unable to sync', error);

frontend/src/types/Version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export type Version = {
88
mimeType: string;
99
objectId: string;
1010
s3VersionId: string;
11+
lastModifiedDate: string;
1112
} & IAudit;

frontend/tests/unit/store/versionStore.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const version: Version = {
3131
objectId: '000',
3232
s3VersionId: 's3123',
3333
isLatest: true,
34-
createdAt: '2023-05-01T22:18:12.553Z'
34+
createdAt: '2023-05-01T22:18:12.553Z',
35+
lastModifiedDate: '2023-05-01T22:18:12.553Z',
3536
};
3637

3738
const versionOld: Version = {
@@ -41,7 +42,8 @@ const versionOld: Version = {
4142
objectId: '000',
4243
s3VersionId: 's2000',
4344
isLatest: false,
44-
createdAt: '2022-05-01T18:25:42.462Z'
45+
createdAt: '2022-05-01T18:25:42.462Z',
46+
lastModifiedDate: '2023-05-01T22:18:12.553Z',
4547
};
4648

4749
const mockToast = vi.fn();

0 commit comments

Comments
 (0)