-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Put formData in store #1281
Conversation
}, | ||
[actions.SET_HAVING_CLAUSE]() { | ||
return Object.assign({}, state, { havingClause: action.havingClause }); | ||
return { |
There was a problem hiding this comment.
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})
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:)
f82f5ce
to
59dfa38
Compare
</div> | ||
</div> | ||
const GroupBy = (props) => { | ||
const selects = []; |
There was a problem hiding this comment.
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
},
];
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:)
2ea9bbd
to
3a51d45
Compare
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, changed:)
3a51d45
to
184134e
Compare
nice PR! 🚢 💯 |
Done:
Todo:
will merge this first and modify PRs for other viz types
needs-review @ascott