Move shimming of workpad CSS to only happen on fetch (#38117) (#38157)

This commit is contained in:
Corey Robertson 2019-06-06 08:13:18 -04:00 committed by GitHub
parent 5746d01ae0
commit 46d781e616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -9,6 +9,7 @@ import {
API_ROUTE_WORKPAD,
API_ROUTE_WORKPAD_ASSETS,
API_ROUTE_WORKPAD_STRUCTURES,
DEFAULT_WORKPAD_CSS,
} from '../../common/lib/constants';
import { fetch } from '../../common/lib/fetch';
@ -22,7 +23,10 @@ export function create(workpad) {
}
export function get(workpadId) {
return fetch.get(`${apiPath}/${workpadId}`).then(({ data: workpad }) => workpad);
return fetch.get(`${apiPath}/${workpadId}`).then(({ data: workpad }) => {
// shim old workpads with new properties
return { css: DEFAULT_WORKPAD_CSS, ...workpad };
});
}
export function update(id, workpad) {

View file

@ -6,7 +6,6 @@
import { get, omit } from 'lodash';
import { safeElementFromExpression, fromExpression } from '@kbn/interpreter/common';
import { DEFAULT_WORKPAD_CSS } from '../../../common/lib/constants';
import { append } from '../../lib/modify_path';
import { getAssets } from './assets';
@ -19,11 +18,7 @@ const appendAst = element => ({
// workpad getters
export function getWorkpad(state) {
return {
// shim old workpads with new properties
css: DEFAULT_WORKPAD_CSS,
...get(state, workpadRoot),
};
return get(state, workpadRoot);
}
// should we split `workpad.js` to eg. `workpad.js` (full) and `persistentWorkpadStructure.js` (persistent.workpad)?