X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f8fb6725beec5b2bf0eec7f375d49f9189ff1bc3..7776b799eed223b9318443c1e319e01957a8fb45:/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 953e5b4c..4cdd8c55 100644 --- a/src/views/collection-panel/collection-panel.tsx +++ b/src/views/collection-panel/collection-panel.tsx @@ -12,16 +12,16 @@ 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, ExpandIcon } from '~/components/icon/icon'; +import { MoreOptionsIcon, CollectionIcon, ReadOnlyIcon, ExpandIcon, CollectionOldVersionIcon } from '~/components/icon/icon'; import { DetailsAttribute } from '~/components/details-attribute/details-attribute'; -import { CollectionResource } from '~/models/collection'; +import { CollectionResource, getCollectionUrl } from '~/models/collection'; import { CollectionPanelFiles } from '~/views-components/collection-panel-files/collection-panel-files'; import { CollectionTagForm } from './collection-tag-form'; import { deleteCollectionTag, navigateToProcess, collectionPanelActions } from '~/store/collection-panel/collection-panel-action'; import { getResource } from '~/store/resources/resources'; import { openContextMenu } from '~/store/context-menu/context-menu-actions'; import { ContextMenuKind } from '~/views-components/context-menu/context-menu'; -import { formatFileSize } from "~/common/formatters"; +import { formatDate, formatFileSize } from "~/common/formatters"; 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'; @@ -31,6 +31,7 @@ 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'; type CssRules = 'root' | 'filesCard' @@ -40,6 +41,8 @@ type CssRules = 'root' | 'value' | 'link' | 'centeredLabel' + | 'warningLabel' + | 'collectionName' | 'readOnlyIcon'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ @@ -67,6 +70,12 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ fontSize: '0.875rem', textAlign: 'center' }, + warningLabel: { + fontStyle: 'italic' + }, + collectionName: { + flexDirection: 'column', + }, value: { textTransform: 'none', fontSize: '0.875rem' @@ -87,6 +96,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ interface CollectionPanelDataProps { item: CollectionResource; isWritable: boolean; + isOldVersion: boolean; isLoadingFiles: boolean; tooManyFiles: boolean; } @@ -99,72 +109,75 @@ export const CollectionPanel = withStyles(styles)( const currentUserUUID = getUserUuid(state); const item = getResource(props.match.params.id)(state.resources); let isWritable = false; - if (item && item.ownerUuid === currentUserUUID) { - isWritable = true; - } else if (item) { - const itemOwner = getResource(item.ownerUuid)(state.resources); - if (itemOwner) { - isWritable = itemOwner.writableBy.indexOf(currentUserUUID || '') >= 0; + const isOldVersion = item && item.currentVersionUuid !== item.uuid; + if (item && !isOldVersion) { + if (item.ownerUuid === currentUserUUID) { + isWritable = true; + } else { + const itemOwner = getResource(item.ownerUuid)(state.resources); + if (itemOwner) { + isWritable = itemOwner.writableBy.indexOf(currentUserUUID || '') >= 0; + } } } 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, isLoadingFiles, tooManyFiles }; + return { item, isWritable, isOldVersion, isLoadingFiles, tooManyFiles }; })( class extends React.Component { render() { - const { classes, item, dispatch, isWritable, isLoadingFiles, tooManyFiles } = this.props; + const { classes, item, dispatch, isWritable, isOldVersion, isLoadingFiles, tooManyFiles } = this.props; return item ?
}> - - - - - - {item.name} - {isWritable || - - - - } - + + + + {isOldVersion + ? + : } + + + + {item.name} + {isWritable || + + + + } + + + + + + + + + + - + {item.description} - - - - - + {(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. + + } @@ -180,25 +193,25 @@ export const CollectionPanel = withStyles(styles)( } - { Object.keys(item.properties).length > 0 - ? Object.keys(item.properties).map(k => - Array.isArray(item.properties[k]) - ? item.properties[k].map((v: string) => - getPropertyChip( - k, v, - isWritable - ? this.handleDelete(k, item.properties[k]) - : undefined, - classes.tag)) - : getPropertyChip( - k, item.properties[k], - isWritable - ? this.handleDelete(k, item.properties[k]) - : undefined, - classes.tag) - ) - :
No properties set on this collection.
- } + {Object.keys(item.properties).length > 0 + ? Object.keys(item.properties).map(k => + Array.isArray(item.properties[k]) + ? item.properties[k].map((v: string) => + getPropertyChip( + k, v, + isWritable + ? this.handleDelete(k, item.properties[k]) + : undefined, + classes.tag)) + : getPropertyChip( + k, item.properties[k], + isWritable + ? this.handleDelete(k, item.properties[k]) + : undefined, + classes.tag) + ) + :
No properties set on this collection.
+ }
@@ -212,7 +225,7 @@ export const CollectionPanel = withStyles(styles)( dispatch(collectionPanelActions.LOAD_BIG_COLLECTIONS(true)); dispatch(loadCollectionFiles(this.props.item.uuid)); } - } /> + } />
: null; @@ -233,6 +246,8 @@ export const CollectionPanel = withStyles(styles)( : ContextMenuKind.COLLECTION : ContextMenuKind.READONLY_COLLECTION }; + // Avoid expanding/collapsing the panel + event.stopPropagation(); this.props.dispatch(openContextMenu(event, resource)); } @@ -261,3 +276,52 @@ export const CollectionPanel = withStyles(styles)( } ) ); + +export const CollectionDetailsAttributes = (props: { item: CollectionResource, twoCol: boolean, classes?: Record }) => { + const item = props.item; + const classes = props.classes || { label: '', value: '' }; + const isOldVersion = item && item.currentVersionUuid !== item.uuid; + const mdSize = props.twoCol ? 6 : 12; + return + + + + + + + + + + + {isOldVersion && + + + + } + + + + + + + + + + + + + + + + ; +};