🍄 Separate trash for the personal and shared drive (#189)

This commit is contained in:
Montassar Ghanmy
2023-10-06 17:05:07 +01:00
committed by GitHub
parent f0dcf34bbe
commit edfd765d57
34 changed files with 440 additions and 185 deletions
@@ -96,6 +96,18 @@ export const useDriveActions = () => {
[refresh],
);
const restore = useCallback(
async (id: string, parentId: string) => {
try {
await DriveApiClient.restore(companyId, id);
await refresh(parentId || '');
} catch (e) {
ToasterService.error(Languages.t('hooks.use-drive-actions.unable_restore_file'));
}
},
[refresh],
);
const update = useCallback(
async (update: Partial<DriveItem>, id: string, parentId: string) => {
try {
@@ -127,5 +139,5 @@ export const useDriveActions = () => {
[refresh],
);
return { create, refresh, download, downloadZip, remove, update, updateLevel };
return { create, refresh, download, downloadZip, remove, restore, update, updateLevel };
};
@@ -19,7 +19,7 @@ export const useDriveItem = (id: string) => {
const item = useRecoilValue(DriveItemAtom(id));
const children = useRecoilValue(DriveItemChildrenAtom(id));
const [loading, setLoading] = useRecoilState(LoadingStateInitTrue('useDriveItem-' + id));
const { refresh: refreshItem, create, update: _update, updateLevel: _updateLevel, remove: _remove } = useDriveActions();
const { refresh: refreshItem, create, update: _update, updateLevel: _updateLevel, remove: _remove, restore: _restore } = useDriveActions();
const { uploadVersion: _uploadVersion } = useDriveUpload();
const refresh = useCallback(
@@ -44,6 +44,16 @@ export const useDriveItem = (id: string) => {
setLoading(false);
}, [id, setLoading, refresh, item?.item?.parent_id]);
const restore = useCallback(async () => {
setLoading(true);
try {
await _restore(id, item?.item?.parent_id || '');
} catch (e) {
ToasterService.error('Unable to restore this item.');
}
setLoading(false);
}, [id, setLoading, refresh, item?.item?.parent_id]);
const update = useCallback(
async (update: Partial<DriveItem>) => {
setLoading(true);
@@ -83,7 +93,7 @@ export const useDriveItem = (id: string) => {
[companyId, id, setLoading, refresh, item?.item?.parent_id],
);
const inTrash = id === 'trash' || item?.path?.some(i => i.parent_id === 'trash');
const inTrash = id.includes('trash') || item?.path?.some(i => i?.parent_id?.includes('trash')) || item?.item?.is_in_trash;
const sharedWithMe = id =="shared_with_me";
return {
@@ -31,7 +31,6 @@ export const useDrivePreviewModal = () => {
const close = () => {
setStatus({ item: null, loading: true });
history.push(RouterServices.generateRouteFromState({companyId: company, itemId: ""}));
}
return { open, close, isOpen: !!status.item };