X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/d60348e41975a5e48f09773f4d0accec11e93da4..5b30fab0552f623a35ff5b89b90dab82dfcee258:/src/views/collection-panel/collection-panel.tsx diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx index 5aeaef18..d93d6e92 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -3,7 +3,6 @@ // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; -import { Dispatch } from 'redux'; import { StyleRulesCallback, WithStyles, @@ -12,33 +11,33 @@ import { Grid, Tooltip, Typography, - Card + Card, CardHeader, CardContent } from '@material-ui/core'; import { connect, DispatchProp } from "react-redux"; import { RouteComponentProps } from 'react-router'; import { ArvadosTheme } from 'common/custom-theme'; import { RootState } from 'store/store'; -import { MoreOptionsIcon, CollectionIcon, ReadOnlyIcon, CollectionOldVersionIcon, RenameIcon } from 'components/icon/icon'; +import { MoreVerticalIcon, CollectionIcon, ReadOnlyIcon, CollectionOldVersionIcon } from 'components/icon/icon'; import { DetailsAttribute } from 'components/details-attribute/details-attribute'; import { CollectionResource, getCollectionUrl } from 'models/collection'; import { CollectionPanelFiles } from 'views-components/collection-panel-files/collection-panel-files'; -import { navigateToProcess, collectionPanelActions } from 'store/collection-panel/collection-panel-action'; +import { navigateToProcess } from 'store/collection-panel/collection-panel-action'; import { getResource } from 'store/resources/resources'; import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions'; import { formatDate, formatFileSize } from "common/formatters"; -import { openDetailsPanel, openResourcePropertiesDialog } from 'store/details-panel/details-panel-action'; +import { openDetailsPanel } from 'store/details-panel/details-panel-action'; import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; import { getPropertyChip } from 'views-components/resource-properties-form/property-chip'; import { IllegalNamingWarning } from 'components/warning/warning'; import { GroupResource } from 'models/group'; import { UserResource } from 'models/user'; import { getUserUuid } from 'common/getuser'; -import { getProgressIndicator } from 'store/progress-indicator/progress-indicator-reducer'; -import { COLLECTION_PANEL_LOAD_FILES, loadCollectionFiles, COLLECTION_PANEL_LOAD_FILES_THRESHOLD } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions'; import { Link } from 'react-router-dom'; import { Link as ButtonLink } from '@material-ui/core'; -import { ResourceOwnerWithName, ResponsiblePerson } from 'views-components/data-explorer/renderers'; +import { ResourceWithName, ResponsiblePerson } from 'views-components/data-explorer/renderers'; import { MPVContainer, MPVPanelContent, MPVPanelState } from 'components/multi-panel-view/multi-panel-view'; +import { resourceIsFrozen } from 'common/frozen-resources'; +import { NotFoundView } from 'views/not-found-panel/not-found-panel'; type CssRules = 'root' | 'button' @@ -53,7 +52,11 @@ type CssRules = 'root' | 'centeredLabel' | 'warningLabel' | 'collectionName' - | 'readOnlyIcon'; + | 'readOnlyIcon' + | 'header' + | 'title' + | 'avatar' + | 'content'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { @@ -63,9 +66,6 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ cursor: 'pointer' }, infoCard: { - paddingLeft: theme.spacing.unit * 2, - paddingRight: theme.spacing.unit * 2, - paddingBottom: theme.spacing.unit * 2, }, propertiesCard: { padding: 0, @@ -75,14 +75,14 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, iconHeader: { fontSize: '1.875rem', - color: theme.customs.colors.yellow700 + color: theme.customs.colors.greyL }, tag: { - marginRight: theme.spacing.unit, - marginBottom: theme.spacing.unit + marginRight: theme.spacing.unit / 2, + marginBottom: theme.spacing.unit / 2 }, label: { - fontSize: '0.875rem' + fontSize: '0.875rem', }, centeredLabel: { fontSize: '0.875rem', @@ -108,6 +108,26 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ readOnlyIcon: { marginLeft: theme.spacing.unit, fontSize: 'small', + }, + header: { + paddingTop: theme.spacing.unit, + paddingBottom: theme.spacing.unit, + }, + title: { + overflow: 'hidden', + paddingTop: theme.spacing.unit * 0.5, + color: theme.customs.colors.green700, + }, + avatar: { + alignSelf: 'flex-start', + paddingTop: theme.spacing.unit * 0.5 + }, + content: { + padding: theme.spacing.unit * 1.0, + paddingTop: theme.spacing.unit * 0.5, + '&:last-child': { + paddingBottom: theme.spacing.unit * 1, + } } }); @@ -116,14 +136,12 @@ interface CollectionPanelDataProps { isWritable: boolean; isOldVersion: boolean; isLoadingFiles: boolean; - tooManyFiles: boolean; } -type CollectionPanelProps = CollectionPanelDataProps & DispatchProp - & WithStyles & RouteComponentProps<{ id: string }>; +type CollectionPanelProps = CollectionPanelDataProps & DispatchProp & WithStyles -export const CollectionPanel = withStyles(styles)( - connect((state: RootState, props: RouteComponentProps<{ id: string }>) => { +export const CollectionPanel = withStyles(styles)(connect( + (state: RootState, props: RouteComponentProps<{ id: string }>) => { const currentUserUUID = getUserUuid(state); const item = getResource(props.match.params.id)(state.resources); let isWritable = false; @@ -133,94 +151,95 @@ export const CollectionPanel = withStyles(styles)( isWritable = true; } else { const itemOwner = getResource(item.ownerUuid)(state.resources); - if (itemOwner && itemOwner.writableBy) { - isWritable = itemOwner.writableBy.indexOf(currentUserUUID || '') >= 0; + if (itemOwner) { + isWritable = itemOwner.canWrite; } } } - const loadingFilesIndicator = getProgressIndicator(COLLECTION_PANEL_LOAD_FILES)(state.progressIndicator); - const isLoadingFiles = (loadingFilesIndicator && loadingFilesIndicator!.working) || false; - const tooManyFiles = (!state.collectionPanel.loadBigCollections && item && item.fileCount > COLLECTION_PANEL_LOAD_FILES_THRESHOLD) || false; - return { item, isWritable, isOldVersion, isLoadingFiles, tooManyFiles }; + + if (item && isWritable) { + isWritable = !resourceIsFrozen(item, state.resources); + } + + return { item, isWritable, isOldVersion }; })( class extends React.Component { render() { - const { classes, item, dispatch, isWritable, isOldVersion, isLoadingFiles, tooManyFiles } = this.props; + const { classes, item, dispatch, isWritable, isOldVersion } = this.props; const panelsData: MPVPanelState[] = [ - {name: "Details"}, - {name: "Files"}, + { name: "Details" }, + { name: "Files" }, ]; return item ? - - - - {isOldVersion - ? - : } - - + + {isOldVersion + ? + : } + } + title={ + {item.name} {isWritable || - - } + } - - + } + action={ - + - - - - - - {item.description} + } + /> + + + {item.description} + + dispatch(openDetailsPanel(item.uuid, 1))} /> + {(item.properties.container_request || item.properties.containerRequest) && + dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> + + + } + {isOldVersion && + + This is an old version. Make a copy to make changes. Go to the head version for sharing options. - dispatch(openDetailsPanel(item.uuid, 1))} /> - {(item.properties.container_request || item.properties.containerRequest) && - dispatch(navigateToProcess(item.properties.container_request || item.properties.containerRequest))}> - - - } - {isOldVersion && - - This is an old version. Make a copy to make changes. Go to the head version for sharing options. - - } - - + } + - { - dispatch(collectionPanelActions.LOAD_BIG_COLLECTIONS(true)); - dispatch(loadCollectionFiles(this.props.item.uuid)); - } - } /> + - - : null; + + : + ; } handleContextMenu = (event: React.MouseEvent) => { - const { uuid, ownerUuid, name, description, kind, storageClassesDesired } = this.props.item; + const { uuid, ownerUuid, name, description, + kind, storageClassesDesired, properties } = this.props.item; const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(uuid)); const resource = { uuid, @@ -230,6 +249,7 @@ export const CollectionPanel = withStyles(styles)( storageClassesDesired, kind, menuKind, + properties, }; // Avoid expanding/collapsing the panel event.stopPropagation(); @@ -259,10 +279,6 @@ export const CollectionPanel = withStyles(styles)( ) ); -interface CollectionDetailsActionProps { - onClick: () => void; -} - interface CollectionDetailsProps { item: CollectionResource; classes?: any; @@ -270,12 +286,7 @@ interface CollectionDetailsProps { showVersionBrowser?: () => void; } -const mapDispatchToProps = (dispatch: Dispatch) => ({ - onClick: () => dispatch(openResourcePropertiesDialog()), -}); - -export const CollectionDetailsAttributes = connect(null, mapDispatchToProps)( -(props: CollectionDetailsProps & CollectionDetailsActionProps) => { +export const CollectionDetailsAttributes = (props: CollectionDetailsProps) => { const item = props.item; const classes = props.classes || { label: '', value: '', button: '', tag: '' }; const isOldVersion = item && item.currentVersionUuid !== item.uuid; @@ -296,7 +307,7 @@ export const CollectionDetailsAttributes = connect(null, mapDispatchToProps)( } /> + uuidEnhancer={(uuid: string) => } />
@@ -331,7 +342,7 @@ export const CollectionDetailsAttributes = connect(null, mapDispatchToProps)( + label='Number of files' value={{item.fileCount}} /> - + + {/* + NOTE: The property list should be kept at the bottom, because it spans + the entire available width, without regards of the twoCol prop. + */} + - { !props.twoCol - ?
- -
- : '' } -
- { Object.keys(item.properties).length > 0 + label='Properties' /> + {Object.keys(item.properties).length > 0 ? Object.keys(item.properties).map(k => - Array.isArray(item.properties[k]) + Array.isArray(item.properties[k]) ? item.properties[k].map((v: string) => getPropertyChip(k, v, undefined, classes.tag)) : getPropertyChip(k, item.properties[k], undefined, classes.tag)) - :
No properties
} + :
No properties
}
; -}); +};