From 46f597da5c34d80250cc7efd87d2ce087528ed5f Mon Sep 17 00:00:00 2001 From: Daniel Kos Date: Mon, 3 Sep 2018 12:43:45 +0200 Subject: [PATCH] CR fixes Feature #13828 Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- src/store/trash/trash-actions.ts | 58 +++++++++---------- .../context-menu/actions/trash-action.tsx | 4 +- .../data-explorer/renderers.tsx | 16 ++--- src/views/project-panel/project-panel.tsx | 2 +- src/views/trash-panel/trash-panel.tsx | 5 +- 5 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/store/trash/trash-actions.ts b/src/store/trash/trash-actions.ts index 34d034a2..4b2000d7 100644 --- a/src/store/trash/trash-actions.ts +++ b/src/store/trash/trash-actions.ts @@ -14,25 +14,23 @@ export const toggleProjectTrashed = (resource: { uuid: string; name: string, isT async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise => { if (resource.isTrashed) { dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." })); - return services.groupsService.untrash(resource.uuid).then(() => { - dispatch(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(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(loadSidePanelTreeProjects(resource.ownerUuid!!)); - dispatch(snackbarActions.CLOSE_SNACKBAR()); - dispatch(snackbarActions.OPEN_SNACKBAR({ - message: "Added to trash", - hideDuration: 2000 - })); - }); + await services.groupsService.trash(resource.uuid); + dispatch(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 => { 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 + })); } }; diff --git a/src/views-components/context-menu/actions/trash-action.tsx b/src/views-components/context-menu/actions/trash-action.tsx index d6c8b2f5..e465bb6d 100644 --- a/src/views-components/context-menu/actions/trash-action.tsx +++ b/src/views-components/context-menu/actions/trash-action.tsx @@ -22,8 +22,6 @@ export const ToggleTrashAction = connect(mapStateToProps)((props: { isTrashed?: : } - {props.isTrashed - ? <>Restore - : <>Move to trash} + {props.isTrashed ? "Restore" : "Move to trash"} ); diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 2e1d608c..9bcbcf61 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -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(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(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(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(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(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(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(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(props.uuid)(state.resources); return { status: resource ? resource.state : '-' }; })((props: { status: string }) => renderType(props.status)); diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx index ebaba839..d3b0474b 100644 --- a/src/views/project-panel/project-panel.tsx +++ b/src/views/project-panel/project-panel.tsx @@ -197,7 +197,7 @@ export const ProjectPanel = withStyles(styles)( handleContextMenu = (event: React.MouseEvent, resourceUuid: string) => { const kind = resourceKindToContextMenuKind(resourceUuid); - const resource = getResource(resourceUuid)(this.props.resources) as ProjectResource; + const resource = getResource(resourceUuid)(this.props.resources); if (kind && resource) { this.props.dispatch(openContextMenu(event, { name: resource.name, diff --git a/src/views/trash-panel/trash-panel.tsx b/src/views/trash-panel/trash-panel.tsx index 5aa45594..0d3a4ddc 100644 --- a/src/views/trash-panel/trash-panel.tsx +++ b/src/views/trash-panel/trash-panel.tsx @@ -60,10 +60,7 @@ export const trashPanelColumns: DataColumns = [ configurable: true, sortDirection: SortDirection.ASC, filters: [], - render: uuid => { - console.log(uuid); - return ; - }, + render: uuid => , width: "450px" }, { -- 2.30.2