cartodb-4.42/lib/assets/javascripts/new-dashboard/store/mutations/apps.js
2024-04-06 05:25:13 +00:00

35 lines
774 B
JavaScript

import toObject from 'new-dashboard/utils/to-object';
export function setApps (state, apps) {
state.list = toObject(apps, 'id');
state.isFetching = false;
state.isErrored = false;
state.error = [];
}
export function addApp (state, app) {
state.list = { ...state.list, [app.id]: app };
}
export function updateOAuthApp (state, app) {
const isOAuthAppPresent = state.list.hasOwnProperty(app.id);
if (isOAuthAppPresent) {
Object.assign(state.list[app.id], app);
}
}
export function setRequestError (state, error) {
state.isFetching = false;
state.isErrored = true;
state.error = error;
state.list = {};
}
export function setFetchingState (state) {
state.isFetching = true;
state.isErrored = false;
state.error = [];
state.list = {};
}