From: Janicki Artur Date: Wed, 12 Dec 2018 11:57:55 +0000 (+0100) Subject: change code after CR, clean code and add vm to nav action X-Git-Tag: 1.4.0~91^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/8c9cf2d12a513379d13db279b076314b292c037e change code after CR, clean code and add vm to nav action Feature #14512_admin_links Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- diff --git a/src/common/labels.ts b/src/common/labels.ts index 133a0e45..c3c4fcd0 100644 --- a/src/common/labels.ts +++ b/src/common/labels.ts @@ -16,6 +16,8 @@ export const resourceLabel = (type: string) => { return "User"; case ResourceKind.GROUP: return "Group"; + case ResourceKind.VIRTUAL_MACHINE: + return "Virtual Machine"; default: return "Unknown"; } diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts index cbd983a6..92443c02 100644 --- a/src/store/navigation/navigation-action.ts +++ b/src/store/navigation/navigation-action.ts @@ -21,6 +21,8 @@ export const navigateTo = (uuid: string) => dispatch(navigateToCollection(uuid)); } else if (kind === ResourceKind.CONTAINER_REQUEST) { dispatch(navigateToProcess(uuid)); + } else if (kind === ResourceKind.VIRTUAL_MACHINE) { + dispatch(navigateToAdminVirtualMachines); } if (uuid === SidePanelTreeCategory.FAVORITES) { dispatch(navigateToFavorites); diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 1be47be7..a4713c8d 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -210,9 +210,23 @@ export const ResourceLinkClass = connect( return resource || { linkClass: '' }; })(renderLinkClass); -const renderLinkTail = (dispatch: Dispatch, item: { uuid: string, tailUuid: string, tailKind: string }) => - dispatch(navigateTo(item.uuid))}> - {resourceLabel(item.tailKind)}: {item.tailUuid} +const renderLinkTail = (dispatch: Dispatch, item: { uuid: string, tailUuid: string, tailKind: string }) => { + const currentLabel = resourceLabel(item.tailKind); + const isUnknow = currentLabel === "Unknown"; + return (
+ { !isUnknow ? ( + renderLink(dispatch, item.tailUuid, currentLabel) + ) : ( + + {item.tailUuid} + + )} +
); +}; + +const renderLink = (dispatch: Dispatch, uuid: string, label: string) => + dispatch(navigateTo(uuid))}> + {label}: {uuid} ; export const ResourceLinkTail = connect( @@ -225,9 +239,7 @@ export const ResourceLinkTail = connect( renderLinkTail(props.dispatch, props.item)); const renderLinkHead = (dispatch: Dispatch, item: { uuid: string, headUuid: string, headKind: ResourceKind }) => - dispatch(navigateTo(item.uuid))}> - {resourceLabel(item.headKind)}: {item.headUuid} - ; + renderLink(dispatch, item.headUuid, resourceLabel(item.headKind)); export const ResourceLinkHead = connect( (state: RootState, props: { uuid: string }) => { diff --git a/src/views/link-panel/link-panel-root.tsx b/src/views/link-panel/link-panel-root.tsx index 73b53fc1..d5ba79b3 100644 --- a/src/views/link-panel/link-panel-root.tsx +++ b/src/views/link-panel/link-panel-root.tsx @@ -37,7 +37,6 @@ export const linkPanelColumns: DataColumns = [ name: LinkPanelColumnNames.LINK_CLASS, selected: true, configurable: true, - // sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, @@ -45,7 +44,6 @@ export const linkPanelColumns: DataColumns = [ name: LinkPanelColumnNames.TAIL, selected: true, configurable: true, - // sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, @@ -53,7 +51,6 @@ export const linkPanelColumns: DataColumns = [ name: LinkPanelColumnNames.HEAD, selected: true, configurable: true, - // sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }, @@ -61,7 +58,6 @@ export const linkPanelColumns: DataColumns = [ name: LinkPanelColumnNames.UUID, selected: true, configurable: true, - // sortDirection: SortDirection.NONE, filters: createTree(), render: uuid => }