jamespot-front-business 1.1.30 → 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 +166 -32
- package/dist/cjs.js.map +1 -1
- package/dist/esm.js +166 -32
- package/dist/esm.js.map +1 -1
- package/dist/types.d.ts +90 -24
- package/package.json +5 -3
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,
|
|
@@ -1919,20 +1920,7 @@ function InstalledAppStudioAdapter(serverApp, serverApps) {
|
|
|
1919
1920
|
const studioApp = {
|
|
1920
1921
|
idApp: serverApp.idApp,
|
|
1921
1922
|
status: _formatStatus(serverApp),
|
|
1922
|
-
manifest: {
|
|
1923
|
-
appShortName: serverApp.name,
|
|
1924
|
-
appName: serverApp.label,
|
|
1925
|
-
description: serverApp.description,
|
|
1926
|
-
author: serverApp.author,
|
|
1927
|
-
cssColor: appTypeServer.cssColor,
|
|
1928
|
-
cssClass: { label: appTypeServer.cssClass, value: appTypeServer.cssClass },
|
|
1929
|
-
version: version,
|
|
1930
|
-
dateCreation: dateCreation,
|
|
1931
|
-
checkAccess: serverApp.checkAccess,
|
|
1932
|
-
attrExposed: serverApp.attrExposed,
|
|
1933
|
-
viewSolr: serverApp.view,
|
|
1934
|
-
typeLabel: appTypeServer.typeLabel,
|
|
1935
|
-
},
|
|
1923
|
+
manifest: Object.assign({ appShortName: serverApp.name, appName: serverApp.label, description: serverApp.description, author: serverApp.author, cssColor: appTypeServer.cssColor, cssClass: { label: appTypeServer.cssClass, value: appTypeServer.cssClass }, version: version, dateCreation: dateCreation, checkAccess: serverApp.checkAccess, attrExposed: serverApp.attrExposed, viewSolr: serverApp.view, typeLabel: appTypeServer.typeLabel }, (serverApp.articlesCount && { articlesCount: serverApp.articlesCount })),
|
|
1936
1924
|
};
|
|
1937
1925
|
const inWorkAppVersion = _findAssociatedDraft(serverApp.idApp, serverApps);
|
|
1938
1926
|
if (!inWorkAppVersion)
|
|
@@ -1983,29 +1971,92 @@ function serverAppsToStudioApps(serverApps) {
|
|
|
1983
1971
|
return studioApps;
|
|
1984
1972
|
}
|
|
1985
1973
|
|
|
1974
|
+
function cloneStudioAppFromExistingApp(existingApp, author) {
|
|
1975
|
+
const newApp = existingApp.inWorkVersion
|
|
1976
|
+
? JSON.parse(JSON.stringify(existingApp.inWorkVersion))
|
|
1977
|
+
: JSON.parse(JSON.stringify(existingApp));
|
|
1978
|
+
const newAppId = v4();
|
|
1979
|
+
const newAppName = `${existingApp.manifest.appName} Copie`;
|
|
1980
|
+
newApp.idApp = newAppId;
|
|
1981
|
+
newApp.status = APP_STATUS_TYPE.DRAFT;
|
|
1982
|
+
newApp.manifest = Object.assign(Object.assign({}, newApp.manifest), { appName: newAppName, appShortName: newAppName, author: author || '', dateCreation: new Date().toISOString(), version: 0.1, articlesCount: 0 });
|
|
1983
|
+
return [newApp, newAppId];
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
1986
|
const initialState = {
|
|
1987
1987
|
studioAppsList: [],
|
|
1988
1988
|
loadingStudioAppsList: 'idle',
|
|
1989
|
+
deleteStudioAppStatus: 'idle',
|
|
1990
|
+
suspendStudioAppStatus: 'idle',
|
|
1991
|
+
restartStudioAppStatus: 'idle',
|
|
1992
|
+
cloneStudioAppStatus: 'idle',
|
|
1989
1993
|
};
|
|
1990
|
-
const fetchStudioAppsList = createAsyncThunk('studio/appsList', (_, { extra }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1994
|
+
const fetchStudioAppsList = createAsyncThunk('studio/appsList', (_, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1991
1995
|
const jApi = extra.jApi;
|
|
1992
|
-
|
|
1993
|
-
jApi.application
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
}))
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
1996
|
+
try {
|
|
1997
|
+
const { result } = yield jApi.application.list();
|
|
1998
|
+
return yield Promise.all(result.map((app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1999
|
+
const coreApp = (yield jApi.application.get(app.idApp, app.status)).result;
|
|
2000
|
+
const articlesCount = (yield jApi.article.count(app.idApp)).result;
|
|
2001
|
+
return Object.assign(Object.assign({}, coreApp), { articlesCount });
|
|
2002
|
+
})));
|
|
2003
|
+
}
|
|
2004
|
+
catch (_) {
|
|
2005
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error retrieving applications' });
|
|
2006
|
+
}
|
|
2007
|
+
}));
|
|
2008
|
+
const deleteStudioApp = createAsyncThunk('studio/deleteApp', ({ idApp, status }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2009
|
+
const jApi = extra.jApi;
|
|
2010
|
+
try {
|
|
2011
|
+
return yield jApi.application.delete(idApp, status);
|
|
2012
|
+
}
|
|
2013
|
+
catch (_) {
|
|
2014
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error deleting application' });
|
|
2015
|
+
}
|
|
2016
|
+
}));
|
|
2017
|
+
const suspendStudioApp = createAsyncThunk('studio/suspendStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2018
|
+
const jApi = extra.jApi;
|
|
2019
|
+
try {
|
|
2020
|
+
yield jApi.application.suspend(idApp);
|
|
2021
|
+
}
|
|
2022
|
+
catch (_) {
|
|
2023
|
+
throw rejectWithValue({ error: 1, errorMsg: 'Error suspending application' });
|
|
2024
|
+
}
|
|
2025
|
+
}));
|
|
2026
|
+
const restartStudioApp = createAsyncThunk('studio/restartStudioApp', ({ idApp }, { extra, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2027
|
+
const jApi = extra.jApi;
|
|
2028
|
+
try {
|
|
2029
|
+
yield jApi.application.restart(idApp);
|
|
2030
|
+
}
|
|
2031
|
+
catch (_) {
|
|
2032
|
+
throw rejectWithValue({ error: 1, errorMsg: 'Error restarting application' });
|
|
2033
|
+
}
|
|
2034
|
+
}));
|
|
2035
|
+
const cloneStudioApp = createAsyncThunk('studio/cloneStudioApp', ({ idApp }, { extra, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2036
|
+
var _a;
|
|
2037
|
+
const jApi = extra.jApi;
|
|
2038
|
+
const existingStudioApp = getState().studio.studioAppsList.studioAppsList.find((app) => app.idApp === idApp);
|
|
2039
|
+
if (!existingStudioApp)
|
|
2040
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
|
|
2041
|
+
const currentUser = (_a = getState().userCurrent) === null || _a === void 0 ? void 0 : _a.uri;
|
|
2042
|
+
const [clonedStudioApp, newAppId] = cloneStudioAppFromExistingApp(existingStudioApp, currentUser);
|
|
2043
|
+
const clonedStudioAppReady = JSON.stringify(clonedStudioApp);
|
|
2044
|
+
try {
|
|
2045
|
+
yield jApi.application.save(newAppId, clonedStudioAppReady, 'saved');
|
|
2046
|
+
return clonedStudioApp;
|
|
2047
|
+
}
|
|
2048
|
+
catch (_) {
|
|
2049
|
+
return rejectWithValue({ error: 1, errorMsg: 'Error cloning application' });
|
|
2050
|
+
}
|
|
2004
2051
|
}));
|
|
2005
2052
|
const StudioAppsListSlice = createSlice({
|
|
2006
2053
|
name: 'studioAppsList',
|
|
2007
2054
|
initialState,
|
|
2008
|
-
reducers: {
|
|
2055
|
+
reducers: {
|
|
2056
|
+
setAppsList: (state, action) => {
|
|
2057
|
+
state.studioAppsList = action.payload;
|
|
2058
|
+
},
|
|
2059
|
+
},
|
|
2009
2060
|
extraReducers: (builder) => {
|
|
2010
2061
|
builder
|
|
2011
2062
|
.addCase(fetchStudioAppsList.pending, (state) => {
|
|
@@ -2013,13 +2064,94 @@ const StudioAppsListSlice = createSlice({
|
|
|
2013
2064
|
state.loadingStudioAppsList = 'pending';
|
|
2014
2065
|
})
|
|
2015
2066
|
.addCase(fetchStudioAppsList.fulfilled, (state, action) => {
|
|
2016
|
-
if (state.loadingStudioAppsList === 'pending')
|
|
2067
|
+
if (state.loadingStudioAppsList === 'pending') {
|
|
2017
2068
|
state.loadingStudioAppsList = 'idle';
|
|
2069
|
+
}
|
|
2018
2070
|
state.studioAppsList = serverAppsToStudioApps(action.payload);
|
|
2019
2071
|
})
|
|
2020
2072
|
.addCase(fetchStudioAppsList.rejected, (state) => {
|
|
2021
2073
|
if (state.loadingStudioAppsList === 'pending')
|
|
2022
2074
|
state.loadingStudioAppsList = 'idle';
|
|
2075
|
+
})
|
|
2076
|
+
.addCase(deleteStudioApp.pending, (state) => {
|
|
2077
|
+
if (state.deleteStudioAppStatus === 'idle')
|
|
2078
|
+
state.deleteStudioAppStatus = 'pending';
|
|
2079
|
+
})
|
|
2080
|
+
.addCase(deleteStudioApp.fulfilled, (state, action) => {
|
|
2081
|
+
if (state.deleteStudioAppStatus === 'pending') {
|
|
2082
|
+
state.deleteStudioAppStatus = 'idle';
|
|
2083
|
+
}
|
|
2084
|
+
state.studioAppsList = state.studioAppsList.reduce((acc, app) => {
|
|
2085
|
+
const { idApp, status } = action.meta.arg;
|
|
2086
|
+
if (app.idApp === idApp && app.status === status)
|
|
2087
|
+
return acc;
|
|
2088
|
+
if (app.inWorkVersion &&
|
|
2089
|
+
app.inWorkVersion.idApp === idApp &&
|
|
2090
|
+
app.inWorkVersion.status === status) {
|
|
2091
|
+
delete app.inWorkVersion;
|
|
2092
|
+
}
|
|
2093
|
+
return [...acc, app];
|
|
2094
|
+
}, []);
|
|
2095
|
+
})
|
|
2096
|
+
.addCase(deleteStudioApp.rejected, (state) => {
|
|
2097
|
+
if (state.deleteStudioAppStatus === 'pending')
|
|
2098
|
+
state.deleteStudioAppStatus = 'idle';
|
|
2099
|
+
})
|
|
2100
|
+
.addCase(suspendStudioApp.pending, (state) => {
|
|
2101
|
+
if (state.suspendStudioAppStatus === 'idle')
|
|
2102
|
+
state.suspendStudioAppStatus = 'pending';
|
|
2103
|
+
})
|
|
2104
|
+
.addCase(suspendStudioApp.fulfilled, (state, action) => {
|
|
2105
|
+
if (state.suspendStudioAppStatus === 'pending') {
|
|
2106
|
+
state.suspendStudioAppStatus = 'idle';
|
|
2107
|
+
}
|
|
2108
|
+
state.studioAppsList = state.studioAppsList.map((app) => {
|
|
2109
|
+
const { idApp } = action.meta.arg;
|
|
2110
|
+
if (app.idApp === idApp) {
|
|
2111
|
+
app.status = APP_STATUS_TYPE.SUSPENDED;
|
|
2112
|
+
return app;
|
|
2113
|
+
}
|
|
2114
|
+
return app;
|
|
2115
|
+
});
|
|
2116
|
+
})
|
|
2117
|
+
.addCase(suspendStudioApp.rejected, (state) => {
|
|
2118
|
+
if (state.suspendStudioAppStatus === 'pending')
|
|
2119
|
+
state.suspendStudioAppStatus = 'idle';
|
|
2120
|
+
})
|
|
2121
|
+
.addCase(restartStudioApp.pending, (state) => {
|
|
2122
|
+
if (state.restartStudioAppStatus === 'idle')
|
|
2123
|
+
state.restartStudioAppStatus = 'pending';
|
|
2124
|
+
})
|
|
2125
|
+
.addCase(restartStudioApp.fulfilled, (state, action) => {
|
|
2126
|
+
if (state.restartStudioAppStatus === 'pending') {
|
|
2127
|
+
state.restartStudioAppStatus = 'idle';
|
|
2128
|
+
}
|
|
2129
|
+
state.studioAppsList = state.studioAppsList.map((app) => {
|
|
2130
|
+
const { idApp } = action.meta.arg;
|
|
2131
|
+
if (app.idApp === idApp) {
|
|
2132
|
+
app.status = APP_STATUS_TYPE.INSTALLED;
|
|
2133
|
+
return app;
|
|
2134
|
+
}
|
|
2135
|
+
return app;
|
|
2136
|
+
});
|
|
2137
|
+
})
|
|
2138
|
+
.addCase(restartStudioApp.rejected, (state) => {
|
|
2139
|
+
if (state.restartStudioAppStatus === 'pending')
|
|
2140
|
+
state.restartStudioAppStatus = 'idle';
|
|
2141
|
+
})
|
|
2142
|
+
.addCase(cloneStudioApp.pending, (state) => {
|
|
2143
|
+
if (state.cloneStudioAppStatus === 'idle')
|
|
2144
|
+
state.cloneStudioAppStatus = 'pending';
|
|
2145
|
+
})
|
|
2146
|
+
.addCase(cloneStudioApp.fulfilled, (state, action) => {
|
|
2147
|
+
if (state.cloneStudioAppStatus === 'pending') {
|
|
2148
|
+
state.cloneStudioAppStatus = 'idle';
|
|
2149
|
+
}
|
|
2150
|
+
state.studioAppsList = [...state.studioAppsList, action.payload];
|
|
2151
|
+
})
|
|
2152
|
+
.addCase(cloneStudioApp.rejected, (state) => {
|
|
2153
|
+
if (state.cloneStudioAppStatus === 'pending')
|
|
2154
|
+
state.cloneStudioAppStatus = 'idle';
|
|
2023
2155
|
});
|
|
2024
2156
|
},
|
|
2025
2157
|
});
|
|
@@ -2036,9 +2168,11 @@ const studioSlice = {
|
|
|
2036
2168
|
};
|
|
2037
2169
|
const studio = {
|
|
2038
2170
|
slice: studioSlice,
|
|
2039
|
-
actions: {
|
|
2040
|
-
|
|
2041
|
-
|
|
2171
|
+
actions: Object.assign(Object.assign({}, StudioAppsListSlice.actions), { fetchStudioAppsList,
|
|
2172
|
+
deleteStudioApp,
|
|
2173
|
+
suspendStudioApp,
|
|
2174
|
+
restartStudioApp,
|
|
2175
|
+
cloneStudioApp }),
|
|
2042
2176
|
selectors: {
|
|
2043
2177
|
selectStudioAppsList,
|
|
2044
2178
|
},
|