-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
reducer.js
64 lines (61 loc) 路 1.64 KB
/
reducer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable consistent-return */
import produce from 'immer';
import Cog from '@strapi/icons/Cog';
import Puzzle from '@strapi/icons/Puzzle';
import ShoppingCart from '@strapi/icons/ShoppingCart';
import adminPermissions from '../../permissions';
const initialState = {
generalSectionLinks: [
{
icon: Puzzle,
intlLabel: {
id: 'global.plugins',
defaultMessage: 'Plugins',
},
to: '/list-plugins',
permissions: adminPermissions.marketplace.main,
},
{
icon: ShoppingCart,
intlLabel: {
id: 'global.marketplace',
defaultMessage: 'Marketplace',
},
to: '/marketplace',
permissions: adminPermissions.marketplace.main,
},
{
icon: Cog,
intlLabel: {
id: 'global.settings',
defaultMessage: 'Settings',
},
to: '/settings',
// Permissions of this link are retrieved in the init phase
// using the settings menu
permissions: [],
notificationsCount: 0,
},
],
pluginsSectionLinks: [],
isLoading: true,
};
const reducer = (state = initialState, action) =>
produce(state, draftState => {
switch (action.type) {
case 'SET_SECTION_LINKS': {
const { authorizedGeneralSectionLinks, authorizedPluginSectionLinks } = action.data;
draftState.generalSectionLinks = authorizedGeneralSectionLinks;
draftState.pluginsSectionLinks = authorizedPluginSectionLinks;
break;
}
case 'UNSET_IS_LOADING': {
draftState.isLoading = false;
break;
}
default:
return draftState;
}
});
export default reducer;
export { initialState };