From 970c338729ef7490f380b82c4a0acdb33a8fbe98 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 7 Mar 2022 17:49:57 -0300 Subject: [PATCH] 18787: Removes explicit collection reload after file operations. It's not necessary anymore, as websocket events would make the app to refresh the content when needed. This is not needed anymore as Workbench2 now listens websocket events. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../collection-panel-files-actions.ts | 25 ------------------- .../collections/collection-upload-actions.ts | 4 --- .../collection-panel/collection-panel.tsx | 23 +++++------------ 3 files changed, 6 insertions(+), 46 deletions(-) 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 da6cfeb0..8c5e5b5a 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,8 +15,6 @@ import { filterCollectionFilesBySelection } from './collection-panel-files-state 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 { loadCollectionPanel } from "../collection-panel-action"; export const collectionPanelFilesAction = unionize({ SET_COLLECTION_FILES: ofType(), @@ -38,33 +36,11 @@ export const setCollectionFiles = (files, joinParents = true) => (dispatch: any) dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES(mapped)); }; -export const loadCollectionFiles = (uuid: string) => - (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(progressIndicatorActions.START_WORKING(COLLECTION_PANEL_LOAD_FILES)); - services.collectionService.files(uuid).then(files => { - // Given the array of directories and files, create the appropriate tree nodes, - // sort them, and add the complete url to each. - const tree = createCollectionFilesTree(files); - const sorted = sortFilesTree(tree); - const mapped = mapTreeValues(services.collectionService.extendFileURL)(sorted); - dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES(mapped)); - dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PANEL_LOAD_FILES)); - }).catch(() => { - dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PANEL_LOAD_FILES)); - dispatch(snackbarActions.OPEN_SNACKBAR({ - message: `Error getting file list`, - hideDuration: 2000, - kind: SnackbarKind.ERROR - })); - }); - }; - export const removeCollectionFiles = (filePaths: string[]) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const currentCollection = getState().collectionPanel.item; if (currentCollection) { services.collectionService.deleteFiles(currentCollection.uuid, filePaths).then(() => { - dispatch(loadCollectionPanel(currentCollection.uuid, true)); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000, @@ -154,7 +130,6 @@ export const renameFile = (newFullPath: string) => const oldPath = getFileFullPath(file); const newPath = newFullPath; services.collectionService.moveFile(currentCollection.uuid, oldPath, newPath).then(() => { - dispatch(loadCollectionPanel(currentCollection.uuid, true)); dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 })); }).catch(e => { diff --git a/src/store/collections/collection-upload-actions.ts b/src/store/collections/collection-upload-actions.ts index 135538b0..9e9fea52 100644 --- a/src/store/collections/collection-upload-actions.ts +++ b/src/store/collections/collection-upload-actions.ts @@ -6,14 +6,12 @@ import { Dispatch } from 'redux'; import { RootState } from 'store/store'; import { ServiceRepository } from 'services/services'; import { dialogActions } from 'store/dialog/dialog-actions'; -import { loadCollectionFiles } from '../collection-panel/collection-panel-files/collection-panel-files-actions'; import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; import { fileUploaderActions } from 'store/file-uploader/file-uploader-actions'; import { reset, startSubmit, stopSubmit } from 'redux-form'; import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions"; import { collectionPanelFilesAction } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions'; import { createTree } from 'models/tree'; -import { loadCollectionPanel } from '../collection-panel/collection-panel-action'; import * as WorkbenchActions from 'store/workbench/workbench-actions'; export const uploadCollectionFiles = (collectionUuid: string, targetLocation?: string) => @@ -42,8 +40,6 @@ export const submitCollectionFiles = (targetLocation?: string) => dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG)); await dispatch(uploadCollectionFiles(currentCollection.uuid, targetLocation)) .then(() => dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() }))); - dispatch(loadCollectionFiles(currentCollection.uuid)); - dispatch(loadCollectionPanel(currentCollection.uuid)); dispatch(closeUploadCollectionFilesDialog()); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Data has been uploaded.', diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index db273b99..9d127a60 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -32,8 +32,6 @@ import { IllegalNamingWarning } from 'components/warning/warning'; import { GroupResource } from 'models/group'; import { UserResource } from 'models/user'; import { getUserUuid } from 'common/getuser'; -import { getProgressIndicator } from 'store/progress-indicator/progress-indicator-reducer'; -import { COLLECTION_PANEL_LOAD_FILES, loadCollectionFiles } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions'; import { Link } from 'react-router-dom'; import { Link as ButtonLink } from '@material-ui/core'; import { ResourceWithName, ResponsiblePerson } from 'views-components/data-explorer/renderers'; @@ -117,11 +115,10 @@ interface CollectionPanelDataProps { isLoadingFiles: boolean; } -type CollectionPanelProps = CollectionPanelDataProps & DispatchProp - & WithStyles & RouteComponentProps<{ id: string }>; +type CollectionPanelProps = CollectionPanelDataProps & DispatchProp & WithStyles -export const CollectionPanel = withStyles(styles)( - connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { +export const CollectionPanel = withStyles(styles)(connect( + (state: RootState, props: RouteComponentProps<{ id: string }>) => { const currentUserUUID = getUserUuid(state); const item = getResource(props.match.params.id)(state.resources); let isWritable = false; @@ -136,13 +133,11 @@ export const CollectionPanel = withStyles(styles)( } } } - const loadingFilesIndicator = getProgressIndicator(COLLECTION_PANEL_LOAD_FILES)(state.progressIndicator); - const isLoadingFiles = (loadingFilesIndicator && loadingFilesIndicator!.working) || false; - return { item, isWritable, isOldVersion, isLoadingFiles }; + return { item, isWritable, isOldVersion }; })( class extends React.Component { render() { - const { classes, item, dispatch, isWritable, isOldVersion, isLoadingFiles } = this.props; + const { classes, item, dispatch, isWritable, isOldVersion } = this.props; const panelsData: MPVPanelState[] = [ { name: "Details" }, { name: "Files" }, @@ -201,13 +196,7 @@ export const CollectionPanel = withStyles(styles)( - { - dispatch(loadCollectionFiles(this.props.item.uuid)); - } - } /> + -- 2.30.2