jamespot-front-business 1.1.31 → 1.1.33

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/esm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createEntityAdapter, createSlice, createAsyncThunk, combineReducers } from '@reduxjs/toolkit';
2
2
  import { combineReducers as combineReducers$1 } from 'redux';
3
3
  import jamespot, { jEnsure, formatImgUrl, UserLevel, StudioApplicationStatus } from 'jamespot-user-api';
4
+ import { v4 } from 'uuid';
4
5
 
5
6
  const adapter$1 = createEntityAdapter({
6
7
  selectId: (app) => app.name,
@@ -59,7 +60,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
59
60
  });
60
61
  }
61
62
 
62
- const initialState$g = {
63
+ const initialState$h = {
63
64
  entities: [],
64
65
  loading: 'idle',
65
66
  nbResults: 0,
@@ -70,7 +71,7 @@ const fetchBookableAsset = createAsyncThunk('BookableAsset/fetchBookableAsset',
70
71
  }));
71
72
  const BookableAssetSlice = createSlice({
72
73
  name: 'bookableAsset',
73
- initialState: initialState$g,
74
+ initialState: initialState$h,
74
75
  reducers: {},
75
76
  extraReducers: (builder) => {
76
77
  builder
@@ -91,7 +92,7 @@ const BookableAssetSlice = createSlice({
91
92
  const fetchConfiguration = createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
92
93
  return yield extra.jApi.assetReservation.configuration();
93
94
  }));
94
- const initialState$f = {
95
+ const initialState$g = {
95
96
  description: '',
96
97
  right: {
97
98
  manage: false,
@@ -105,7 +106,7 @@ const initialState$f = {
105
106
  };
106
107
  const AssetReservationConfigurationSlice = createSlice({
107
108
  name: 'configuration',
108
- initialState: initialState$f,
109
+ initialState: initialState$g,
109
110
  reducers: {},
110
111
  extraReducers: (builder) => {
111
112
  builder
@@ -126,7 +127,7 @@ const initForm = {
126
127
  hourStart: '',
127
128
  hourEnd: '',
128
129
  };
129
- const initialState$e = {
130
+ const initialState$f = {
130
131
  entities: [],
131
132
  loading: 'idle',
132
133
  nbResults: 0,
@@ -138,7 +139,7 @@ const fetchReservation = createAsyncThunk('Reservation/fetchReservation', (viewM
138
139
  }));
139
140
  const ReservationSlice = createSlice({
140
141
  name: 'reservation',
141
- initialState: initialState$e,
142
+ initialState: initialState$f,
142
143
  reducers: {
143
144
  setForm: (state, action) => {
144
145
  state.form = action.payload;
@@ -231,7 +232,7 @@ const Toast = {
231
232
  selectors: selectors$1,
232
233
  };
233
234
 
234
- const initialState$d = {
235
+ const initialState$e = {
235
236
  bookmarks: [],
236
237
  loading: 'idle',
237
238
  status: undefined,
@@ -294,7 +295,7 @@ const deleteBookmark = createAsyncThunk('bookmarkList/deleteBookmark', (bookmark
294
295
  }));
295
296
  const BookmarkListSlice = createSlice({
296
297
  name: 'bookmarkList',
297
- initialState: initialState$d,
298
+ initialState: initialState$e,
298
299
  reducers: {
299
300
  resetAddBookmarkStatus: (state, action) => {
300
301
  if (state.add[action.payload]) {
@@ -457,7 +458,7 @@ const getRTHandlers = function (dispatch) {
457
458
  ];
458
459
  };
459
460
 
460
- const initialState$c = {
461
+ const initialState$d = {
461
462
  bookmark: undefined,
462
463
  status: undefined,
463
464
  loading: 'idle',
@@ -479,7 +480,7 @@ const editBookmark = createAsyncThunk('bookmarkEdit/editBookmark', (bookmark, {
479
480
  }));
480
481
  const BookmarkEditSlice = createSlice({
481
482
  name: 'bookmarkEdit',
482
- initialState: initialState$c,
483
+ initialState: initialState$d,
483
484
  reducers: {
484
485
  setEditBookmark: (state, action) => {
485
486
  state.bookmark = Object.assign({}, action.payload);
@@ -532,7 +533,7 @@ const Bookmark = {
532
533
  getRTHandlers: getRTHandlers,
533
534
  };
534
535
 
535
- const initialState$b = {
536
+ const initialState$c = {
536
537
  loading: 'idle',
537
538
  access: { createCategory: false },
538
539
  };
@@ -560,7 +561,7 @@ const fetchFaqConfig = createAsyncThunk('faqConfig/fetch', () => __awaiter(void
560
561
  }));
561
562
  const FaqConfigSlice = createSlice({
562
563
  name: 'config',
563
- initialState: initialState$b,
564
+ initialState: initialState$c,
564
565
  reducers: {},
565
566
  extraReducers: (builder) => {
566
567
  builder
@@ -592,7 +593,7 @@ const FaqConfigSlice = createSlice({
592
593
  },
593
594
  });
594
595
 
595
- const initialState$a = {
596
+ const initialState$b = {
596
597
  loading: 'idle',
597
598
  categories: null,
598
599
  };
@@ -604,7 +605,7 @@ const fetchFaqCategories = createAsyncThunk('faqCategories/fetch', () => __await
604
605
  }));
605
606
  const FaqCategoriesSlice = createSlice({
606
607
  name: 'categories',
607
- initialState: initialState$a,
608
+ initialState: initialState$b,
608
609
  reducers: {},
609
610
  extraReducers: (builder) => {
610
611
  builder
@@ -886,7 +887,7 @@ const initialMap = {
886
887
  illustration: '',
887
888
  assignLicense: false,
888
889
  };
889
- const initialState$9 = {
890
+ const initialState$a = {
890
891
  map: Object.assign({}, initialMap),
891
892
  loading: 'idle',
892
893
  status: undefined,
@@ -930,13 +931,13 @@ const createMap = createAsyncThunk('mapCreate/create', ({ map, jlandUrlBase }, {
930
931
  }));
931
932
  const MapCreateSlice = createSlice({
932
933
  name: 'mapCreate',
933
- initialState: initialState$9,
934
+ initialState: initialState$a,
934
935
  reducers: {
935
936
  setMap: (state, action) => {
936
937
  state.map = action.payload;
937
938
  },
938
939
  resetCreateMapState: () => {
939
- return initialState$9;
940
+ return initialState$a;
940
941
  },
941
942
  },
942
943
  extraReducers: (builder) => {
@@ -1023,10 +1024,10 @@ const Model = {
1023
1024
  selectors: Object.assign(Object.assign({}, selectors), { selectByIds }),
1024
1025
  };
1025
1026
 
1026
- const initialState$8 = {};
1027
+ const initialState$9 = {};
1027
1028
  const NetworkStaticsSlice = createSlice({
1028
1029
  name: 'statics',
1029
- initialState: initialState$8,
1030
+ initialState: initialState$9,
1030
1031
  reducers: {
1031
1032
  initNetworkStatics: (_, { payload }) => {
1032
1033
  return payload;
@@ -1082,7 +1083,7 @@ const fetchRecentFiles = createAsyncThunk('/fetchRecentFiles', (_, { extra, getS
1082
1083
  return yield jApi.wedoc.getFiles(Object.assign(Object.assign({}, initialQuery), { filters, limit: 4 }));
1083
1084
  }));
1084
1085
 
1085
- const initialState$7 = {
1086
+ const initialState$8 = {
1086
1087
  entities: [],
1087
1088
  nbEntities: 0,
1088
1089
  entitiesRecent: [],
@@ -1094,7 +1095,7 @@ const initialState$7 = {
1094
1095
  };
1095
1096
  const WedocAppSlice = createSlice({
1096
1097
  name: 'wedoc',
1097
- initialState: initialState$7,
1098
+ initialState: initialState$8,
1098
1099
  reducers: {
1099
1100
  update: (state, action) => {
1100
1101
  state.entities = [
@@ -1167,14 +1168,14 @@ const fetchRequest = createAsyncThunk('/fetchRequest', ({ uri, idUser }, { extra
1167
1168
  return yield jApi.wedoc.getAccessRequest(uri, idUser);
1168
1169
  }));
1169
1170
 
1170
- const initialState$6 = {
1171
+ const initialState$7 = {
1171
1172
  entities: [],
1172
1173
  nbEntities: 0,
1173
1174
  loading: 'idle',
1174
1175
  };
1175
1176
  const ShareSlice = createSlice({
1176
1177
  name: 'share',
1177
- initialState: initialState$6,
1178
+ initialState: initialState$7,
1178
1179
  reducers: {
1179
1180
  remove: (state, action) => {
1180
1181
  state.entities = [
@@ -1212,7 +1213,7 @@ const Share = {
1212
1213
  },
1213
1214
  };
1214
1215
 
1215
- const initialState$5 = {
1216
+ const initialState$6 = {
1216
1217
  channels: undefined,
1217
1218
  loading: 'idle',
1218
1219
  loadingChannelDeletion: 'idle',
@@ -1255,7 +1256,7 @@ const deleteChannel = createAsyncThunk('/deleteChannel', ({ channel }, { extra,
1255
1256
  }));
1256
1257
  const ChannelsListSlice = createSlice({
1257
1258
  name: 'channelsList',
1258
- initialState: Object.assign({}, initialState$5),
1259
+ initialState: Object.assign({}, initialState$6),
1259
1260
  reducers: {},
1260
1261
  extraReducers: (builder) => {
1261
1262
  builder
@@ -1324,10 +1325,10 @@ const TVDisplay = {
1324
1325
  },
1325
1326
  };
1326
1327
 
1327
- const initialState$4 = {};
1328
+ const initialState$5 = {};
1328
1329
  const TinyMCEOptionsSlice = createSlice({
1329
1330
  name: 'options',
1330
- initialState: initialState$4,
1331
+ initialState: initialState$5,
1331
1332
  reducers: {
1332
1333
  initOptions: (_, { payload }) => {
1333
1334
  return { common: payload };
@@ -1353,7 +1354,7 @@ const TinyMCE = {
1353
1354
  },
1354
1355
  };
1355
1356
 
1356
- const initialState$3 = {
1357
+ const initialState$4 = {
1357
1358
  id: 0,
1358
1359
  mainType: 'user',
1359
1360
  type: 'user',
@@ -1367,7 +1368,7 @@ const initialState$3 = {
1367
1368
  };
1368
1369
  const slice = createSlice({
1369
1370
  name: 'userCurrent',
1370
- initialState: initialState$3,
1371
+ initialState: initialState$4,
1371
1372
  reducers: {
1372
1373
  init: (_, { payload }) => {
1373
1374
  return payload;
@@ -1585,7 +1586,7 @@ function widgetDefinition(name) {
1585
1586
 
1586
1587
  const MODE_EDIT = 'edit';
1587
1588
  const MODE_VIEW = 'view';
1588
- const initialState$2 = {
1589
+ const initialState$3 = {
1589
1590
  token: undefined,
1590
1591
  ids: {},
1591
1592
  layers: {},
@@ -1597,7 +1598,7 @@ const initialState$2 = {
1597
1598
  };
1598
1599
  const widgetsSlice = createSlice({
1599
1600
  name: 'widgets',
1600
- initialState: initialState$2,
1601
+ initialState: initialState$3,
1601
1602
  reducers: {
1602
1603
  registerWidget: (state, action) => {
1603
1604
  const { uniqid, widget } = action.payload;
@@ -1739,12 +1740,12 @@ const Widget = {
1739
1740
  },
1740
1741
  };
1741
1742
 
1742
- const initialState$1 = {
1743
+ const initialState$2 = {
1743
1744
  editors: [],
1744
1745
  };
1745
1746
  const editorsSlice = createSlice({
1746
1747
  name: 'editors',
1747
- initialState: initialState$1,
1748
+ initialState: initialState$2,
1748
1749
  reducers: {
1749
1750
  registerEditor: (state, action) => {
1750
1751
  const { uniqid, name } = action.payload;
@@ -1970,43 +1971,174 @@ function serverAppsToStudioApps(serverApps) {
1970
1971
  return studioApps;
1971
1972
  }
1972
1973
 
1974
+ const initialState$1 = {
1975
+ currentStudioApp: null,
1976
+ fetchCurrentStudioAppStatus: 'idle',
1977
+ };
1978
+ const fetchCurrentStudioApp = createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
1979
+ const jApi = extra.jApi;
1980
+ const error = { error: 1, errorMsg: 'Error fetching application' };
1981
+ try {
1982
+ const studioApplicationBase = (yield jApi.application.get(idApp, status)).result;
1983
+ const studioApplication = serverAppsToStudioApps([studioApplicationBase])[0];
1984
+ if (!studioApplication) {
1985
+ return rejectWithValue(error);
1986
+ }
1987
+ return studioApplication;
1988
+ }
1989
+ catch (_) {
1990
+ return rejectWithValue(error);
1991
+ }
1992
+ }));
1993
+ const CurrentStudioAppSlice = createSlice({
1994
+ name: 'currentStudioApp',
1995
+ initialState: initialState$1,
1996
+ reducers: {
1997
+ setCurrentApp: (state, action) => {
1998
+ state.currentStudioApp = action.payload;
1999
+ },
2000
+ },
2001
+ extraReducers: (builder) => {
2002
+ builder
2003
+ .addCase(fetchCurrentStudioApp.pending, (state) => {
2004
+ if (state.fetchCurrentStudioAppStatus === 'idle')
2005
+ state.fetchCurrentStudioAppStatus = 'pending';
2006
+ })
2007
+ .addCase(fetchCurrentStudioApp.fulfilled, (state, action) => {
2008
+ if (state.fetchCurrentStudioAppStatus === 'pending')
2009
+ state.fetchCurrentStudioAppStatus = 'idle';
2010
+ state.currentStudioApp = action.payload;
2011
+ })
2012
+ .addCase(fetchCurrentStudioApp.rejected, (state) => {
2013
+ if (state.fetchCurrentStudioAppStatus === 'pending')
2014
+ state.fetchCurrentStudioAppStatus = 'idle';
2015
+ });
2016
+ },
2017
+ });
2018
+
2019
+ function cloneStudioAppFromExistingApp(existingApp, author) {
2020
+ const newApp = existingApp.inWorkVersion
2021
+ ? JSON.parse(JSON.stringify(existingApp.inWorkVersion))
2022
+ : JSON.parse(JSON.stringify(existingApp));
2023
+ const newAppId = v4();
2024
+ const newAppName = `${existingApp.manifest.appName} Copie`;
2025
+ newApp.idApp = newAppId;
2026
+ newApp.status = APP_STATUS_TYPE.DRAFT;
2027
+ newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
2028
+ return [newApp, newAppId];
2029
+ }
2030
+
2031
+ function createNewStudioApp$1({ author }) {
2032
+ const newAppId = v4();
2033
+ return {
2034
+ newAppId,
2035
+ newStudioApp: {
2036
+ idApp: newAppId,
2037
+ status: APP_STATUS_TYPE.DRAFT,
2038
+ author: author || '',
2039
+ manifest: {
2040
+ appShortName: newAppId,
2041
+ appName: newAppId,
2042
+ author: author || '',
2043
+ description: '',
2044
+ typeLabel: '',
2045
+ cssColor: '#392994',
2046
+ cssClass: {
2047
+ label: 'star',
2048
+ value: 'star',
2049
+ },
2050
+ version: 0.1,
2051
+ dateCreation: new Date().toISOString(),
2052
+ viewSolr: 'solr',
2053
+ checkAccess: false,
2054
+ accessRightList: '',
2055
+ attrExposed: [],
2056
+ articlesCount: 0,
2057
+ },
2058
+ },
2059
+ };
2060
+ }
2061
+
1973
2062
  const initialState = {
1974
2063
  studioAppsList: [],
1975
2064
  loadingStudioAppsList: 'idle',
1976
2065
  deleteStudioAppStatus: 'idle',
2066
+ suspendStudioAppStatus: 'idle',
2067
+ restartStudioAppStatus: 'idle',
2068
+ cloneStudioAppStatus: 'idle',
2069
+ createNewStudioAppStatus: 'idle',
1977
2070
  };
1978
- const fetchStudioAppsList = createAsyncThunk('studio/appsList', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
2071
+ const fetchStudioAppsList = createAsyncThunk('studio/appsList', (_, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
1979
2072
  const jApi = extra.jApi;
1980
- return yield new Promise((resolve, rejectWithValue) => {
1981
- jApi.application
1982
- .list()
1983
- .then((res) => __awaiter(void 0, void 0, void 0, function* () {
1984
- const coreApps = yield Promise.all(res.result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
1985
- const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
1986
- const articlesCount = (yield jApi.article.count(app.idApp)).result;
1987
- return Object.assign(Object.assign({}, coreApp), { articlesCount });
1988
- })));
1989
- resolve(coreApps);
1990
- }))
1991
- .catch((e) => {
1992
- var _a, _b;
1993
- rejectWithValue({ error: (_a = e.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = e.errorMsg) !== null && _b !== void 0 ? _b : 'Error retrieving applications' });
1994
- });
1995
- });
2073
+ try {
2074
+ const { result } = yield jApi.application.list();
2075
+ return yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
2076
+ const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
2077
+ const articlesCount = (yield jApi.article.count(app.idApp)).result;
2078
+ return Object.assign(Object.assign({}, coreApp), { articlesCount });
2079
+ })));
2080
+ }
2081
+ catch (_) {
2082
+ throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
2083
+ }
1996
2084
  }));
1997
- const deleteStudioApp = createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
2085
+ const createNewStudioApp = createAsyncThunk('studio/createApp', (_, { extra, dispatch, rejectWithValue, getState }) => __awaiter(void 0, void 0, void 0, function* () {
2086
+ var _a;
1998
2087
  const jApi = extra.jApi;
1999
- return yield new Promise((resolve, rejectWithValue) => {
2000
- jApi.application
2001
- .delete(idApp, status)
2002
- .then((res) => {
2003
- resolve(res);
2004
- })
2005
- .catch((e) => {
2006
- var _a, _b;
2007
- rejectWithValue({ error: (_a = e.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = e.errorMsg) !== null && _b !== void 0 ? _b : 'Error deleting application' });
2008
- });
2009
- });
2088
+ const author = (_a = getState().userCurrent) === null || _a === void 0 ? void 0 : _a.uri;
2089
+ const { newAppId, newStudioApp } = createNewStudioApp$1(Object.assign({}, (author && { author })));
2090
+ try {
2091
+ yield jApi.application.save(newAppId, JSON.stringify(newStudioApp), 'saved');
2092
+ dispatch(CurrentStudioAppSlice.actions.setCurrentApp(newStudioApp));
2093
+ return newStudioApp;
2094
+ }
2095
+ catch (_) {
2096
+ throw rejectWithValue({ error: 1, errorMsg: 'Error creating application' });
2097
+ }
2098
+ }));
2099
+ const deleteStudioApp = createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2100
+ const jApi = extra.jApi;
2101
+ try {
2102
+ return yield jApi.application.delete(idApp, status);
2103
+ }
2104
+ catch (_) {
2105
+ return rejectWithValue({ error: 1, errorMsg: 'Error deleting application' });
2106
+ }
2107
+ }));
2108
+ const suspendStudioApp = createAsyncThunk('studio/suspendStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2109
+ const jApi = extra.jApi;
2110
+ try {
2111
+ yield jApi.application.suspend(idApp);
2112
+ }
2113
+ catch (_) {
2114
+ throw rejectWithValue({ error: 1, errorMsg: 'Error suspending application' });
2115
+ }
2116
+ }));
2117
+ const restartStudioApp = createAsyncThunk('studio/restartStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2118
+ const jApi = extra.jApi;
2119
+ try {
2120
+ yield jApi.application.restart(idApp);
2121
+ }
2122
+ catch (_) {
2123
+ throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
2124
+ }
2125
+ }));
2126
+ const cloneStudioApp = createAsyncThunk('studio/cloneStudioApp', ({ idApp }, { extra, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2127
+ var _b;
2128
+ const jApi = extra.jApi;
2129
+ const existingStudioApp = getState().studio.studioAppsList.studioAppsList.find((app) => app.idApp === idApp);
2130
+ if (!existingStudioApp)
2131
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
2132
+ const currentUser = (_b = getState().userCurrent) === null || _b === void 0 ? void 0 : _b.uri;
2133
+ const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
2134
+ const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
2135
+ try {
2136
+ yield jApi.application.save(newAppId, clonedStudioAppReady, 'saved');
2137
+ return clonedStudioApp;
2138
+ }
2139
+ catch (_) {
2140
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
2141
+ }
2010
2142
  }));
2011
2143
  const StudioAppsListSlice = createSlice({
2012
2144
  name: 'studioAppsList',
@@ -2040,31 +2172,121 @@ const StudioAppsListSlice = createSlice({
2040
2172
  if (state.deleteStudioAppStatus === 'pending') {
2041
2173
  state.deleteStudioAppStatus = 'idle';
2042
2174
  }
2043
- state.studioAppsList = state.studioAppsList.filter((app) => app.idApp !== action.meta.arg.idApp && app.status !== action.meta.arg.status);
2175
+ state.studioAppsList = state.studioAppsList.reduce((acc, app) => {
2176
+ const { idApp, status } = action.meta.arg;
2177
+ if (app.idApp === idApp && app.status === status)
2178
+ return acc;
2179
+ if (app.inWorkVersion &&
2180
+ app.inWorkVersion.idApp === idApp &&
2181
+ app.inWorkVersion.status === status) {
2182
+ delete app.inWorkVersion;
2183
+ }
2184
+ return [...acc, app];
2185
+ }, []);
2044
2186
  })
2045
2187
  .addCase(deleteStudioApp.rejected, (state) => {
2046
2188
  if (state.deleteStudioAppStatus === 'pending')
2047
2189
  state.deleteStudioAppStatus = 'idle';
2190
+ })
2191
+ .addCase(suspendStudioApp.pending, (state) => {
2192
+ if (state.suspendStudioAppStatus === 'idle')
2193
+ state.suspendStudioAppStatus = 'pending';
2194
+ })
2195
+ .addCase(suspendStudioApp.fulfilled, (state, action) => {
2196
+ if (state.suspendStudioAppStatus === 'pending') {
2197
+ state.suspendStudioAppStatus = 'idle';
2198
+ }
2199
+ state.studioAppsList = state.studioAppsList.map((app) => {
2200
+ const { idApp } = action.meta.arg;
2201
+ if (app.idApp === idApp) {
2202
+ app.status = APP_STATUS_TYPE.SUSPENDED;
2203
+ return app;
2204
+ }
2205
+ return app;
2206
+ });
2207
+ })
2208
+ .addCase(suspendStudioApp.rejected, (state) => {
2209
+ if (state.suspendStudioAppStatus === 'pending')
2210
+ state.suspendStudioAppStatus = 'idle';
2211
+ })
2212
+ .addCase(restartStudioApp.pending, (state) => {
2213
+ if (state.restartStudioAppStatus === 'idle')
2214
+ state.restartStudioAppStatus = 'pending';
2215
+ })
2216
+ .addCase(restartStudioApp.fulfilled, (state, action) => {
2217
+ if (state.restartStudioAppStatus === 'pending') {
2218
+ state.restartStudioAppStatus = 'idle';
2219
+ }
2220
+ state.studioAppsList = state.studioAppsList.map((app) => {
2221
+ const { idApp } = action.meta.arg;
2222
+ if (app.idApp === idApp) {
2223
+ app.status = APP_STATUS_TYPE.INSTALLED;
2224
+ return app;
2225
+ }
2226
+ return app;
2227
+ });
2228
+ })
2229
+ .addCase(restartStudioApp.rejected, (state) => {
2230
+ if (state.restartStudioAppStatus === 'pending')
2231
+ state.restartStudioAppStatus = 'idle';
2232
+ })
2233
+ .addCase(cloneStudioApp.pending, (state) => {
2234
+ if (state.cloneStudioAppStatus === 'idle')
2235
+ state.cloneStudioAppStatus = 'pending';
2236
+ })
2237
+ .addCase(cloneStudioApp.fulfilled, (state, action) => {
2238
+ if (state.cloneStudioAppStatus === 'pending') {
2239
+ state.cloneStudioAppStatus = 'idle';
2240
+ }
2241
+ state.studioAppsList = [...state.studioAppsList, action.payload];
2242
+ })
2243
+ .addCase(cloneStudioApp.rejected, (state) => {
2244
+ if (state.cloneStudioAppStatus === 'pending')
2245
+ state.cloneStudioAppStatus = 'idle';
2246
+ })
2247
+ .addCase(createNewStudioApp.pending, (state) => {
2248
+ if (state.createNewStudioAppStatus === 'idle')
2249
+ state.createNewStudioAppStatus = 'pending';
2250
+ })
2251
+ .addCase(createNewStudioApp.fulfilled, (state, action) => {
2252
+ if (state.createNewStudioAppStatus === 'pending') {
2253
+ state.createNewStudioAppStatus = 'idle';
2254
+ }
2255
+ state.studioAppsList = [...state.studioAppsList, action.payload];
2256
+ })
2257
+ .addCase(createNewStudioApp.rejected, (state) => {
2258
+ if (state.createNewStudioAppStatus === 'pending')
2259
+ state.createNewStudioAppStatus = 'idle';
2048
2260
  });
2049
2261
  },
2050
2262
  });
2051
2263
 
2052
2264
  const joinedReducers = combineReducers$1({
2053
2265
  [StudioAppsListSlice.name]: StudioAppsListSlice.reducer,
2266
+ [CurrentStudioAppSlice.name]: CurrentStudioAppSlice.reducer,
2054
2267
  });
2055
- const selectStudioAppsList = function selectStudioAppsList(state) {
2268
+ function selectStudioAppsList(state) {
2056
2269
  return state.studio.studioAppsList;
2057
- };
2270
+ }
2271
+ function selectCurrentStudioApp(state) {
2272
+ return state.studio.currentStudioApp;
2273
+ }
2058
2274
  const studioSlice = {
2059
2275
  name: 'studio',
2060
2276
  reducer: joinedReducers,
2061
2277
  };
2062
2278
  const studio = {
2063
2279
  slice: studioSlice,
2064
- actions: Object.assign(Object.assign({}, StudioAppsListSlice.actions), { fetchStudioAppsList,
2065
- deleteStudioApp }),
2280
+ actions: Object.assign(Object.assign(Object.assign({}, StudioAppsListSlice.actions), CurrentStudioAppSlice.actions), { fetchStudioAppsList,
2281
+ deleteStudioApp,
2282
+ suspendStudioApp,
2283
+ restartStudioApp,
2284
+ cloneStudioApp,
2285
+ createNewStudioApp,
2286
+ fetchCurrentStudioApp }),
2066
2287
  selectors: {
2067
2288
  selectStudioAppsList,
2289
+ selectCurrentStudioApp,
2068
2290
  },
2069
2291
  };
2070
2292