chore: Migrates RefreshChartOverlay into Chart (#13274)

* Migrates RefreshChartOverlay into Chart

* Removes unused Chart width prop
This commit is contained in:
Michael S. Molina 2021-03-01 17:04:16 -03:00 committed by GitHub
parent 6028a691b7
commit a36c8336ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 66 deletions

View File

@ -19,15 +19,15 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import Alert from 'src/components/Alert'; import Alert from 'src/components/Alert';
import { styled, logging } from '@superset-ui/core'; import { styled, logging, t } from '@superset-ui/core';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import { Logger, LOG_ACTIONS_RENDER_CHART } from '../logger/LogUtils'; import Button from 'src/components/Button';
import Loading from '../components/Loading'; import Loading from '../components/Loading';
import RefreshChartOverlay from '../components/RefreshChartOverlay';
import ErrorBoundary from '../components/ErrorBoundary'; import ErrorBoundary from '../components/ErrorBoundary';
import ChartRenderer from './ChartRenderer'; import ChartRenderer from './ChartRenderer';
import { ChartErrorMessage } from './ChartErrorMessage'; import { ChartErrorMessage } from './ChartErrorMessage';
import { Logger, LOG_ACTIONS_RENDER_CHART } from '../logger/LogUtils';
const propTypes = { const propTypes = {
annotationData: PropTypes.object, annotationData: PropTypes.object,
@ -43,8 +43,8 @@ const propTypes = {
// formData contains chart's own filter parameter // formData contains chart's own filter parameter
// and merged with extra filter that current dashboard applying // and merged with extra filter that current dashboard applying
formData: PropTypes.object.isRequired, formData: PropTypes.object.isRequired,
height: PropTypes.number,
width: PropTypes.number, width: PropTypes.number,
height: PropTypes.number,
setControlValue: PropTypes.func, setControlValue: PropTypes.func,
timeout: PropTypes.number, timeout: PropTypes.number,
vizType: PropTypes.string.isRequired, vizType: PropTypes.string.isRequired,
@ -87,6 +87,17 @@ const Styles = styled.div`
} }
`; `;
const RefreshOverlayWrapper = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
`;
class Chart extends React.PureComponent { class Chart extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
@ -168,7 +179,6 @@ class Chart extends React.PureComponent {
render() { render() {
const { const {
width,
height, height,
chartAlert, chartAlert,
chartStatus, chartStatus,
@ -212,11 +222,11 @@ class Chart extends React.PureComponent {
</div> </div>
{!isLoading && !chartAlert && isFaded && ( {!isLoading && !chartAlert && isFaded && (
<RefreshChartOverlay <RefreshOverlayWrapper>
width={width} <Button onClick={onQuery} buttonStyle="primary">
height={height} {t('Run query')}
onQuery={onQuery} </Button>
/> </RefreshOverlayWrapper>
)} )}
{isLoading && <Loading />} {isLoading && <Loading />}

View File

@ -1,56 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { t, styled } from '@superset-ui/core';
import Button from 'src/components/Button';
type Callback = (...args: any[]) => void;
interface Props {
height: number;
width: number;
onQuery: Callback;
}
const RefreshOverlayWrapper = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
`;
class RefreshChartOverlay extends React.PureComponent<Props> {
render() {
return (
<RefreshOverlayWrapper>
<div>
<Button onClick={this.props.onQuery} buttonStyle="primary">
{t('Run query')}
</Button>
</div>
</RefreshOverlayWrapper>
);
}
}
export default RefreshChartOverlay;