Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement new version of word cloud #9962

Merged
merged 1 commit into from Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,7 +23,7 @@ import DashboardFilterTest from './filter';
import DashboardLoadTest from './load';
import DashboardSaveTest from './save';
import DashboardTabsTest from './tabs';
import DashboardUrlParamsTest from './url_params';
import DashboardFormDataTest from './url_params';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to rename this file to formData.js, but a recently added linting rule preferring TypeScript threw a weird exception that I didn't have time to debug now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you get a screenshot of the exception? It's supposed to post a comment but not block merge if a new js file is added, maybe i missed something though?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etr2460 I don't think it was throwing a normal comment, it looked more like it borked somehow. Let me redo the rename so we can get a screenshot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is: image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes... so one of the actions the workflow was depending on didn't work :( it doesn't block the PR merge though, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like someone else reported this as well (2 hours ago) trilom/file-changes-action#100. I'll wait a few days to see if it gets resolved, otherwise, i can remove the workflow and try to fix it since it's not required to pass

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good to know it's a known bug. I can do the rename in a separate PR if we want to debug this further, but for now I'll leave the rename out of this PR.


describe('Dashboard', () => {
DashboardControlsTest();
Expand All @@ -33,5 +33,5 @@ describe('Dashboard', () => {
DashboardLoadTest();
DashboardSaveTest();
DashboardTabsTest();
DashboardUrlParamsTest();
DashboardFormDataTest();
});
Expand Up @@ -19,7 +19,7 @@
import { WORLD_HEALTH_DASHBOARD } from './dashboard.helper';

export default () =>
describe('dashboard url params', () => {
describe('dashboard form data', () => {
const urlParams = { param1: '123', param2: 'abc' };
let sliceIds = [];
let dashboardId;
Expand All @@ -38,7 +38,7 @@ export default () =>
});
});

it('should apply url params to slice requests', () => {
it('should apply url params and queryFields to slice requests', () => {
const aliases = [];
sliceIds.forEach(id => {
const alias = `getJson_${id}`;
Expand All @@ -53,6 +53,7 @@ export default () =>
requests.forEach(xhr => {
const requestFormData = xhr.request.body;
const requestParams = JSON.parse(requestFormData.get('form_data'));
expect(requestParams).to.have.property('queryFields');
expect(requestParams.url_params).deep.eq(urlParams);
});
});
Expand Down
19 changes: 10 additions & 9 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions superset-frontend/package.json
Expand Up @@ -63,7 +63,7 @@
"@superset-ui/chart-composition": "^0.13.5",
"@superset-ui/color": "^0.13.3",
"@superset-ui/connection": "^0.13.5",
"@superset-ui/control-utils": "^0.13.12",
"@superset-ui/control-utils": "^0.13.21",
"@superset-ui/core": "^0.13.5",
"@superset-ui/dimension": "^0.13.3",
"@superset-ui/legacy-plugin-chart-calendar": "^0.13.6",
Expand Down Expand Up @@ -91,9 +91,9 @@
"@superset-ui/legacy-preset-chart-deckgl": "^0.2.3",
"@superset-ui/legacy-preset-chart-nvd3": "^0.13.23",
"@superset-ui/number-format": "^0.13.3",
"@superset-ui/plugin-chart-word-cloud": "^0.13.9",
"@superset-ui/plugin-chart-word-cloud": "^0.13.24",
"@superset-ui/preset-chart-xy": "^0.13.11",
"@superset-ui/query": "^0.13.6",
"@superset-ui/query": "^0.13.21",
"@superset-ui/style": "^0.13.11",
"@superset-ui/time-format": "^0.13.15",
"@superset-ui/translation": "^0.13.3",
Expand Down
Expand Up @@ -109,7 +109,7 @@ describe('controlUtils', () => {
name: 'all_columns',
config: {
type: 'SelectControl',
controlGroup: 'columns',
queryField: 'columns',
multi: true,
label: t('Columns'),
default: [],
Expand Down Expand Up @@ -250,11 +250,11 @@ describe('controlUtils', () => {
});
});

describe('controlGroup', () => {
describe('queryFields', () => {
it('in formData', () => {
const controlsState = getAllControlsState('table', 'table', {}, {});
const formData = getFormDataFromControls(controlsState);
expect(formData.controlGroups).toEqual({ all_columns: 'columns' });
expect(formData.queryFields).toEqual({ all_columns: 'columns' });
});
});
});
3 changes: 3 additions & 0 deletions superset-frontend/spec/javascripts/explore/store_spec.jsx
Expand Up @@ -68,13 +68,16 @@ describe('store', () => {
});

it('removes out of scope, or deprecated keys', () => {
const staleQueryFields = { staleKey: 'staleValue' };
const inputFormData = {
datasource: '11_table',
viz_type: 'table',
queryFields: staleQueryFields,
this_should_no_be_here: true,
};
const outputFormData = applyDefaultFormData(inputFormData);
expect(outputFormData.this_should_no_be_here).toBe(undefined);
expect(outputFormData.queryFields).not.toBe(staleQueryFields);
});
});
});
7 changes: 3 additions & 4 deletions superset-frontend/src/explore/controlUtils.js
Expand Up @@ -21,13 +21,12 @@ import { controls as SHARED_CONTROLS } from './controls';
import * as SECTIONS from './controlPanels/sections';

export function getFormDataFromControls(controlsState) {
const formData = {};
formData.controlGroups = {};
const formData = { queryFields: {} };
Object.keys(controlsState).forEach(controlName => {
const control = controlsState[controlName];
formData[controlName] = control.value;
if (control.hasOwnProperty('controlGroup')) {
formData.controlGroups[controlName] = control.controlGroup;
if (control.hasOwnProperty('queryField')) {
formData.queryFields[controlName] = control.queryField;
}
});
return formData;
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/explore/controls.jsx
Expand Up @@ -125,7 +125,7 @@ const timeColumnOption = {

const groupByControl = {
type: 'SelectControl',
controlGroup: 'groupby',
queryField: 'groupby',
multi: true,
freeForm: true,
label: t('Group by'),
Expand Down Expand Up @@ -157,7 +157,7 @@ const groupByControl = {

const metrics = {
type: 'MetricsControl',
controlGroup: 'metrics',
queryField: 'metrics',
multi: true,
label: t('Metrics'),
validators: [validateNonEmpty],
Expand Down
7 changes: 5 additions & 2 deletions superset-frontend/src/explore/store.js
Expand Up @@ -67,16 +67,19 @@ export function applyDefaultFormData(inputFormData) {
const controlsState = getAllControlsState(vizType, datasourceType, null, {
...inputFormData,
});
const formData = {};
const controlFormData = getFormDataFromControls(controlsState);

const formData = {};
Object.keys(controlsState).forEach(controlName => {
if (inputFormData[controlName] === undefined) {
formData[controlName] = controlsState[controlName].value;
formData[controlName] = controlFormData[controlName];
} else {
formData[controlName] = inputFormData[controlName];
}
});

// always use dynamically generated queryFields
formData.queryFields = controlFormData.queryFields;
return formData;
}

Expand Down