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/cjs.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var toolkit = require('@reduxjs/toolkit');
6
6
  var redux = require('redux');
7
7
  var jamespot = require('jamespot-user-api');
8
+ var uuid = require('uuid');
8
9
 
9
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
11
 
@@ -67,7 +68,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
67
68
  });
68
69
  }
69
70
 
70
- const initialState$g = {
71
+ const initialState$h = {
71
72
  entities: [],
72
73
  loading: 'idle',
73
74
  nbResults: 0,
@@ -78,7 +79,7 @@ const fetchBookableAsset = toolkit.createAsyncThunk('BookableAsset/fetchBookable
78
79
  }));
79
80
  const BookableAssetSlice = toolkit.createSlice({
80
81
  name: 'bookableAsset',
81
- initialState: initialState$g,
82
+ initialState: initialState$h,
82
83
  reducers: {},
83
84
  extraReducers: (builder) => {
84
85
  builder
@@ -99,7 +100,7 @@ const BookableAssetSlice = toolkit.createSlice({
99
100
  const fetchConfiguration = toolkit.createAsyncThunk('AssetReservation/configuration', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
100
101
  return yield extra.jApi.assetReservation.configuration();
101
102
  }));
102
- const initialState$f = {
103
+ const initialState$g = {
103
104
  description: '',
104
105
  right: {
105
106
  manage: false,
@@ -113,7 +114,7 @@ const initialState$f = {
113
114
  };
114
115
  const AssetReservationConfigurationSlice = toolkit.createSlice({
115
116
  name: 'configuration',
116
- initialState: initialState$f,
117
+ initialState: initialState$g,
117
118
  reducers: {},
118
119
  extraReducers: (builder) => {
119
120
  builder
@@ -134,7 +135,7 @@ const initForm = {
134
135
  hourStart: '',
135
136
  hourEnd: '',
136
137
  };
137
- const initialState$e = {
138
+ const initialState$f = {
138
139
  entities: [],
139
140
  loading: 'idle',
140
141
  nbResults: 0,
@@ -146,7 +147,7 @@ const fetchReservation = toolkit.createAsyncThunk('Reservation/fetchReservation'
146
147
  }));
147
148
  const ReservationSlice = toolkit.createSlice({
148
149
  name: 'reservation',
149
- initialState: initialState$e,
150
+ initialState: initialState$f,
150
151
  reducers: {
151
152
  setForm: (state, action) => {
152
153
  state.form = action.payload;
@@ -239,7 +240,7 @@ const Toast = {
239
240
  selectors: selectors$1,
240
241
  };
241
242
 
242
- const initialState$d = {
243
+ const initialState$e = {
243
244
  bookmarks: [],
244
245
  loading: 'idle',
245
246
  status: undefined,
@@ -302,7 +303,7 @@ const deleteBookmark = toolkit.createAsyncThunk('bookmarkList/deleteBookmark', (
302
303
  }));
303
304
  const BookmarkListSlice = toolkit.createSlice({
304
305
  name: 'bookmarkList',
305
- initialState: initialState$d,
306
+ initialState: initialState$e,
306
307
  reducers: {
307
308
  resetAddBookmarkStatus: (state, action) => {
308
309
  if (state.add[action.payload]) {
@@ -465,7 +466,7 @@ const getRTHandlers = function (dispatch) {
465
466
  ];
466
467
  };
467
468
 
468
- const initialState$c = {
469
+ const initialState$d = {
469
470
  bookmark: undefined,
470
471
  status: undefined,
471
472
  loading: 'idle',
@@ -487,7 +488,7 @@ const editBookmark = toolkit.createAsyncThunk('bookmarkEdit/editBookmark', (book
487
488
  }));
488
489
  const BookmarkEditSlice = toolkit.createSlice({
489
490
  name: 'bookmarkEdit',
490
- initialState: initialState$c,
491
+ initialState: initialState$d,
491
492
  reducers: {
492
493
  setEditBookmark: (state, action) => {
493
494
  state.bookmark = Object.assign({}, action.payload);
@@ -540,7 +541,7 @@ const Bookmark = {
540
541
  getRTHandlers: getRTHandlers,
541
542
  };
542
543
 
543
- const initialState$b = {
544
+ const initialState$c = {
544
545
  loading: 'idle',
545
546
  access: { createCategory: false },
546
547
  };
@@ -568,7 +569,7 @@ const fetchFaqConfig = toolkit.createAsyncThunk('faqConfig/fetch', () => __await
568
569
  }));
569
570
  const FaqConfigSlice = toolkit.createSlice({
570
571
  name: 'config',
571
- initialState: initialState$b,
572
+ initialState: initialState$c,
572
573
  reducers: {},
573
574
  extraReducers: (builder) => {
574
575
  builder
@@ -600,7 +601,7 @@ const FaqConfigSlice = toolkit.createSlice({
600
601
  },
601
602
  });
602
603
 
603
- const initialState$a = {
604
+ const initialState$b = {
604
605
  loading: 'idle',
605
606
  categories: null,
606
607
  };
@@ -612,7 +613,7 @@ const fetchFaqCategories = toolkit.createAsyncThunk('faqCategories/fetch', () =>
612
613
  }));
613
614
  const FaqCategoriesSlice = toolkit.createSlice({
614
615
  name: 'categories',
615
- initialState: initialState$a,
616
+ initialState: initialState$b,
616
617
  reducers: {},
617
618
  extraReducers: (builder) => {
618
619
  builder
@@ -894,7 +895,7 @@ const initialMap = {
894
895
  illustration: '',
895
896
  assignLicense: false,
896
897
  };
897
- const initialState$9 = {
898
+ const initialState$a = {
898
899
  map: Object.assign({}, initialMap),
899
900
  loading: 'idle',
900
901
  status: undefined,
@@ -938,13 +939,13 @@ const createMap = toolkit.createAsyncThunk('mapCreate/create', ({ map, jlandUrlB
938
939
  }));
939
940
  const MapCreateSlice = toolkit.createSlice({
940
941
  name: 'mapCreate',
941
- initialState: initialState$9,
942
+ initialState: initialState$a,
942
943
  reducers: {
943
944
  setMap: (state, action) => {
944
945
  state.map = action.payload;
945
946
  },
946
947
  resetCreateMapState: () => {
947
- return initialState$9;
948
+ return initialState$a;
948
949
  },
949
950
  },
950
951
  extraReducers: (builder) => {
@@ -1031,10 +1032,10 @@ const Model = {
1031
1032
  selectors: Object.assign(Object.assign({}, selectors), { selectByIds }),
1032
1033
  };
1033
1034
 
1034
- const initialState$8 = {};
1035
+ const initialState$9 = {};
1035
1036
  const NetworkStaticsSlice = toolkit.createSlice({
1036
1037
  name: 'statics',
1037
- initialState: initialState$8,
1038
+ initialState: initialState$9,
1038
1039
  reducers: {
1039
1040
  initNetworkStatics: (_, { payload }) => {
1040
1041
  return payload;
@@ -1090,7 +1091,7 @@ const fetchRecentFiles = toolkit.createAsyncThunk('/fetchRecentFiles', (_, { ext
1090
1091
  return yield jApi.wedoc.getFiles(Object.assign(Object.assign({}, initialQuery), { filters, limit: 4 }));
1091
1092
  }));
1092
1093
 
1093
- const initialState$7 = {
1094
+ const initialState$8 = {
1094
1095
  entities: [],
1095
1096
  nbEntities: 0,
1096
1097
  entitiesRecent: [],
@@ -1102,7 +1103,7 @@ const initialState$7 = {
1102
1103
  };
1103
1104
  const WedocAppSlice = toolkit.createSlice({
1104
1105
  name: 'wedoc',
1105
- initialState: initialState$7,
1106
+ initialState: initialState$8,
1106
1107
  reducers: {
1107
1108
  update: (state, action) => {
1108
1109
  state.entities = [
@@ -1175,14 +1176,14 @@ const fetchRequest = toolkit.createAsyncThunk('/fetchRequest', ({ uri, idUser },
1175
1176
  return yield jApi.wedoc.getAccessRequest(uri, idUser);
1176
1177
  }));
1177
1178
 
1178
- const initialState$6 = {
1179
+ const initialState$7 = {
1179
1180
  entities: [],
1180
1181
  nbEntities: 0,
1181
1182
  loading: 'idle',
1182
1183
  };
1183
1184
  const ShareSlice = toolkit.createSlice({
1184
1185
  name: 'share',
1185
- initialState: initialState$6,
1186
+ initialState: initialState$7,
1186
1187
  reducers: {
1187
1188
  remove: (state, action) => {
1188
1189
  state.entities = [
@@ -1220,7 +1221,7 @@ const Share = {
1220
1221
  },
1221
1222
  };
1222
1223
 
1223
- const initialState$5 = {
1224
+ const initialState$6 = {
1224
1225
  channels: undefined,
1225
1226
  loading: 'idle',
1226
1227
  loadingChannelDeletion: 'idle',
@@ -1263,7 +1264,7 @@ const deleteChannel = toolkit.createAsyncThunk('/deleteChannel', ({ channel }, {
1263
1264
  }));
1264
1265
  const ChannelsListSlice = toolkit.createSlice({
1265
1266
  name: 'channelsList',
1266
- initialState: Object.assign({}, initialState$5),
1267
+ initialState: Object.assign({}, initialState$6),
1267
1268
  reducers: {},
1268
1269
  extraReducers: (builder) => {
1269
1270
  builder
@@ -1332,10 +1333,10 @@ const TVDisplay = {
1332
1333
  },
1333
1334
  };
1334
1335
 
1335
- const initialState$4 = {};
1336
+ const initialState$5 = {};
1336
1337
  const TinyMCEOptionsSlice = toolkit.createSlice({
1337
1338
  name: 'options',
1338
- initialState: initialState$4,
1339
+ initialState: initialState$5,
1339
1340
  reducers: {
1340
1341
  initOptions: (_, { payload }) => {
1341
1342
  return { common: payload };
@@ -1361,7 +1362,7 @@ const TinyMCE = {
1361
1362
  },
1362
1363
  };
1363
1364
 
1364
- const initialState$3 = {
1365
+ const initialState$4 = {
1365
1366
  id: 0,
1366
1367
  mainType: 'user',
1367
1368
  type: 'user',
@@ -1375,7 +1376,7 @@ const initialState$3 = {
1375
1376
  };
1376
1377
  const slice = toolkit.createSlice({
1377
1378
  name: 'userCurrent',
1378
- initialState: initialState$3,
1379
+ initialState: initialState$4,
1379
1380
  reducers: {
1380
1381
  init: (_, { payload }) => {
1381
1382
  return payload;
@@ -1593,7 +1594,7 @@ function widgetDefinition(name) {
1593
1594
 
1594
1595
  const MODE_EDIT = 'edit';
1595
1596
  const MODE_VIEW = 'view';
1596
- const initialState$2 = {
1597
+ const initialState$3 = {
1597
1598
  token: undefined,
1598
1599
  ids: {},
1599
1600
  layers: {},
@@ -1605,7 +1606,7 @@ const initialState$2 = {
1605
1606
  };
1606
1607
  const widgetsSlice = toolkit.createSlice({
1607
1608
  name: 'widgets',
1608
- initialState: initialState$2,
1609
+ initialState: initialState$3,
1609
1610
  reducers: {
1610
1611
  registerWidget: (state, action) => {
1611
1612
  const { uniqid, widget } = action.payload;
@@ -1747,12 +1748,12 @@ const Widget = {
1747
1748
  },
1748
1749
  };
1749
1750
 
1750
- const initialState$1 = {
1751
+ const initialState$2 = {
1751
1752
  editors: [],
1752
1753
  };
1753
1754
  const editorsSlice = toolkit.createSlice({
1754
1755
  name: 'editors',
1755
- initialState: initialState$1,
1756
+ initialState: initialState$2,
1756
1757
  reducers: {
1757
1758
  registerEditor: (state, action) => {
1758
1759
  const { uniqid, name } = action.payload;
@@ -1978,43 +1979,174 @@ function serverAppsToStudioApps(serverApps) {
1978
1979
  return studioApps;
1979
1980
  }
1980
1981
 
1982
+ const initialState$1 = {
1983
+ currentStudioApp: null,
1984
+ fetchCurrentStudioAppStatus: 'idle',
1985
+ };
1986
+ const fetchCurrentStudioApp = toolkit.createAsyncThunk('studio/fetchCurrentStudioApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
1987
+ const jApi = extra.jApi;
1988
+ const error = { error: 1, errorMsg: 'Error fetching application' };
1989
+ try {
1990
+ const studioApplicationBase = (yield jApi.application.get(idApp, status)).result;
1991
+ const studioApplication = serverAppsToStudioApps([studioApplicationBase])[0];
1992
+ if (!studioApplication) {
1993
+ return rejectWithValue(error);
1994
+ }
1995
+ return studioApplication;
1996
+ }
1997
+ catch (_) {
1998
+ return rejectWithValue(error);
1999
+ }
2000
+ }));
2001
+ const CurrentStudioAppSlice = toolkit.createSlice({
2002
+ name: 'currentStudioApp',
2003
+ initialState: initialState$1,
2004
+ reducers: {
2005
+ setCurrentApp: (state, action) => {
2006
+ state.currentStudioApp = action.payload;
2007
+ },
2008
+ },
2009
+ extraReducers: (builder) => {
2010
+ builder
2011
+ .addCase(fetchCurrentStudioApp.pending, (state) => {
2012
+ if (state.fetchCurrentStudioAppStatus === 'idle')
2013
+ state.fetchCurrentStudioAppStatus = 'pending';
2014
+ })
2015
+ .addCase(fetchCurrentStudioApp.fulfilled, (state, action) => {
2016
+ if (state.fetchCurrentStudioAppStatus === 'pending')
2017
+ state.fetchCurrentStudioAppStatus = 'idle';
2018
+ state.currentStudioApp = action.payload;
2019
+ })
2020
+ .addCase(fetchCurrentStudioApp.rejected, (state) => {
2021
+ if (state.fetchCurrentStudioAppStatus === 'pending')
2022
+ state.fetchCurrentStudioAppStatus = 'idle';
2023
+ });
2024
+ },
2025
+ });
2026
+
2027
+ function cloneStudioAppFromExistingApp(existingApp, author) {
2028
+ const newApp = existingApp.inWorkVersion
2029
+ ? JSON.parse(JSON.stringify(existingApp.inWorkVersion))
2030
+ : JSON.parse(JSON.stringify(existingApp));
2031
+ const newAppId = uuid.v4();
2032
+ const newAppName = `${existingApp.manifest.appName} Copie`;
2033
+ newApp.idApp = newAppId;
2034
+ newApp.status = APP_STATUS_TYPE.DRAFT;
2035
+ newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
2036
+ return [newApp, newAppId];
2037
+ }
2038
+
2039
+ function createNewStudioApp$1({ author }) {
2040
+ const newAppId = uuid.v4();
2041
+ return {
2042
+ newAppId,
2043
+ newStudioApp: {
2044
+ idApp: newAppId,
2045
+ status: APP_STATUS_TYPE.DRAFT,
2046
+ author: author || '',
2047
+ manifest: {
2048
+ appShortName: newAppId,
2049
+ appName: newAppId,
2050
+ author: author || '',
2051
+ description: '',
2052
+ typeLabel: '',
2053
+ cssColor: '#392994',
2054
+ cssClass: {
2055
+ label: 'star',
2056
+ value: 'star',
2057
+ },
2058
+ version: 0.1,
2059
+ dateCreation: new Date().toISOString(),
2060
+ viewSolr: 'solr',
2061
+ checkAccess: false,
2062
+ accessRightList: '',
2063
+ attrExposed: [],
2064
+ articlesCount: 0,
2065
+ },
2066
+ },
2067
+ };
2068
+ }
2069
+
1981
2070
  const initialState = {
1982
2071
  studioAppsList: [],
1983
2072
  loadingStudioAppsList: 'idle',
1984
2073
  deleteStudioAppStatus: 'idle',
2074
+ suspendStudioAppStatus: 'idle',
2075
+ restartStudioAppStatus: 'idle',
2076
+ cloneStudioAppStatus: 'idle',
2077
+ createNewStudioAppStatus: 'idle',
1985
2078
  };
1986
- const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
2079
+ const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (_, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
1987
2080
  const jApi = extra.jApi;
1988
- return yield new Promise((resolve, rejectWithValue) => {
1989
- jApi.application
1990
- .list()
1991
- .then((res) => __awaiter(void 0, void 0, void 0, function* () {
1992
- const coreApps = yield Promise.all(res.result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
1993
- const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
1994
- const articlesCount = (yield jApi.article.count(app.idApp)).result;
1995
- return Object.assign(Object.assign({}, coreApp), { articlesCount });
1996
- })));
1997
- resolve(coreApps);
1998
- }))
1999
- .catch((e) => {
2000
- var _a, _b;
2001
- rejectWithValue({ error: (_a = e.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = e.errorMsg) !== null && _b !== void 0 ? _b : 'Error retrieving applications' });
2002
- });
2003
- });
2081
+ try {
2082
+ const { result } = yield jApi.application.list();
2083
+ return yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
2084
+ const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
2085
+ const articlesCount = (yield jApi.article.count(app.idApp)).result;
2086
+ return Object.assign(Object.assign({}, coreApp), { articlesCount });
2087
+ })));
2088
+ }
2089
+ catch (_) {
2090
+ throw rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
2091
+ }
2004
2092
  }));
2005
- const deleteStudioApp = toolkit.createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
2093
+ const createNewStudioApp = toolkit.createAsyncThunk('studio/createApp', (_, { extra, dispatch, rejectWithValue, getState }) => __awaiter(void 0, void 0, void 0, function* () {
2094
+ var _a;
2006
2095
  const jApi = extra.jApi;
2007
- return yield new Promise((resolve, rejectWithValue) => {
2008
- jApi.application
2009
- .delete(idApp, status)
2010
- .then((res) => {
2011
- resolve(res);
2012
- })
2013
- .catch((e) => {
2014
- var _a, _b;
2015
- rejectWithValue({ error: (_a = e.error) !== null && _a !== void 0 ? _a : 1, errorMsg: (_b = e.errorMsg) !== null && _b !== void 0 ? _b : 'Error deleting application' });
2016
- });
2017
- });
2096
+ const author = (_a = getState().userCurrent) === null || _a === void 0 ? void 0 : _a.uri;
2097
+ const { newAppId, newStudioApp } = createNewStudioApp$1(Object.assign({}, (author && { author })));
2098
+ try {
2099
+ yield jApi.application.save(newAppId, JSON.stringify(newStudioApp), 'saved');
2100
+ dispatch(CurrentStudioAppSlice.actions.setCurrentApp(newStudioApp));
2101
+ return newStudioApp;
2102
+ }
2103
+ catch (_) {
2104
+ throw rejectWithValue({ error: 1, errorMsg: 'Error creating application' });
2105
+ }
2106
+ }));
2107
+ const deleteStudioApp = toolkit.createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2108
+ const jApi = extra.jApi;
2109
+ try {
2110
+ return yield jApi.application.delete(idApp, status);
2111
+ }
2112
+ catch (_) {
2113
+ return rejectWithValue({ error: 1, errorMsg: 'Error deleting application' });
2114
+ }
2115
+ }));
2116
+ const suspendStudioApp = toolkit.createAsyncThunk('studio/suspendStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2117
+ const jApi = extra.jApi;
2118
+ try {
2119
+ yield jApi.application.suspend(idApp);
2120
+ }
2121
+ catch (_) {
2122
+ throw rejectWithValue({ error: 1, errorMsg: 'Error suspending application' });
2123
+ }
2124
+ }));
2125
+ const restartStudioApp = toolkit.createAsyncThunk('studio/restartStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2126
+ const jApi = extra.jApi;
2127
+ try {
2128
+ yield jApi.application.restart(idApp);
2129
+ }
2130
+ catch (_) {
2131
+ throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
2132
+ }
2133
+ }));
2134
+ const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idApp }, { extra, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
2135
+ var _b;
2136
+ const jApi = extra.jApi;
2137
+ const existingStudioApp = getState().studio.studioAppsList.studioAppsList.find((app) => app.idApp === idApp);
2138
+ if (!existingStudioApp)
2139
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
2140
+ const currentUser = (_b = getState().userCurrent) === null || _b === void 0 ? void 0 : _b.uri;
2141
+ const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
2142
+ const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
2143
+ try {
2144
+ yield jApi.application.save(newAppId, clonedStudioAppReady, 'saved');
2145
+ return clonedStudioApp;
2146
+ }
2147
+ catch (_) {
2148
+ return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
2149
+ }
2018
2150
  }));
2019
2151
  const StudioAppsListSlice = toolkit.createSlice({
2020
2152
  name: 'studioAppsList',
@@ -2048,31 +2180,121 @@ const StudioAppsListSlice = toolkit.createSlice({
2048
2180
  if (state.deleteStudioAppStatus === 'pending') {
2049
2181
  state.deleteStudioAppStatus = 'idle';
2050
2182
  }
2051
- state.studioAppsList = state.studioAppsList.filter((app) => app.idApp !== action.meta.arg.idApp && app.status !== action.meta.arg.status);
2183
+ state.studioAppsList = state.studioAppsList.reduce((acc, app) => {
2184
+ const { idApp, status } = action.meta.arg;
2185
+ if (app.idApp === idApp && app.status === status)
2186
+ return acc;
2187
+ if (app.inWorkVersion &&
2188
+ app.inWorkVersion.idApp === idApp &&
2189
+ app.inWorkVersion.status === status) {
2190
+ delete app.inWorkVersion;
2191
+ }
2192
+ return [...acc, app];
2193
+ }, []);
2052
2194
  })
2053
2195
  .addCase(deleteStudioApp.rejected, (state) => {
2054
2196
  if (state.deleteStudioAppStatus === 'pending')
2055
2197
  state.deleteStudioAppStatus = 'idle';
2198
+ })
2199
+ .addCase(suspendStudioApp.pending, (state) => {
2200
+ if (state.suspendStudioAppStatus === 'idle')
2201
+ state.suspendStudioAppStatus = 'pending';
2202
+ })
2203
+ .addCase(suspendStudioApp.fulfilled, (state, action) => {
2204
+ if (state.suspendStudioAppStatus === 'pending') {
2205
+ state.suspendStudioAppStatus = 'idle';
2206
+ }
2207
+ state.studioAppsList = state.studioAppsList.map((app) => {
2208
+ const { idApp } = action.meta.arg;
2209
+ if (app.idApp === idApp) {
2210
+ app.status = APP_STATUS_TYPE.SUSPENDED;
2211
+ return app;
2212
+ }
2213
+ return app;
2214
+ });
2215
+ })
2216
+ .addCase(suspendStudioApp.rejected, (state) => {
2217
+ if (state.suspendStudioAppStatus === 'pending')
2218
+ state.suspendStudioAppStatus = 'idle';
2219
+ })
2220
+ .addCase(restartStudioApp.pending, (state) => {
2221
+ if (state.restartStudioAppStatus === 'idle')
2222
+ state.restartStudioAppStatus = 'pending';
2223
+ })
2224
+ .addCase(restartStudioApp.fulfilled, (state, action) => {
2225
+ if (state.restartStudioAppStatus === 'pending') {
2226
+ state.restartStudioAppStatus = 'idle';
2227
+ }
2228
+ state.studioAppsList = state.studioAppsList.map((app) => {
2229
+ const { idApp } = action.meta.arg;
2230
+ if (app.idApp === idApp) {
2231
+ app.status = APP_STATUS_TYPE.INSTALLED;
2232
+ return app;
2233
+ }
2234
+ return app;
2235
+ });
2236
+ })
2237
+ .addCase(restartStudioApp.rejected, (state) => {
2238
+ if (state.restartStudioAppStatus === 'pending')
2239
+ state.restartStudioAppStatus = 'idle';
2240
+ })
2241
+ .addCase(cloneStudioApp.pending, (state) => {
2242
+ if (state.cloneStudioAppStatus === 'idle')
2243
+ state.cloneStudioAppStatus = 'pending';
2244
+ })
2245
+ .addCase(cloneStudioApp.fulfilled, (state, action) => {
2246
+ if (state.cloneStudioAppStatus === 'pending') {
2247
+ state.cloneStudioAppStatus = 'idle';
2248
+ }
2249
+ state.studioAppsList = [...state.studioAppsList, action.payload];
2250
+ })
2251
+ .addCase(cloneStudioApp.rejected, (state) => {
2252
+ if (state.cloneStudioAppStatus === 'pending')
2253
+ state.cloneStudioAppStatus = 'idle';
2254
+ })
2255
+ .addCase(createNewStudioApp.pending, (state) => {
2256
+ if (state.createNewStudioAppStatus === 'idle')
2257
+ state.createNewStudioAppStatus = 'pending';
2258
+ })
2259
+ .addCase(createNewStudioApp.fulfilled, (state, action) => {
2260
+ if (state.createNewStudioAppStatus === 'pending') {
2261
+ state.createNewStudioAppStatus = 'idle';
2262
+ }
2263
+ state.studioAppsList = [...state.studioAppsList, action.payload];
2264
+ })
2265
+ .addCase(createNewStudioApp.rejected, (state) => {
2266
+ if (state.createNewStudioAppStatus === 'pending')
2267
+ state.createNewStudioAppStatus = 'idle';
2056
2268
  });
2057
2269
  },
2058
2270
  });
2059
2271
 
2060
2272
  const joinedReducers = redux.combineReducers({
2061
2273
  [StudioAppsListSlice.name]: StudioAppsListSlice.reducer,
2274
+ [CurrentStudioAppSlice.name]: CurrentStudioAppSlice.reducer,
2062
2275
  });
2063
- const selectStudioAppsList = function selectStudioAppsList(state) {
2276
+ function selectStudioAppsList(state) {
2064
2277
  return state.studio.studioAppsList;
2065
- };
2278
+ }
2279
+ function selectCurrentStudioApp(state) {
2280
+ return state.studio.currentStudioApp;
2281
+ }
2066
2282
  const studioSlice = {
2067
2283
  name: 'studio',
2068
2284
  reducer: joinedReducers,
2069
2285
  };
2070
2286
  const studio = {
2071
2287
  slice: studioSlice,
2072
- actions: Object.assign(Object.assign({}, StudioAppsListSlice.actions), { fetchStudioAppsList,
2073
- deleteStudioApp }),
2288
+ actions: Object.assign(Object.assign(Object.assign({}, StudioAppsListSlice.actions), CurrentStudioAppSlice.actions), { fetchStudioAppsList,
2289
+ deleteStudioApp,
2290
+ suspendStudioApp,
2291
+ restartStudioApp,
2292
+ cloneStudioApp,
2293
+ createNewStudioApp,
2294
+ fetchCurrentStudioApp }),
2074
2295
  selectors: {
2075
2296
  selectStudioAppsList,
2297
+ selectCurrentStudioApp,
2076
2298
  },
2077
2299
  };
2078
2300