feat: ability to add and delete files of existing share (#306)

* feat(share): delete file api, revert complete share api.

* feat(share): share edit page.

* feat(share): Modify the DropZone title of the edit sharing UI.

* feat(share): i18n for edit share. (en, zh)

* feat(share): allow creator get share by id.

* feat(share): add edit button in account/shares.

* style(share): lint.

* chore: some minor adjustments.

* refactor: run formatter

* refactor: remove unused return

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
Ivan Li
2023-11-05 03:39:58 +08:00
committed by GitHub
parent e377ed10e1
commit 98380e2d48
15 changed files with 493 additions and 36 deletions

View File

@@ -19,10 +19,18 @@ const completeShare = async (id: string) => {
return (await api.post(`shares/${id}/complete`)).data;
};
const revertComplete = async (id: string) => {
return (await api.delete(`shares/${id}/complete`)).data;
};
const get = async (id: string): Promise<Share> => {
return (await api.get(`shares/${id}`)).data;
};
const getFromOwner = async (id: string): Promise<Share> => {
return (await api.get(`shares/${id}/from-owner`)).data;
};
const getMetaData = async (id: string): Promise<ShareMetaData> => {
return (await api.get(`shares/${id}/metaData`)).data;
};
@@ -63,6 +71,10 @@ const downloadFile = async (shareId: string, fileId: string) => {
window.location.href = `${window.location.origin}/api/shares/${shareId}/files/${fileId}`;
};
const removeFile = async (shareId: string, fileId: string) => {
await api.delete(`shares/${shareId}/files/${fileId}`);
};
const uploadFile = async (
shareId: string,
readerEvent: ProgressEvent<FileReader>,
@@ -121,14 +133,17 @@ const removeReverseShare = async (id: string) => {
export default {
create,
completeShare,
revertComplete,
getShareToken,
get,
getFromOwner,
remove,
getMetaData,
doesFileSupportPreview,
getMyShares,
isShareIdAvailable,
downloadFile,
removeFile,
uploadFile,
setReverseShare,
createReverseShare,