1
0
Fork 0
mirror of synced 2024-07-19 21:26:22 +12:00

Allow delete attachments from builder data section

This commit is contained in:
Mel O'Hagan 2022-08-15 15:46:55 +01:00
parent 9fb5b2a37d
commit 1200f4d2a0
5 changed files with 34 additions and 3 deletions

View file

@ -95,9 +95,11 @@
"change",
value.filter((x, idx) => idx !== selectedImageIdx)
)
await deleteAttachments(
value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
)
if (deleteAttachments) {
await deleteAttachments(
value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
)
}
selectedImageIdx = 0
}

View file

@ -10,6 +10,7 @@
export let error = null
export let fileSizeLimit = undefined
export let processFiles = undefined
export let deleteAttachments = undefined
export let handleFileTooLarge = undefined
export let handleTooManyFiles = undefined
export let gallery = true
@ -30,6 +31,7 @@
{value}
{fileSizeLimit}
{processFiles}
{deleteAttachments}
{handleFileTooLarge}
{handleTooManyFiles}
{gallery}

View file

@ -27,6 +27,14 @@
return []
}
}
async function deleteAttachments(fileList) {
try {
return await API.deleteBuilderAttachments(fileList)
} catch (error) {
return []
}
}
</script>
<Dropzone
@ -34,5 +42,6 @@
{label}
{...$$restProps}
{processFiles}
{deleteAttachments}
{handleFileTooLarge}
/>

View file

@ -75,5 +75,18 @@ export const buildAttachmentEndpoints = API => {
},
})
},
/**
* Deletes attachments from the builder bucket.
* @param keys the attachments to delete
*/
deleteBuilderAttachments: async keys => {
return await API.post({
url: `/api/attachments/delete`,
body: {
keys,
},
})
},
}
}

View file

@ -38,6 +38,11 @@ router
// TODO: for now this builder endpoint is not authorized/secured, will need to be
.get("/builder/:file*", controller.serveBuilder)
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
.post(
"/api/attachments/delete",
authorized(BUILDER),
controller.deleteObjects
)
.post("/api/beta/:feature", controller.toggleBetaUiFeature)
.post(
"/api/attachments/:tableId/upload",