Fixes loading component (#25819) (#25876)

* Removes redux selectors from loading component. Fixes how loading accesses page background color

* Fixed props
This commit is contained in:
Catherine Liu 2018-11-19 14:47:09 -07:00 committed by GitHub
parent 1edb9a9bc8
commit a9bde972d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 14 deletions

View file

@ -16,10 +16,7 @@ import {
EuiButton,
EuiFieldText,
} from '@elastic/eui';
// TODO: (clintandrewhall) This is a quick fix for #25342 -- we should figure out how to use the overall component.
import { Loading } from '../../../../public/components/loading/loading';
import { Loading } from '../../../../public/components/loading';
import { FileUpload } from '../../../../public/components/file_upload';
import { elasticOutline } from '../../../lib/elastic_outline';
import { resolveFromArgs } from '../../../../common/lib/resolve_dataurl';

View file

@ -23,8 +23,7 @@ const branches = [
// no renderable or renderable config value, render loading
branch(({ renderable, state }) => {
return !state || !renderable;
}, renderComponent(Loading)),
}, renderComponent(({ backgroundColor }) => <Loading backgroundColor={backgroundColor} />)),
// renderable is available, but no matching element is found, render invalid
branch(({ renderable, renderFunction }) => {
return renderable && getType(renderable) !== 'render' && !renderFunction;
@ -90,4 +89,5 @@ ElementContent.propTypes = {
onComplete: PropTypes.func.isRequired, // local, not passed through
}).isRequired,
state: PropTypes.string,
backgroundColor: PropTypes.string,
};

View file

@ -5,12 +5,19 @@
*/
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose, withProps } from 'recompose';
import { get } from 'lodash';
import { renderFunctionsRegistry } from '../../lib/render_functions_registry';
import { getSelectedPage, getPageById } from '../../state/selectors/workpad';
import { ElementContent as Component } from './element_content';
const mapStateToProps = state => ({
backgroundColor: getPageById(state, getSelectedPage(state)).style.background,
});
export const ElementContent = compose(
connect(mapStateToProps),
withProps(({ renderable }) => ({
renderFunction: renderFunctionsRegistry.get(get(renderable, 'as')),
}))

View file

@ -4,12 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { connect } from 'react-redux';
import { getSelectedPage, getPageById } from '../../state/selectors/workpad';
import { pure } from 'recompose';
import { Loading as Component } from './loading';
const mapStateToProps = state => ({
backgroundColor: getPageById(state, getSelectedPage(state)).style.background,
});
export const Loading = connect(mapStateToProps)(Component);
export const Loading = pure(Component);

View file

@ -41,11 +41,12 @@ export const Loading = ({ animated, text, backgroundColor }) => {
Loading.propTypes = {
animated: PropTypes.bool,
text: PropTypes.string,
backgroundColor: PropTypes.string,
text: PropTypes.string,
};
Loading.defaultProps = {
animated: false,
backgroundColor: '#000000',
text: '',
};