18594: Added multiple tails display, added tests
[arvados-workbench2.git] / src / views-components / advanced-tab-dialog / metadataTab.tsx
index eea438d7e8793478b31c9a4a2868e635106c4b70..88d0137f8a7ede6a1df055a3250a8a10325e67e8 100644 (file)
@@ -2,8 +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 { UserResource } from "models/user";
 
 type CssRules = 'cell';
 
@@ -17,16 +18,17 @@ interface MetadataTable {
     uuid: string;
     linkClass: string;
     name: string;
-    tail: string;
-    head: string;
+    tailUuid: string;
+    headUuid: string;
     properties: any;
 }
 
 interface MetadataProps {
     items: MetadataTable[];
+    user: UserResource;
+    uuid: string;
 }
 
-
 export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles<CssRules>) =>
     <Table>
         <TableHead>
@@ -40,21 +42,16 @@ export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles
             </TableRow>
         </TableHead>
         <TableBody>
-            {props.items.map((it: any, index: number) => {
-                return (
-                    <TableRow key={index}>
-                        {tableCell(it.uuid, props.classes)}
-                        {tableCell(it.linkClass, props.classes)}
-                        {tableCell(it.name, props.classes)}
-                        {tableCell(it.tailUuid, props.classes)}
-                        {tableCell(it.headUuid, props.classes)}
-                        {tableCell(JSON.stringify(it.properties, null, 2), props.classes)}
-                    </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>
-);
-
-const tableCell = (value: string, classes: any) =>
-    <TableCell className={classes.cell}>{value}</TableCell>;
\ No newline at end of file
+);
\ No newline at end of file