-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
satellite/{web,console}: add duplicate upload warning
This change adds a warning dialog to warn users of potential file overwrites when they upload to an unversioned bucket. Issue: #6925 Change-Id: I54d4b8913e19802ca04e0ecafc453a6319725e5c
- Loading branch information
1 parent
e156216
commit f9db000
Showing
11 changed files
with
252 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
web/satellite/src/components/dialogs/UploadOverwriteWarningDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright (C) 2023 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<v-dialog | ||
v-model="model" | ||
width="auto" | ||
min-width="400px" | ||
max-width="450px" | ||
transition="fade-transition" | ||
> | ||
<v-card rounded="xlg"> | ||
<v-sheet> | ||
<v-card-item class="py-4 pl-6"> | ||
<template #prepend> | ||
<v-sheet | ||
class="border-sm d-flex justify-center align-center" | ||
width="40" | ||
height="40" | ||
rounded="lg" | ||
> | ||
<icon-info size="22" /> | ||
</v-sheet> | ||
</template> | ||
<v-card-title class="font-weight-bold"> | ||
File Overwrite Warning | ||
</v-card-title> | ||
<template #append> | ||
<v-btn | ||
icon="$close" | ||
variant="text" | ||
size="small" | ||
color="default" | ||
@click="onCancel" | ||
/> | ||
</template> | ||
</v-card-item> | ||
</v-sheet> | ||
|
||
<v-divider /> | ||
|
||
<v-row> | ||
<v-col class="pa-6 mx-3"> | ||
<p class="my-2 font-weight-bold"> | ||
You are uploading to an unversioned bucket. | ||
</p> | ||
<p> | ||
This non-exhaustive list of files you are uploading have the same names as existing files in this bucket: | ||
</p> | ||
<v-chip v-for="name in filenames" :key="name" class="font-weight-bold text-wrap mt-3 mr-1 py-2"> | ||
{{ name }} | ||
</v-chip> | ||
<p /> | ||
<v-alert color="default" border variant="tonal" class="my-4"> | ||
If you continue with the upload, the existing file(s) will be permanently overwritten, and previous versions cannot be recovered. | ||
</v-alert> | ||
<v-checkbox-btn v-model="dismissPermanently" density="comfortable" class="mb-2 ml-n2" label="Do not show this warning again." /> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-divider /> | ||
|
||
<v-card-actions class="pa-6"> | ||
<v-row> | ||
<v-col> | ||
<v-btn :disabled="isLoading" variant="outlined" color="default" block @click="onCancel">Cancel</v-btn> | ||
</v-col> | ||
<v-col> | ||
<v-btn :loading="isLoading" color="primary" variant="flat" block @click="onContinue"> | ||
Continue | ||
</v-btn> | ||
</v-col> | ||
</v-row> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { | ||
VAlert, | ||
VBtn, | ||
VCard, | ||
VCardActions, | ||
VCardItem, | ||
VCardTitle, | ||
VCheckboxBtn, | ||
VChip, | ||
VCol, | ||
VDialog, | ||
VDivider, | ||
VRow, | ||
VSheet, | ||
} from 'vuetify/components'; | ||
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; | ||
import { useLoading } from '@/composables/useLoading'; | ||
import { useUsersStore } from '@/store/modules/usersStore'; | ||
import { useNotify } from '@/utils/hooks'; | ||
import IconInfo from '@/components/icons/IconInfo.vue'; | ||
const userStore = useUsersStore(); | ||
const notify = useNotify(); | ||
const { withLoading, isLoading } = useLoading(); | ||
withDefaults(defineProps<{ | ||
filenames: string[], | ||
}>(), { | ||
filenames: () => [], | ||
}); | ||
const model = defineModel<boolean>({ required: true }); | ||
const emit = defineEmits(['proceed', 'cancel']); | ||
const dismissPermanently = ref(false); | ||
function onContinue() { | ||
withLoading(async () => { | ||
try { | ||
if (dismissPermanently.value) { | ||
const noticeDismissal = { ...userStore.state.settings.noticeDismissal }; | ||
noticeDismissal.uploadOverwriteWarning = true; | ||
await userStore.updateSettings({ noticeDismissal }); | ||
} | ||
model.value = false; | ||
emit('proceed'); | ||
} catch (error) { | ||
notify.notifyError(error, AnalyticsErrorEventSource.UPLOAD_OVERWRITE_WARNING_DIALOG); | ||
} | ||
}); | ||
} | ||
async function onCancel() { | ||
emit('cancel'); | ||
model.value = false; | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.