// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { CustomStyleRulesCallback } from 'common/custom-theme'; import { WithStyles } from '@mui/styles'; import withStyles from '@mui/styles/withStyles'; import { DataExplorer } from "views-components/data-explorer/data-explorer"; import { connect, DispatchProp } from 'react-redux'; import { DataColumns } from 'components/data-table/data-table'; import { RouteComponentProps } from 'react-router'; import { DataTableFilterItem } from 'components/data-table-filters/data-table-filters'; import { ResourceKind } from 'models/resource'; import { ArvadosTheme } from 'common/custom-theme'; import { ProcessStatus, ResourceFileSize, ResourceLastModifiedDate, ResourceType, ResourceName, ResourceOwnerWithName } from 'views-components/data-explorer/renderers'; import { PublicFavoriteIcon } from 'components/icon/icon'; import { Dispatch } from 'redux'; 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'; import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions'; type CssRules = "toolbar" | "button" | "root"; const styles: CustomStyleRulesCallback = (theme: ArvadosTheme) => ({ toolbar: { paddingBottom: theme.spacing(3), textAlign: "right" }, button: { marginLeft: theme.spacing(1) }, root: { width: '100%', }, }); export enum PublicFavoritePanelColumnNames { NAME = "Name", STATUS = "Status", TYPE = "Type", OWNER = "Owner", FILE_SIZE = "File size", LAST_MODIFIED = "Last modified" } export interface FavoritePanelFilter extends DataTableFilterItem { type: ResourceKind | ContainerRequestState; } export const publicFavoritePanelColumns: DataColumns = [ { name: PublicFavoritePanelColumnNames.NAME, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: "Status", selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: PublicFavoritePanelColumnNames.TYPE, selected: true, configurable: true, filters: getSimpleObjectTypeFilters(), render: uuid => }, { name: PublicFavoritePanelColumnNames.OWNER, selected: false, configurable: true, filters: createTree(), render: uuid => }, { name: PublicFavoritePanelColumnNames.FILE_SIZE, selected: true, configurable: true, filters: createTree(), render: uuid => }, { name: PublicFavoritePanelColumnNames.LAST_MODIFIED, selected: true, configurable: true, filters: createTree(), render: uuid => } ]; interface PublicFavoritePanelDataProps { publicFavorites: PublicFavoritesState; resources: ResourcesState; } interface PublicFavoritePanelActionProps { onItemClick: (item: string) => void; onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent, item: string) => void; onDialogOpen: (ownerUuid: string) => void; onItemDoubleClick: (item: string) => void; } const mapStateToProps = ({ publicFavorites, resources }: RootState): PublicFavoritePanelDataProps => ({ publicFavorites, resources, }); const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps => ({ onContextMenu: (resources: ResourcesState) => (event, resourceUuid) => { const resource = getResource(resourceUuid)(resources); const kind = dispatch(resourceUuidToContextMenuKind(resourceUuid)); if (kind && resource) { dispatch(openContextMenu(event, { name: resource.name, description: resource.description, storageClassesDesired: (resource as CollectionResource).storageClassesDesired, uuid: resourceUuid, ownerUuid: '', kind: ResourceKind.NONE, menuKind: kind })); } dispatch(loadDetailsPanel(resourceUuid)); }, onDialogOpen: (ownerUuid: string) => { return; }, onItemClick: (uuid: string) => { dispatch(toggleOne(uuid)) dispatch(deselectAllOthers(uuid)) dispatch(loadDetailsPanel(uuid)); }, onItemDoubleClick: uuid => { dispatch(navigateTo(uuid)); } }); type FavoritePanelProps = PublicFavoritePanelDataProps & PublicFavoritePanelActionProps & DispatchProp & WithStyles & RouteComponentProps<{ id: string }>; export const PublicFavoritePanel = withStyles(styles)( connect(mapStateToProps, mapDispatchToProps)( class extends React.Component { render() { return
; } } ) );