X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/fa29a709a18ab248f87d954cbac9cf89de34c031..7bbd67535b2ee9e8abd3342d5a9de5a22ef786a3:/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 5c19c30b..dcae6807 100644 --- a/src/views/favorite-panel/favorite-panel.tsx +++ b/src/views/favorite-panel/favorite-panel.tsx @@ -22,8 +22,10 @@ import { ResourceType } from '~/views-components/data-explorer/renderers'; import { FavoriteIcon } from '~/components/icon/icon'; -import { Dispatch } from 'redux'; -import { openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-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"; @@ -32,6 +34,11 @@ 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 { 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'; type CssRules = "toolbar" | "button"; @@ -83,7 +90,7 @@ export const favoritePanelColumns: DataColumns = [ }, { name: FavoritePanelColumnNames.OWNER, - selected: true, + selected: false, configurable: true, filters: createTree(), render: uuid => @@ -106,54 +113,72 @@ export const favoritePanelColumns: DataColumns = [ ]; interface FavoritePanelDataProps { + currentItemId: any; favorites: FavoritesState; + resources: ResourcesState; + userUuid: string; } interface FavoritePanelActionProps { onItemClick: (item: string) => void; - onContextMenu: (event: React.MouseEvent, item: string) => void; onDialogOpen: (ownerUuid: string) => void; onItemDoubleClick: (item: string) => void; } -const mapStateToProps = ({ favorites }: RootState): FavoritePanelDataProps => ({ - favorites -}); - -const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({ - onContextMenu: (event, resourceUuid) => { - const kind = resourceKindToContextMenuKind(resourceUuid); - if (kind) { - dispatch(openContextMenu(event, { - name: '', - uuid: resourceUuid, - ownerUuid: '', - kind: ResourceKind.NONE, - menuKind: kind - })); - } - dispatch(loadDetailsPanel(resourceUuid)); - }, - onDialogOpen: (ownerUuid: string) => { return; }, - onItemClick: (resourceUuid: string) => { - dispatch(loadDetailsPanel(resourceUuid)); - }, - onItemDoubleClick: uuid => { - dispatch(navigateTo(uuid)); - } +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 & WithStyles & RouteComponentProps<{ id: string }>; export const FavoritePanel = withStyles(styles)( - connect(mapStateToProps, mapDispatchToProps)( + connect(mapStateToProps)( class extends React.Component { + + handleContextMenu = (event: React.MouseEvent, resourceUuid: string) => { + 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: resource.name, + uuid: resource.uuid, + ownerUuid: resource.ownerUuid, + isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false, + kind: resource.kind, + menuKind, + description: resource.description, + })); + } + this.props.dispatch(loadDetailsPanel(resourceUuid)); + } + + handleRowDoubleClick = (uuid: string) => { + this.props.dispatch(navigateTo(uuid)); + } + + handleRowClick = (uuid: string) => { + this.props.dispatch(loadDetailsPanel(uuid)); + } + render() { return