Skip to content

Commit

Permalink
refactor(explore): convert ControlPanelsContainer to typescript (#13221)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud authored Feb 28, 2021
1 parent 892eef1 commit 3c62069
Show file tree
Hide file tree
Showing 27 changed files with 386 additions and 327 deletions.
2 changes: 2 additions & 0 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = {
'no-mixed-operators': 0,
'no-multi-assign': 0,
'no-multi-spaces': 0,
'no-nested-ternary': 0,
'no-prototype-builtins': 0,
'no-restricted-properties': 0,
'no-restricted-imports': [
Expand Down Expand Up @@ -226,6 +227,7 @@ module.exports = {
'no-mixed-operators': 0,
'no-multi-assign': 0,
'no-multi-spaces': 0,
'no-nested-ternary': 0,
'no-prototype-builtins': 0,
'no-restricted-properties': 0,
'no-restricted-imports': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,3 @@ describe('Advanced analytics', () => {
.contains('1 year');
});
});

describe('Annotations', () => {
beforeEach(() => {
cy.login();
cy.intercept('GET', '/superset/explore_json/**').as('getJson');
cy.intercept('POST', '/superset/explore_json/**').as('postJson');
});

it('Create formula annotation y-axis goal line', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

cy.get('[data-test=annotation_layers]').within(() => {
cy.get('button').click();
});

cy.get('[data-test="popover-content"]').within(() => {
cy.get('[data-test=annotation-layer-name-header]')
.siblings()
.first()
.within(() => {
cy.get('input').type('Goal line');
});
cy.get('[data-test=annotation-layer-value-header]')
.siblings()
.first()
.within(() => {
cy.get('input').type('y=1400000');
});
cy.get('button').contains('OK').click({ force: true });
});

cy.get('button[data-test="run-query-button"]').click();
cy.verifySliceSuccess({
waitAlias: '@postJson',
chartSelector: 'svg',
});

cy.get('.nv-legend-text').should('have.length', 2);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.
*/
describe('Annotations', () => {
beforeEach(() => {
cy.login();
cy.intercept('GET', '/superset/explore_json/**').as('getJson');
cy.intercept('POST', '/superset/explore_json/**').as('postJson');
});

it('Create formula annotation y-axis goal line', () => {
cy.visitChartByName('Num Births Trend');
cy.verifySliceSuccess({ waitAlias: '@postJson' });

const layerLabel = 'Goal line';

cy.get('[data-test=annotation_layers] button').click();

cy.get('[data-test="popover-content"]').within(() => {
cy.get('[data-test=annotation-layer-name-header]')
.siblings()
.first()
.within(() => {
cy.get('input').type(layerLabel);
});
cy.get('[data-test=annotation-layer-value-header]')
.siblings()
.first()
.within(() => {
cy.get('input').type('y=1400000');
});
cy.get('button').contains('OK').click();
});

cy.get('button[data-test="run-query-button"]').click();
cy.get('[data-test=annotation_layers]').contains(layerLabel);

cy.verifySliceSuccess({
waitAlias: '@postJson',
chartSelector: 'svg',
});
cy.get('.nv-legend-text').should('have.length', 2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Visualization > Pivot Table', () => {
adhoc_filters: [],
groupby: ['name'],
columns: ['state'],
row_limit: 50000,
row_limit: 5000,
pandas_aggfunc: 'sum',
pivot_margins: true,
number_format: '.3s',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { getChartControlPanelRegistry, t } from '@superset-ui/core';
import {
DatasourceType,
getChartControlPanelRegistry,
t,
} from '@superset-ui/core';
import { defaultControls } from 'src/explore/store';
import { getFormDataFromControls } from 'src/explore/controlUtils';
import { ControlPanelsContainer } from 'src/explore/components/ControlPanelsContainer';
import {
ControlPanelsContainer,
ControlPanelsContainerProps,
} from 'src/explore/components/ControlPanelsContainer';
import Collapse from 'src/common/components/Collapse';

describe('ControlPanelsContainer', () => {
Expand Down Expand Up @@ -78,15 +85,15 @@ describe('ControlPanelsContainer', () => {
});

function getDefaultProps() {
const controls = defaultControls as ControlPanelsContainerProps['controls'];
return {
datasource_type: 'table',
datasource_type: DatasourceType.Table,
actions: {},
controls: defaultControls,
// Note: default viz_type is table
form_data: getFormDataFromControls(defaultControls),
controls,
form_data: getFormDataFromControls(controls),
isDatasourceMetaLoading: false,
exploreState: {},
};
} as ControlPanelsContainerProps;
}

it('renders ControlPanelSections', () => {
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
export const DATETIME_WITH_TIME_ZONE = 'YYYY-MM-DD HH:mm:ssZ';

export const TIME_WITH_MS = 'HH:mm:ss.SSS';

export const BOOL_TRUE_DISPLAY = 'True';
Expand Down
8 changes: 1 addition & 7 deletions superset-frontend/src/explore/actions/exploreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const SET_FIELD_VALUE = 'SET_FIELD_VALUE';
export function setControlValue(
controlName: string,
value: any,
validationErrors: any[],
validationErrors?: any[],
) {
return { type: SET_FIELD_VALUE, controlName, value, validationErrors };
}
Expand All @@ -109,11 +109,6 @@ export function setExploreControls(formData: QueryFormData) {
return { type: SET_EXPLORE_CONTROLS, formData };
}

export const REMOVE_CONTROL_PANEL_ALERT = 'REMOVE_CONTROL_PANEL_ALERT';
export function removeControlPanelAlert() {
return { type: REMOVE_CONTROL_PANEL_ALERT };
}

export const UPDATE_CHART_TITLE = 'UPDATE_CHART_TITLE';
export function updateChartTitle(sliceName: string) {
return { type: UPDATE_CHART_TITLE, sliceName };
Expand Down Expand Up @@ -154,7 +149,6 @@ export const exploreActions = {
saveFaveStar,
setControlValue,
setExploreControls,
removeControlPanelAlert,
updateChartTitle,
createNewSlice,
sliceUpdated,
Expand Down
Loading

0 comments on commit 3c62069

Please sign in to comment.