jamespot-front-business 1.1.31 → 1.1.32
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 +141 -31
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +141 -31
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +68 -23
- package/package.json +4 -2
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
|
|
|
@@ -1978,43 +1979,83 @@ function serverAppsToStudioApps(serverApps) {
|
|
|
1978
1979
|
return studioApps;
|
|
1979
1980
|
}
|
|
1980
1981
|
|
|
1982
|
+
function cloneStudioAppFromExistingApp(existingApp, author) {
|
|
1983
|
+
const newApp = existingApp.inWorkVersion
|
|
1984
|
+
? JSON.parse(JSON.stringify(existingApp.inWorkVersion))
|
|
1985
|
+
: JSON.parse(JSON.stringify(existingApp));
|
|
1986
|
+
const newAppId = uuid.v4();
|
|
1987
|
+
const newAppName = `${existingApp.manifest.appName} Copie`;
|
|
1988
|
+
newApp.idApp = newAppId;
|
|
1989
|
+
newApp.status = APP_STATUS_TYPE.DRAFT;
|
|
1990
|
+
newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
|
|
1991
|
+
return [newApp, newAppId];
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1981
1994
|
const initialState = {
|
|
1982
1995
|
studioAppsList: [],
|
|
1983
1996
|
loadingStudioAppsList: 'idle',
|
|
1984
1997
|
deleteStudioAppStatus: 'idle',
|
|
1998
|
+
suspendStudioAppStatus: 'idle',
|
|
1999
|
+
restartStudioAppStatus: 'idle',
|
|
2000
|
+
cloneStudioAppStatus: 'idle',
|
|
1985
2001
|
};
|
|
1986
|
-
const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2002
|
+
const fetchStudioAppsList = toolkit.createAsyncThunk('studio/appsList', (_, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1987
2003
|
const jApi = extra.jApi;
|
|
1988
|
-
|
|
1989
|
-
jApi.application
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
const
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
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
|
-
});
|
|
2004
|
+
try {
|
|
2005
|
+
const { result } = yield jApi.application.list();
|
|
2006
|
+
return yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2007
|
+
const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
|
|
2008
|
+
const articlesCount = (yield jApi.article.count(app.idApp)).result;
|
|
2009
|
+
return Object.assign(Object.assign({}, coreApp), { articlesCount });
|
|
2010
|
+
})));
|
|
2011
|
+
}
|
|
2012
|
+
catch (_) {
|
|
2013
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
|
|
2014
|
+
}
|
|
2004
2015
|
}));
|
|
2005
|
-
const deleteStudioApp = toolkit.createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2016
|
+
const deleteStudioApp = toolkit.createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2006
2017
|
const jApi = extra.jApi;
|
|
2007
|
-
|
|
2008
|
-
jApi.application
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
+
try {
|
|
2019
|
+
return yield jApi.application.delete(idApp, status);
|
|
2020
|
+
}
|
|
2021
|
+
catch (_) {
|
|
2022
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error deleting application' });
|
|
2023
|
+
}
|
|
2024
|
+
}));
|
|
2025
|
+
const suspendStudioApp = toolkit.createAsyncThunk('studio/suspendStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2026
|
+
const jApi = extra.jApi;
|
|
2027
|
+
try {
|
|
2028
|
+
yield jApi.application.suspend(idApp);
|
|
2029
|
+
}
|
|
2030
|
+
catch (_) {
|
|
2031
|
+
throw rejectWithValue({ error: 1, errorMsg: 'Error suspending application' });
|
|
2032
|
+
}
|
|
2033
|
+
}));
|
|
2034
|
+
const restartStudioApp = toolkit.createAsyncThunk('studio/restartStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2035
|
+
const jApi = extra.jApi;
|
|
2036
|
+
try {
|
|
2037
|
+
yield jApi.application.restart(idApp);
|
|
2038
|
+
}
|
|
2039
|
+
catch (_) {
|
|
2040
|
+
throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
|
|
2041
|
+
}
|
|
2042
|
+
}));
|
|
2043
|
+
const cloneStudioApp = toolkit.createAsyncThunk('studio/cloneStudioApp', ({ idApp }, { extra, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2044
|
+
var _a;
|
|
2045
|
+
const jApi = extra.jApi;
|
|
2046
|
+
const existingStudioApp = getState().studio.studioAppsList.studioAppsList.find((app) => app.idApp === idApp);
|
|
2047
|
+
if (!existingStudioApp)
|
|
2048
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
|
|
2049
|
+
const currentUser = (_a = getState().userCurrent) === null || _a === void 0 ? void 0 : _a.uri;
|
|
2050
|
+
const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
|
|
2051
|
+
const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
|
|
2052
|
+
try {
|
|
2053
|
+
yield jApi.application.save(newAppId, clonedStudioAppReady, 'saved');
|
|
2054
|
+
return clonedStudioApp;
|
|
2055
|
+
}
|
|
2056
|
+
catch (_) {
|
|
2057
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
|
|
2058
|
+
}
|
|
2018
2059
|
}));
|
|
2019
2060
|
const StudioAppsListSlice = toolkit.createSlice({
|
|
2020
2061
|
name: 'studioAppsList',
|
|
@@ -2048,11 +2089,77 @@ const StudioAppsListSlice = toolkit.createSlice({
|
|
|
2048
2089
|
if (state.deleteStudioAppStatus === 'pending') {
|
|
2049
2090
|
state.deleteStudioAppStatus = 'idle';
|
|
2050
2091
|
}
|
|
2051
|
-
state.studioAppsList = state.studioAppsList.
|
|
2092
|
+
state.studioAppsList = state.studioAppsList.reduce((acc, app) => {
|
|
2093
|
+
const { idApp, status } = action.meta.arg;
|
|
2094
|
+
if (app.idApp === idApp && app.status === status)
|
|
2095
|
+
return acc;
|
|
2096
|
+
if (app.inWorkVersion &&
|
|
2097
|
+
app.inWorkVersion.idApp === idApp &&
|
|
2098
|
+
app.inWorkVersion.status === status) {
|
|
2099
|
+
delete app.inWorkVersion;
|
|
2100
|
+
}
|
|
2101
|
+
return [...acc, app];
|
|
2102
|
+
}, []);
|
|
2052
2103
|
})
|
|
2053
2104
|
.addCase(deleteStudioApp.rejected, (state) => {
|
|
2054
2105
|
if (state.deleteStudioAppStatus === 'pending')
|
|
2055
2106
|
state.deleteStudioAppStatus = 'idle';
|
|
2107
|
+
})
|
|
2108
|
+
.addCase(suspendStudioApp.pending, (state) => {
|
|
2109
|
+
if (state.suspendStudioAppStatus === 'idle')
|
|
2110
|
+
state.suspendStudioAppStatus = 'pending';
|
|
2111
|
+
})
|
|
2112
|
+
.addCase(suspendStudioApp.fulfilled, (state, action) => {
|
|
2113
|
+
if (state.suspendStudioAppStatus === 'pending') {
|
|
2114
|
+
state.suspendStudioAppStatus = 'idle';
|
|
2115
|
+
}
|
|
2116
|
+
state.studioAppsList = state.studioAppsList.map((app) => {
|
|
2117
|
+
const { idApp } = action.meta.arg;
|
|
2118
|
+
if (app.idApp === idApp) {
|
|
2119
|
+
app.status = APP_STATUS_TYPE.SUSPENDED;
|
|
2120
|
+
return app;
|
|
2121
|
+
}
|
|
2122
|
+
return app;
|
|
2123
|
+
});
|
|
2124
|
+
})
|
|
2125
|
+
.addCase(suspendStudioApp.rejected, (state) => {
|
|
2126
|
+
if (state.suspendStudioAppStatus === 'pending')
|
|
2127
|
+
state.suspendStudioAppStatus = 'idle';
|
|
2128
|
+
})
|
|
2129
|
+
.addCase(restartStudioApp.pending, (state) => {
|
|
2130
|
+
if (state.restartStudioAppStatus === 'idle')
|
|
2131
|
+
state.restartStudioAppStatus = 'pending';
|
|
2132
|
+
})
|
|
2133
|
+
.addCase(restartStudioApp.fulfilled, (state, action) => {
|
|
2134
|
+
if (state.restartStudioAppStatus === 'pending') {
|
|
2135
|
+
state.restartStudioAppStatus = 'idle';
|
|
2136
|
+
}
|
|
2137
|
+
state.studioAppsList = state.studioAppsList.map((app) => {
|
|
2138
|
+
const { idApp } = action.meta.arg;
|
|
2139
|
+
if (app.idApp === idApp) {
|
|
2140
|
+
app.status = APP_STATUS_TYPE.INSTALLED;
|
|
2141
|
+
return app;
|
|
2142
|
+
}
|
|
2143
|
+
return app;
|
|
2144
|
+
});
|
|
2145
|
+
})
|
|
2146
|
+
.addCase(restartStudioApp.rejected, (state) => {
|
|
2147
|
+
if (state.restartStudioAppStatus === 'pending')
|
|
2148
|
+
state.restartStudioAppStatus = 'idle';
|
|
2149
|
+
})
|
|
2150
|
+
.addCase(cloneStudioApp.pending, (state) => {
|
|
2151
|
+
if (state.cloneStudioAppStatus === 'idle')
|
|
2152
|
+
state.cloneStudioAppStatus = 'pending';
|
|
2153
|
+
})
|
|
2154
|
+
.addCase(cloneStudioApp.fulfilled, (state, action) => {
|
|
2155
|
+
if (state.cloneStudioAppStatus === 'pending') {
|
|
2156
|
+
state.cloneStudioAppStatus = 'idle';
|
|
2157
|
+
}
|
|
2158
|
+
state.studioAppsList = [...state.studioAppsList, action.payload];
|
|
2159
|
+
})
|
|
2160
|
+
.addCase(cloneStudioApp.rejected, (state) => {
|
|
2161
|
+
if (state.cloneStudioAppStatus === 'pending')
|
|
2162
|
+
state.cloneStudioAppStatus = 'idle';
|
|
2056
2163
|
});
|
|
2057
2164
|
},
|
|
2058
2165
|
});
|
|
@@ -2070,7 +2177,10 @@ const studioSlice = {
|
|
|
2070
2177
|
const studio = {
|
|
2071
2178
|
slice: studioSlice,
|
|
2072
2179
|
actions: Object.assign(Object.assign({}, StudioAppsListSlice.actions), { fetchStudioAppsList,
|
|
2073
|
-
deleteStudioApp
|
|
2180
|
+
deleteStudioApp,
|
|
2181
|
+
suspendStudioApp,
|
|
2182
|
+
restartStudioApp,
|
|
2183
|
+
cloneStudioApp }),
|
|
2074
2184
|
selectors: {
|
|
2075
2185
|
selectStudioAppsList,
|
|
2076
2186
|
},
|