Skip to content

Commit

Permalink
Rework deletes to have the component issue multiple calls instead of …
Browse files Browse the repository at this point in the history
…objectStore
  • Loading branch information
wilwong89 committed Oct 17, 2023
1 parent 7a11dfe commit ebf8a7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
45 changes: 10 additions & 35 deletions frontend/src/components/object/DeleteObjectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,14 @@ const confirmDelete = () => {
const msgContext = props.ids.length > 1 ? `the selected ${props.ids.length} ${item}s` : `this ${item}`;
confirm.require({
message: `Please confirm that you want to delete ${msgContext}.`,
header: `Delete ${props.ids.length > 1 ? item + 's' : item }`,
header: `Delete ${props.ids.length > 1 ? item + 's' : item}`,
acceptLabel: 'Confirm',
rejectLabel: 'Cancel',
accept: async () => {
try {
const res = await objectStore.deleteObjects(props.ids, props.versionId);
res?.forEach((ele, index)=>{
if (ele.status === 'fulfilled') {
emit('on-deleted-success', props.ids[index]);
} else {
toast.error(`Error deleting ${props.ids[index]}`);
emit('on-deleted-error');
}
props.ids?.forEach(async (ele) => {
const res = await objectStore.deleteObjects([ele], props.versionId);
if (res) emit('on-deleted-success', props.versionId);
});
} catch (error: any) {
toast.error(`Error deleting one or more ${item}s`);
Expand All @@ -64,38 +59,18 @@ const confirmDelete = () => {
</script>

<template>
<Dialog
v-model:visible="displayNoFileDialog"
header="No File Selected"
:modal="true"
>
<Dialog v-model:visible="displayNoFileDialog" header="No File Selected" :modal="true">

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'header' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

':modal' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'header' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

':modal' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'header' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

':modal' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'header' should be on a new line

Check warning on line 62 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

':modal' should be on a new line
<p>Please select at least one file from the list to delete.</p>
<template #footer>
<Button
label="Ok"
autofocus
@click="displayNoFileDialog = false"
/>
<Button label="Ok" autofocus @click="displayNoFileDialog = false" />

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'autofocus' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'autofocus' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'autofocus' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'autofocus' should be on a new line

Check warning on line 65 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line
</template>
</Dialog>

<Button
v-if="props.mode === ButtonMode.ICON"
class="p-button-lg p-button-text p-button-danger"
:disabled="props.disabled"
@click="confirmDelete()"
>
<Button v-if="props.mode === ButtonMode.ICON" class="p-button-lg p-button-text p-button-danger"

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected a linebreak before this attribute

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected a linebreak before this attribute

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected a linebreak before this attribute

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected a linebreak before this attribute

Check warning on line 69 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line
:disabled="props.disabled" @click="confirmDelete()">

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected indentation of 10 spaces but found 4 spaces

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected 1 line break before closing bracket, but no line breaks found

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected indentation of 10 spaces but found 4 spaces

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected 1 line break before closing bracket, but no line breaks found

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected indentation of 10 spaces but found 4 spaces

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected 1 line break before closing bracket, but no line breaks found

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected indentation of 10 spaces but found 4 spaces

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'@click' should be on a new line

Check warning on line 70 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

Expected 1 line break before closing bracket, but no line breaks found
<font-awesome-icon icon="fa-solid fa-trash" />
</Button>
<Button
v-else
class="p-button-outlined p-button-danger"
:disabled="props.disabled"
@click="confirmDelete()"
>
<font-awesome-icon
icon="fa-solid fa-trash"
class="mr-1"
/> Delete
<Button v-else class="p-button-outlined p-button-danger" :disabled="props.disabled" @click="confirmDelete()">

Check warning on line 73 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 73 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 73 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line

Check warning on line 73 in frontend/src/components/object/DeleteObjectButton.vue

View workflow job for this annotation

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

'class' should be on a new line
<font-awesome-icon icon="fa-solid fa-trash" class="mr-1" /> Delete
</Button>
</template>
4 changes: 1 addition & 3 deletions frontend/src/store/objectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ export const useObjectStore = defineStore('object', () => {

try {
appStore.beginIndeterminateLoading();
// Promise.allSettled returns array with an object per promise
// check MDN for details
return await Promise.allSettled(
return await Promise.all(
objectIds.map(async (id) => {
await objectService.deleteObject(id, versionId);
})
Expand Down

0 comments on commit ebf8a7e

Please sign in to comment.