From 188fed64a7cfe68460f64a874dba3fd280d5d561 Mon Sep 17 00:00:00 2001 From: Pawel Kowalczyk Date: Mon, 10 Dec 2018 15:53:25 +0100 Subject: [PATCH 1/1] show-link-to-process-which-created-a-collection Feature #14480 Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- .../collection-panel/collection-panel-action.ts | 12 ++++++++++++ src/views/collection-panel/collection-panel.tsx | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index 265b5cf8..3b3e34c2 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -13,6 +13,8 @@ import { TagProperty } from "~/models/tag"; import { snackbarActions } from "../snackbar/snackbar-actions"; import { resourcesActions } from "~/store/resources/resources-actions"; import { unionize, ofType, UnionOf } from '~/common/unionize'; +import { SnackbarKind } from '~/store/snackbar/snackbar-actions'; +import { navigateTo } from '~/store/navigation/navigation-action'; export const collectionPanelActions = unionize({ SET_COLLECTION: ofType(), @@ -53,6 +55,16 @@ export const createCollectionTag = (data: TagProperty) => } }; +export const navigateToProcess = (uuid: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + try { + await services.containerRequestService.get(uuid); + dispatch(navigateTo(uuid)); + } catch { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This process does not exists!', hideDuration: 2000, kind: SnackbarKind.ERROR })); + } + }; + export const deleteCollectionTag = (key: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const item = getState().collectionPanel.item; diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 26ee1887..119b9e99 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -17,7 +17,7 @@ import { CollectionResource } from '~/models/collection'; import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files'; import * as CopyToClipboard from 'react-copy-to-clipboard'; import { CollectionTagForm } from './collection-tag-form'; -import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action'; +import { deleteCollectionTag, navigateToProcess } from '~/store/collection-panel/collection-panel-action'; import { snackbarActions } from '~/store/snackbar/snackbar-actions'; import { getResource } from '~/store/resources/resources'; import { openContextMenu } from '~/store/context-menu/context-menu-actions'; @@ -26,7 +26,7 @@ import { formatFileSize } from "~/common/formatters"; import { getResourceData } from "~/store/resources-data/resources-data"; import { ResourceData } from "~/store/resources-data/resources-data-reducer"; -type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value'; +type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value' | 'link'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ card: { @@ -52,6 +52,13 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ value: { textTransform: 'none', fontSize: '0.875rem' + }, + link: { + fontSize: '0.875rem', + color: theme.palette.primary.main, + '&:hover': { + cursor: 'pointer' + } } }); @@ -63,7 +70,6 @@ interface CollectionPanelDataProps { type CollectionPanelProps = CollectionPanelDataProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; - export const CollectionPanel = withStyles(styles)( connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { const item = getResource(props.match.params.id)(state.resources); @@ -72,7 +78,7 @@ export const CollectionPanel = withStyles(styles)( })( class extends React.Component { render() { - const { classes, item, data } = this.props; + const { classes, item, data, dispatch } = this.props; return item ? <> @@ -107,6 +113,9 @@ export const CollectionPanel = withStyles(styles)( label='Content size' value={data && formatFileSize(data.fileSize)} /> + dispatch(navigateToProcess(item.properties.container_request))}> + + -- 2.30.2