X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f62ba0aeff590ef1c57669d4f46e43b5ee169522..76b1c50413fee98f2ff8a3d2308252de6a37048c:/src/views/public-favorites-panel/public-favorites-panel.tsx

diff --git a/src/views/public-favorites-panel/public-favorites-panel.tsx b/src/views/public-favorites-panel/public-favorites-panel.tsx
index 635ac621..8eb2a87c 100644
--- a/src/views/public-favorites-panel/public-favorites-panel.tsx
+++ b/src/views/public-favorites-panel/public-favorites-panel.tsx
@@ -2,39 +2,43 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
-import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
+import { DataExplorer } from "views-components/data-explorer/data-explorer";
 import { connect, DispatchProp } from 'react-redux';
-import { DataColumns } from '~/components/data-table/data-table';
+import { DataColumns } from 'components/data-table/data-table';
 import { RouteComponentProps } from 'react-router';
-import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
-import { SortDirection } from '~/components/data-table/data-column';
-import { ResourceKind } from '~/models/resource';
-import { ArvadosTheme } from '~/common/custom-theme';
+import { DataTableFilterItem } from 'components/data-table-filters/data-table-filters';
+import { SortDirection } from 'components/data-table/data-column';
+import { ResourceKind } from 'models/resource';
+import { ArvadosTheme } from 'common/custom-theme';
 import {
     ProcessStatus,
     ResourceFileSize,
     ResourceLastModifiedDate,
     ResourceType,
     ResourceName,
-    ResourceOwner
-} from '~/views-components/data-explorer/renderers';
-import { PublicFavoriteIcon } from '~/components/icon/icon';
+    ResourceOwnerWithName
+} from 'views-components/data-explorer/renderers';
+import { PublicFavoriteIcon } from 'components/icon/icon';
 import { Dispatch } from 'redux';
-import { openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-actions';
-import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
-import { navigateTo } from '~/store/navigation/navigation-action';
-import { ContainerRequestState } from "~/models/container-request";
-import { RootState } from '~/store/store';
-import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
-import { createTree } from '~/models/tree';
-import { getSimpleObjectTypeFilters } from '~/store/resource-type-filters/resource-type-filters';
-import { PUBLIC_FAVORITE_PANEL_ID } from '~/store/public-favorites-panel/public-favorites-action';
-import { PublicFavoritesState } from '~/store/public-favorites/public-favorites-reducer';
-import { getIsAdmin } from '~/store/public-favorites/public-favorites-actions';
+import {
+    openContextMenu,
+    resourceUuidToContextMenuKind
+} from 'store/context-menu/context-menu-actions';
+import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
+import { navigateTo } from 'store/navigation/navigation-action';
+import { ContainerRequestState } from "models/container-request";
+import { RootState } from 'store/store';
+import { createTree } from 'models/tree';
+import { getSimpleObjectTypeFilters } from 'store/resource-type-filters/resource-type-filters';
+import { PUBLIC_FAVORITE_PANEL_ID } from 'store/public-favorites-panel/public-favorites-action';
+import { PublicFavoritesState } from 'store/public-favorites/public-favorites-reducer';
+import { getResource, ResourcesState } from 'store/resources/resources';
+import { GroupContentsResource } from 'services/groups-service/groups-service';
+import { CollectionResource } from 'models/collection';
 
-type CssRules = "toolbar" | "button";
+type CssRules = "toolbar" | "button" | "root";
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     toolbar: {
@@ -44,6 +48,9 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     button: {
         marginLeft: theme.spacing.unit
     },
+    root: {
+        width: '100%',
+    },
 });
 
 export enum PublicFavoritePanelColumnNames {
@@ -87,7 +94,7 @@ export const publicFavoritePanelColumns: DataColumns<string> = [
         selected: false,
         configurable: true,
         filters: createTree(),
-        render: uuid => <ResourceOwner uuid={uuid} />
+        render: uuid => <ResourceOwnerWithName uuid={uuid} />
     },
     {
         name: PublicFavoritePanelColumnNames.FILE_SIZE,
@@ -108,25 +115,29 @@ export const publicFavoritePanelColumns: DataColumns<string> = [
 
 interface PublicFavoritePanelDataProps {
     publicFavorites: PublicFavoritesState;
+    resources: ResourcesState;
 }
 
 interface PublicFavoritePanelActionProps {
     onItemClick: (item: string) => void;
-    onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
+    onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent<HTMLElement>, item: string) => void;
     onDialogOpen: (ownerUuid: string) => void;
     onItemDoubleClick: (item: string) => void;
 }
-const mapStateToProps = ({ publicFavorites }: RootState): PublicFavoritePanelDataProps => ({
-    publicFavorites
+const mapStateToProps = ({ publicFavorites, resources }: RootState): PublicFavoritePanelDataProps => ({
+    publicFavorites,
+    resources,
 });
 
 const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps => ({
-    onContextMenu: (event, resourceUuid) => {
-        const isAdmin = dispatch<any>(getIsAdmin());
-        const kind = resourceKindToContextMenuKind(resourceUuid, isAdmin);
-        if (kind) {
+    onContextMenu: (resources: ResourcesState) => (event, resourceUuid) => {
+        const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
+        const kind = dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
+        if (kind && resource) {
             dispatch<any>(openContextMenu(event, {
-                name: '',
+                name: resource.name,
+                description: resource.description,
+                storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
                 uuid: resourceUuid,
                 ownerUuid: '',
                 kind: ResourceKind.NONE,
@@ -151,17 +162,15 @@ export const PublicFavoritePanel = withStyles(styles)(
     connect(mapStateToProps, mapDispatchToProps)(
         class extends React.Component<FavoritePanelProps> {
             render() {
-                return <DataExplorer
+                return <div className={this.props.classes.root}><DataExplorer
                     id={PUBLIC_FAVORITE_PANEL_ID}
                     onRowClick={this.props.onItemClick}
                     onRowDoubleClick={this.props.onItemDoubleClick}
-                    onContextMenu={this.props.onContextMenu}
+                    onContextMenu={this.props.onContextMenu(this.props.resources)}
                     contextMenuColumn={true}
-                    dataTableDefaultView={
-                        <DataTableDefaultView
-                            icon={PublicFavoriteIcon}
-                            messages={['Public favorites list is empty.']} />
-                    } />;
+                    defaultViewIcon={PublicFavoriteIcon}
+                    defaultViewMessages={['Public favorites list is empty.']} />
+                </div>;
             }
         }
     )
