// SPDX-License-Identifier: AGPL-3.0
import { unionize, ofType, UnionOf } from "unionize";
+import { Dispatch } from "../../../node_modules/redux";
+import { favoriteService } from "../../services/services";
export const favoritesActions = unionize({
+ CHECK_PRESENCE_IN_FAVORITES: ofType<string[]>(),
UPDATE_FAVORITES: ofType<Record<string, boolean>>()
}, { tag: 'type', value: 'payload' });
-export type FavoritesAction = UnionOf<typeof favoritesActions>;
\ No newline at end of file
+export type FavoritesAction = UnionOf<typeof favoritesActions>;
+
+export const checkPresenceInFavorites = (userUuid: string, resourceUuids: string[]) =>
+ (dispatch: Dispatch) => {
+ dispatch(favoritesActions.CHECK_PRESENCE_IN_FAVORITES(resourceUuids));
+ favoriteService
+ .checkPresenceInFavorites(userUuid, resourceUuids)
+ .then(results => {
+ dispatch(favoritesActions.UPDATE_FAVORITES(results));
+ });
+ };
+
import { Dispatch } from "redux";
import { FilterBuilder } from "../../common/api/filter-builder";
import { RootState } from "../store";
+import { checkPresenceInFavorites } from "../favorites/favorites-actions";
export const projectActions = unionize({
OPEN_PROJECT_CREATOR: ofType<{ ownerUuid: string }>(),
value: 'payload'
});
-export const getProjectList = (parentUuid: string = '') => (dispatch: Dispatch) => {
+export const getProjectList = (parentUuid: string = '') => (dispatch: Dispatch, getState: () => RootState) => {
dispatch(projectActions.PROJECTS_REQUEST(parentUuid));
return projectService.list({
filters: FilterBuilder
.addEqual("ownerUuid", parentUuid)
}).then(({ items: projects }) => {
dispatch(projectActions.PROJECTS_SUCCESS({ projects, parentItemId: parentUuid }));
+ const { user } = getState().auth;
+ dispatch<any>(checkPresenceInFavorites(user ? user.uuid : "", projects.map(project => project.uuid)));
return projects;
});
};
import { SortDirection } from '../../components/data-table/data-column';
import { ResourceKind } from '../../models/resource';
import { resourceLabel } from '../../common/labels';
-import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon } from '../../components/icon/icon';
+import { ProjectIcon, CollectionIcon, ProcessIcon, DefaultIcon, FavoriteIcon } from '../../components/icon/icon';
import { ArvadosTheme } from '../../common/custom-theme';
+import { FavoriteStar } from '../../views-components/favorite-star/favorite-star';
type CssRules = "toolbar" | "button";
{item.name}
</Typography>
</Grid>
+ <Grid item>
+ <Typography variant="caption" style={{fontSize: '8px'}}>
+ <FavoriteStar resourceUuid={item.uuid} />
+ </Typography>
+ </Grid>
</Grid>;
}
type ProjectPanelProps = ProjectPanelDataProps & ProjectPanelActionProps & DispatchProp
- & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
+ & WithStyles<CssRules> & RouteComponentProps<{ id: string }>;
export const ProjectPanel = withStyles(styles)(
connect((state: RootState) => ({ currentItemId: state.projects.currentItemId }))(