Fix 'workpad flash' when loading new workpad (#44387) (#44539)

* Fix 'workpad flash' when loading new workpad

* Fix SCSS path
This commit is contained in:
Clint Andrew Hall 2019-08-30 18:11:29 -04:00 committed by GitHub
parent 1ce9d993f9
commit 04ef24f0f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 5 deletions

View file

@ -6,10 +6,11 @@
import React from 'react';
import { EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui';
import { WorkpadManager } from '../../components/workpad_manager';
import { setDocTitle } from '../../lib/doc_title';
import { WorkpadManager } from '../../../components/workpad_manager';
import { setDocTitle } from '../../../lib/doc_title';
export const HomeApp = () => {
export const HomeApp = ({ onLoad = () => {} }) => {
onLoad();
setDocTitle('Canvas');
return (
<EuiPage className="canvasHomeApp" restrictWidth>

View file

@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { connect } from 'react-redux';
import { resetWorkpad } from '../../../state/actions/workpad';
import { HomeApp as Component } from './home_app';
const mapDispatchToProps = dispatch => ({
onLoad() {
dispatch(resetWorkpad());
},
});
export const HomeApp = connect(
null,
mapDispatchToProps
)(Component);

View file

@ -18,6 +18,7 @@ export const setRefreshInterval = createAction('setRefreshInterval');
export const setWorkpadCSS = createAction('setWorkpadCSS');
export const enableAutoplay = createAction('enableAutoplay');
export const setAutoplayInterval = createAction('setAutoplayInterval');
export const resetWorkpad = createAction('resetWorkpad');
export const initializeWorkpad = createThunk('initializeWorkpad', ({ dispatch }) => {
dispatch(fetchAllRenderables());

View file

@ -7,7 +7,8 @@
import { isEqual } from 'lodash';
import { getWorkpad, getFullWorkpadPersisted, getWorkpadPersisted } from '../selectors/workpad';
import { getAssetIds } from '../selectors/assets';
import { setWorkpad, setRefreshInterval } from '../actions/workpad';
import { appReady } from '../actions/app';
import { setWorkpad, setRefreshInterval, resetWorkpad } from '../actions/workpad';
import { setAssets, resetAssets } from '../actions/assets';
import * as transientActions from '../actions/transient';
import * as resolvedArgsActions from '../actions/resolved_args';
@ -28,6 +29,8 @@ const assetsChanged = (before, after) => {
export const esPersistMiddleware = ({ getState }) => {
// these are the actions we don't want to trigger a persist call
const skippedActions = [
appReady, // there's no need to resave the workpad once we've loaded it.
resetWorkpad, // used for resetting the workpad in state
setWorkpad, // used for loading and creating workpads
setAssets, // used when loading assets
resetAssets, // used when creating new workpads

View file

@ -6,6 +6,7 @@
import { handleActions } from 'redux-actions';
import { recentlyAccessed } from 'ui/persisted_log';
import { getDefaultWorkpad } from '../defaults';
import {
setWorkpad,
sizeWorkpad,
@ -13,6 +14,7 @@ import {
setName,
setWriteable,
setWorkpadCSS,
resetWorkpad,
} from '../actions/workpad';
import { APP_ROUTE_WORKPAD } from '../../../common/lib/constants';
@ -44,6 +46,8 @@ export const workpadReducer = handleActions(
[setWorkpadCSS]: (workpadState, { payload }) => {
return { ...workpadState, css: payload };
},
[resetWorkpad]: () => ({ ...getDefaultWorkpad() }),
},
{}
);

View file

@ -5,7 +5,7 @@
@import 'main';
// Canvas apps
@import '../apps/home/home_app';
@import '../apps/home/home_app/home_app';
@import '../apps/workpad/workpad_app/workpad_app';
@import '../apps/export/export/export_app';