From: Lucas Di Pentima Date: Fri, 20 Nov 2020 18:07:04 +0000 (-0300) Subject: 13494: Forces complete collection panel reload on after file operations. X-Git-Tag: 2.1.2~26^2~3 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/0ac876abda98d11364e59846789e36bb4546765e 13494: Forces complete collection panel reload on after file operations. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index 58407b90..7881d672 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -29,10 +29,12 @@ export type CollectionPanelAction = UnionOf; export const COLLECTION_TAG_FORM_NAME = 'collectionTagForm'; -export const loadCollectionPanel = (uuid: string) => +export const loadCollectionPanel = (uuid: string, forceReload = false) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const { collectionPanel: { item } } = getState(); - const collection = item ? item : await services.collectionService.get(uuid); + const collection = (item && item.uuid === uuid && !forceReload) + ? item + : await services.collectionService.get(uuid); dispatch(loadDetailsPanel(collection.uuid)); dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection })); dispatch(resourcesActions.SET_RESOURCES([collection])); diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts index 1d2a40b2..3f9948fc 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts @@ -15,7 +15,7 @@ import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form'; import { getDialog } from "~/store/dialog/dialog-reducer"; import { getFileFullPath, sortFilesTree } from "~/services/collection-service/collection-service-files-response"; import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; -import { loadDetailsPanel } from "~/store/details-panel/details-panel-action"; +import { loadCollectionPanel } from "../collection-panel-action"; export const collectionPanelFilesAction = unionize({ SET_COLLECTION_FILES: ofType(), @@ -56,13 +56,12 @@ export const removeCollectionFiles = (filePaths: string[]) => const currentCollection = getState().collectionPanel.item; if (currentCollection) { services.collectionService.deleteFiles(currentCollection.uuid, filePaths).then(() => { - dispatch(loadCollectionFiles(currentCollection.uuid)); + dispatch(loadCollectionPanel(currentCollection.uuid, true)); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); - dispatch(loadDetailsPanel(currentCollection.uuid)); }).catch(e => dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not remove file.', @@ -147,10 +146,9 @@ export const renameFile = (newFullPath: string) => const oldPath = getFileFullPath(file); const newPath = newFullPath; services.collectionService.moveFile(currentCollection.uuid, oldPath, newPath).then(() => { - dispatch(loadCollectionFiles(currentCollection.uuid)); + dispatch(loadCollectionPanel(currentCollection.uuid, true)); dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 })); - dispatch(loadDetailsPanel(currentCollection.uuid)); }).catch (e => { const errors: FormErrors = { path: `Could not rename the file: ${e.responseText}`