X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/524ce540a6aacece98c402591b8907d2d52122e7..17a3019e33d6d6820f50dabfa9d9ad7a4b02a4b8:/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 e09160661b..d274157c48 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -36,7 +36,7 @@ import { connect, DispatchProp } from 'react-redux'; import { RootState } from 'store/store'; import { getResource, filterResources } from 'store/resources/resources'; import { GroupContentsResource } from 'services/groups-service/groups-service'; -import { getProcess, Process, getProcessStatus, getProcessStatusColor, getProcessRuntime } from 'store/processes/process'; +import { getProcess, Process, getProcessStatus, getProcessStatusStyles, getProcessRuntime } from 'store/processes/process'; import { ArvadosTheme } from 'common/custom-theme'; import { compose, Dispatch } from 'redux'; import { WorkflowResource } from 'models/workflow'; @@ -61,9 +61,10 @@ import { getUserUuid } from 'common/getuser'; import { VirtualMachinesResource } from 'models/virtual-machines'; import { CopyToClipboardSnackbar } from 'components/copy-to-clipboard-snackbar/copy-to-clipboard-snackbar'; import { ProjectResource } from 'models/project'; +import { ProcessResource } from 'models/process'; -const renderName = (dispatch: Dispatch, item: GroupContentsResource) => { +const renderName = (dispatch: Dispatch, item: GroupContentsResource) => { const navFunc = ("groupClass" in item && item.groupClass === GroupClass.ROLE ? navigateToGroupDetails : navigateTo); return @@ -89,6 +90,7 @@ const renderName = (dispatch: Dispatch, item: GroupContentsResource) => { ; }; + const FrozenProject = (props: {item: ProjectResource}) => { const [fullUsername, setFullusername] = React.useState(null); const getFullName = React.useCallback(() => { @@ -113,6 +115,7 @@ export const ResourceName = connect( return resource; })((resource: GroupContentsResource & DispatchProp) => renderName(resource.dispatch, resource)); + const renderIcon = (item: GroupContentsResource) => { switch (item.kind) { case ResourceKind.PROJECT: @@ -227,7 +230,12 @@ export const UserResourceFullName = connect( const renderUuid = (item: { uuid: string }) => {item.uuid} - + {(item.uuid && ) || '-' } + ; + +const renderUuidCopyIcon = (item: { uuid: string }) => + + {(item.uuid && ) || '-' } ; export const ResourceUuid = connect((state: RootState, props: { uuid: string }) => ( @@ -446,7 +454,7 @@ export const ResourceCluster = (props: { uuid: string }) => { // Links Resources const renderLinkName = (item: { name: string }) => - {item.name || '(none)'}; + {item.name || '-'}; export const ResourceLinkName = connect( (state: RootState, props: { uuid: string }) => { @@ -664,17 +672,69 @@ export const ResourceWorkflowStatus = connect( }; })((props: { ownerUuid?: string, uuidPrefix: string }) => renderWorkflowStatus(props.uuidPrefix, props.ownerUuid)); -export const ResourceLastModifiedDate = connect( +export const ResourceContainerUuid = connect( (state: RootState, props: { uuid: string }) => { - const resource = getResource(props.uuid)(state.resources); - return { date: resource ? resource.modifiedAt : '' }; - })((props: { date: string }) => renderDate(props.date)); + const process = getProcess(props.uuid)(state.resources) + return { uuid: process?.container?.uuid ? process?.container?.uuid : '' }; + })((props: { uuid: string }) => renderUuid({ uuid: props.uuid })); + +enum ColumnSelection { + OUTPUT_UUID = 'outputUuid', + LOG_UUID = 'logUuid' +} -export const ResourceCreatedAtDate = connect( +const renderUuidLinkWithCopyIcon = (dispatch: Dispatch, item: ProcessResource, column: string) => { + const selectedColumnUuid = item[column] + return + + {selectedColumnUuid ? + dispatch(navigateTo(selectedColumnUuid))}> + {selectedColumnUuid} + + : '-' } + + + {selectedColumnUuid && renderUuidCopyIcon({ uuid: selectedColumnUuid })} + + ; +}; + +export const ResourceOutputUuid = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return resource; + })((process: ProcessResource & DispatchProp) => renderUuidLinkWithCopyIcon(process.dispatch, process, ColumnSelection.OUTPUT_UUID)); + +export const ResourceLogUuid = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return resource; + })((process: ProcessResource & DispatchProp) => renderUuidLinkWithCopyIcon(process.dispatch, process, ColumnSelection.LOG_UUID)); + +export const ResourceParentProcess = connect( + (state: RootState, props: { uuid: string }) => { + const process = getProcess(props.uuid)(state.resources) + return { parentProcess: process?.containerRequest?.requestingContainerUuid || '' }; + })((props: { parentProcess: string }) => renderUuid({uuid: props.parentProcess})); + +export const ResourceModifiedByUserUuid = connect( + (state: RootState, props: { uuid: string }) => { + const process = getProcess(props.uuid)(state.resources) + return { userUuid: process?.containerRequest?.modifiedByUserUuid || '' }; + })((props: { userUuid: string }) => renderUuid({uuid: props.userUuid})); + + export const ResourceCreatedAtDate = connect( (state: RootState, props: { uuid: string }) => { const resource = getResource(props.uuid)(state.resources); return { date: resource ? resource.createdAt : '' }; })((props: { date: string }) => renderDate(props.date)); + +export const ResourceLastModifiedDate = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return { date: resource ? resource.modifiedAt : '' }; + })((props: { date: string }) => renderDate(props.date)); export const ResourceTrashDate = connect( (state: RootState, props: { uuid: string }) => { @@ -706,7 +766,7 @@ export const ResourceFileSize = connect( const renderOwner = (owner: string) => - {owner} + {owner || '-'} ; export const ResourceOwner = connect( @@ -723,6 +783,45 @@ export const ResourceOwnerName = connect( return { owner: ownerName ? ownerName!.name : resource!.ownerUuid }; })((props: { owner: string }) => renderOwner(props.owner)); +export const ResourceUUID = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return { uuid: resource ? resource.uuid : '' }; + })((props: { uuid: string }) => renderUuid({uuid: props.uuid})); + +const renderVersion = (version: number) =>{ + return {version ?? '-'} +} + +export const ResourceVersion = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return { version: resource ? resource.version: '' }; + })((props: { version: number }) => renderVersion(props.version)); + +const renderPortableDataHash = (portableDataHash:string | null) => + + {portableDataHash ? <>{portableDataHash} + : '-' } + + +export const ResourcePortableDataHash = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return { portableDataHash: resource ? resource.portableDataHash : '' }; + })((props: { portableDataHash: string }) => renderPortableDataHash(props.portableDataHash)); + + +const renderFileCount = (fileCount: number) =>{ + return {fileCount ?? '-'} +} + +export const ResourceFileCount = connect( + (state: RootState, props: { uuid: string }) => { + const resource = getResource(props.uuid)(state.resources); + return { fileCount: resource ? resource.fileCount: '' }; + })((props: { fileCount: number }) => renderFileCount(props.fileCount)); + const userFromID = connect( (state: RootState, props: { uuid: string }) => { @@ -745,11 +844,14 @@ const ownerFromResourceId = userFromID ); + + + + const _resourceWithName = withStyles({}, { withTheme: true }) ((props: { uuid: string, userFullname: string, dispatch: Dispatch, theme: ArvadosTheme }) => { const { uuid, userFullname, dispatch, theme } = props; - if (userFullname === '') { dispatch(loadResource(uuid, false)); return @@ -766,6 +868,8 @@ export const ResourceOwnerWithName = ownerFromResourceId(_resourceWithName); export const ResourceWithName = userFromID(_resourceWithName); + + export const UserNameFromID = compose(userFromID)( (props: { uuid: string, displayAsText?: string, userFullname: string, dispatch: Dispatch }) => { @@ -862,6 +966,16 @@ export const CollectionStatus = connect((state: RootState, props: { uuid: string : head version ); +export const CollectionName = connect((state: RootState, props: { uuid: string, className?: string }) => { + return { + collection: getResource(props.uuid)(state.resources), + uuid: props.uuid, + className: props.className, + }; +})((props: { collection: CollectionResource, uuid: string, className?: string }) => + {props.collection?.name || props.uuid} +); + export const ProcessStatus = compose( connect((state: RootState, props: { uuid: string }) => { return { process: getProcess(props.uuid)(state.resources) }; @@ -873,15 +987,14 @@ export const ProcessStatus = compose( style={{ height: props.theme.spacing.unit * 3, width: props.theme.spacing.unit * 12, - backgroundColor: getProcessStatusColor( + ...getProcessStatusStyles( getProcessStatus(props.process), props.theme), - color: props.theme.palette.common.white, fontSize: '0.875rem', borderRadius: props.theme.spacing.unit * 0.625, }} /> : - - ); + ); export const ProcessStartDate = connect( (state: RootState, props: { uuid: string }) => { @@ -929,6 +1042,6 @@ export const ContainerRunTime = connect((state: RootState, props: { uuid: string } render() { - return renderRunTime(this.state.runtime); + return this.props.process ? renderRunTime(this.state.runtime) : -; } });