CR fixes
authorDaniel Kos <daniel.kos@contractors.roche.com>
Mon, 3 Sep 2018 10:43:45 +0000 (12:43 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Mon, 3 Sep 2018 10:43:45 +0000 (12:43 +0200)
Feature #13828

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

src/store/trash/trash-actions.ts
src/views-components/context-menu/actions/trash-action.tsx
src/views-components/data-explorer/renderers.tsx
src/views/project-panel/project-panel.tsx
src/views/trash-panel/trash-panel.tsx

index 34d034a2de4c661577abf1c6a29179a1f42e2513..4b2000d7b6003469ecedf12d6982aea31ffd882c 100644 (file)
@@ -14,25 +14,23 @@ export const toggleProjectTrashed = (resource: { uuid: string; name: string, isT
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
         if (resource.isTrashed) {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
-            return services.groupsService.untrash(resource.uuid).then(() => {
-                dispatch<any>(activateSidePanelTreeItem(resource.uuid));
-                dispatch(trashPanelActions.REQUEST_ITEMS());
-                dispatch(snackbarActions.CLOSE_SNACKBAR());
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Restored from trash",
-                    hideDuration: 2000
-                }));
-            });
+            await services.groupsService.untrash(resource.uuid);
+            dispatch<any>(activateSidePanelTreeItem(resource.uuid));
+            dispatch(trashPanelActions.REQUEST_ITEMS());
+            dispatch(snackbarActions.CLOSE_SNACKBAR());
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Restored from trash",
+                hideDuration: 2000
+            }));
         } else {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
-            return services.groupsService.trash(resource.uuid).then(() => {
-                dispatch<any>(loadSidePanelTreeProjects(resource.ownerUuid!!));
-                dispatch(snackbarActions.CLOSE_SNACKBAR());
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Added to trash",
-                    hideDuration: 2000
-                }));
-            });
+            await services.groupsService.trash(resource.uuid);
+            dispatch<any>(loadSidePanelTreeProjects(resource.ownerUuid!!));
+            dispatch(snackbarActions.CLOSE_SNACKBAR());
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Added to trash",
+                hideDuration: 2000
+            }));
         }
     };
 
@@ -40,21 +38,19 @@ export const toggleCollectionTrashed = (resource: { uuid: string; name: string,
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
         if (resource.isTrashed) {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
-            return services.collectionService.untrash(resource.uuid).then(() => {
-                dispatch(trashPanelActions.REQUEST_ITEMS());
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Restored from trash",
-                    hideDuration: 2000
-                }));
-            });
+            await services.collectionService.untrash(resource.uuid);
+            dispatch(trashPanelActions.REQUEST_ITEMS());
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Restored from trash",
+                hideDuration: 2000
+            }));
         } else {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
-            return services.collectionService.trash(resource.uuid).then(() => {
-                dispatch(projectPanelActions.REQUEST_ITEMS());
-                dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: "Added to trash",
-                    hideDuration: 2000
-                }));
-            });
+            await services.collectionService.trash(resource.uuid);
+            dispatch(projectPanelActions.REQUEST_ITEMS());
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Added to trash",
+                hideDuration: 2000
+            }));
         }
     };
index d6c8b2f5f4701c47a97f2b955ff093fdd3d818be..e465bb6d80305abe78a4dea5b225df1586baf74e 100644 (file)
@@ -22,8 +22,6 @@ export const ToggleTrashAction = connect(mapStateToProps)((props: { isTrashed?:
                 : <TrashIcon/>}
         </ListItemIcon>
         <ListItemText style={{ textDecoration: 'none' }}>
-            {props.isTrashed
-                ? <>Restore</>
-                : <>Move to trash</>}
+            {props.isTrashed ? "Restore" : "Move to trash"}
         </ListItemText>
     </ListItem >);
index 2e1d608c20d75d97f758692ebd4e97ad880a0133..9bcbcf611c288b50b5434c5a8c8ecca1d99ab334 100644 (file)
@@ -35,7 +35,7 @@ export const renderName = (item: { name: string; uuid: string, kind: string }) =
 
 export const ResourceName = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as GroupContentsResource | undefined;
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
         return resource || { name: '', uuid: '', kind: '' };
     })(renderName);
 
@@ -58,19 +58,19 @@ export const renderDate = (date?: string) => {
 
 export const ResourceLastModifiedDate = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as GroupContentsResource | undefined;
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
         return { date: resource ? resource.modifiedAt : '' };
     })((props: { date: string }) => renderDate(props.date));
 
 export const ResourceTrashDate = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as TrashResource | undefined;
+        const resource = getResource<TrashResource>(props.uuid)(state.resources);
         return { date: resource ? resource.trashAt : '' };
     })((props: { date: string }) => renderDate(props.date));
 
 export const ResourceDeleteDate = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as TrashResource | undefined;
+        const resource = getResource<TrashResource>(props.uuid)(state.resources);
         return { date: resource ? resource.deleteAt : '' };
     })((props: { date: string }) => renderDate(props.date));
 
@@ -81,7 +81,7 @@ export const renderFileSize = (fileSize?: number) =>
 
 export const ResourceFileSize = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as GroupContentsResource | undefined;
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
         return {};
     })((props: { fileSize?: number }) => renderFileSize(props.fileSize));
 
@@ -92,7 +92,7 @@ export const renderOwner = (owner: string) =>
 
 export const ResourceOwner = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as GroupContentsResource | undefined;
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
         return { owner: resource ? resource.ownerUuid : '' };
     })((props: { owner: string }) => renderOwner(props.owner));
 
@@ -103,7 +103,7 @@ export const renderType = (type: string) =>
 
 export const ResourceType = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as GroupContentsResource | undefined;
+        const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
         return { type: resource ? resource.kind : '' };
     })((props: { type: string }) => renderType(props.type));
 
@@ -114,6 +114,6 @@ export const renderStatus = (item: { status?: string }) =>
 
 export const ProcessStatus = connect(
     (state: RootState, props: { uuid: string }) => {
-        const resource = getResource(props.uuid)(state.resources) as ProcessResource | undefined;
+        const resource = getResource<ProcessResource>(props.uuid)(state.resources);
         return { status: resource ? resource.state : '-' };
     })((props: { status: string }) => renderType(props.status));
index ebaba83947753340d564bcef80e948994cd9b7b0..d3b0474b9d0eb8b05822c74774ff3c3f39996b11 100644 (file)
@@ -197,7 +197,7 @@ export const ProjectPanel = withStyles(styles)(
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
                 const kind = resourceKindToContextMenuKind(resourceUuid);
-                const resource = getResource(resourceUuid)(this.props.resources) as ProjectResource;
+                const resource = getResource<ProjectResource>(resourceUuid)(this.props.resources);
                 if (kind && resource) {
                     this.props.dispatch<any>(openContextMenu(event, {
                         name: resource.name,
index 5aa45594b2749972e24833c6a78838e2596c6f93..0d3a4ddc7815e30e0cf7ef48c39dd7e709097957 100644 (file)
@@ -60,10 +60,7 @@ export const trashPanelColumns: DataColumns<string, TrashPanelFilter> = [
         configurable: true,
         sortDirection: SortDirection.ASC,
         filters: [],
-        render: uuid => {
-            console.log(uuid);
-            return <ResourceName uuid={uuid}/>;
-        },
+        render: uuid => <ResourceName uuid={uuid}/>,
         width: "450px"
     },
     {