strapi-plugin-navigation 2.0.0-beta.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
LoadingIndicatorPage,
|
|
9
9
|
useNotification,
|
|
10
10
|
useAppInfos,
|
|
11
|
-
useStrapiApp,
|
|
12
11
|
} from "@strapi/helper-plugin";
|
|
13
12
|
import DataManagerContext from "../../contexts/DataManagerContext";
|
|
14
13
|
import getTrad from "../../utils/getTrad";
|
|
@@ -39,7 +38,7 @@ const DataManagerProvider = ({ children }) => {
|
|
|
39
38
|
const toggleNotification = useNotification();
|
|
40
39
|
const { autoReload } = useAppInfos();
|
|
41
40
|
const { formatMessage } = useIntl();
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
const {
|
|
44
43
|
items,
|
|
45
44
|
config,
|
|
@@ -54,10 +53,8 @@ const DataManagerProvider = ({ children }) => {
|
|
|
54
53
|
isLoadingForAdditionalDataToBeSet,
|
|
55
54
|
isLoadingForSubmit,
|
|
56
55
|
error
|
|
57
|
-
} = reducerState
|
|
56
|
+
} = reducerState;
|
|
58
57
|
const { pathname } = useLocation();
|
|
59
|
-
const { getPlugin } = useStrapiApp();
|
|
60
|
-
const { apis } = getPlugin(pluginId);
|
|
61
58
|
const formatMessageRef = useRef();
|
|
62
59
|
formatMessageRef.current = formatMessage;
|
|
63
60
|
|
|
@@ -164,7 +161,7 @@ const DataManagerProvider = ({ children }) => {
|
|
|
164
161
|
}
|
|
165
162
|
}, [autoReload]);
|
|
166
163
|
|
|
167
|
-
const getContentTypeItems = async ({ modelUID, query }
|
|
164
|
+
const getContentTypeItems = async ({ modelUID, query }) => {
|
|
168
165
|
dispatch({
|
|
169
166
|
type: GET_CONTENT_TYPE_ITEMS,
|
|
170
167
|
});
|
|
@@ -174,7 +171,7 @@ const DataManagerProvider = ({ children }) => {
|
|
|
174
171
|
if (query) {
|
|
175
172
|
queryParams.append('_q', query);
|
|
176
173
|
}
|
|
177
|
-
|
|
174
|
+
|
|
178
175
|
const contentTypeItems = await request(`${url}?${queryParams.toString()}`, {
|
|
179
176
|
method: "GET",
|
|
180
177
|
signal,
|
|
@@ -229,7 +226,7 @@ const DataManagerProvider = ({ children }) => {
|
|
|
229
226
|
dispatch({
|
|
230
227
|
type: SUBMIT_NAVIGATION,
|
|
231
228
|
});
|
|
232
|
-
|
|
229
|
+
|
|
233
230
|
const nagivationId = payload.id ? `/${payload.id}` : "";
|
|
234
231
|
const method = payload.id ? "PUT" : "POST";
|
|
235
232
|
const navigation = await request(`/${pluginId}${nagivationId}`, {
|
|
@@ -309,4 +306,4 @@ DataManagerProvider.propTypes = {
|
|
|
309
306
|
children: PropTypes.node.isRequired,
|
|
310
307
|
};
|
|
311
308
|
|
|
312
|
-
export default memo(DataManagerProvider);
|
|
309
|
+
export default memo(DataManagerProvider);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import produce from 'immer';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
GET_LIST_DATA,
|
|
4
5
|
GET_LIST_DATA_SUCCEEDED,
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
SUBMIT_NAVIGATION_ERROR,
|
|
19
20
|
} from './actions';
|
|
20
21
|
|
|
21
|
-
const initialState =
|
|
22
|
+
const initialState = {
|
|
22
23
|
items: [],
|
|
23
24
|
activeItem: undefined,
|
|
24
25
|
changedActiveItem: undefined,
|
|
@@ -31,106 +32,94 @@ const initialState = fromJS({
|
|
|
31
32
|
isLoadingForAdditionalDataToBeSet: false,
|
|
32
33
|
isLoadingForSubmit: false,
|
|
33
34
|
error: undefined,
|
|
34
|
-
}
|
|
35
|
+
};
|
|
35
36
|
|
|
36
|
-
const reducer = (state, action) => {
|
|
37
|
+
const reducer = (state, action) => produce(state, draftState => {
|
|
37
38
|
switch (action.type) {
|
|
38
39
|
case GET_CONFIG: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
draftState.isLoadingForDetailsDataToBeSet = true;
|
|
41
|
+
draftState.config = {};
|
|
42
|
+
break;
|
|
42
43
|
}
|
|
43
44
|
case GET_CONFIG_SUCCEEDED: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
draftState.isLoadingForDetailsDataToBeSet = false;
|
|
46
|
+
draftState.config = action.config;
|
|
47
|
+
break;
|
|
47
48
|
}
|
|
48
49
|
case GET_LIST_DATA: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
draftState.items = [];
|
|
51
|
+
draftState.isLoadingForDataToBeSet = true;
|
|
52
|
+
break;
|
|
52
53
|
}
|
|
53
54
|
case GET_LIST_DATA_SUCCEEDED: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
draftState.items = action.items;
|
|
56
|
+
draftState.isLoading = false;
|
|
57
|
+
draftState.isLoadingForDataToBeSet = false;
|
|
58
|
+
break;
|
|
58
59
|
}
|
|
59
60
|
case GET_NAVIGATION_DATA: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
draftState.activeItem = undefined;
|
|
62
|
+
draftState.changedActiveItem = undefined;
|
|
63
|
+
draftState.isLoadingForDetailsDataToBeSet = true;
|
|
64
|
+
break;
|
|
64
65
|
}
|
|
65
66
|
case GET_NAVIGATION_DATA_SUCCEEDED: {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const activeItem = action.activeItem || {};
|
|
68
|
+
draftState.activeItem = activeItem;
|
|
69
|
+
draftState.changedActiveItem = activeItem;
|
|
70
|
+
draftState.isLoadingForDetailsDataToBeSet = false;
|
|
71
|
+
break;
|
|
71
72
|
}
|
|
72
73
|
case CHANGE_NAVIGATION_DATA: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
case RESET_NAVIGATION_DATA: {
|
|
83
|
-
const { activeItem = {} } = action;
|
|
84
|
-
return state.update("changedActiveItem", () => activeItem);
|
|
74
|
+
draftState.changedActiveItem = action.changedActiveItem;
|
|
75
|
+
draftState.navigationPopupOpened = action.forceClosePopups ? false : state.navigationPopupOpened;
|
|
76
|
+
draftState.navigationItemPopupOpened = action.forceClosePopups ? false : state.navigationItemPopupOpened;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case RESET_NAVIGATION_DATA : {
|
|
80
|
+
draftState.changedActiveItem = action.activeItem || {};
|
|
81
|
+
break;
|
|
85
82
|
}
|
|
86
83
|
case GET_CONTENT_TYPE_ITEMS: {
|
|
87
|
-
|
|
84
|
+
draftState.isLoadingForAdditionalDataToBeSet = true;
|
|
85
|
+
break;
|
|
88
86
|
}
|
|
89
87
|
case GET_CONTENT_TYPE_ITEMS_SUCCEEDED: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
fromJS(action.contentTypeItems),
|
|
94
|
-
);
|
|
88
|
+
draftState.isLoadingForAdditionalDataToBeSet = false;
|
|
89
|
+
draftState.config.contentTypeItems = action.contentTypeItems;
|
|
90
|
+
break;
|
|
95
91
|
}
|
|
96
92
|
case CHANGE_NAVIGATION_POPUP_VISIBILITY: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
() => action.navigationPopupOpened,
|
|
100
|
-
);
|
|
93
|
+
draftState.navigationPopupOpened = action.navigationPopupOpened;
|
|
94
|
+
break;
|
|
101
95
|
}
|
|
102
96
|
case CHANGE_NAVIGATION_ITEM_POPUP_VISIBILITY: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
() => action.navigationItemPopupOpened,
|
|
106
|
-
);
|
|
97
|
+
draftState.navigationItemPopupOpened = action.navigationItemPopupOpened;
|
|
98
|
+
break;
|
|
107
99
|
}
|
|
108
100
|
case SUBMIT_NAVIGATION: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
draftState.isLoadingForSubmit = true;
|
|
102
|
+
draftState.error = undefined;
|
|
103
|
+
break;
|
|
112
104
|
}
|
|
113
105
|
case SUBMIT_NAVIGATION_SUCCEEDED: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
.update(
|
|
119
|
-
'isLoadingForSubmit',
|
|
120
|
-
() => false,
|
|
121
|
-
);
|
|
106
|
+
draftState.activeItem = action.navigation || {};
|
|
107
|
+
draftState.changedActiveItem = action.navigation || {};
|
|
108
|
+
draftState.isLoadingForSubmit = false;
|
|
109
|
+
break;
|
|
122
110
|
}
|
|
123
111
|
case SUBMIT_NAVIGATION_ERROR: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
draftState.isLoadingForSubmit = false;
|
|
113
|
+
draftState.error = action.error;
|
|
114
|
+
break;
|
|
127
115
|
}
|
|
128
|
-
case RELOAD_PLUGIN:
|
|
116
|
+
case RELOAD_PLUGIN: {
|
|
129
117
|
return initialState;
|
|
118
|
+
}
|
|
130
119
|
default:
|
|
131
|
-
return
|
|
120
|
+
return draftState;
|
|
132
121
|
}
|
|
133
|
-
};
|
|
122
|
+
});
|
|
134
123
|
|
|
135
124
|
export default reducer;
|
|
136
125
|
export { initialState };
|