EnxDev commented on code in PR #28370:
URL: https://github.com/apache/superset/pull/28370#discussion_r1593693631
##########
superset-frontend/src/components/Chart/Chart.tsx:
##########
@@ -40,69 +41,71 @@ import ChartRenderer from './ChartRenderer';
import { ChartErrorMessage } from './ChartErrorMessage';
import { getChartRequiredFieldsMissingMessage } from
'../../utils/getChartRequiredFieldsMissingMessage';
-const propTypes = {
- annotationData: PropTypes.object,
- actions: PropTypes.object,
- chartId: PropTypes.number.isRequired,
- datasource: PropTypes.object,
- // current chart is included by dashboard
- dashboardId: PropTypes.number,
- // original selected values for FilterBox viz
- // so that FilterBox can pre-populate selected values
- // only affect UI control
- initialValues: PropTypes.object,
- // formData contains chart's own filter parameter
- // and merged with extra filter that current dashboard applying
- formData: PropTypes.object.isRequired,
- labelColors: PropTypes.object,
- sharedLabelColors: PropTypes.object,
- width: PropTypes.number,
- height: PropTypes.number,
- setControlValue: PropTypes.func,
- timeout: PropTypes.number,
- vizType: PropTypes.string.isRequired,
- triggerRender: PropTypes.bool,
- force: PropTypes.bool,
- isFiltersInitialized: PropTypes.bool,
- // state
- chartAlert: PropTypes.string,
- chartStatus: PropTypes.string,
- chartStackTrace: PropTypes.string,
- queriesResponse: PropTypes.arrayOf(PropTypes.object),
- triggerQuery: PropTypes.bool,
- chartIsStale: PropTypes.bool,
- errorMessage: PropTypes.node,
- // dashboard callbacks
- addFilter: PropTypes.func,
- onQuery: PropTypes.func,
- onFilterMenuOpen: PropTypes.func,
- onFilterMenuClose: PropTypes.func,
- ownState: PropTypes.object,
- postTransformProps: PropTypes.func,
- datasetsStatus: PropTypes.oneOf(['loading', 'error', 'complete']),
- isInView: PropTypes.bool,
- emitCrossFilters: PropTypes.bool,
-};
+export interface ChartProps {
+ annotationData?: object;
+ actions: any;
+ chartId: string;
+ datasource?: {
+ database?: {
+ name: string;
+ };
+ };
+ dashboardId?: number;
+ initialValues?: object;
+ formData: QueryFormData;
+ labelColors?: object;
+ sharedLabelColors?: object;
+ width: number;
+ height: number;
+ setControlValue: Function;
+ timeout?: number;
+ vizType: string;
+ triggerRender?: boolean;
+ force?: boolean;
+ isFiltersInitialized?: boolean;
+ chartAlert?: string;
+ chartStatus?: string;
+ chartStackTrace?: string;
+ queriesResponse?: queryResponse[];
+ triggerQuery?: boolean;
+ chartIsStale?: boolean;
+ errorMessage?: React.ReactNode;
+ addFilter?: Function;
+ onQuery?: MouseEventHandler<HTMLSpanElement>;
+ onFilterMenuOpen?: Function;
+ onFilterMenuClose?: Function;
+ ownState?: any;
+ postTransformProps?: Function;
+ datasetsStatus?: 'loading' | 'error' | 'complete';
+ isInView?: boolean;
+ emitCrossFilters?: boolean;
+ renderStartTime?: Date;
+}
+export type queryResponse = {
+ errors: SupersetError[];
+ message: string;
+ link: string;
+};
const BLANK = {};
const NONEXISTENT_DATASET = t(
'The dataset associated with this chart no longer exists',
);
-const defaultProps = {
+const defaultProps: Partial<ChartProps> = {
addFilter: () => BLANK,
onFilterMenuOpen: () => BLANK,
onFilterMenuClose: () => BLANK,
initialValues: BLANK,
- setControlValue() {},
+ setControlValue: () => BLANK,
triggerRender: false,
- dashboardId: null,
- chartStackTrace: null,
+ dashboardId: undefined,
+ chartStackTrace: undefined,
force: false,
isInView: true,
};
-const Styles = styled.div`
+const Styles = styled.div<{ height: number; width?: number }>`
Review Comment:
I removed it, thank you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]