18594: Added multiple tails display, added tests
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 10 Feb 2022 21:54:13 +0000 (22:54 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 10 Feb 2022 21:54:13 +0000 (22:54 +0100)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/project.spec.js
src/store/advanced-tab/advanced-tab.tsx
src/views-components/advanced-tab-dialog/advanced-tab-dialog.tsx
src/views-components/advanced-tab-dialog/metadataTab.tsx

index f369330e577090011ffc222837fe4ca214a8904a..96e73bc127d197e81aab1d496ae342a59fe30647 100644 (file)
@@ -200,7 +200,10 @@ describe('Project tests', function() {
         cy.createGroup(activeUser.token, {
             name: `Test root project ${Math.floor(Math.random() * 999999)}`,
             group_class: 'project',
         cy.createGroup(activeUser.token, {
             name: `Test root project ${Math.floor(Math.random() * 999999)}`,
             group_class: 'project',
-        }).as('testProject1');
+        }).as('testProject1').then((testProject1) => {
+      
+            cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, 'can_write');
+        });
 
         cy.getAll('@testProject1').then(function([testProject1]) {
             cy.loginAs(activeUser);
 
         cy.getAll('@testProject1').then(function([testProject1]) {
             cy.loginAs(activeUser);
@@ -216,29 +219,46 @@ describe('Project tests', function() {
     });
 
     it('opens advanced popup for project with username', () => {
     });
 
     it('opens advanced popup for project with username', () => {
-        const projectName = `Test root project ${Math.floor(Math.random() * 999999)}`;
-
-        cy.createProject({
-            owningUser: adminUser,
-            targetUser: activeUser,
-            projectName,
-            canWrite: true,
-            addToFavorites: true
-        }).as('mySharedProject');
-
-        cy.getAll('@mySharedProject')
-            .then(function ([mySharedProject]) {
-                cy.loginAs(activeUser);
+        const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
+
+        cy.createGroup(adminUser.token, {
+            name: projectName,
+            group_class: 'project',
+        }).as('mainProject')
+
+        cy.getAll('@mainProject')
+            .then(function ([mainProject]) {
+                cy.loginAs(adminUser);
                 
                 
-                cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
+                cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
+
+                cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
+                    cy.createLink(adminUser.token, {
+                        name: 'can_write',
+                        link_class: 'permission',
+                        head_uuid: mainProject.uuid,
+                        tail_uuid: uuid
+                    });
 
 
-                cy.get('main').contains(projectName).rightclick();
+                    cy.createLink(adminUser.token, {
+                        name: 'can_write',
+                        link_class: 'permission',
+                        head_uuid: mainProject.uuid,
+                        tail_uuid: activeUser.user.uuid
+                    });
+
+                    cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
+
+                    cy.get('main').contains(projectName).rightclick();
 
 
-                cy.get('[data-cy=context-menu]').contains('Advanced').click();
+                    cy.get('[data-cy=context-menu]').contains('Advanced').click();
 
 
-                cy.get('[role=tablist]').contains('METADATA').click();
+                    cy.get('[role=tablist]').contains('METADATA').click();
 
 
-                cy.get('td').contains('User: Active User').should('exist');
+                    cy.get('td').contains(uuid).should('exist');
+
+                    cy.get('td').contains('Active User').should('exist');
+                });
         });
     });
 });
\ No newline at end of file
         });
     });
 });
\ No newline at end of file
index 052df3a2622fc3b4b68eda28897345f7cd748505..33faebbed67a7dd7c0da27bbecfcc35dcf820964 100644 (file)
@@ -18,7 +18,7 @@ import { ListResults } from 'services/common-service/common-service';
 import { RepositoryResource } from 'models/repositories';
 import { SshKeyResource } from 'models/ssh-key';
 import { VirtualMachinesResource } from 'models/virtual-machines';
 import { RepositoryResource } from 'models/repositories';
 import { SshKeyResource } from 'models/ssh-key';
 import { VirtualMachinesResource } from 'models/virtual-machines';
-import { UserResource } from 'models/user';
+import { UserResource, getUserDisplayName } from 'models/user';
 import { LinkResource } from 'models/link';
 import { KeepServiceResource } from 'models/keep-services';
 import { ApiClientAuthorization } from 'models/api-client-authorization';
 import { LinkResource } from 'models/link';
 import { KeepServiceResource } from 'models/keep-services';
 import { ApiClientAuthorization } from 'models/api-client-authorization';
@@ -282,11 +282,18 @@ const getDataForAdvancedTab = (uuid: string) =>
         });
         let user;
 
         });
         let user;
 
-        try {
-            if (metadata.itemsAvailable && metadata.items[0].tailKind === ResourceKind.USER) {
-                user = await services.userService.get(metadata.items[0].tailUuid || '');
-            }
-        } catch {};
+        if (metadata.itemsAvailable) {
+            metadata.items.forEach(async (item) => {
+                const {tailKind, tailUuid, properties} = item;
+                properties['tail'] = tailUuid;
+                try {
+                    if (tailKind === ResourceKind.USER && tailUuid) {
+                        user = await services.userService.get(tailUuid);
+                        properties['tail'] = getUserDisplayName(user);
+                    }
+                } catch {};
+            });
+        }
 
         return { data, metadata, user };
     };
 
         return { data, metadata, user };
     };
index b631a74cee2e828328e87068bcc104880ba189e1..e8d4aaefd3773b6f13f1cba008951c740ecab6fc 100644 (file)
@@ -78,7 +78,11 @@ export const AdvancedTabDialog = compose(
                 </Tabs>
                 <DialogContent className={classes.content}>
                     {value === 0 && <div>{dialogContentExample(apiResponse, classes)}</div>}
                 </Tabs>
                 <DialogContent className={classes.content}>
                     {value === 0 && <div>{dialogContentExample(apiResponse, classes)}</div>}
-                    {value === 1 && <div>{metadata !== '' && metadata.items.length > 0 ? <MetadataTab items={metadata.items} uuid={uuid} user={user} /> : dialogContentHeader('(No metadata links found)')}</div>}
+                    {value === 1 && <div>
+                        {metadata !== '' && metadata.items.length > 0 ?
+                            <MetadataTab items={metadata.items} uuid={uuid} user={user} />
+                            : dialogContentHeader('(No metadata links found)')}
+                    </div>}
                     {value === 2 && dialogContent(pythonHeader, pythonExample, classes)}
                     {value === 3 && <div>
                         {dialogContent(cliGetHeader, cliGetExample, classes)}
                     {value === 2 && dialogContent(pythonHeader, pythonExample, classes)}
                     {value === 3 && <div>
                         {dialogContent(cliGetHeader, cliGetExample, classes)}
index 9f08d1e3baa77612935635a5d0422b885a4fa408..88d0137f8a7ede6a1df055a3250a8a10325e67e8 100644 (file)
@@ -4,7 +4,7 @@
 
 import React from "react";
 import { Table, TableHead, TableCell, TableRow, TableBody, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
 
 import React from "react";
 import { Table, TableHead, TableCell, TableRow, TableBody, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { UserResource, getUserDisplayName } from "models/user";
+import { UserResource } from "models/user";
 
 type CssRules = 'cell';
 
 
 type CssRules = 'cell';
 
@@ -47,9 +47,9 @@ export const MetadataTab = withStyles(styles)((props: MetadataProps & WithStyles
                     <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.uuid}</TableCell>
                     <TableCell className={props.classes.cell}>{it.linkClass}</TableCell>
                     <TableCell className={props.classes.cell}>{it.name}</TableCell>
-                    <TableCell className={props.classes.cell}>{props.user && `User: ${getUserDisplayName(props.user)}`}</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}>{it.headUuid === props.uuid ? 'this' : it.headUuid}</TableCell>
-                    <TableCell className={props.classes.cell}>{JSON.stringify(it.properties)}</TableCell>
+                    <TableCell className={props.classes.cell}>{JSON.stringify(it.properties, (key, value) => { return key === 'tail' ? undefined : value; })}</TableCell>
                 </TableRow>
             )}
         </TableBody>
                 </TableRow>
             )}
         </TableBody>