Skip to content

Commit

Permalink
Add Navigation to Delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
jatindersingh93 committed Jun 26, 2024
1 parent dca646b commit f86f534
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/bucket/BucketTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const showPermissions = async (bucketId: string, bucketName: string) => {
};
const confirmDeleteBucket = (bucketId: string) => {
focusedElement.value = document.activeElement;
confirm.require({
message:
'Are you sure you want to delete this folder in BCBox? \
Expand All @@ -73,7 +74,8 @@ const confirmDeleteBucket = (bucketId: string) => {
header: 'Delete folder',
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
accept: () => deleteBucket(bucketId)
accept: () => deleteBucket(bucketId),
onHide: () => onDialogHide()
});
};
Expand Down Expand Up @@ -344,7 +346,6 @@ watch(getBuckets, () => {
class="p-button-lg p-button-text p-button-danger"
aria-label="Delete folder"
@click="confirmDeleteBucket(node.data.bucketId)"
@keyup.enter="confirmDeleteBucket(node.data.bucketId)"
>
<font-awesome-icon icon="fa-solid fa-trash" />
</Button>
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/object/DeleteObjectButton.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { ref } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { Button, Dialog, useConfirm } from '@/lib/primevue';
import { useObjectStore } from '@/store/objectStore';
//import { useObjectStore } from '@/store/objectStore';
import { useNavStore, useObjectStore } from '@/store';
import { ButtonMode } from '@/utils/enums';
import { onDialogHide } from '@/utils/utils';
// Props
type Props = {
Expand All @@ -23,6 +26,7 @@ const emit = defineEmits(['on-deleted-success', 'on-deleted-error']);
// Store
const objectStore = useObjectStore();
const { focusedElement } = storeToRefs(useNavStore());
// State
const displayNoFileDialog = ref(false);
Expand All @@ -31,6 +35,7 @@ const displayNoFileDialog = ref(false);
const confirm = useConfirm();
const confirmDelete = () => {
focusedElement.value = document.activeElement;
if (props.ids.length) {
const item = props.versionId ? 'version' : 'object';
const msgContext = props.ids.length > 1 ? `the selected ${props.ids.length} ${item}s` : `this ${item}`;
Expand All @@ -46,7 +51,8 @@ const confirmDelete = () => {
.then(() => emit('on-deleted-success', props.versionId))
.catch(() => {});
});
}
},
onHide: () => onDialogHide()
});
} else {
displayNoFileDialog.value = true;
Expand Down

0 comments on commit f86f534

Please sign in to comment.