18594: Added multiple tails display, added tests
[arvados-workbench2.git] / src / views-components / advanced-tab-dialog / metadataTab.tsx
index 340149a3e97b38bb787651df5ea63c83b5ae799b..88d0137f8a7ede6a1df055a3250a8a10325e67e8 100644 (file)
@@ -2,9 +2,9 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
+import React from "react";
 import { Table, TableHead, TableCell, TableRow, TableBody, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { navigateTo } from "~/store/navigation/navigation-action";
+import { UserResource } from "models/user";
 
 type CssRules = 'cell';
 
@@ -25,6 +25,8 @@ interface MetadataTable {
 
 interface MetadataProps {
     items: MetadataTable[];
+    user: UserResource;
+    uuid: string;
 }
 
 export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles<CssRules>) =>
@@ -40,18 +42,16 @@ export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles
             </TableRow>
         </TableHead>
         <TableBody>
-            {props.items.map((it, index) => {
-                return (
-                    <TableRow key={index}>
-                        <TableCell className={props.classes.cell}>{it.uuid}</TableCell>
-                        <TableCell className={props.classes.cell}>{it.linkClass}</TableCell>
-                        <TableCell className={props.classes.cell}>{it.name}</TableCell>
-                        <TableCell className={props.classes.cell}>{it.tailUuid}</TableCell>
-                        <TableCell className={props.classes.cell}>{it.headUuid}</TableCell>
-                        <TableCell className={props.classes.cell}>{JSON.stringify(it.properties, null, 2)}</TableCell>
-                    </TableRow>
-                );
-            })}
+            {props.items.map((it, index) =>
+                <TableRow key={index}>
+                    <TableCell className={props.classes.cell}>{it.uuid}</TableCell>
+                    <TableCell className={props.classes.cell}>{it.linkClass}</TableCell>
+                    <TableCell className={props.classes.cell}>{it.name}</TableCell>
+                    <TableCell className={props.classes.cell}>{it.properties.tail}</TableCell>
+                    <TableCell className={props.classes.cell}>{it.headUuid === props.uuid ? 'this' : it.headUuid}</TableCell>
+                    <TableCell className={props.classes.cell}>{JSON.stringify(it.properties, (key, value) => { return key === 'tail' ? undefined : value; })}</TableCell>
+                </TableRow>
+            )}
         </TableBody>
     </Table>
 );
\ No newline at end of file