jamespot-front-business 1.1.89 → 1.1.91
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.
- package/dist/cjs.js +487 -254
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +480 -256
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +5938 -2011
- package/package.json +2 -2
package/dist/esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEntityAdapter, createSlice, createAsyncThunk, combineReducers } from '@reduxjs/toolkit';
|
|
2
2
|
import { combineReducers as combineReducers$1 } from 'redux';
|
|
3
|
-
import jamespot, { jEnsure, formatImgUrl, UserLevel, WidgetsName, StudioApplicationStatus } from 'jamespot-user-api';
|
|
3
|
+
import jamespot, { jEnsure, Format, formatImgUrl, UserLevel, WidgetsName, StudioApplicationStatus } from 'jamespot-user-api';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
5
5
|
|
|
6
6
|
/******************************************************************************
|
|
@@ -49,9 +49,16 @@ const isAbortError = (error) => {
|
|
|
49
49
|
return !!error && typeof error === 'object' && 'aborted' in error && !!error.aborted;
|
|
50
50
|
};
|
|
51
51
|
const getErrorMessage = (error, defaultError) => {
|
|
52
|
-
|
|
53
|
-
?
|
|
54
|
-
|
|
52
|
+
if (!error || typeof error !== 'object') {
|
|
53
|
+
return defaultError !== null && defaultError !== void 0 ? defaultError : 'GLOBAL_Technical_Error';
|
|
54
|
+
}
|
|
55
|
+
if ('errorMsg' in error && typeof error.errorMsg === 'string') {
|
|
56
|
+
return error.errorMsg;
|
|
57
|
+
}
|
|
58
|
+
if ('message' in error && typeof error.message === 'string') {
|
|
59
|
+
return error.message;
|
|
60
|
+
}
|
|
61
|
+
return defaultError !== null && defaultError !== void 0 ? defaultError : 'GLOBAL_Technical_Error';
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
const toastAdapter = createEntityAdapter({
|
|
@@ -97,7 +104,7 @@ const oneMonthAgo$2 = () => {
|
|
|
97
104
|
date.setMonth(date.getMonth() - 1);
|
|
98
105
|
return date;
|
|
99
106
|
};
|
|
100
|
-
const initialState$
|
|
107
|
+
const initialState$r = {
|
|
101
108
|
data: [],
|
|
102
109
|
loading: 'idle',
|
|
103
110
|
page: 1,
|
|
@@ -122,14 +129,14 @@ const fetchLogsNavigation = createAsyncThunk('admin/fetchLogsNavigation', (param
|
|
|
122
129
|
}
|
|
123
130
|
catch (err) {
|
|
124
131
|
if (!isAbortError(err)) {
|
|
125
|
-
dispatch(Toast.actions.error({ label:
|
|
132
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
126
133
|
}
|
|
127
134
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs navigation' });
|
|
128
135
|
}
|
|
129
136
|
}));
|
|
130
137
|
const adminLogsNavigationSlice = createSlice({
|
|
131
138
|
name: 'logsNavigation',
|
|
132
|
-
initialState: initialState$
|
|
139
|
+
initialState: initialState$r,
|
|
133
140
|
reducers: {
|
|
134
141
|
setNavigationOrder: (state, action) => {
|
|
135
142
|
state.orders = [...action.payload];
|
|
@@ -167,7 +174,7 @@ const oneMonthAgo$1 = () => {
|
|
|
167
174
|
date.setMonth(date.getMonth() - 1);
|
|
168
175
|
return date;
|
|
169
176
|
};
|
|
170
|
-
const initialState$
|
|
177
|
+
const initialState$q = {
|
|
171
178
|
data: [],
|
|
172
179
|
loading: 'idle',
|
|
173
180
|
page: 1,
|
|
@@ -192,14 +199,14 @@ const fetchLogsObjects = createAsyncThunk('admin/fetchLogsObjects', (params, { e
|
|
|
192
199
|
}
|
|
193
200
|
catch (err) {
|
|
194
201
|
if (!isAbortError(err)) {
|
|
195
|
-
dispatch(Toast.actions.error({ label:
|
|
202
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
196
203
|
}
|
|
197
204
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs Objects' });
|
|
198
205
|
}
|
|
199
206
|
}));
|
|
200
207
|
const adminLogsObjectsSlice = createSlice({
|
|
201
208
|
name: 'logsObjects',
|
|
202
|
-
initialState: initialState$
|
|
209
|
+
initialState: initialState$q,
|
|
203
210
|
reducers: {
|
|
204
211
|
setObjectsOrder: (state, action) => {
|
|
205
212
|
state.orders = [...action.payload];
|
|
@@ -236,7 +243,7 @@ const oneMonthAgo = () => {
|
|
|
236
243
|
date.setMonth(date.getMonth() - 1);
|
|
237
244
|
return date;
|
|
238
245
|
};
|
|
239
|
-
const initialState$
|
|
246
|
+
const initialState$p = {
|
|
240
247
|
data: [],
|
|
241
248
|
loading: 'idle',
|
|
242
249
|
page: 1,
|
|
@@ -261,14 +268,14 @@ const fetchLogsSearch = createAsyncThunk('admin/fetchLogsSearch', (params, { ext
|
|
|
261
268
|
}
|
|
262
269
|
catch (err) {
|
|
263
270
|
if (!isAbortError(err)) {
|
|
264
|
-
dispatch(Toast.actions.error({ label:
|
|
271
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
265
272
|
}
|
|
266
273
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve admin logs Search' });
|
|
267
274
|
}
|
|
268
275
|
}));
|
|
269
276
|
const adminLogsSearchSlice = createSlice({
|
|
270
277
|
name: 'logsSearch',
|
|
271
|
-
initialState: initialState$
|
|
278
|
+
initialState: initialState$p,
|
|
272
279
|
reducers: {
|
|
273
280
|
setSearchOrder: (state, action) => {
|
|
274
281
|
state.orders = [...action.payload];
|
|
@@ -321,7 +328,7 @@ const AdminLogs = {
|
|
|
321
328
|
selectors: { selectAdminLogsNavigation, selectAdminLogsObjects, selectAdminLogsSearch },
|
|
322
329
|
};
|
|
323
330
|
|
|
324
|
-
const initialState$
|
|
331
|
+
const initialState$o = {
|
|
325
332
|
animationConfiguration: null,
|
|
326
333
|
isActiveForCurrentUser: false,
|
|
327
334
|
isInitialized: false,
|
|
@@ -329,7 +336,7 @@ const initialState$n = {
|
|
|
329
336
|
};
|
|
330
337
|
const animationsListSlice = createSlice({
|
|
331
338
|
name: 'animationsList',
|
|
332
|
-
initialState: initialState$
|
|
339
|
+
initialState: initialState$o,
|
|
333
340
|
reducers: {},
|
|
334
341
|
extraReducers: (builder) => {
|
|
335
342
|
builder.addCase(fetchCurrentAnimation.fulfilled, (state, action) => {
|
|
@@ -361,7 +368,7 @@ const fetchCurrentAnimation = createAsyncThunk('animations/fetchCurrentAnimation
|
|
|
361
368
|
}
|
|
362
369
|
catch (err) {
|
|
363
370
|
if (!isAbortError(err)) {
|
|
364
|
-
dispatch(Toast.actions.error({ label:
|
|
371
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
365
372
|
}
|
|
366
373
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation' });
|
|
367
374
|
}
|
|
@@ -370,8 +377,8 @@ const fetchCurrentAnimationApp = createAsyncThunk('animations/fetchCurrentAnimat
|
|
|
370
377
|
try {
|
|
371
378
|
return (yield extra.jApi.animations.GetCurrentAnimationApp()).result;
|
|
372
379
|
}
|
|
373
|
-
catch (
|
|
374
|
-
dispatch(Toast.actions.error({ label:
|
|
380
|
+
catch (err) {
|
|
381
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
375
382
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation' });
|
|
376
383
|
}
|
|
377
384
|
}));
|
|
@@ -380,8 +387,8 @@ const deleteCurrentAnimation = createAsyncThunk('animations/deleteCurrentAnimati
|
|
|
380
387
|
yield extra.jApi.animations.DeleteAnimation();
|
|
381
388
|
return;
|
|
382
389
|
}
|
|
383
|
-
catch (
|
|
384
|
-
dispatch(Toast.actions.error({ label:
|
|
390
|
+
catch (err) {
|
|
391
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
385
392
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot delete animation' });
|
|
386
393
|
}
|
|
387
394
|
}));
|
|
@@ -390,8 +397,8 @@ const saveCurrentAnimation = createAsyncThunk('animations/saveCurrentAnimation',
|
|
|
390
397
|
yield extra.jApi.animations.SaveAnimationConfiguration(params);
|
|
391
398
|
return;
|
|
392
399
|
}
|
|
393
|
-
catch (
|
|
394
|
-
dispatch(Toast.actions.error({ label:
|
|
400
|
+
catch (err) {
|
|
401
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
395
402
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot update animation' });
|
|
396
403
|
}
|
|
397
404
|
}));
|
|
@@ -400,8 +407,8 @@ const toggleAnimationIsActive = createAsyncThunk('animations/toggleAnimationIsAc
|
|
|
400
407
|
yield extra.jApi.animations.ToggleAnimationActive();
|
|
401
408
|
return;
|
|
402
409
|
}
|
|
403
|
-
catch (
|
|
404
|
-
dispatch(Toast.actions.error({ label:
|
|
410
|
+
catch (err) {
|
|
411
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
405
412
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot update animation' });
|
|
406
413
|
}
|
|
407
414
|
}));
|
|
@@ -448,8 +455,8 @@ const fetchAnimationStats = createAsyncThunk('animations/fetchAnimationStats', (
|
|
|
448
455
|
const stats = (yield extra.jApi.animations.GetAnimationStats(name)).result.data;
|
|
449
456
|
return stats;
|
|
450
457
|
}
|
|
451
|
-
catch (
|
|
452
|
-
dispatch(Toast.actions.error({ label:
|
|
458
|
+
catch (err) {
|
|
459
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
453
460
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation stats' });
|
|
454
461
|
}
|
|
455
462
|
}));
|
|
@@ -480,8 +487,8 @@ const fetchAnimationStatsCurrent = createAsyncThunk('animations/fetchAnimationSt
|
|
|
480
487
|
const stats = (yield extra.jApi.animations.GetAnimationStatsCurrent(uri)).result;
|
|
481
488
|
return stats;
|
|
482
489
|
}
|
|
483
|
-
catch (
|
|
484
|
-
dispatch(Toast.actions.error({ label:
|
|
490
|
+
catch (err) {
|
|
491
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
485
492
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve animation stats current' });
|
|
486
493
|
}
|
|
487
494
|
}));
|
|
@@ -564,7 +571,7 @@ const Application = {
|
|
|
564
571
|
selectors: selectors$2,
|
|
565
572
|
};
|
|
566
573
|
|
|
567
|
-
const initialState$
|
|
574
|
+
const initialState$n = {
|
|
568
575
|
entities: [],
|
|
569
576
|
loading: 'idle',
|
|
570
577
|
nbResults: 0,
|
|
@@ -580,7 +587,7 @@ const fetchBookableAsset = createAsyncThunk('BookableAsset/fetchBookableAsset',
|
|
|
580
587
|
}));
|
|
581
588
|
const BookableAssetSlice = createSlice({
|
|
582
589
|
name: 'bookableAsset',
|
|
583
|
-
initialState: initialState$
|
|
590
|
+
initialState: initialState$n,
|
|
584
591
|
reducers: {},
|
|
585
592
|
extraReducers: (builder) => {
|
|
586
593
|
builder
|
|
@@ -601,7 +608,7 @@ const BookableAssetSlice = createSlice({
|
|
|
601
608
|
const fetchConfiguration = createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
602
609
|
return yield extra.jApi.assetReservation.configuration();
|
|
603
610
|
}));
|
|
604
|
-
const initialState$
|
|
611
|
+
const initialState$m = {
|
|
605
612
|
description: '',
|
|
606
613
|
right: {
|
|
607
614
|
manage: false,
|
|
@@ -615,7 +622,7 @@ const initialState$l = {
|
|
|
615
622
|
};
|
|
616
623
|
const AssetReservationConfigurationSlice = createSlice({
|
|
617
624
|
name: 'configuration',
|
|
618
|
-
initialState: initialState$
|
|
625
|
+
initialState: initialState$m,
|
|
619
626
|
reducers: {},
|
|
620
627
|
extraReducers: (builder) => {
|
|
621
628
|
builder
|
|
@@ -636,7 +643,7 @@ const initForm = {
|
|
|
636
643
|
hourStart: '',
|
|
637
644
|
hourEnd: '',
|
|
638
645
|
};
|
|
639
|
-
const initialState$
|
|
646
|
+
const initialState$l = {
|
|
640
647
|
entities: [],
|
|
641
648
|
loading: 'idle',
|
|
642
649
|
nbResults: 0,
|
|
@@ -652,7 +659,7 @@ const fetchReservation = createAsyncThunk('Reservation/fetchReservation', (viewM
|
|
|
652
659
|
}));
|
|
653
660
|
const ReservationSlice = createSlice({
|
|
654
661
|
name: 'reservation',
|
|
655
|
-
initialState: initialState$
|
|
662
|
+
initialState: initialState$l,
|
|
656
663
|
reducers: {
|
|
657
664
|
setForm: (state, action) => {
|
|
658
665
|
state.form = action.payload;
|
|
@@ -708,181 +715,7 @@ const AssetReservation = {
|
|
|
708
715
|
},
|
|
709
716
|
};
|
|
710
717
|
|
|
711
|
-
const initialState$
|
|
712
|
-
loading: 'idle',
|
|
713
|
-
comments: [],
|
|
714
|
-
};
|
|
715
|
-
const fetchComments = createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
716
|
-
var _a;
|
|
717
|
-
try {
|
|
718
|
-
const res = yield extra.jApi.article.getComments(params, {
|
|
719
|
-
format: 'raw-list',
|
|
720
|
-
formatExtension: ['actions'],
|
|
721
|
-
});
|
|
722
|
-
return { idArticle: params.idArticle, list: res.result };
|
|
723
|
-
}
|
|
724
|
-
catch (error) {
|
|
725
|
-
dispatch(Toast.actions.error({ label: (_a = error.errorMsg) !== null && _a !== void 0 ? _a : 'GLOBAL_Technical_Error' }));
|
|
726
|
-
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
|
|
727
|
-
}
|
|
728
|
-
}));
|
|
729
|
-
const deleteComment = createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
730
|
-
var _b;
|
|
731
|
-
try {
|
|
732
|
-
yield extra.jApi.article.deleteComment(params.idComment);
|
|
733
|
-
return true;
|
|
734
|
-
}
|
|
735
|
-
catch (error) {
|
|
736
|
-
dispatch(Toast.actions.error({ label: (_b = error.errorMsg) !== null && _b !== void 0 ? _b : 'GLOBAL_Technical_Error' }));
|
|
737
|
-
return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
|
|
738
|
-
}
|
|
739
|
-
}));
|
|
740
|
-
const CommentListSlice = createSlice({
|
|
741
|
-
name: 'commentList',
|
|
742
|
-
initialState: initialState$j,
|
|
743
|
-
reducers: {
|
|
744
|
-
discardComments: (state, action) => {
|
|
745
|
-
state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
|
|
746
|
-
},
|
|
747
|
-
hydrateComment: (state, action) => {
|
|
748
|
-
const { idArticle, list } = action.payload;
|
|
749
|
-
const hasList = state.comments.find((c) => c.idArticle === idArticle);
|
|
750
|
-
if (!hasList) {
|
|
751
|
-
state.comments = [
|
|
752
|
-
...state.comments.filter((c) => c.idArticle !== idArticle),
|
|
753
|
-
{
|
|
754
|
-
idArticle,
|
|
755
|
-
list: Array.isArray(list) ? list : [],
|
|
756
|
-
},
|
|
757
|
-
];
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
const initialUris = [];
|
|
761
|
-
const allUris = state.comments.reduce((uris, c) => {
|
|
762
|
-
return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
|
|
763
|
-
}, initialUris);
|
|
764
|
-
const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
|
|
765
|
-
state.comments = state.comments.map((c) => {
|
|
766
|
-
return c.idArticle === idArticle
|
|
767
|
-
? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
|
|
768
|
-
});
|
|
769
|
-
},
|
|
770
|
-
updateComment: (state, action) => {
|
|
771
|
-
state.comments = state.comments.map((c) => {
|
|
772
|
-
const { idArticle, idComment, data } = action.payload;
|
|
773
|
-
return c.idArticle === idArticle
|
|
774
|
-
? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
|
|
775
|
-
});
|
|
776
|
-
},
|
|
777
|
-
},
|
|
778
|
-
extraReducers: (builder) => {
|
|
779
|
-
builder
|
|
780
|
-
.addCase(fetchComments.pending, (state) => {
|
|
781
|
-
state.loading = 'pending';
|
|
782
|
-
})
|
|
783
|
-
.addCase(fetchComments.fulfilled, (state, action) => {
|
|
784
|
-
state.loading = 'idle';
|
|
785
|
-
state.comments = [
|
|
786
|
-
...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
|
|
787
|
-
{
|
|
788
|
-
idArticle: action.payload.idArticle,
|
|
789
|
-
list: action.payload.list.reverse(),
|
|
790
|
-
},
|
|
791
|
-
];
|
|
792
|
-
})
|
|
793
|
-
.addCase(fetchComments.rejected, (state) => {
|
|
794
|
-
state.loading = 'idle';
|
|
795
|
-
})
|
|
796
|
-
.addCase(deleteComment.pending, (state, action) => {
|
|
797
|
-
state.comments = state.comments.map((c) => {
|
|
798
|
-
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
799
|
-
return c;
|
|
800
|
-
}
|
|
801
|
-
return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: true }) : comment) });
|
|
802
|
-
});
|
|
803
|
-
})
|
|
804
|
-
.addCase(deleteComment.rejected, (state, action) => {
|
|
805
|
-
state.comments = state.comments.map((c) => {
|
|
806
|
-
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
807
|
-
return c;
|
|
808
|
-
}
|
|
809
|
-
return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: false }) : comment) });
|
|
810
|
-
});
|
|
811
|
-
});
|
|
812
|
-
},
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
const getCommentRTHandlers = function (dispatch, idArticle) {
|
|
816
|
-
const addCommentHandler = function (message) {
|
|
817
|
-
if (message.namespace === 'JAMESPOT' &&
|
|
818
|
-
message.function === 'comment-create' &&
|
|
819
|
-
message.object.idArticle === idArticle) {
|
|
820
|
-
dispatch(fetchComments({ idArticle }));
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
const deleteCommentHandler = function (message) {
|
|
824
|
-
if (message.namespace === 'JAMESPOT' &&
|
|
825
|
-
message.function === 'comment-delete' &&
|
|
826
|
-
Number(message.object.idArticle) === idArticle) {
|
|
827
|
-
dispatch(fetchComments({ idArticle }));
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
return [
|
|
831
|
-
{
|
|
832
|
-
namespace: 'JAMESPOT',
|
|
833
|
-
function: 'comment-create',
|
|
834
|
-
handler: addCommentHandler,
|
|
835
|
-
},
|
|
836
|
-
{
|
|
837
|
-
namespace: 'JAMESPOT',
|
|
838
|
-
function: 'comment-delete',
|
|
839
|
-
handler: deleteCommentHandler,
|
|
840
|
-
},
|
|
841
|
-
];
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
|
|
845
|
-
const commentLikeHandler = function (message) {
|
|
846
|
-
if (message.namespace === 'CUSTOM-ACTION' &&
|
|
847
|
-
(message.function === 'add' || message.function === 'remove') &&
|
|
848
|
-
message.object.type === 'sociallike' &&
|
|
849
|
-
message.object.targetId &&
|
|
850
|
-
idComments &&
|
|
851
|
-
idComments.includes(message.object.targetId)) {
|
|
852
|
-
dispatch(fetchComments({ idArticle }));
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
return idComments
|
|
856
|
-
? [
|
|
857
|
-
{ namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
|
|
858
|
-
{ namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
|
|
859
|
-
]
|
|
860
|
-
: [];
|
|
861
|
-
};
|
|
862
|
-
|
|
863
|
-
const CommentReducer = combineReducers$1({
|
|
864
|
-
[CommentListSlice.name]: CommentListSlice.reducer,
|
|
865
|
-
});
|
|
866
|
-
const commentSlice = {
|
|
867
|
-
name: 'comment',
|
|
868
|
-
reducer: CommentReducer,
|
|
869
|
-
};
|
|
870
|
-
const selectCommentList = (state, idArticle, limit = 0) => {
|
|
871
|
-
const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
|
|
872
|
-
const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
|
|
873
|
-
return limit !== 0 ? list.slice(-limit) : list;
|
|
874
|
-
};
|
|
875
|
-
const Comment = {
|
|
876
|
-
slice: commentSlice,
|
|
877
|
-
actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
|
|
878
|
-
selectors: {
|
|
879
|
-
commentList: selectCommentList,
|
|
880
|
-
},
|
|
881
|
-
getCommentRTHandlers,
|
|
882
|
-
getCommentsLikeRTHandlers,
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
const initialState$i = {
|
|
718
|
+
const initialState$k = {
|
|
886
719
|
loading: 'idle',
|
|
887
720
|
reports: [],
|
|
888
721
|
page: 1,
|
|
@@ -895,7 +728,7 @@ const initialState$i = {
|
|
|
895
728
|
};
|
|
896
729
|
const contentReportSlice = createSlice({
|
|
897
730
|
name: 'contentReport',
|
|
898
|
-
initialState: initialState$
|
|
731
|
+
initialState: initialState$k,
|
|
899
732
|
reducers: {
|
|
900
733
|
setTab: (state, action) => {
|
|
901
734
|
state.tab = action.payload;
|
|
@@ -1001,7 +834,7 @@ const ContentReport = {
|
|
|
1001
834
|
selectors: { selectContentReport },
|
|
1002
835
|
};
|
|
1003
836
|
|
|
1004
|
-
const initialState$
|
|
837
|
+
const initialState$j = {
|
|
1005
838
|
bookmarks: [],
|
|
1006
839
|
loading: 'idle',
|
|
1007
840
|
status: undefined,
|
|
@@ -1019,13 +852,12 @@ const fetchBookmark = createAsyncThunk('bookmarkList/fetchbookmarkList', (_, { e
|
|
|
1019
852
|
try {
|
|
1020
853
|
return yield extra.jApi.bookmark.getFormattedList(filterSpec, 'raw-list');
|
|
1021
854
|
}
|
|
1022
|
-
catch (
|
|
1023
|
-
dispatch(Toast.actions.error({ label:
|
|
855
|
+
catch (err) {
|
|
856
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1024
857
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve bookmarks' });
|
|
1025
858
|
}
|
|
1026
859
|
}));
|
|
1027
860
|
const addBookmark = createAsyncThunk('bookmarkList/addBookmark', (bookmark, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1028
|
-
var _a;
|
|
1029
861
|
try {
|
|
1030
862
|
if (jEnsure.isBookmarkLink(bookmark)) {
|
|
1031
863
|
const result = yield extra.jApi.bookmark.addFormattedLink(bookmark.targetId, bookmark.targetType, 'raw-list');
|
|
@@ -1037,7 +869,7 @@ const addBookmark = createAsyncThunk('bookmarkList/addBookmark', (bookmark, { ex
|
|
|
1037
869
|
}
|
|
1038
870
|
}
|
|
1039
871
|
catch (error) {
|
|
1040
|
-
const toastLabel = (
|
|
872
|
+
const toastLabel = getErrorMessage(error);
|
|
1041
873
|
dispatch(Toast.actions.error({ label: toastLabel }));
|
|
1042
874
|
return rejectWithValue({ error: 1, errorMsg: 'Error saving bookmark' });
|
|
1043
875
|
}
|
|
@@ -1047,8 +879,8 @@ const moveBookmark = createAsyncThunk('bookmarkList/moveBookmark', ({ bookmark,
|
|
|
1047
879
|
yield extra.jApi.bookmark.move(bookmark.id, bookmarkReference.id, position);
|
|
1048
880
|
return;
|
|
1049
881
|
}
|
|
1050
|
-
catch (
|
|
1051
|
-
dispatch(Toast.actions.error({ label:
|
|
882
|
+
catch (err) {
|
|
883
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1052
884
|
return rejectWithValue({ error: 1, errorMsg: 'Error moving bookmark' });
|
|
1053
885
|
}
|
|
1054
886
|
}));
|
|
@@ -1057,14 +889,14 @@ const deleteBookmark = createAsyncThunk('bookmarkList/deleteBookmark', (bookmark
|
|
|
1057
889
|
yield extra.jApi.bookmark.delete(bookmark.id);
|
|
1058
890
|
return;
|
|
1059
891
|
}
|
|
1060
|
-
catch (
|
|
1061
|
-
dispatch(Toast.actions.error({ label:
|
|
892
|
+
catch (err) {
|
|
893
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1062
894
|
return rejectWithValue({ error: 1, errorMsg: 'Error deleting bookmark' });
|
|
1063
895
|
}
|
|
1064
896
|
}));
|
|
1065
897
|
const BookmarkListSlice = createSlice({
|
|
1066
898
|
name: 'bookmarkList',
|
|
1067
|
-
initialState: initialState$
|
|
899
|
+
initialState: initialState$j,
|
|
1068
900
|
reducers: {
|
|
1069
901
|
resetAddBookmarkStatus: (state, action) => {
|
|
1070
902
|
if (state.add[action.payload]) {
|
|
@@ -1227,7 +1059,7 @@ const getBookmarkRTHandlers = function (dispatch) {
|
|
|
1227
1059
|
];
|
|
1228
1060
|
};
|
|
1229
1061
|
|
|
1230
|
-
const initialState$
|
|
1062
|
+
const initialState$i = {
|
|
1231
1063
|
bookmark: undefined,
|
|
1232
1064
|
status: undefined,
|
|
1233
1065
|
loading: 'idle',
|
|
@@ -1249,7 +1081,7 @@ const editBookmark = createAsyncThunk('bookmarkEdit/editBookmark', (bookmark, {
|
|
|
1249
1081
|
}));
|
|
1250
1082
|
const BookmarkEditSlice = createSlice({
|
|
1251
1083
|
name: 'bookmarkEdit',
|
|
1252
|
-
initialState: initialState$
|
|
1084
|
+
initialState: initialState$i,
|
|
1253
1085
|
reducers: {
|
|
1254
1086
|
setEditBookmark: (state, action) => {
|
|
1255
1087
|
state.bookmark = Object.assign({}, action.payload);
|
|
@@ -1308,6 +1140,405 @@ const Bookmark = {
|
|
|
1308
1140
|
getRTHandlers: getBookmarkRTHandlers,
|
|
1309
1141
|
};
|
|
1310
1142
|
|
|
1143
|
+
const initialState$h = {
|
|
1144
|
+
loading: 'idle',
|
|
1145
|
+
comments: [],
|
|
1146
|
+
};
|
|
1147
|
+
const fetchComments = createAsyncThunk('commentList/fetchCommentList', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1148
|
+
try {
|
|
1149
|
+
const res = yield extra.jApi.article.getComments(params, {
|
|
1150
|
+
format: 'raw-list',
|
|
1151
|
+
formatExtension: ['actions'],
|
|
1152
|
+
});
|
|
1153
|
+
return { idArticle: params.idArticle, list: res.result };
|
|
1154
|
+
}
|
|
1155
|
+
catch (error) {
|
|
1156
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
1157
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve comments' });
|
|
1158
|
+
}
|
|
1159
|
+
}));
|
|
1160
|
+
const deleteComment = createAsyncThunk('commentList/deleteComment', (params, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1161
|
+
try {
|
|
1162
|
+
yield extra.jApi.article.deleteComment(params.idComment);
|
|
1163
|
+
return true;
|
|
1164
|
+
}
|
|
1165
|
+
catch (error) {
|
|
1166
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
1167
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot delete comment' });
|
|
1168
|
+
}
|
|
1169
|
+
}));
|
|
1170
|
+
const CommentListSlice = createSlice({
|
|
1171
|
+
name: 'commentList',
|
|
1172
|
+
initialState: initialState$h,
|
|
1173
|
+
reducers: {
|
|
1174
|
+
discardComments: (state, action) => {
|
|
1175
|
+
state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
|
|
1176
|
+
},
|
|
1177
|
+
hydrateComment: (state, action) => {
|
|
1178
|
+
const { idArticle, list } = action.payload;
|
|
1179
|
+
const hasList = state.comments.find((c) => c.idArticle === idArticle);
|
|
1180
|
+
if (!hasList) {
|
|
1181
|
+
state.comments = [
|
|
1182
|
+
...state.comments.filter((c) => c.idArticle !== idArticle),
|
|
1183
|
+
{
|
|
1184
|
+
idArticle,
|
|
1185
|
+
list: Array.isArray(list) ? list : [],
|
|
1186
|
+
},
|
|
1187
|
+
];
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
const initialUris = [];
|
|
1191
|
+
const allUris = state.comments.reduce((uris, c) => {
|
|
1192
|
+
return Array.isArray(c.list) ? [...uris, ...c.list.map((el) => el.uri)] : [...uris];
|
|
1193
|
+
}, initialUris);
|
|
1194
|
+
const safeList = Array.isArray(list) ? list.filter((el) => !allUris.includes(el.uri)) : [];
|
|
1195
|
+
state.comments = state.comments.map((c) => {
|
|
1196
|
+
return c.idArticle === idArticle
|
|
1197
|
+
? Object.assign(Object.assign({}, c), { list: Array.isArray(c.list) ? [...c.list, ...safeList] : [...safeList] }) : c;
|
|
1198
|
+
});
|
|
1199
|
+
},
|
|
1200
|
+
updateComment: (state, action) => {
|
|
1201
|
+
state.comments = state.comments.map((c) => {
|
|
1202
|
+
const { idArticle, idComment, data } = action.payload;
|
|
1203
|
+
return c.idArticle === idArticle
|
|
1204
|
+
? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
|
|
1205
|
+
});
|
|
1206
|
+
},
|
|
1207
|
+
},
|
|
1208
|
+
extraReducers: (builder) => {
|
|
1209
|
+
builder
|
|
1210
|
+
.addCase(fetchComments.pending, (state) => {
|
|
1211
|
+
state.loading = 'pending';
|
|
1212
|
+
})
|
|
1213
|
+
.addCase(fetchComments.fulfilled, (state, action) => {
|
|
1214
|
+
state.loading = 'idle';
|
|
1215
|
+
state.comments = [
|
|
1216
|
+
...state.comments.filter((c) => c.idArticle !== action.payload.idArticle),
|
|
1217
|
+
{
|
|
1218
|
+
idArticle: action.payload.idArticle,
|
|
1219
|
+
list: action.payload.list.reverse(),
|
|
1220
|
+
},
|
|
1221
|
+
];
|
|
1222
|
+
})
|
|
1223
|
+
.addCase(fetchComments.rejected, (state) => {
|
|
1224
|
+
state.loading = 'idle';
|
|
1225
|
+
})
|
|
1226
|
+
.addCase(deleteComment.pending, (state, action) => {
|
|
1227
|
+
state.comments = state.comments.map((c) => {
|
|
1228
|
+
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
1229
|
+
return c;
|
|
1230
|
+
}
|
|
1231
|
+
return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: true }) : comment) });
|
|
1232
|
+
});
|
|
1233
|
+
})
|
|
1234
|
+
.addCase(deleteComment.rejected, (state, action) => {
|
|
1235
|
+
state.comments = state.comments.map((c) => {
|
|
1236
|
+
if (c.idArticle !== action.meta.arg.idArticle) {
|
|
1237
|
+
return c;
|
|
1238
|
+
}
|
|
1239
|
+
return Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === action.meta.arg.idComment ? Object.assign(Object.assign({}, comment), { pending: false }) : comment) });
|
|
1240
|
+
});
|
|
1241
|
+
});
|
|
1242
|
+
},
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
const getCommentRTHandlers = function (dispatch, idArticle) {
|
|
1246
|
+
const addCommentHandler = function (message) {
|
|
1247
|
+
if (message.namespace === 'JAMESPOT' &&
|
|
1248
|
+
message.function === 'comment-create' &&
|
|
1249
|
+
message.object.idArticle === idArticle) {
|
|
1250
|
+
dispatch(fetchComments({ idArticle }));
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
const deleteCommentHandler = function (message) {
|
|
1254
|
+
if (message.namespace === 'JAMESPOT' &&
|
|
1255
|
+
message.function === 'comment-delete' &&
|
|
1256
|
+
Number(message.object.idArticle) === idArticle) {
|
|
1257
|
+
dispatch(fetchComments({ idArticle }));
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
return [
|
|
1261
|
+
{
|
|
1262
|
+
namespace: 'JAMESPOT',
|
|
1263
|
+
function: 'comment-create',
|
|
1264
|
+
handler: addCommentHandler,
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
namespace: 'JAMESPOT',
|
|
1268
|
+
function: 'comment-delete',
|
|
1269
|
+
handler: deleteCommentHandler,
|
|
1270
|
+
},
|
|
1271
|
+
];
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
const getCommentsLikeRTHandlers = function (dispatch, idComments, idArticle) {
|
|
1275
|
+
const commentLikeHandler = function (message) {
|
|
1276
|
+
if (message.namespace === 'CUSTOM-ACTION' &&
|
|
1277
|
+
(message.function === 'add' || message.function === 'remove') &&
|
|
1278
|
+
message.object.type === 'sociallike' &&
|
|
1279
|
+
message.object.targetId &&
|
|
1280
|
+
idComments &&
|
|
1281
|
+
idComments.includes(message.object.targetId)) {
|
|
1282
|
+
dispatch(fetchComments({ idArticle }));
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
return idComments
|
|
1286
|
+
? [
|
|
1287
|
+
{ namespace: 'CUSTOM-ACTION', function: 'add', handler: commentLikeHandler },
|
|
1288
|
+
{ namespace: 'CUSTOM-ACTION', function: 'remove', handler: commentLikeHandler },
|
|
1289
|
+
]
|
|
1290
|
+
: [];
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
const CommentReducer = combineReducers$1({
|
|
1294
|
+
[CommentListSlice.name]: CommentListSlice.reducer,
|
|
1295
|
+
});
|
|
1296
|
+
const commentSlice = {
|
|
1297
|
+
name: 'comment',
|
|
1298
|
+
reducer: CommentReducer,
|
|
1299
|
+
};
|
|
1300
|
+
const selectCommentList = (state, idArticle, limit = 0) => {
|
|
1301
|
+
const data = state.comment.commentList.comments.find((c) => c.idArticle === idArticle);
|
|
1302
|
+
const list = data ? [...data.list].sort((c1, c2) => c1.id - c2.id) : [];
|
|
1303
|
+
return limit !== 0 ? list.slice(-limit) : list;
|
|
1304
|
+
};
|
|
1305
|
+
const Comment = {
|
|
1306
|
+
slice: commentSlice,
|
|
1307
|
+
actions: Object.assign({ fetchComments, deleteComment }, CommentListSlice.actions),
|
|
1308
|
+
selectors: {
|
|
1309
|
+
commentList: selectCommentList,
|
|
1310
|
+
},
|
|
1311
|
+
getCommentRTHandlers,
|
|
1312
|
+
getCommentsLikeRTHandlers,
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
const ExtraBotConst = {
|
|
1316
|
+
route: 'extra-bot',
|
|
1317
|
+
moduleName: 'ExtraBotHook',
|
|
1318
|
+
configurationType: 'extraBot',
|
|
1319
|
+
listLimit: 20,
|
|
1320
|
+
listDefaultPage: 1,
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1323
|
+
const initialState$g = {
|
|
1324
|
+
global: {
|
|
1325
|
+
loading: 'idle',
|
|
1326
|
+
},
|
|
1327
|
+
listAll: {
|
|
1328
|
+
loading: 'idle',
|
|
1329
|
+
data: [],
|
|
1330
|
+
limit: ExtraBotConst.listLimit,
|
|
1331
|
+
nbResults: 0,
|
|
1332
|
+
page: ExtraBotConst.listDefaultPage,
|
|
1333
|
+
filters: [],
|
|
1334
|
+
orders: [],
|
|
1335
|
+
},
|
|
1336
|
+
listMines: {
|
|
1337
|
+
loading: 'idle',
|
|
1338
|
+
data: [],
|
|
1339
|
+
limit: ExtraBotConst.listLimit,
|
|
1340
|
+
nbResults: 0,
|
|
1341
|
+
page: ExtraBotConst.listDefaultPage,
|
|
1342
|
+
filters: [],
|
|
1343
|
+
orders: [],
|
|
1344
|
+
},
|
|
1345
|
+
formModal: {
|
|
1346
|
+
open: false,
|
|
1347
|
+
mode: 'create',
|
|
1348
|
+
type: 'all',
|
|
1349
|
+
extraBot: undefined,
|
|
1350
|
+
},
|
|
1351
|
+
};
|
|
1352
|
+
const fetchExtraBotListAll = createAsyncThunk('extraBot/fetchAll', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1353
|
+
const state = getState().extraBot.listAll;
|
|
1354
|
+
try {
|
|
1355
|
+
return (yield extra.jApi.extraBot.list('all', {
|
|
1356
|
+
limit: state.limit,
|
|
1357
|
+
page: state.page,
|
|
1358
|
+
filters: state.filters,
|
|
1359
|
+
orders: state.orders,
|
|
1360
|
+
})).result;
|
|
1361
|
+
}
|
|
1362
|
+
catch (err) {
|
|
1363
|
+
if (!isAbortError(err)) {
|
|
1364
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1365
|
+
}
|
|
1366
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
|
|
1367
|
+
}
|
|
1368
|
+
}));
|
|
1369
|
+
const fetchExtraBotListMines = createAsyncThunk('extraBot/fetchMines', (_, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1370
|
+
const state = getState().extraBot.listMines;
|
|
1371
|
+
try {
|
|
1372
|
+
return (yield extra.jApi.extraBot.list('mines', {
|
|
1373
|
+
limit: state.limit,
|
|
1374
|
+
page: state.page,
|
|
1375
|
+
filters: state.filters,
|
|
1376
|
+
orders: state.orders,
|
|
1377
|
+
})).result;
|
|
1378
|
+
}
|
|
1379
|
+
catch (err) {
|
|
1380
|
+
if (!isAbortError(err)) {
|
|
1381
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1382
|
+
}
|
|
1383
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot list' });
|
|
1384
|
+
}
|
|
1385
|
+
}));
|
|
1386
|
+
const toggleExtraBotActivation = createAsyncThunk('extraBot/toggleActivation', (extraBot, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1387
|
+
try {
|
|
1388
|
+
const enabled = !extraBot.enabled;
|
|
1389
|
+
const res = (yield extra.jApi.article.update(Object.assign(Object.assign({}, extraBot), { enabled }), { format: Format.VIEW })).result;
|
|
1390
|
+
dispatch(Toast.actions.success({
|
|
1391
|
+
label: enabled ? 'APP_ExtraBot_Toast_ActivationSuccess' : 'APP_ExtraBot_Toast_DeactivationSuccess',
|
|
1392
|
+
}));
|
|
1393
|
+
return res;
|
|
1394
|
+
}
|
|
1395
|
+
catch (err) {
|
|
1396
|
+
if (!isAbortError(err)) {
|
|
1397
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1398
|
+
}
|
|
1399
|
+
return rejectWithValue({ error: 1, errorMsg: 'Failed to change extra bot activation' });
|
|
1400
|
+
}
|
|
1401
|
+
}));
|
|
1402
|
+
const saveExtraBot = createAsyncThunk('extraBot/save', ({ extraBot }, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1403
|
+
try {
|
|
1404
|
+
const data = Object.assign(Object.assign({}, extraBot), { type: ExtraBotConst.configurationType, publishTo: '' });
|
|
1405
|
+
let res;
|
|
1406
|
+
let user;
|
|
1407
|
+
delete data.avatar;
|
|
1408
|
+
if (extraBot.uri) {
|
|
1409
|
+
res = (yield extra.jApi.article.update(data, { format: Format.VIEW }))
|
|
1410
|
+
.result;
|
|
1411
|
+
user = (yield extra.jApi.extraBot.updateBot(res.uri)).result;
|
|
1412
|
+
}
|
|
1413
|
+
else {
|
|
1414
|
+
res = (yield extra.jApi.article.create(Object.assign({}, data), Format.VIEW)).result[0];
|
|
1415
|
+
if (!res) {
|
|
1416
|
+
throw new Error('ExtraBot configuration creation failed');
|
|
1417
|
+
}
|
|
1418
|
+
user = (yield extra.jApi.extraBot.createBot(res.uri)).result;
|
|
1419
|
+
res._user = user;
|
|
1420
|
+
}
|
|
1421
|
+
const label = extraBot.uri ? 'APP_ExtraBot_Toast_SaveEdit' : 'APP_ExtraBot_Toast_SaveCreate';
|
|
1422
|
+
dispatch(Toast.actions.success({ label }));
|
|
1423
|
+
return res;
|
|
1424
|
+
}
|
|
1425
|
+
catch (err) {
|
|
1426
|
+
if (!isAbortError(err)) {
|
|
1427
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
1428
|
+
}
|
|
1429
|
+
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve extra bot' });
|
|
1430
|
+
}
|
|
1431
|
+
}));
|
|
1432
|
+
const updateListBotProperty = (state, extraBotUri, property, value) => {
|
|
1433
|
+
const listAllExtraBot = state.listAll.data.find((eb) => eb.uri === extraBotUri);
|
|
1434
|
+
const listMinesExtraBot = state.listMines.data.find((eb) => eb.uri === extraBotUri);
|
|
1435
|
+
if (listAllExtraBot) {
|
|
1436
|
+
listAllExtraBot[property] = value;
|
|
1437
|
+
}
|
|
1438
|
+
if (listMinesExtraBot) {
|
|
1439
|
+
listMinesExtraBot[property] = value;
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
const extraBotSlice = createSlice({
|
|
1443
|
+
name: 'extraBot',
|
|
1444
|
+
initialState: initialState$g,
|
|
1445
|
+
reducers: {
|
|
1446
|
+
setListAllOrder: (state, action) => {
|
|
1447
|
+
state.listAll.orders = [...action.payload];
|
|
1448
|
+
state.listAll.page = ExtraBotConst.listDefaultPage;
|
|
1449
|
+
},
|
|
1450
|
+
setListAllFilter: (state, action) => {
|
|
1451
|
+
state.listAll.filters = [...action.payload];
|
|
1452
|
+
state.listAll.page = ExtraBotConst.listDefaultPage;
|
|
1453
|
+
},
|
|
1454
|
+
setListAllPage: (state, action) => {
|
|
1455
|
+
state.listAll.page = action.payload;
|
|
1456
|
+
},
|
|
1457
|
+
setListMinesOrder: (state, action) => {
|
|
1458
|
+
state.listMines.orders = [...action.payload];
|
|
1459
|
+
state.listMines.page = ExtraBotConst.listDefaultPage;
|
|
1460
|
+
},
|
|
1461
|
+
setListMinesFilter: (state, action) => {
|
|
1462
|
+
state.listMines.filters = [...action.payload];
|
|
1463
|
+
state.listMines.page = ExtraBotConst.listDefaultPage;
|
|
1464
|
+
},
|
|
1465
|
+
setListMinesPage: (state, action) => {
|
|
1466
|
+
state.listMines.page = action.payload;
|
|
1467
|
+
},
|
|
1468
|
+
openFormModal: (state, action) => {
|
|
1469
|
+
state.formModal.open = true;
|
|
1470
|
+
state.formModal.mode = action.payload.mode;
|
|
1471
|
+
state.formModal.type = action.payload.type;
|
|
1472
|
+
state.formModal.extraBot = action.payload.extraBot;
|
|
1473
|
+
},
|
|
1474
|
+
closeFormModal: (state) => {
|
|
1475
|
+
state.formModal.open = false;
|
|
1476
|
+
},
|
|
1477
|
+
},
|
|
1478
|
+
extraReducers: (builder) => {
|
|
1479
|
+
builder
|
|
1480
|
+
.addCase(fetchExtraBotListAll.pending, (state) => {
|
|
1481
|
+
state.listAll.loading = 'pending';
|
|
1482
|
+
})
|
|
1483
|
+
.addCase(fetchExtraBotListAll.fulfilled, (state, action) => {
|
|
1484
|
+
var _a;
|
|
1485
|
+
state.listAll.data = action.payload.data;
|
|
1486
|
+
state.listAll.nbResults = action.payload.cnt;
|
|
1487
|
+
state.listAll.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
|
|
1488
|
+
state.listAll.page = action.payload.page;
|
|
1489
|
+
state.listAll.loading = 'idle';
|
|
1490
|
+
})
|
|
1491
|
+
.addCase(fetchExtraBotListAll.rejected, (state) => {
|
|
1492
|
+
state.listAll.loading = 'idle';
|
|
1493
|
+
})
|
|
1494
|
+
.addCase(fetchExtraBotListMines.pending, (state) => {
|
|
1495
|
+
state.listMines.loading = 'pending';
|
|
1496
|
+
})
|
|
1497
|
+
.addCase(fetchExtraBotListMines.fulfilled, (state, action) => {
|
|
1498
|
+
var _a;
|
|
1499
|
+
state.listMines.data = action.payload.data;
|
|
1500
|
+
state.listMines.nbResults = action.payload.cnt;
|
|
1501
|
+
state.listMines.limit = (_a = action.payload.limit) !== null && _a !== void 0 ? _a : ExtraBotConst.listLimit;
|
|
1502
|
+
state.listMines.page = action.payload.page;
|
|
1503
|
+
state.listMines.loading = 'idle';
|
|
1504
|
+
})
|
|
1505
|
+
.addCase(fetchExtraBotListMines.rejected, (state) => {
|
|
1506
|
+
state.listMines.loading = 'idle';
|
|
1507
|
+
})
|
|
1508
|
+
.addCase(toggleExtraBotActivation.pending, (state) => {
|
|
1509
|
+
state.global.loading = 'pending';
|
|
1510
|
+
})
|
|
1511
|
+
.addCase(toggleExtraBotActivation.fulfilled, (state, action) => {
|
|
1512
|
+
state.global.loading = 'idle';
|
|
1513
|
+
const extraBot = action.payload;
|
|
1514
|
+
updateListBotProperty(state, extraBot.uri, 'enabled', extraBot.enabled);
|
|
1515
|
+
})
|
|
1516
|
+
.addCase(toggleExtraBotActivation.rejected, (state) => {
|
|
1517
|
+
state.global.loading = 'idle';
|
|
1518
|
+
})
|
|
1519
|
+
.addCase(saveExtraBot.pending, (state) => {
|
|
1520
|
+
state.global.loading = 'pending';
|
|
1521
|
+
})
|
|
1522
|
+
.addCase(saveExtraBot.fulfilled, (state, _action) => {
|
|
1523
|
+
state.global.loading = 'idle';
|
|
1524
|
+
state.formModal.open = false;
|
|
1525
|
+
})
|
|
1526
|
+
.addCase(saveExtraBot.rejected, (state) => {
|
|
1527
|
+
state.global.loading = 'idle';
|
|
1528
|
+
});
|
|
1529
|
+
},
|
|
1530
|
+
});
|
|
1531
|
+
const selectExtraBotListAll = (state) => state.extraBot.listAll;
|
|
1532
|
+
const selectExtraBotListMines = (state) => state.extraBot.listMines;
|
|
1533
|
+
const ExtraBot = {
|
|
1534
|
+
slice: extraBotSlice,
|
|
1535
|
+
actions: Object.assign({ fetchExtraBotListAll,
|
|
1536
|
+
fetchExtraBotListMines,
|
|
1537
|
+
toggleExtraBotActivation,
|
|
1538
|
+
saveExtraBot }, extraBotSlice.actions),
|
|
1539
|
+
selectors: { selectExtraBotListAll, selectExtraBotListMines },
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1311
1542
|
const initialState$f = {
|
|
1312
1543
|
loading: 'idle',
|
|
1313
1544
|
access: { createCategory: false },
|
|
@@ -1859,7 +2090,6 @@ const magicPadSlice = createSlice({
|
|
|
1859
2090
|
},
|
|
1860
2091
|
});
|
|
1861
2092
|
const fetchPads = createAsyncThunk('magicPad/fetchPads', (params, { extra, rejectWithValue, dispatch, getState }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1862
|
-
var _a;
|
|
1863
2093
|
try {
|
|
1864
2094
|
const state = getState().magicPad;
|
|
1865
2095
|
const page = state.page;
|
|
@@ -1887,7 +2117,7 @@ const fetchPads = createAsyncThunk('magicPad/fetchPads', (params, { extra, rejec
|
|
|
1887
2117
|
})).result;
|
|
1888
2118
|
}
|
|
1889
2119
|
catch (error) {
|
|
1890
|
-
dispatch(Toast.actions.error({ label: (
|
|
2120
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
1891
2121
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot fetch pads' });
|
|
1892
2122
|
}
|
|
1893
2123
|
}));
|
|
@@ -2011,7 +2241,6 @@ const mediaLibrarySlice = createSlice({
|
|
|
2011
2241
|
},
|
|
2012
2242
|
});
|
|
2013
2243
|
const fetchMediaLibraryFolders = createAsyncThunk('MediaLibrary/fetchMediaLibraryFolders', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2014
|
-
var _a;
|
|
2015
2244
|
const args = {
|
|
2016
2245
|
type: MediaLibraryAppConst.typeMediaLibraryFolder,
|
|
2017
2246
|
format: 'raw-little',
|
|
@@ -2021,12 +2250,11 @@ const fetchMediaLibraryFolders = createAsyncThunk('MediaLibrary/fetchMediaLibrar
|
|
|
2021
2250
|
return yield extra.jApi.article.list(args);
|
|
2022
2251
|
}
|
|
2023
2252
|
catch (error) {
|
|
2024
|
-
dispatch(Toast.actions.error({ label: (
|
|
2253
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2025
2254
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve folders' });
|
|
2026
2255
|
}
|
|
2027
2256
|
}));
|
|
2028
2257
|
const fetchMediaLibraryUnclassifiedFiles = createAsyncThunk('MediaLibrary/fetchMediaLibraryUnclassifiedFiles', (page, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2029
|
-
var _b;
|
|
2030
2258
|
try {
|
|
2031
2259
|
return yield extra.jApi.mediaLibrary.GetUnclassifiedFiles({
|
|
2032
2260
|
format: 'raw-little',
|
|
@@ -2035,47 +2263,43 @@ const fetchMediaLibraryUnclassifiedFiles = createAsyncThunk('MediaLibrary/fetchM
|
|
|
2035
2263
|
});
|
|
2036
2264
|
}
|
|
2037
2265
|
catch (error) {
|
|
2038
|
-
dispatch(Toast.actions.error({ label: (
|
|
2266
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2039
2267
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot retrieve UnclassifiedFiles' });
|
|
2040
2268
|
}
|
|
2041
2269
|
}));
|
|
2042
2270
|
const fetchMediaLibraryConfig = createAsyncThunk('MediaLibrary/fetchMediaLibraryConfig', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2043
|
-
var _c;
|
|
2044
2271
|
try {
|
|
2045
2272
|
return yield extra.jApi.mediaLibrary.getAccess();
|
|
2046
2273
|
}
|
|
2047
2274
|
catch (error) {
|
|
2048
|
-
dispatch(Toast.actions.error({ label: (
|
|
2275
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2049
2276
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot get MediaLibrary Config' });
|
|
2050
2277
|
}
|
|
2051
2278
|
}));
|
|
2052
2279
|
const fetchMediaLibraryFoldersStats = createAsyncThunk('MediaLibrary/fetchMediaLibraryFoldersStats', ({ page, filters, orders }, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2053
|
-
var _d;
|
|
2054
2280
|
try {
|
|
2055
2281
|
return yield extra.jApi.mediaLibrary.getFoldersStatsList(filters, orders, page);
|
|
2056
2282
|
}
|
|
2057
2283
|
catch (error) {
|
|
2058
|
-
dispatch(Toast.actions.error({ label: (
|
|
2284
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2059
2285
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot get MediaLibrary folders stats' });
|
|
2060
2286
|
}
|
|
2061
2287
|
}));
|
|
2062
2288
|
const fetchMediaLibraryFilesStats = createAsyncThunk('MediaLibrary/fetchMediaLibraryFilesStats', ({ page, filters, orders }, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2063
|
-
var _e;
|
|
2064
2289
|
try {
|
|
2065
2290
|
return yield extra.jApi.mediaLibrary.getFilesStatsList(filters, orders, page);
|
|
2066
2291
|
}
|
|
2067
2292
|
catch (error) {
|
|
2068
|
-
dispatch(Toast.actions.error({ label: (
|
|
2293
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2069
2294
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot get MediaLibrary files stats' });
|
|
2070
2295
|
}
|
|
2071
2296
|
}));
|
|
2072
2297
|
const fetchMediaLibraryStats = createAsyncThunk('MediaLibrary/fetchMediaLibraryStats', (_, { extra, rejectWithValue, dispatch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2073
|
-
var _f;
|
|
2074
2298
|
try {
|
|
2075
2299
|
return yield extra.jApi.mediaLibrary.getStats();
|
|
2076
2300
|
}
|
|
2077
2301
|
catch (error) {
|
|
2078
|
-
dispatch(Toast.actions.error({ label: (
|
|
2302
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(error) }));
|
|
2079
2303
|
return rejectWithValue({ error: 1, errorMsg: 'Cannot get MediaLibrary stats' });
|
|
2080
2304
|
}
|
|
2081
2305
|
}));
|
|
@@ -5210,8 +5434,8 @@ const saveCurrentStudioApp = createAsyncThunk('studio/saveCurrentStudioApp', (_,
|
|
|
5210
5434
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Edition_Saved' }));
|
|
5211
5435
|
return;
|
|
5212
5436
|
}
|
|
5213
|
-
catch (
|
|
5214
|
-
dispatch(Toast.actions.error({ label:
|
|
5437
|
+
catch (err) {
|
|
5438
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5215
5439
|
return rejectWithValue(error);
|
|
5216
5440
|
}
|
|
5217
5441
|
}));
|
|
@@ -5230,8 +5454,8 @@ const installStudioApp = createAsyncThunk('studio/installApp', ({ callback }, {
|
|
|
5230
5454
|
callback();
|
|
5231
5455
|
return;
|
|
5232
5456
|
}
|
|
5233
|
-
catch (
|
|
5234
|
-
dispatch(Toast.actions.error({ label:
|
|
5457
|
+
catch (err) {
|
|
5458
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5235
5459
|
return rejectWithValue(error);
|
|
5236
5460
|
}
|
|
5237
5461
|
}));
|
|
@@ -5425,9 +5649,9 @@ const fetchStudioAppsList = createAsyncThunk('studio/appsList', (intl, { extra,
|
|
|
5425
5649
|
}));
|
|
5426
5650
|
return transformedApps;
|
|
5427
5651
|
}
|
|
5428
|
-
catch (
|
|
5429
|
-
console.error(
|
|
5430
|
-
dispatch(Toast.actions.error({ label:
|
|
5652
|
+
catch (err) {
|
|
5653
|
+
console.error(err);
|
|
5654
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5431
5655
|
throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
|
|
5432
5656
|
}
|
|
5433
5657
|
}));
|
|
@@ -5464,8 +5688,8 @@ const createNewStudioApp = createAsyncThunk('studio/createApp', ({ appName, call
|
|
|
5464
5688
|
callback();
|
|
5465
5689
|
return newStudioApp;
|
|
5466
5690
|
}
|
|
5467
|
-
catch (
|
|
5468
|
-
dispatch(Toast.actions.error({ label:
|
|
5691
|
+
catch (err) {
|
|
5692
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5469
5693
|
throw rejectWithValue({ error: 1, errorMsg: 'Error creating application' });
|
|
5470
5694
|
}
|
|
5471
5695
|
}));
|
|
@@ -5476,8 +5700,8 @@ const deleteStudioApp = createAsyncThunk('studio/deleteApp', ({ idApp, status },
|
|
|
5476
5700
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_StudioApp_Deleted' }));
|
|
5477
5701
|
return deleteRes;
|
|
5478
5702
|
}
|
|
5479
|
-
catch (
|
|
5480
|
-
dispatch(Toast.actions.error({ label:
|
|
5703
|
+
catch (err) {
|
|
5704
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5481
5705
|
return rejectWithValue({ error: 1, errorMsg: 'Error deleting application' });
|
|
5482
5706
|
}
|
|
5483
5707
|
}));
|
|
@@ -5487,8 +5711,8 @@ const suspendStudioApp = createAsyncThunk('studio/suspendStudioApp', ({ idApp },
|
|
|
5487
5711
|
yield jApi.application.studioSuspend(idApp);
|
|
5488
5712
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Suspended' }));
|
|
5489
5713
|
}
|
|
5490
|
-
catch (
|
|
5491
|
-
dispatch(Toast.actions.error({ label:
|
|
5714
|
+
catch (err) {
|
|
5715
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5492
5716
|
throw rejectWithValue({ error: 1, errorMsg: 'Error suspending application' });
|
|
5493
5717
|
}
|
|
5494
5718
|
}));
|
|
@@ -5498,8 +5722,8 @@ const restartStudioApp = createAsyncThunk('studio/restartStudioApp', ({ idApp },
|
|
|
5498
5722
|
yield jApi.application.studioRestart(idApp);
|
|
5499
5723
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Restarted' }));
|
|
5500
5724
|
}
|
|
5501
|
-
catch (
|
|
5502
|
-
dispatch(Toast.actions.error({ label:
|
|
5725
|
+
catch (err) {
|
|
5726
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5503
5727
|
throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
|
|
5504
5728
|
}
|
|
5505
5729
|
}));
|
|
@@ -5525,8 +5749,8 @@ const cloneStudioApp = createAsyncThunk('studio/cloneStudioApp', ({ idApp, inWor
|
|
|
5525
5749
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_Cloned' }));
|
|
5526
5750
|
return clonedStudioApp;
|
|
5527
5751
|
}
|
|
5528
|
-
catch (
|
|
5529
|
-
dispatch(Toast.actions.error({ label:
|
|
5752
|
+
catch (err) {
|
|
5753
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5530
5754
|
return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
|
|
5531
5755
|
}
|
|
5532
5756
|
}));
|
|
@@ -5546,8 +5770,8 @@ const createInWorkStudioApp = createAsyncThunk('studio/createInWorkStudioApp', (
|
|
|
5546
5770
|
dispatch(Toast.actions.success({ label: 'APPSTUDIO_AppItem_CreateInWork' }));
|
|
5547
5771
|
return clonedStudioApp;
|
|
5548
5772
|
}
|
|
5549
|
-
catch (
|
|
5550
|
-
dispatch(Toast.actions.error({ label:
|
|
5773
|
+
catch (err) {
|
|
5774
|
+
dispatch(Toast.actions.error({ label: getErrorMessage(err) }));
|
|
5551
5775
|
return rejectWithValue({ error: 1, errorMsg: 'Error creating in work version for application' });
|
|
5552
5776
|
}
|
|
5553
5777
|
}));
|
|
@@ -5751,5 +5975,5 @@ const studio = {
|
|
|
5751
5975
|
},
|
|
5752
5976
|
};
|
|
5753
5977
|
|
|
5754
|
-
export { APP_STATUS_TYPE, AUDIENCE, AdminLogs, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, ContentReport, Description, Element, ExtraAppFieldsItemViews, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, adminLogsReducer, adminLogsSlice, animationsReducer, animationsSlice, contentReportSlice, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, fetchReports, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, slice$1 as slice, studio, updateStatus, updateWidgetContent, viewsList };
|
|
5978
|
+
export { APP_STATUS_TYPE, AUDIENCE, AdminLogs, Animations, AppColumnsDefaultTypes, AppFieldFormPropertyTypes, AppFormBannedFromViews$1 as AppFormBannedFromViews, AppFormFieldOnlyInView, AppFormFixedList$1 as AppFormFixedList, AppFormItemTypes, AppFormNoAsFieldList, AppFormNonPrimaryList, AppFormPrimaryList, AppFormPrimaryListValues, AppFormUniqueList, AppFormUniqueListCheck, Application, AssetReservation, Bookmark, Comment, ContentReport, Description, Element, ExtraAppFieldsItemViews, ExtraBot, Faq, Hook, MagicPad, MapExtraFieldsWithView, MediaLibrary, Model, Network, Platform, STUDIO_VIEW, Share, SocialActions, StatusType$1 as StatusType, TVDisplay, TinyMCE, Toast, UserCurrent, WedocApp, Widget, WidgetEditor, actions, adminLogsReducer, adminLogsSlice, animationsReducer, animationsSlice, contentReportSlice, extraBotSlice, fetchExtraBotListAll, fetchExtraBotListMines, fetchMediaLibraryConfig, fetchMediaLibraryFilesStats, fetchMediaLibraryFolders, fetchMediaLibraryFoldersStats, fetchMediaLibraryStats, fetchMediaLibraryUnclassifiedFiles, fetchPads, fetchReports, jland, magicPadSlice, mediaLibraryReducer, mediaLibrarySlice, saveExtraBot, selectExtraBotListAll, selectExtraBotListMines, slice$1 as slice, studio, toggleExtraBotActivation, updateListBotProperty, updateStatus, updateWidgetContent, viewsList };
|
|
5755
5979
|
//# sourceMappingURL=esm.js.map
|