change code after CR, clean code and add vm to nav action
[arvados-workbench2.git] / src / views-components / data-explorer / renderers.tsx
index 1be47be7093695dad9d7a33026ac813fff6e6a5d..a4713c8dc2337a8df20bb27d2094beff6fab32c5 100644 (file)
@@ -210,9 +210,23 @@ export const ResourceLinkClass = connect(
         return resource || { linkClass: '' };
     })(renderLinkClass);
 
-const renderLinkTail = (dispatch: Dispatch, item: { uuid: string, tailUuid: string, tailKind: string }) =>
-    <Typography noWrap color="primary" onClick={() => dispatch<any>(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 (<div>
+        { !isUnknow  ? (
+                renderLink(dispatch, item.tailUuid, currentLabel)
+            ) : (
+                <Typography noWrap color="default">
+                    {item.tailUuid}
+                </Typography>
+        )}
+    </div>);
+};
+
+const renderLink = (dispatch: Dispatch, uuid: string, label: string) =>
+    <Typography noWrap color="primary" style={{ 'cursor': 'pointer' }} onClick={() => dispatch<any>(navigateTo(uuid))}>
+        {label}: {uuid}
     </Typography>;
 
 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 }) =>
-    <Typography noWrap color="primary" onClick={() => dispatch<any>(navigateTo(item.uuid))}>
-        {resourceLabel(item.headKind)}: {item.headUuid}
-    </Typography>;
+    renderLink(dispatch, item.headUuid, resourceLabel(item.headKind));
 
 export const ResourceLinkHead = connect(
     (state: RootState, props: { uuid: string }) => {