feat(workflow): add deploy preview links (#2028)
This commit is contained in:
45
packages/netlify-cms-core/src/reducers/deploys.js
Normal file
45
packages/netlify-cms-core/src/reducers/deploys.js
Normal 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;
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user