X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/80fdf9603c057f1e41915e7c8890c942d240b36e..6d2e6d292161d566f54e94f048805569ede8e3d5:/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 f559a616..ab423a6e 100644
--- a/src/views/public-favorites-panel/public-favorites-panel.tsx
+++ b/src/views/public-favorites-panel/public-favorites-panel.tsx
@@ -16,22 +16,22 @@ import {
     ProcessStatus,
     ResourceFileSize,
     ResourceLastModifiedDate,
-    ResourceName,
-    ResourceOwner,
-    ResourceType
+    ResourceType,
+    ResourceName
 } from '~/views-components/data-explorer/renderers';
-import { FavoriteIcon } from '~/components/icon/icon';
+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 { FavoritesState } from '~/store/favorites/favorites-reducer';
 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';
 
 type CssRules = "toolbar" | "button";
 
@@ -45,7 +45,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     },
 });
 
-export enum FavoritePanelColumnNames {
+export enum PublicFavoritePanelColumnNames {
     NAME = "Name",
     STATUS = "Status",
     TYPE = "Type",
@@ -58,9 +58,9 @@ export interface FavoritePanelFilter extends DataTableFilterItem {
     type: ResourceKind | ContainerRequestState;
 }
 
-export const favoritePanelColumns: DataColumns<string> = [
+export const publicFavoritePanelColumns: DataColumns<string> = [
     {
-        name: FavoritePanelColumnNames.NAME,
+        name: PublicFavoritePanelColumnNames.NAME,
         selected: true,
         configurable: true,
         sortDirection: SortDirection.NONE,
@@ -75,28 +75,21 @@ export const favoritePanelColumns: DataColumns<string> = [
         render: uuid => <ProcessStatus uuid={uuid} />
     },
     {
-        name: FavoritePanelColumnNames.TYPE,
+        name: PublicFavoritePanelColumnNames.TYPE,
         selected: true,
         configurable: true,
         filters: getSimpleObjectTypeFilters(),
         render: uuid => <ResourceType uuid={uuid} />
     },
     {
-        name: FavoritePanelColumnNames.OWNER,
-        selected: true,
-        configurable: true,
-        filters: createTree(),
-        render: uuid => <ResourceOwner uuid={uuid} />
-    },
-    {
-        name: FavoritePanelColumnNames.FILE_SIZE,
+        name: PublicFavoritePanelColumnNames.FILE_SIZE,
         selected: true,
         configurable: true,
         filters: createTree(),
         render: uuid => <ResourceFileSize uuid={uuid} />
     },
     {
-        name: FavoritePanelColumnNames.LAST_MODIFIED,
+        name: PublicFavoritePanelColumnNames.LAST_MODIFIED,
         selected: true,
         configurable: true,
         sortDirection: SortDirection.DESC,
@@ -105,23 +98,24 @@ export const favoritePanelColumns: DataColumns<string> = [
     }
 ];
 
-interface FavoritePanelDataProps {
-    favorites: FavoritesState;
+interface PublicFavoritePanelDataProps {
+    publicFavorites: PublicFavoritesState;
 }
 
-interface FavoritePanelActionProps {
+interface PublicFavoritePanelActionProps {
     onItemClick: (item: string) => void;
     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
     onDialogOpen: (ownerUuid: string) => void;
     onItemDoubleClick: (item: string) => void;
 }
-const mapStateToProps = ({ favorites }: RootState): FavoritePanelDataProps => ({
-    favorites
+const mapStateToProps = ({ publicFavorites }: RootState): PublicFavoritePanelDataProps => ({
+    publicFavorites
 });
 
-const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({
+const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps => ({
     onContextMenu: (event, resourceUuid) => {
-        const kind = resourceKindToContextMenuKind(resourceUuid);
+        const isAdmin = dispatch<any>(getIsAdmin());
+        const kind = resourceKindToContextMenuKind(resourceUuid, isAdmin);
         if (kind) {
             dispatch<any>(openContextMenu(event, {
                 name: '',
@@ -134,15 +128,15 @@ const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({
         dispatch<any>(loadDetailsPanel(resourceUuid));
     },
     onDialogOpen: (ownerUuid: string) => { return; },
-    onItemClick: (resourceUuid: string) => {
-        dispatch<any>(loadDetailsPanel(resourceUuid));
+    onItemClick: (uuid: string) => {
+        dispatch<any>(loadDetailsPanel(uuid));
     },
     onItemDoubleClick: uuid => {
         dispatch<any>(navigateTo(uuid));
     }
 });
 
-type FavoritePanelProps = FavoritePanelDataProps & FavoritePanelActionProps & DispatchProp
+type FavoritePanelProps = PublicFavoritePanelDataProps & PublicFavoritePanelActionProps & DispatchProp
     & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
 
 export const PublicFavoritePanel = withStyles(styles)(
@@ -157,9 +151,8 @@ export const PublicFavoritePanel = withStyles(styles)(
                     contextMenuColumn={true}
                     dataTableDefaultView={
                         <DataTableDefaultView
-                            icon={FavoriteIcon}
-                            messages={['Public favorites list is empty.']}
-                            />
+                            icon={PublicFavoriteIcon}
+                            messages={['Public favorites list is empty.']} />
                     } />;
             }
         }
