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

Put formData in store #1281

Merged
merged 4 commits into from Oct 7, 2016
Merged

Conversation

vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Oct 7, 2016

Done:

  • added viz, formData into store with same structure as bootstrapData.viz and form_data
  • rewrite reducers and action creators for new structured store
  • Added SelectArray component
    Todo:
  • do this for other vizTypes
  • rewrite tests for reducers

will merge this first and modify PRs for other viz types

needs-review @ascott

},
[actions.SET_HAVING_CLAUSE]() {
return Object.assign({}, state, { havingClause: action.havingClause });
return {
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 a lot of code repitition, what about defining the function setFormData that will modify the state for the form data
return setFormData({having: action.having})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

whereClause: bootstrapData.viz.form_data.where,
viz: {
formData: {
sliceId: bootstrapData.viz.form_data.slice_id,
Copy link
Member

Choose a reason for hiding this comment

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

I like @mistercrunch approach to the
formData=bootstrapData and make sure that bootstrapData returned from the server complies to the UI expectations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is for transferring variable names from snake_case to camelCase for javascript conventions. We haven't concluded the best way for this yet. Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bkyryliuk what do you mean about making sure the data complies to the UI expectations? can you clarify?

Copy link
Member

Choose a reason for hiding this comment

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

it's fine to format the json output in the camel case on python side.

where: null,
columns: [],
orderings: [],
rowLimit: 50000,
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to move this const to the backend - into the caravel config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for bringing it up! I will issue a separate PR for setting all the default values in store based on what we have in forms.py :)

columns: [],
orderings: [],
rowLimit: 50000,
timeStampFormat: 'smart_date',
Copy link
Member

Choose a reason for hiding this comment

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

ditto

searchBox: false,
whereClause: '',
havingClause: '',
filters: [],
filterColumnOpts: [],
viz: {
formData: {
Copy link
Member

Choose a reason for hiding this comment

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

could you do defaultFormData: defaultFormData ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

</div>
</div>
const GroupBy = (props) => {
const selects = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

we can assign these select objects directly, rather than using .push

also, we could make use of the spread operator here for the common keys for each select.

const commonOpts = {
  multi: true,
  width: '12',
};

const selects = [
  {
    key: 'groupByColumns',
    title: 'Group By',
    options: props.groupByColumnOpts,
    value: props.groupByColumns,
    ...commonOpts
 },
 {
    key: 'metrics',
    title: 'Metrics',
    options: props.metricsOpts,
    value: props.metrics,
    ...commonOpts
  },
];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

const selects = [];
selects.push({
key: 'groupByColumns',
title: 'GroupBy Column',
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be Group By rather then GroupBy Column?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

width: '12',
});
return (
<div className="panel space-1">
Copy link
Contributor

@ascott ascott Oct 7, 2016

Choose a reason for hiding this comment

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

i don't think space-1 is a util class bootstrap has... we could add these utils to cosmo/bootswatch.less

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

title: 'Orderings',
options: props.orderingOpts,
value: props.orderings,
multi: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since most of the selects use the same multi and width values, could we add them as default values in the SelectArray component?

</div>
const TimeFilter = (props) => {
const timeColumnTitle =
(props.datasourceType === 'table') ? 'Time Column' : 'Time Granularity';
Copy link
Contributor

Choose a reason for hiding this comment

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

could DRY this up to

const isDatasourceTypeTable = props.datasourceType === 'table'
const timeColumnTitle = isDatasourceTypeTable ? 'Time Column' : 'Time Granularity';
const timeGrainTitle = isDatasourceTypeTable ? 'Time Grain' : 'Origin';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

@vera-liu
Copy link
Contributor Author

vera-liu commented Oct 7, 2016

Emailed codeclimate's support team for the syntax error

@@ -2,71 +2,50 @@ import { defaultFormData, defaultOpts } from '../stores/store';
import * as actions from '../actions/exploreActions';
import { addToArr, removeFromArr, alterInArr } from '../../../utils/reducerUtils';

const setFormInViz = function (state, action) {
const newForm = Object.assign({}, state);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be called newFormData for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, changed:)

@ascott
Copy link
Contributor

ascott commented Oct 7, 2016

nice PR! 🚢 💯

@vera-liu vera-liu merged commit b7d1f78 into apache:master Oct 7, 2016
@dpgaspar dpgaspar mentioned this pull request Feb 19, 2020
12 tasks
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants