import { publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
import { DataColumns } from '~/components/data-table/data-table';
import { serializeSimpleObjectTypeFilters } from '../resource-type-filters/resource-type-filters';
-import { LinkResource } from '~/models/link';
+import { LinkResource, LinkClass } from '~/models/link';
import { GroupContentsResource, GroupContentsResourcePrefix } from '~/services/groups-service/groups-service';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { loadMissingProcessesInformation } from '~/store/project-panel/project-panel-middleware-service';
}
try {
api.dispatch(progressIndicatorActions.START_WORKING(this.getId()));
- const response = await this.services.favoriteService
- .list(this.services.authService.getUuid()!, {
- limit: dataExplorer.rowsPerPage,
- offset: dataExplorer.page * dataExplorer.rowsPerPage,
- linkOrder: linkOrder.getOrder(),
- contentOrder: contentOrder.getOrder(),
- filters: new FilterBuilder()
- .addILike("name", dataExplorer.searchValue)
- .addIsA("headUuid", typeFilters)
- .getFilters(),
-
- });
+ const uuidPrefix = api.getState().config.uuidPrefix;
+ const uuid = `${uuidPrefix}-j7d0g-fffffffffffffff`;
+ const response = await this.services.linkService.list({
+ limit: dataExplorer.rowsPerPage,
+ offset: dataExplorer.page * dataExplorer.rowsPerPage,
+ filters: new FilterBuilder()
+ .addEqual('linkClass', LinkClass.STAR)
+ .addILike("name", dataExplorer.searchValue)
+ .addEqual('ownerUuid', uuid)
+ .addIsA("headUuid", typeFilters)
+ .getFilters()
+ });
api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
api.dispatch(resourcesActions.SET_RESOURCES(response.items));
- await api.dispatch<any>(loadMissingProcessesInformation(response.items));
api.dispatch(publicFavoritePanelActions.SET_ITEMS({
items: response.items.map(resource => resource.uuid),
itemsAvailable: response.itemsAvailable,
page: Math.floor(response.offset / response.limit),
rowsPerPage: response.limit
}));
- api.dispatch<any>(updatePublicFavorites(response.items.map(item => item.uuid)));
+ api.dispatch<any>(updatePublicFavorites(response.items.map(item => item.headUuid)));
} catch (e) {
api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
api.dispatch(publicFavoritePanelActions.SET_ITEMS({
import { groupDetailsPanelColumns } from '~/views/group-details-panel/group-details-panel';
import { DataTableFetchMode } from "~/components/data-table/data-table";
import { loadPublicFavoritePanel, publicFavoritePanelActions } from '~/store/public-favorites-panel/public-favorites-action';
+import { publicFavoritePanelColumns } from '~/views/public-favorites-panel/public-favorites-panel';
export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
if (user) {
dispatch(projectPanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
dispatch(favoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
- dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: favoritePanelColumns }));
+ dispatch(publicFavoritePanelActions.SET_COLUMNS({ columns: publicFavoritePanelColumns }));
dispatch(trashPanelActions.SET_COLUMNS({ columns: trashPanelColumns }));
dispatch(sharedWithMePanelActions.SET_COLUMNS({ columns: projectPanelColumns }));
dispatch(workflowPanelActions.SET_COLUMNS({ columns: workflowPanelColumns }));
import { LinkResource } from '~/models/link';
import { navigateTo } from '~/store/navigation/navigation-action';
import { withResourceData } from '~/views-components/data-explorer/with-resources';
-import { PublicFavorite } from '~/views-components/public-favorite-icon/public-favorite-icon';
const renderName = (item: { name: string; uuid: string, kind: string }) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
- {renderIcon(item)}
+ {renderIcon(item.kind)}
</Grid>
<Grid item>
<Typography color="primary" style={{ width: 'auto' }}>
<FavoriteStar resourceUuid={item.uuid} />
</Typography>
</Grid>
- <Grid item>
- <Typography variant="caption">
- <PublicFavorite resourceUuid={item.uuid} />
- </Typography>
- </Grid>
</Grid>;
export const ResourceName = connect(
return resource || { name: '', uuid: '', kind: '' };
})(renderName);
-const renderIcon = (item: { kind: string }) => {
- switch (item.kind) {
+const renderIcon = (kind: string) => {
+ switch (kind) {
case ResourceKind.PROJECT:
return <ProjectIcon />;
case ResourceKind.COLLECTION:
const renderWorkflowName = (item: { name: string; uuid: string, kind: string, ownerUuid: string }) =>
<Grid container alignItems="center" wrap="nowrap" spacing={16}>
<Grid item>
- {renderIcon(item)}
+ {renderIcon(item.kind)}
</Grid>
<Grid item>
<Typography color="primary" style={{ width: '100px' }}>
return resource || { uuid: '' };
})(renderUuid);
+const renderLinkNameAndIcon = (item: { name: string; headUuid: string, headKind: string }) =>
+ <Grid container alignItems="center" wrap="nowrap" spacing={16}>
+ <Grid item>
+ {renderIcon(item.headKind)}
+ </Grid>
+ <Grid item>
+ <Typography color="primary" style={{ width: 'auto' }}>
+ {item.name}
+ </Typography>
+ </Grid>
+ <Grid item>
+ <Typography variant="caption">
+ <FavoriteStar resourceUuid={item.headUuid} />
+ </Typography>
+ </Grid>
+ </Grid>;
+
+export const ResourceLinkNameAndIcon = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<LinkResource>(props.uuid)(state.resources);
+ return resource || { name: '', headUuid: '', headKind: '' };
+ })(renderLinkNameAndIcon);
+
+export const ResourceLinkType = connect(
+ (state: RootState, props: { uuid: string }) => {
+ const resource = getResource<LinkResource>(props.uuid)(state.resources);
+ return { type: resource ? resource.headKind : '' };
+ })((props: { type: string }) => renderType(props.type));
+
// Process Resources
const resourceRunProcess = (dispatch: Dispatch, uuid: string) => {
return (
const mapStateToProps = (state: RootState, props: { resourceUuid: string; className?: string; }) => ({
...props,
- visible: state.favorites[props.resourceUuid],
+ isFavoriteVisible: state.favorites[props.resourceUuid],
+ isPublicFavoriteVisible: state.publicFavorites[props.resourceUuid]
});
export const FavoriteStar = connect(mapStateToProps)(
- withStyles(styles)((props: { visible: boolean; className?: string; } & WithStyles<CssRules>) =>
- props.visible ? <FavoriteIcon className={props.className || props.classes.icon} /> : null
- ));
+ withStyles(styles)((props: { isFavoriteVisible: boolean; isPublicFavoriteVisible: boolean; className?: string; } & WithStyles<CssRules>) => {
+ if (props.isPublicFavoriteVisible) {
+ return <FavoriteIcon className={props.className || props.classes.icon} />;
+ } else if (props.isFavoriteVisible) {
+ return <FavoriteIcon className={props.className || props.classes.icon} />;
+ } else {
+ return null;
+ }
+ }));
+++ /dev/null
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import * as React from "react";
-import { FavoriteIcon } from "~/components/icon/icon";
-import { connect } from "react-redux";
-import { RootState } from "~/store/store";
-import { withStyles, StyleRulesCallback, WithStyles } from "@material-ui/core";
-
-type CssRules = "icon";
-
-const styles: StyleRulesCallback<CssRules> = theme => ({
- icon: {
- fontSize: "inherit"
- }
-});
-
-const mapStateToProps = (state: RootState, props: { resourceUuid: string; className?: string; }) => ({
- ...props,
- visible: state.publicFavorites[props.resourceUuid],
-});
-
-export const PublicFavorite = connect(mapStateToProps)(
- withStyles(styles)((props: { visible: boolean; className?: string; } & WithStyles<CssRules>) =>
- props.visible ? <FavoriteIcon className={props.className || props.classes.icon} /> : null
- ));
ProcessStatus,
ResourceFileSize,
ResourceLastModifiedDate,
- ResourceName,
- ResourceOwner,
- ResourceType
+ ResourceLinkNameAndIcon,
+ ResourceLinkType
} from '~/views-components/data-explorer/renderers';
import { FavoriteIcon } from '~/components/icon/icon';
import { Dispatch } from 'redux';
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';
type CssRules = "toolbar" | "button";
type: ResourceKind | ContainerRequestState;
}
-export const favoritePanelColumns: DataColumns<string> = [
+export const publicFavoritePanelColumns: DataColumns<string> = [
{
name: FavoritePanelColumnNames.NAME,
selected: true,
configurable: true,
sortDirection: SortDirection.NONE,
filters: createTree(),
- render: uuid => <ResourceName uuid={uuid} />
+ render: uuid => <ResourceLinkNameAndIcon uuid={uuid} />
},
{
name: "Status",
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} />
+ render: uuid => <ResourceLinkType uuid={uuid} />
},
{
name: FavoritePanelColumnNames.FILE_SIZE,
}
];
-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);
if (kind) {
}
});
-type FavoritePanelProps = FavoritePanelDataProps & FavoritePanelActionProps & DispatchProp
+type FavoritePanelProps = PublicFavoritePanelDataProps & PublicFavoritePanelActionProps & DispatchProp
& WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
export const PublicFavoritePanel = withStyles(styles)(
dataTableDefaultView={
<DataTableDefaultView
icon={FavoriteIcon}
- messages={['Public favorites list is empty.']}
- />
+ messages={['Public favorites list is empty.']} />
} />;
}
}