18787: Removes explicit collection reload after file operations.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 7 Mar 2022 20:49:57 +0000 (17:49 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 30 May 2022 18:55:10 +0000 (15:55 -0300)
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 <lucas.dipentima@curii.com>

src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts
src/store/collections/collection-upload-actions.ts
src/views/collection-panel/collection-panel.tsx

index da6cfeb068be2ae969afef4fcb5e920d54c1de9c..8c5e5b5a67df1f345ccd0ef645b7ec2e25e858c0 100644 (file)
@@ -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<CollectionFilesTree>(),
@@ -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<any>(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<any>(loadCollectionPanel(currentCollection.uuid, true));
                     dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG }));
                     dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 }));
                 }).catch(e => {
index 135538b074dbee437cebf55b5b9daf4ab4d1ecc8..9e9fea5263032ebb78fef86f4548a13c0fbb7db4 100644 (file)
@@ -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<any>(uploadCollectionFiles(currentCollection.uuid, targetLocation))
                     .then(() => dispatch<any>(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() })));
-                dispatch<any>(loadCollectionFiles(currentCollection.uuid));
-                dispatch<any>(loadCollectionPanel(currentCollection.uuid));
                 dispatch(closeUploadCollectionFilesDialog());
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Data has been uploaded.',
index db273b99726390918110f170faf04f21e06ac448..9d127a605cc617cd2c7367aa460a039c185e34e9 100644 (file)
@@ -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<CssRules> & RouteComponentProps<{ id: string }>;
+type CollectionPanelProps = CollectionPanelDataProps & DispatchProp & WithStyles<CssRules>
 
-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<CollectionResource>(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<CollectionPanelProps> {
             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)(
                         </MPVPanelContent>
                         <MPVPanelContent xs>
                             <Card className={classes.filesCard}>
-                                <CollectionPanelFiles
-                                    isWritable={isWritable}
-                                    isLoading={isLoadingFiles}
-                                    loadFilesFunc={() => {
-                                        dispatch<any>(loadCollectionFiles(this.props.item.uuid));
-                                    }
-                                    } />
+                                <CollectionPanelFiles isWritable={isWritable} />
                             </Card>
                         </MPVPanelContent>
                     </MPVContainer>