feat(workflow): add deploy preview links (#2028)

This commit is contained in:
Shawn Erquhart
2019-02-08 12:26:59 -05:00
committed by GitHub
parent f0553c720a
commit 15d221d4a4
24 changed files with 861 additions and 42 deletions

View File

@ -0,0 +1,45 @@
import { Map, fromJS } from 'immutable';
import {
DEPLOY_PREVIEW_REQUEST,
DEPLOY_PREVIEW_SUCCESS,
DEPLOY_PREVIEW_FAILURE,
} from 'Actions/deploys';
const deploys = (state = Map({ deploys: Map() }), action) => {
switch (action.type) {
case DEPLOY_PREVIEW_REQUEST: {
const { collection, slug } = action.payload;
return state.setIn(['deploys', `${collection}.${slug}`, 'isFetching'], true);
}
case DEPLOY_PREVIEW_SUCCESS: {
const { collection, slug, url, status } = action.payload;
return state.setIn(
['deploys', `${collection}.${slug}`],
fromJS({
isFetching: false,
url,
status,
}),
);
}
case DEPLOY_PREVIEW_FAILURE: {
const { collection, slug } = action.payload;
return state.setIn(
['deploys', `${collection}.${slug}`],
fromJS({
isFetching: false,
}),
);
}
default:
return state;
}
};
export const selectDeployPreview = (state, collection, slug) =>
state.getIn(['deploys', `${collection}.${slug}`]);
export default deploys;

View File

@ -9,6 +9,7 @@ import collections from './collections';
import search from './search';
import mediaLibrary from './mediaLibrary';
import medias, * as fromMedias from './medias';
import deploys, * as fromDeploys from './deploys';
import globalUI from './globalUI';
const reducers = {
@ -23,6 +24,7 @@ const reducers = {
entryDraft,
mediaLibrary,
medias,
deploys,
globalUI,
};
@ -47,6 +49,9 @@ export const selectSearchedEntries = state => {
);
};
export const selectDeployPreview = (state, collection, slug) =>
fromDeploys.selectDeployPreview(state.deploys, collection, slug);
export const selectUnpublishedEntry = (state, collection, slug) =>
fromEditorialWorkflow.selectUnpublishedEntry(state.editorialWorkflow, collection, slug);