mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
683ae7e6d8
* Use prettier * Upgrade to 1.6 beta * Update lint deps * Upgrade to full 1.6
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import api from '../../data/applications-api';
|
|
|
|
export const RECEIVE_ALL_APPLICATIONS = 'RECEIVE_ALL_APPLICATIONS';
|
|
export const ERROR_RECEIVE_ALL_APPLICATIONS = 'ERROR_RECEIVE_ALL_APPLICATIONS';
|
|
export const ERROR_UPDATING_APPLICATION_DATA =
|
|
'ERROR_UPDATING_APPLICATION_DATA';
|
|
|
|
export const RECEIVE_APPLICATION = 'RECEIVE_APPLICATION';
|
|
|
|
const recieveAllApplications = json => ({
|
|
type: RECEIVE_ALL_APPLICATIONS,
|
|
value: json,
|
|
});
|
|
|
|
const recieveApplication = json => ({
|
|
type: RECEIVE_APPLICATION,
|
|
value: json,
|
|
});
|
|
|
|
const errorReceiveApplications = (
|
|
statusCode,
|
|
type = ERROR_RECEIVE_ALL_APPLICATIONS
|
|
) => ({
|
|
type,
|
|
statusCode,
|
|
});
|
|
|
|
export function fetchAll() {
|
|
return dispatch =>
|
|
api
|
|
.fetchAll()
|
|
.then(json => dispatch(recieveAllApplications(json)))
|
|
.catch(error => dispatch(errorReceiveApplications(error)));
|
|
}
|
|
|
|
export function storeApplicationMetaData(appName, key, value) {
|
|
return dispatch =>
|
|
api
|
|
.storeApplicationMetaData(appName, key, value)
|
|
.catch(error =>
|
|
dispatch(
|
|
errorReceiveApplications(
|
|
error,
|
|
ERROR_UPDATING_APPLICATION_DATA
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
export function fetchApplication(appName) {
|
|
return dispatch =>
|
|
api
|
|
.fetchApplication(appName)
|
|
.then(json => dispatch(recieveApplication(json)))
|
|
.catch(error => dispatch(errorReceiveApplications(error)));
|
|
}
|