17532: Add modifiedByUser to collection details version history table
[arvados.git] / src / views-components / details-panel / collection-details.tsx
index f5bac3662c7b96668df47a60ee5d5d1174ad3525..0d4fce51adb778d7e03da1dfbc8835b81a0f77da 100644 (file)
@@ -2,19 +2,20 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { CollectionIcon } from '~/components/icon/icon';
-import { CollectionResource } from '~/models/collection';
+import React from 'react';
+import { CollectionIcon } from 'components/icon/icon';
+import { CollectionResource } from 'models/collection';
 import { DetailsData } from "./details-data";
-import { CollectionDetailsAttributes } from '~/views/collection-panel/collection-panel';
-import { RootState } from '~/store/store';
-import { filterResources, getResource } from '~/store/resources/resources';
+import { CollectionDetailsAttributes } from 'views/collection-panel/collection-panel';
+import { RootState } from 'store/store';
+import { filterResources, getResource } from 'store/resources/resources';
 import { connect } from 'react-redux';
 import { Grid, ListItem, StyleRulesCallback, Typography, withStyles, WithStyles } from '@material-ui/core';
-import { formatDate, formatFileSize } from '~/common/formatters';
+import { formatDate, formatFileSize } from 'common/formatters';
+import { UserNameFromID } from '../data-explorer/renderers';
 import { Dispatch } from 'redux';
-import { navigateTo } from '~/store/navigation/navigation-action';
-import { openContextMenu, resourceUuidToContextMenuKind } from '~/store/context-menu/context-menu-actions';
+import { navigateTo } from 'store/navigation/navigation-action';
+import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
 
 export type CssRules = 'versionBrowserHeader' | 'versionBrowserItem';
 
@@ -70,10 +71,10 @@ interface CollectionVersionBrowserDispatchProps {
 
 const mapStateToProps = (state: RootState): CollectionVersionBrowserProps => {
     const currentCollection = getResource<CollectionResource>(state.detailsPanel.resourceUuid)(state.resources);
-    const versions = currentCollection
+    const versions = (currentCollection
         && filterResources(rsc =>
             (rsc as CollectionResource).currentVersionUuid === currentCollection.currentVersionUuid)(state.resources)
-                .sort((a: CollectionResource, b: CollectionResource) => b.version - a.version) as CollectionResource[]
+                .sort((a: CollectionResource, b: CollectionResource) => b.version - a.version) as CollectionResource[])
         || [];
     return { currentCollection, versions };
 };
@@ -87,6 +88,8 @@ const mapDispatchToProps = () =>
                 dispatch<any>(openContextMenu(event, {
                     name: collection.name,
                     uuid: collection.uuid,
+                    description: collection.description,
+                    storageClassesDesired: collection.storageClassesDesired,
                     ownerUuid: collection.ownerUuid,
                     isTrashed: collection.isTrashed,
                     kind: collection.kind,
@@ -106,12 +109,17 @@ const CollectionVersionBrowser = withStyles(styles)(
                             Nr
                         </Typography>
                     </Grid>
-                    <Grid item xs={4}>
+                    <Grid item xs={2}>
                         <Typography variant="caption" className={classes.versionBrowserHeader}>
                             Size
                         </Typography>
                     </Grid>
-                    <Grid item xs={6}>
+                    <Grid item xs={3}>
+                        <Typography variant="caption" className={classes.versionBrowserHeader}>
+                            User
+                        </Typography>
+                    </Grid>
+                    <Grid item xs={5}>
                         <Typography variant="caption" className={classes.versionBrowserHeader}>
                             Date
                         </Typography>
@@ -130,12 +138,17 @@ const CollectionVersionBrowser = withStyles(styles)(
                                     {item.version}
                                 </Typography>
                             </Grid>
-                            <Grid item xs={4}>
+                            <Grid item xs={2}>
                                 <Typography variant="caption" className={classes.versionBrowserItem}>
                                     {formatFileSize(item.fileSizeTotal)}
                                 </Typography>
                             </Grid>
-                            <Grid item xs={6}>
+                            <Grid item xs={3}>
+                                <Typography variant="caption" className={classes.versionBrowserItem}>
+                                    <UserNameFromID uuid={item.modifiedByUserUuid} />
+                                </Typography>
+                            </Grid>
+                            <Grid item xs={5}>
                                 <Typography variant="caption" className={classes.versionBrowserItem}>
                                     {formatDate(item.modifiedAt)}
                                 </Typography>
@@ -145,4 +158,4 @@ const CollectionVersionBrowser = withStyles(styles)(
                 })}
                 </Grid>
             </div>;
-        }));
\ No newline at end of file
+        }));