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

Add clarification to version update action for non-versioned buckets #147

Merged
merged 1 commit into from
Nov 17, 2023
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
10 changes: 8 additions & 2 deletions frontend/src/components/object/ObjectUploadBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ref } from 'vue';

import { ObjectMetadataTagForm } from '@/components/object';
import { Button, Dialog, useConfirm, useToast } from '@/lib/primevue';
import { useAppStore, useMetadataStore, useObjectStore, useTagStore } from '@/store';
import { useAppStore, useMetadataStore, useObjectStore, useTagStore, useVersionStore } from '@/store';

import type { Ref } from 'vue';
import type { ObjectMetadataTagFormType } from '@/components/object/ObjectMetadataTagForm.vue';
Expand All @@ -24,6 +24,7 @@ const appStore = useAppStore();
const metadataStore = useMetadataStore();
const objectStore = useObjectStore();
const tagStore = useTagStore();
const versionStore = useVersionStore();

// State
const fileInput: Ref<any> = ref(null);
Expand All @@ -41,8 +42,13 @@ const confirm = useConfirm();
const toast = useToast();

const confirmUpdate = () => {
let confirmMessage = 'Please confirm that you want to upload a new version.';
if (versionStore.findS3VersionByObjectId(props.objectId) === null) {
confirmMessage = 'This is a non-versioned bucket. ' +
'Uploading a new version will overwrite the current version.';
}
confirm.require({
message: 'Please confirm that you want to upload a new version.',
message: confirmMessage,
header: 'Upload new version',
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/store/versionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export const useVersionStore = defineStore('version', () => {
function findVersionsByObjectId(objectId: string) {
return state.versions.value.filter((x: Version) => x.objectId === objectId);
}

function findS3VersionByObjectId(objectId: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine. but for future reference, findObjectById() already returns the s3VersionId.
so i think you can do formData.value.s3VersionId

return state.versions.value.filter((x: Version) => x.objectId === objectId)[0]?.s3VersionId;
}
return {
// State
...state,
Expand All @@ -143,7 +145,8 @@ export const useVersionStore = defineStore('version', () => {
findMetadataValue,
findTaggingByVersionId,
findVersionById,
findVersionsByObjectId
findVersionsByObjectId,
findS3VersionByObjectId,
};
});

Expand Down