X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/20bb2125fddc247d8ff2df960b3d4d316e4a0d13..d9c7613b436dad495a2b5a3d06b58c5cd5ef9592:/src/views-components/data-explorer/renderers.tsx diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index 039ef47f..c8c64280 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -3,10 +3,10 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { Grid, Typography, withStyles } from '@material-ui/core'; +import { Grid, Typography, withStyles, Tooltip, IconButton } from '@material-ui/core'; import { FavoriteStar } from '../favorite-star/favorite-star'; import { ResourceKind, TrashableResource } from '~/models/resource'; -import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon } from '~/components/icon/icon'; +import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, WorkflowIcon, ShareIcon } from '~/components/icon/icon'; import { formatDate, formatFileSize } from '~/common/formatters'; import { resourceLabel } from '~/common/labels'; import { connect } from 'react-redux'; @@ -17,7 +17,10 @@ import { getProcess, Process, getProcessStatus, getProcessStatusColor } from '~/ import { ArvadosTheme } from '~/common/custom-theme'; import { compose } from 'redux'; import { WorkflowResource } from '~/models/workflow'; -import { ResourceStatus } from '~/views/workflow-panel/workflow-panel'; +import { ResourceStatus } from '~/views/workflow-panel/workflow-panel-view'; +import { getUuidPrefix } from '~/store/workflow-panel/workflow-panel-actions'; +import { CollectionResource } from "~/models/collection"; +import { getResourceData } from "~/store/resources-data/resources-data"; export const renderName = (item: { name: string; uuid: string, kind: string }) => @@ -57,7 +60,11 @@ export const renderIcon = (item: { kind: string }) => { } }; -export const renderWorkflowName = (item: { name: string; uuid: string, kind: string }) => +export const renderDate = (date?: string) => { + return {formatDate(date)}; +}; + +export const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) => {renderIcon(item)} @@ -71,27 +78,60 @@ export const renderWorkflowName = (item: { name: string; uuid: string, kind: str export const RosurceWorkflowName = connect( (state: RootState, props: { uuid: string }) => { - const resource = getResource(props.uuid)(state.resources); - return resource || { name: '', uuid: '', kind: '' }; + const resource = getResource(props.uuid)(state.resources); + return resource || { name: '', uuid: '', kind: '', ownerUuid: '' }; })(renderWorkflowName); -export const renderDate = (date?: string) => { - return {formatDate(date)}; +const getPublicUuid = (uuidPrefix: string) => { + return `${uuidPrefix}-tpzed-anonymouspublic`; +}; + +// ToDo: share onClick +export const resourceShare = (uuidPrefix: string, ownerUuid?: string) => { + const isPublic = ownerUuid === getPublicUuid(uuidPrefix); + return ( +
+ { isPublic && + + undefined}> + + + + } +
+ ); }; -export const renderWorkflowStatus = (ownerUuid?: string) => { - if (ownerUuid === 'qr1hi-j7d0g-2ax8o1pscovq2lg') { - return {ResourceStatus.PUBLIC}; +export const ResourceShare = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + const uuidPrefix = getUuidPrefix(state); + return { + ownerUuid: resource ? resource.ownerUuid : '', + uuidPrefix + }; + })((props: { ownerUuid?: string, uuidPrefix: string }) => resourceShare(props.uuidPrefix, props.ownerUuid)); + +export const renderWorkflowStatus = (uuidPrefix: string, ownerUuid?: string) => { + if (ownerUuid === getPublicUuid(uuidPrefix)) { + return renderStatus(ResourceStatus.PUBLIC); } else { - return {ResourceStatus.PRIVATE}; + return renderStatus(ResourceStatus.PRIVATE); } }; +const renderStatus = (status: string) => + {status}; + export const ResourceWorkflowStatus = connect( (state: RootState, props: { uuid: string }) => { const resource = getResource(props.uuid)(state.resources); - return { ownerUuid: resource ? resource.ownerUuid : '' }; - })((props: { ownerUuid?: string }) => renderWorkflowStatus(props.ownerUuid)); + const uuidPrefix = getUuidPrefix(state); + return { + ownerUuid: resource ? resource.ownerUuid : '', + uuidPrefix + }; + })((props: { ownerUuid?: string, uuidPrefix: string }) => renderWorkflowStatus(props.uuidPrefix, props.ownerUuid)); export const ResourceLastModifiedDate = connect( (state: RootState, props: { uuid: string }) => { @@ -118,8 +158,8 @@ export const renderFileSize = (fileSize?: number) => export const ResourceFileSize = connect( (state: RootState, props: { uuid: string }) => { - const resource = getResource(props.uuid)(state.resources); - return {}; + const resource = getResourceData(props.uuid)(state.resourcesData); + return { fileSize: resource ? resource.fileSize : 0 }; })((props: { fileSize?: number }) => renderFileSize(props.fileSize)); export const renderOwner = (owner: string) =>