import * as _ from "lodash";
import { sidePanelActions, SidePanelAction } from './side-panel-action';
-import { SidePanelItem } from '../../components/side-panel/side-panel';
-import { ProjectsIcon, ShareMeIcon, WorkflowIcon, RecentIcon, FavoriteIcon, TrashIcon } from "../../components/icon/icon";
+import { SidePanelItem } from '~/components/side-panel/side-panel';
+import { ProjectsIcon, ShareMeIcon, WorkflowIcon, RecentIcon, FavoriteIcon, TrashIcon } from "~/components/icon/icon";
+import { Dispatch } from "redux";
+import { push } from "react-router-redux";
+import { favoritePanelActions } from "../favorite-panel/favorite-panel-action";
export type SidePanelState = SidePanelItem[];
return sidePanelData;
} else {
return sidePanelActions.match(action, {
- TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId => state.map(it => itemId === it.id && it.open === false ? {...it, open: true} : {...it, open: false}),
+ TOGGLE_SIDE_PANEL_ITEM_OPEN: itemId =>
+ state.map(it => ({...it, open: itemId === it.id && it.open === false})),
TOGGLE_SIDE_PANEL_ITEM_ACTIVE: itemId => {
const sidePanel = _.cloneDeep(state);
resetSidePanelActivity(sidePanel);
- sidePanel.map(it => {
+ sidePanel.forEach(it => {
if (it.id === itemId) {
it.active = true;
}
};
export enum SidePanelIdentifiers {
- Projects = "Projects",
- SharedWithMe = "SharedWithMe",
- Workflows = "Workflows",
- RecentOpen = "RecentOpen",
- Favourites = "Favourites",
- Trash = "Trash"
+ PROJECTS = "Projects",
+ SHARED_WITH_ME = "SharedWithMe",
+ WORKFLOWS = "Workflows",
+ RECENT_OPEN = "RecentOpen",
+ FAVORITES = "Favourites",
+ TRASH = "Trash"
}
export const sidePanelData = [
{
- id: SidePanelIdentifiers.Projects,
+ id: SidePanelIdentifiers.PROJECTS,
name: "Projects",
icon: ProjectsIcon,
open: false,
openAble: true
},
{
- id: SidePanelIdentifiers.SharedWithMe,
+ id: SidePanelIdentifiers.SHARED_WITH_ME,
name: "Shared with me",
icon: ShareMeIcon,
active: false,
},
{
- id: SidePanelIdentifiers.Workflows,
+ id: SidePanelIdentifiers.WORKFLOWS,
name: "Workflows",
icon: WorkflowIcon,
active: false,
},
{
- id: SidePanelIdentifiers.RecentOpen,
+ id: SidePanelIdentifiers.RECENT_OPEN,
name: "Recent open",
icon: RecentIcon,
active: false,
},
{
- id: SidePanelIdentifiers.Favourites,
+ id: SidePanelIdentifiers.FAVORITES,
name: "Favorites",
icon: FavoriteIcon,
active: false,
+ activeAction: (dispatch: Dispatch) => {
+ dispatch(push("/favorites"));
+ dispatch(favoritePanelActions.RESET_PAGINATION());
+ dispatch(favoritePanelActions.REQUEST_ITEMS());
+ }
},
{
- id: SidePanelIdentifiers.Trash,
+ id: SidePanelIdentifiers.TRASH,
name: "Trash",
icon: TrashIcon,
active: false,