Skip to content

Commit

Permalink
global recycle bin
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Jan 22, 2025
1 parent ae8b120 commit 15040ed
Show file tree
Hide file tree
Showing 18 changed files with 235 additions and 178 deletions.
2 changes: 1 addition & 1 deletion frontend/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ div:focus-visible {

/* footer */
.gov-footer {
background-color: #003366 !important;
background-color: #003366;
border-top: 2px solid #fcba19;
padding-bottom: 3px;
a {
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/components/layout/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ const { getIsAuthenticated } = storeToRefs(useAuthStore());
My Files
</router-link>
</li>
<li
v-if="getIsAuthenticated"
class="mr-2"
>
<router-link
:to="{ name: RouteNames.LIST_OBJECTS_DELETED }"
aria-label="Recycle Bin"
>
Recycle Bin
</router-link>
</li>
<li class="mr-2">
<a
target="_blank"
Expand Down
36 changes: 11 additions & 25 deletions frontend/src/components/object/DeleteObjectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
ids: Array<string>;
mode: ButtonMode;
versionId?: string; // Only use this when deleting a single object
hard?: boolean
hard?: boolean // are we doing a hard delete?
};
const props = withDefaults(defineProps<Props>(), {
Expand Down Expand Up @@ -47,29 +47,15 @@ const confirmDelete = () => {
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
accept: () => {
// props.ids?.forEach((id: string) => {
// objectStore
// .deleteObject(id, props.versionId, props.hard)
// .then(() => emit('on-deleted-success',
// props.versionId, // version Id or undefined
// props.versionId || false, // true or false
// props.hard)) // if doing hard delete of object
// .catch(() => {});
// });
for (const id of props.ids) {
objectStore
.deleteObject(id, props.versionId, props.hard)
.then(() => emit('on-deleted-success',
props.versionId, // version Id or undefined
props.versionId || false, // true or false
props.hard)) // if doing hard delete of object
.catch(() => {});
};
try {
for (const id of props.ids) {
objectStore
.deleteObject(id, props.versionId, props.hard);
};
}
finally {
emit('on-deleted-success', props.versionId, props.versionId || false, props.hard);
}
},
onHide: () => onDialogHide(),
reject: () => onDialogHide()
Expand All @@ -82,7 +68,7 @@ const buttonLabel = computed(() => {
return props.hard ?
(props.versionId ?
'Permanently delete version' : (props.ids.length > 1 ?
'Permanently delete these files' : 'Permanently delete file')) :
'Permanently delete selected files' : 'Permanently delete file')) :
(props.versionId ? 'Delete version' : 'Delete file' );
});
</script>
Expand Down
18 changes: 12 additions & 6 deletions frontend/src/components/object/ObjectFileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ const versionStore = useVersionStore();
const { getUserId } = storeToRefs(useAuthStore());
const { getObject } = storeToRefs(objectStore);
const { getIsDeleted, getLatestVersionIdByObjectId, getVersionsByObjectId } = storeToRefs(versionStore);
const {
getIsDeleted,
getLatestVersionIdByObjectId,
getLatestNonDmVersionIdByObjectId,
getVersionsByObjectId
} = storeToRefs(versionStore);
// State
const object: Ref<COMSObject | undefined> = ref(undefined);
Expand All @@ -61,13 +66,14 @@ const permissionsVisible: Ref<boolean> = ref(false);
// version stuff
const currentVersionId: Ref<string | undefined> = ref(props.versionId);
const latestVersionId = computed(() => getLatestVersionIdByObjectId.value(props.objectId));
const allVersions = computed(() => getVersionsByObjectId.value(props.objectId));
const latestNonDmVersionId = computed(() => getLatestNonDmVersionIdByObjectId.value(props.objectId));
const isDeleted: Ref<boolean> = computed(() => getIsDeleted.value(props.objectId));
async function onVersionsChanged(changedVersionId: string | undefined, isVersion: boolean, hardDelete: boolean) {
// if doing hard delete or no versions left, redirect to object list
const otherVersions = getVersionsByObjectId.value(props.objectId)
.filter(v=>v.id !== changedVersionId);
// if doing hard delete or no versions left, redirect to parent folder
const otherVersions = allVersions.value.filter(v=>v.id !== changedVersionId);
if (hardDelete || (isVersion && otherVersions.length === 0)) {
router.push({ path: '/list/objects', query: { bucketId: bucketId.value }});
}
Expand All @@ -78,7 +84,7 @@ async function onVersionsChanged(changedVersionId: string | undefined, isVersion
metadataStore.fetchMetadata({ objectId: props.objectId }),
tagStore.fetchTagging({ objectId: props.objectId })
]).then(async () => {
currentVersionId.value = latestVersionId.value;
currentVersionId.value = latestNonDmVersionId.value;
await Promise.all([
versionStore.fetchMetadata({ objectId: props.objectId }),
versionStore.fetchTagging({ objectId: props.objectId })
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/components/object/ObjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@/components/object';
import { Button } from '@/lib/primevue';
import { useAuthStore, useObjectStore, useNavStore, usePermissionStore } from '@/store';
import { Permissions, RouteNames } from '@/utils/constants';
import { Permissions } from '@/utils/constants';
import { ButtonMode } from '@/utils/enums';
import { onDialogHide } from '@/utils/utils';
Expand Down Expand Up @@ -131,9 +131,6 @@ const onDeletedSuccess = () => {
/>
</div>
</div>
<router-link :to="{ name: RouteNames.LIST_OBJECTS_DELETED, query: { bucketId: props.bucketId } }">
Recycle Bin
</router-link>
</div>
</template>

Expand Down
31 changes: 13 additions & 18 deletions frontend/src/components/object/ObjectListDeleted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@ import {
DeleteObjectButton,
ObjectSidebar,
ObjectTableDeleted,
RestoreObjectButton
} from '@/components/object';
import { useObjectStore } from '@/store';
import { RouteNames } from '@/utils/constants';
import { ButtonMode } from '@/utils/enums';
import type { Ref } from 'vue';
// Props
type Props = {
bucketId?: string;
};
const props = withDefaults(defineProps<Props>(), {
bucketId: undefined
});
//const navStore = useNavStore();
const objectStore = useObjectStore();
Expand All @@ -46,11 +37,22 @@ const closeObjectInfo = () => {
const onDeletedSuccess = () => {
objectTableKey.value += 1;
};
const onRestoredSuccess = () => {
objectTableKey.value += 1;
};
</script>

<template>
<div>
<div class="head-actions">
<div class="flex align-items-center justify-content-start">
<RestoreObjectButton
v-if="selectedObjectIds.length > 0"
:ids="selectedObjectIds"
:mode="ButtonMode.BUTTON"
:hard="true"
@on-restored-success="onRestoredSuccess"
/>
<DeleteObjectButton
v-if="selectedObjectIds.length > 0"
:ids="selectedObjectIds"
Expand All @@ -67,7 +69,6 @@ const onDeletedSuccess = () => {
<div class="flex-grow-1">
<ObjectTableDeleted
:key="objectTableKey"
:bucket-id="props.bucketId"
:object-info-id="objectInfoId"
@show-object-info="showObjectInfo"
/>
Expand All @@ -82,12 +83,6 @@ const onDeletedSuccess = () => {
/>
</div>
</div>
<router-link
class="deleted-files-link"
:to="{ name: RouteNames.LIST_OBJECTS, query: { bucketId: props.bucketId } }"
>
Back to folder
</router-link>
</div>
</template>

Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/object/ObjectTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ObjectPublicToggle
} from '@/components/object';
import { SyncButton, ShareButton } from '@/components/common';
import { Button, Column, DataTable, Dialog, InputText, useToast } from '@/lib/primevue';
import { Button, Column, DataTable, Dialog, InputText } from '@/lib/primevue';
import { useAuthStore, useObjectStore, useNavStore, usePermissionStore } from '@/store';
import { Permissions, RouteNames } from '@/utils/constants';
import { onDialogHide } from '@/utils/utils';
Expand Down Expand Up @@ -70,10 +70,8 @@ const filters: Ref<DataTableFilter> = ref({
});
// Actions
const toast = useToast();
const formatShortUuid = (uuid: string) => uuid?.slice(0, 8) ?? uuid;
const onDeletedSuccess = () => {
toast.success('File deleted');
loadLazyData();
};
Expand All @@ -92,6 +90,7 @@ async function showPermissions(objectId: string) {
}
onMounted(() => {
console.log('mount');

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Unexpected console statement

Check warning on line 93 in frontend/src/components/object/ObjectTable.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

Unexpected console statement
loading.value = true;
lazyParams.value = {
first: 0,
Expand Down
Loading

0 comments on commit 15040ed

Please sign in to comment.