X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/536568cffa1013e70c6752ac398a005b7396b74d..5d6640046afef7dc3714b784430e18bf2f2153fe:/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 4a01c6f4b0..47c8aedebf 100644 --- a/src/views/public-favorites-panel/public-favorites-panel.tsx +++ b/src/views/public-favorites-panel/public-favorites-panel.tsx @@ -2,38 +2,42 @@ // // 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 { ResourceKind } from 'models/resource'; +import { ArvadosTheme } from 'common/custom-theme'; import { ProcessStatus, ResourceFileSize, ResourceLastModifiedDate, - ResourceLinkNameAndIcon, - ResourceLinkType -} from '~/views-components/data-explorer/renderers'; -import { PublicFavoriteIcon } from '~/components/icon/icon'; + ResourceType, + ResourceName, + 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 { getHeadUuid, 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 = (theme: ArvadosTheme) => ({ toolbar: { @@ -43,9 +47,12 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ button: { marginLeft: theme.spacing.unit }, + root: { + width: '100%', + }, }); -export enum FavoritePanelColumnNames { +export enum PublicFavoritePanelColumnNames { NAME = "Name", STATUS = "Status", TYPE = "Type", @@ -58,14 +65,13 @@ export interface FavoritePanelFilter extends DataTableFilterItem { type: ResourceKind | ContainerRequestState; } -export const publicFavoritePanelColumns: DataColumns = [ +export const publicFavoritePanelColumns: DataColumns = [ { - name: FavoritePanelColumnNames.NAME, + name: PublicFavoritePanelColumnNames.NAME, selected: true, configurable: true, - sortDirection: SortDirection.NONE, filters: createTree(), - render: uuid => + render: uuid => }, { name: "Status", @@ -75,24 +81,30 @@ export const publicFavoritePanelColumns: DataColumns = [ render: uuid => }, { - name: FavoritePanelColumnNames.TYPE, + name: PublicFavoritePanelColumnNames.TYPE, selected: true, configurable: true, filters: getSimpleObjectTypeFilters(), - render: uuid => + render: uuid => + }, + { + name: PublicFavoritePanelColumnNames.OWNER, + selected: false, + configurable: true, + filters: createTree(), + render: uuid => }, { - name: FavoritePanelColumnNames.FILE_SIZE, + name: PublicFavoritePanelColumnNames.FILE_SIZE, selected: true, configurable: true, filters: createTree(), render: uuid => }, { - name: FavoritePanelColumnNames.LAST_MODIFIED, + name: PublicFavoritePanelColumnNames.LAST_MODIFIED, selected: true, configurable: true, - sortDirection: SortDirection.DESC, filters: createTree(), render: uuid => } @@ -100,39 +112,43 @@ export const publicFavoritePanelColumns: DataColumns = [ interface PublicFavoritePanelDataProps { publicFavorites: PublicFavoritesState; + resources: ResourcesState; } interface PublicFavoritePanelActionProps { onItemClick: (item: string) => void; - onContextMenu: (event: React.MouseEvent, item: string) => void; + onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent, 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(getIsAdmin()); - const kind = resourceKindToContextMenuKind(dispatch(getHeadUuid(resourceUuid)), isAdmin); - if (kind) { + onContextMenu: (resources: ResourcesState) => (event, resourceUuid) => { + const resource = getResource(resourceUuid)(resources); + const kind = dispatch(resourceUuidToContextMenuKind(resourceUuid)); + if (kind && resource) { dispatch(openContextMenu(event, { - name: '', - uuid: dispatch(getHeadUuid(resourceUuid)), + name: resource.name, + description: resource.description, + storageClassesDesired: (resource as CollectionResource).storageClassesDesired, + uuid: resourceUuid, ownerUuid: '', kind: ResourceKind.NONE, menuKind: kind })); } - dispatch(loadDetailsPanel(dispatch(getHeadUuid(resourceUuid)))); + dispatch(loadDetailsPanel(resourceUuid)); }, onDialogOpen: (ownerUuid: string) => { return; }, onItemClick: (uuid: string) => { - dispatch(loadDetailsPanel(dispatch(getHeadUuid(uuid)))); + dispatch(loadDetailsPanel(uuid)); }, onItemDoubleClick: uuid => { - dispatch(navigateTo(dispatch(getHeadUuid(uuid)))); + dispatch(navigateTo(uuid)); } }); @@ -143,17 +159,15 @@ export const PublicFavoritePanel = withStyles(styles)( connect(mapStateToProps, mapDispatchToProps)( class extends React.Component { render() { - return - } />; + defaultViewIcon={PublicFavoriteIcon} + defaultViewMessages={['Public favorites list is empty.']} /> + ; } } )