13494: Shows correct collection icon on DataTables.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 16 Oct 2020 14:04:53 +0000 (11:04 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 20 Oct 2020 20:59:19 +0000 (17:59 -0300)
Also, adds 'Status' column on collection by PDH panel, consistently with
the search results listings.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/groups-service/groups-service.ts
src/views-components/data-explorer/renderers.tsx
src/views/collection-content-address-panel/collection-content-address-panel.tsx

index 281aa92152abaaa07f46b169b90ffef27308edaf..f61b9eff05ab2d7b420d9ef764be8cdaf3cb215b 100644 (file)
@@ -9,6 +9,7 @@ import { AxiosInstance, AxiosRequestConfig } from "axios";
 import { CollectionResource } from "~/models/collection";
 import { ProjectResource } from "~/models/project";
 import { ProcessResource } from "~/models/process";
+import { WorkflowResource } from "~/models/workflow";
 import { TrashableResourceService } from "~/services/common-service/trashable-resource-service";
 import { ApiActions } from "~/services/api/api-actions";
 import { GroupResource } from "~/models/group";
@@ -31,7 +32,8 @@ export interface SharedArguments extends ListArguments {
 export type GroupContentsResource =
     CollectionResource |
     ProjectResource |
-    ProcessResource;
+    ProcessResource |
+    WorkflowResource;
 
 export class GroupsService<T extends GroupResource = GroupResource> extends TrashableResourceService<T> {
 
@@ -73,5 +75,6 @@ export class GroupsService<T extends GroupResource = GroupResource> extends Tras
 export enum GroupContentsResourcePrefix {
     COLLECTION = "collections",
     PROJECT = "groups",
-    PROCESS = "container_requests"
+    PROCESS = "container_requests",
+    WORKFLOW = "workflows"
 }
index 8afa45325ee7ba211950ab3015fbf4fb76fe603a..138c76efd24a9ba03cc66a71e51bacc775c6c601 100644 (file)
@@ -6,7 +6,7 @@ import * as React from 'react';
 import { Grid, Typography, withStyles, Tooltip, IconButton, Checkbox } from '@material-ui/core';
 import { FavoriteStar, PublicFavoriteStar } from '../favorite-star/favorite-star';
 import { ResourceKind, TrashableResource } from '~/models/resource';
-import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon, ShareIcon } from '~/components/icon/icon';
+import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, ShareIcon, CollectionOldVersionIcon, WorkflowIcon } from '~/components/icon/icon';
 import { formatDate, formatFileSize, formatTime } from '~/common/formatters';
 import { resourceLabel } from '~/common/labels';
 import { connect, DispatchProp } from 'react-redux';
@@ -28,10 +28,10 @@ import { withResourceData } from '~/views-components/data-explorer/with-resource
 import { CollectionResource } from '~/models/collection';
 import { IllegalNamingWarning } from '~/components/warning/warning';
 
-const renderName = (dispatch: Dispatch, item: { name: string; uuid: string, kind: string }) =>
+const renderName = (dispatch: Dispatch, item: GroupContentsResource) =>
     <Grid container alignItems="center" wrap="nowrap" spacing={16}>
         <Grid item>
-            {renderIcon(item.kind)}
+            {renderIcon(item)}
         </Grid>
         <Grid item>
             <Typography color="primary" style={{ width: 'auto', cursor: 'pointer' }} onClick={() => dispatch<any>(navigateTo(item.uuid))}>
@@ -52,15 +52,18 @@ const renderName = (dispatch: Dispatch, item: { name: string; uuid: string, kind
 export const ResourceName = connect(
     (state: RootState, props: { uuid: string }) => {
         const resource = getResource<GroupContentsResource>(props.uuid)(state.resources);
-        return resource || { name: '', uuid: '', kind: '' };
-    })((resource: { name: string; uuid: string, kind: string } & DispatchProp<any>) => renderName(resource.dispatch, resource));
+        return resource;
+    })((resource: GroupContentsResource & DispatchProp<any>) => renderName(resource.dispatch, resource));
 
-const renderIcon = (kind: string) => {
-    switch (kind) {
+const renderIcon = (item: GroupContentsResource) => {
+    switch (item.kind) {
         case ResourceKind.PROJECT:
             return <ProjectIcon />;
         case ResourceKind.COLLECTION:
-            return <CollectionIcon />;
+            if (item.uuid === item.currentVersionUuid) {
+                return <CollectionIcon />;
+            }
+            return <CollectionOldVersionIcon />;
         case ResourceKind.PROCESS:
             return <ProcessIcon />;
         case ResourceKind.WORKFLOW:
@@ -74,10 +77,10 @@ const renderDate = (date?: string) => {
     return <Typography noWrap style={{ minWidth: '100px' }}>{formatDate(date)}</Typography>;
 };
 
-const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
+const renderWorkflowName = (item: WorkflowResource) =>
     <Grid container alignItems="center" wrap="nowrap" spacing={16}>
         <Grid item>
-            {renderIcon(item.kind)}
+            {renderIcon(item)}
         </Grid>
         <Grid item>
             <Typography color="primary" style={{ width: '100px' }}>
@@ -89,7 +92,7 @@ const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ow
 export const ResourceWorkflowName = connect(
     (state: RootState, props: { uuid: string }) => {
         const resource = getResource<WorkflowResource>(props.uuid)(state.resources);
-        return resource || { name: '', uuid: '', kind: '', ownerUuid: '' };
+        return resource;
     })(renderWorkflowName);
 
 const getPublicUuid = (uuidPrefix: string) => {
index b652b502886653bcf43695cf80eeaefd8d9e86bf..925c5848db6b502ccd4576dfae38b26e9fc1f634 100644 (file)
@@ -20,7 +20,7 @@ import { navigateTo } from '~/store/navigation/navigation-action';
 import { DataColumns } from '~/components/data-table/data-table';
 import { SortDirection } from '~/components/data-table/data-column';
 import { createTree } from '~/models/tree';
-import { ResourceName, ResourceOwnerName, ResourceLastModifiedDate } from '~/views-components/data-explorer/renderers';
+import { ResourceName, ResourceOwnerName, ResourceLastModifiedDate, ResourceStatus } from '~/views-components/data-explorer/renderers';
 
 type CssRules = 'backLink' | 'backIcon' | 'card' | 'title' | 'iconHeader' | 'link';
 
@@ -59,6 +59,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 enum CollectionContentAddressPanelColumnNames {
     COLLECTION_WITH_THIS_ADDRESS = "Collection with this address",
+    STATUS = "Status",
     LOCATION = "Location",
     LAST_MODIFIED = "Last modified"
 }
@@ -72,6 +73,13 @@ export const collectionContentAddressPanelColumns: DataColumns<string> = [
         filters: createTree(),
         render: uuid => <ResourceName uuid={uuid} />
     },
+    {
+        name: CollectionContentAddressPanelColumnNames.STATUS,
+        selected: true,
+        configurable: true,
+        filters: createTree(),
+        render: uuid => <ResourceStatus uuid={uuid} />
+    },
     {
         name: CollectionContentAddressPanelColumnNames.LOCATION,
         selected: true,