X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/25216cc7acedc987c26a159f0b640210c0ef101e..e5dc88dd1a6c54610d92854d527e5048543d93ec:/src/views/favorite-panel/favorite-panel.tsx diff --git a/src/views/favorite-panel/favorite-panel.tsx b/src/views/favorite-panel/favorite-panel.tsx index 89bceecd5d..404baeb9d1 100644 --- a/src/views/favorite-panel/favorite-panel.tsx +++ b/src/views/favorite-panel/favorite-panel.tsx @@ -2,7 +2,7 @@ // // 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 { connect, DispatchProp } from 'react-redux'; @@ -34,7 +34,12 @@ 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 { ResourcesState } from 'store/resources/resources'; +import { getResource, ResourcesState } from 'store/resources/resources'; +import { GroupContentsResource } from 'services/groups-service/groups-service'; +import { GroupClass, GroupResource } from 'models/group'; +import { getProperty } from 'store/properties/properties'; +import { PROJECT_PANEL_CURRENT_UUID } from 'store/project-panel/project-panel-action'; +import { CollectionResource } from 'models/collection'; type CssRules = "toolbar" | "button"; @@ -109,6 +114,7 @@ export const favoritePanelColumns: DataColumns = [ ]; interface FavoritePanelDataProps { + currentItemId: any; favorites: FavoritesState; resources: ResourcesState; userUuid: string; @@ -123,6 +129,7 @@ const mapStateToProps = (state : RootState): FavoritePanelDataProps => ({ favorites: state.favorites, resources: state.resources, userUuid: state.auth.user!.uuid, + currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties), }); type FavoritePanelProps = FavoritePanelDataProps & FavoritePanelActionProps & DispatchProp @@ -133,14 +140,28 @@ export const FavoritePanel = withStyles(styles)( class extends React.Component { handleContextMenu = (event: React.MouseEvent, resourceUuid: string) => { - const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(resourceUuid)); - if (menuKind) { + const { resources } = this.props; + const resource = getResource(resourceUuid)(resources); + + let readonly = false; + const project = getResource(this.props.currentItemId)(resources); + + if (project && project.groupClass === GroupClass.FILTER) { + readonly = true; + } + + const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(resourceUuid, readonly)); + + if (menuKind && resource) { this.props.dispatch(openContextMenu(event, { - name: '', - uuid: resourceUuid, - ownerUuid: '', - kind: ResourceKind.NONE, - menuKind + name: resource.name, + uuid: resource.uuid, + ownerUuid: resource.ownerUuid, + isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false, + kind: resource.kind, + menuKind, + description: resource.description, + storageClassesDesired: (resource as CollectionResource).storageClassesDesired, })); } this.props.dispatch(loadDetailsPanel(resourceUuid));