Skip to content

Conversation

@vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Sep 27, 2016

Sorry I should have divided this to smaller PRs, will work on Todos in future smaller PR
needs-review @ascott

Done:

  • Endpoint for data attached to a datasource
  • Chart options, Time Filter, GroupBy, SQL and Filters component
  • redux-thunk for getting column options for one datasouce
  • actions/reducers for updating states from form-data
  • populates fields in control panel with url params retrieved from bootstrap_data.viz.form_data

Todo:

Side note:
data for slice stored in { bootstrapData.viz.data }
data for pre-populating form stored in { bootstrapData.viz.form_data }

@ascott ascott force-pushed the alanna-explore-v2-main branch from dcfb604 to b67906c Compare September 27, 2016 19:02
Alanna Scott and others added 3 commits September 27, 2016 12:18
* create structure for new forked explore view

* update component name

* add bootstrap data pattern

* remove console.log
* Created store and reducers

* Added spec

* Modifications based on comments
* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments
@vera-liu vera-liu force-pushed the vliu_explore_control branch 7 times, most recently from 50c5a95 to 29df846 Compare September 28, 2016 05:46
@vera-liu vera-liu force-pushed the vliu_explore_control branch 3 times, most recently from 02cc616 to f80bae7 Compare September 28, 2016 18:40
@vera-liu vera-liu changed the title Not ready for review yet...explore controls Explore control panel - Chart control, TimeFilter, GroupBy, Filters Sep 28, 2016
@vera-liu vera-liu force-pushed the vliu_explore_control branch from f80bae7 to ee61d17 Compare September 28, 2016 19:00
export const SET_ROW_LIMIT = 'SET_ROW_LIMIT';
export const TOGGLE_SEARCHBOX = 'TOGGLE_SEARCHBOX';
export const SET_FILTER_COLUMN_OPTS = 'SET_FILTER_COLUMN_OPTS';
export const SET_WHERE_CLAUSE = 'SET_SET_WHERE_CLAUSE';
Copy link

@ascott ascott Sep 28, 2016

Choose a reason for hiding this comment

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

extra SET_ in value

export const TOGGLE_SEARCHBOX = 'TOGGLE_SEARCHBOX';
export const SET_FILTER_COLUMN_OPTS = 'SET_FILTER_COLUMN_OPTS';
export const SET_WHERE_CLAUSE = 'SET_SET_WHERE_CLAUSE';
export const SET_HAVING_CLAUSE = 'SET_SET_HAVING_CLAUSE';
Copy link

Choose a reason for hiding this comment

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

same here

const timeGrainOpts = [];

if (datasourceId) {
const params = [];
Copy link

Choose a reason for hiding this comment

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

could simplify this to:

const params = [`datasource_id=${datasourceId}`, `datasource_type=${datasourceType}`];

import React from 'react';
import Select from 'react-select';
import { bindActionCreators } from 'redux';
import * as actions from '../actions/exploreActions';
Copy link

@ascott ascott Sep 28, 2016

Choose a reason for hiding this comment

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

rather than importing all actions here i would suggest just importing the ones needed for this component...

import { setFormOpts, setDatasource, resetFormData, setVizType }
  as actions from '../actions/exploreActions';

}

ChartControl.propTypes = {
actions: React.PropTypes.object,
Copy link

@ascott ascott Sep 28, 2016

Choose a reason for hiding this comment

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

i think it makes more sense to import the actions in this component rather than passing them in as props.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw Sqllab components were doing this, I think it's for mapDispatchToProps, so that we can bind action creators into one, then dispatch from the component props

class ChartControl extends React.Component {
componentWillMount() {
if (this.props.datasourceId) {
this.props.actions.setFormOpts(this.props.datasourceId, this.props.datasourceType);
Copy link

@ascott ascott Sep 28, 2016

Choose a reason for hiding this comment

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

once we import actions above we can use them like this:
setFormOpts(this.props.datasourceId, this.props.datasourceType);

makes more sense to import the actions in this component rather than passing them in as props.

Copy link
Contributor Author

@vera-liu vera-liu Sep 28, 2016

Choose a reason for hiding this comment

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

This didn't work.. Suggested by the redux doc here: http://redux.js.org/docs/basics/Actions.html#action-creators
We should bind action creators to dispatch() function, then map dispatch to component's props. I could still explicitly import actions like:
import { setFormOpts, setDatasource, resetFormData, setVizType } from '../actions/exploreActions';

and then do this in mapDispatchToProps:
actions: bindActionCreators({ setFormOpts, setDatasource, resetFormData, setVizType, }, dispatch),
But dispatching actions would still be the same:

this.props.actions.setDatasource(val);

Is there a better way to do this?
@ascott

Copy link

Choose a reason for hiding this comment

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

ah ok, maybe i am carrying over some Alt patterns that don't work in redux. so when you call bindActionCreators the actions are passed as props to the component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way I understand it is that bindActionCreators bind all action creators with dispatch function, so that we don't have to write redundant onClick() => dispatch(actionFunc()) statements. mapDispatchToProps() allows us to call dispatch function from the component's props, instead of accessing global store everytime we dispatch.

Copy link

Choose a reason for hiding this comment

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

👍

return { type: CLEAR_ALL_OPTS };
}

export function setFormOpts(datasourceId, datasourceType) {
Copy link

Choose a reason for hiding this comment

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

i think this function belongs in an actionCreators file but it we can change that in a subsequent pr

@has_access
@expose("/fetch_datasource_metadata")
@log_this
def fetch_datasource_metadata(self):
Copy link

Choose a reason for hiding this comment

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

doesn't @has_access do permission checking for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's only checking access to the endpoint, but we need access checking for datasource/slice here

Copy link

Choose a reason for hiding this comment

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

ah gotcha, good catch

return enhancer;
}

export const VIZ_TYPES = [
Copy link

Choose a reason for hiding this comment

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

i think this belongs in a explore/constants.js file


import { exploreReducer } from './reducers/exploreReducer';

const metrics = [];
Copy link

Choose a reason for hiding this comment

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

const metrics = [bootstrapData.viz.form_data.metric]

import * as actions from '../actions/exploreActions';
import { connect } from 'react-redux';

const sinceOptions = ['1 hour ago', '12 hours ago', '1 day ago',
Copy link

Choose a reason for hiding this comment

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

could move these time constants to explore/constants.js

}

TimeFilter.propTypes = {
actions: React.PropTypes.object,
Copy link

Choose a reason for hiding this comment

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

it's a nice pattern to put proptypes at the top of the file like this:

const propTypes = {
  actions: React.PropTypes.object,
  timeColumnOpts: React.PropTypes.array,
  timeColumn: React.PropTypes.string,
  timeGrainOpts: React.PropTypes.array,
  timeGrain: React.PropTypes.string,
  since: React.PropTypes.string,
  until: React.PropTypes.string,
};

const defaultProps = {
 ...
};

and then here at the bottom:

TimeFilter.propTypes = propTypes;
TimeFilter.defaultProps = defaultProps;

<Select
multi
name="select-since"
placeholder={'Select metrics'}
Copy link

Choose a reason for hiding this comment

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

don't need curly brackets here
placeholder="Select metrics"

actions: React.PropTypes.object,
};

SqlClause.defaultProps = {
Copy link

Choose a reason for hiding this comment

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

we can delete this if there are no default props

<Select
className="col-sm-6"
name="select-time-column"
placeholder={'Select a time column'}
Copy link

Choose a reason for hiding this comment

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

placeholder="Select a time column"

import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { getDevEnhancer } from '../../utils/common';
Copy link

@ascott ascott Sep 28, 2016

Choose a reason for hiding this comment

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

@ascott
Copy link

ascott commented Sep 28, 2016

this generally looking good!

i think we could improve the organization of our components, but that can be in a subsequent PR.
i like they way the redux docs use the pattern of container and presentational components: http://redux.js.org/docs/basics/UsageWithReact.html#implementing-components

seems like there maybe some conflicts with master, but we can resolve those once we merge this into alanna-explore-v2-main

another PR for the js tests would be 💯

🚢

@vera-liu vera-liu force-pushed the vliu_explore_control branch from 2ec83db to 6ad3bf7 Compare September 28, 2016 23:14
@vera-liu vera-liu merged commit c0e9d2b into apache:alanna-explore-v2-main Sep 29, 2016
@ascott
Copy link

ascott commented Sep 29, 2016

🎉

ascott pushed a commit that referenced this pull request Oct 4, 2016
* Explore control panel - Chart control, TimeFilter, GroupBy, Filters (#1205)

* create structure for new forked explore view (#1099)

* create structure for new forked explore view

* update component name

* add bootstrap data pattern

* remove console.log

* Associate version to entry files (#1060)

* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments

* Created store and reducers (#1108)

* Created store and reducers

* Added spec

* Modifications based on comments

* Explore control panel components: Chart control, Time filter, SQL,
GroupBy and Filters

* Modifications based on comments

* accommodate old and new explore urls

* move bootstrap data up in scope

* fix code climate issues

* fix long lines

* fix syntax error
vera-liu added a commit to vera-liu/caravel that referenced this pull request Oct 4, 2016
…pache#1205)

* create structure for new forked explore view (apache#1099)

* create structure for new forked explore view

* update component name

* add bootstrap data pattern

* remove console.log

* Associate version to entry files (apache#1060)

* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments

* Created store and reducers (apache#1108)

* Created store and reducers

* Added spec

* Modifications based on comments

* Explore control panel components: Chart control, Time filter, SQL,
GroupBy and Filters

* Modifications based on comments
vera-liu added a commit that referenced this pull request Oct 4, 2016
* Explore control panel - Chart control, TimeFilter, GroupBy, Filters (#1205)

* create structure for new forked explore view (#1099)

* create structure for new forked explore view

* update component name

* add bootstrap data pattern

* remove console.log

* Associate version to entry files (#1060)

* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments

* Created store and reducers (#1108)

* Created store and reducers

* Added spec

* Modifications based on comments

* Explore control panel components: Chart control, Time filter, SQL,
GroupBy and Filters

* Modifications based on comments

* Added access check + Druid in endpoint

* pull grains to constants

* Switch explore.html to old version
vera-liu added a commit to vera-liu/caravel that referenced this pull request Oct 4, 2016
…pache#1205)

* create structure for new forked explore view (apache#1099)

* create structure for new forked explore view

* update component name

* add bootstrap data pattern

* remove console.log

* Associate version to entry files (apache#1060)

* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments

* Created store and reducers (apache#1108)

* Created store and reducers

* Added spec

* Modifications based on comments

* Explore control panel components: Chart control, Time filter, SQL,
GroupBy and Filters

* Modifications based on comments
@dpgaspar dpgaspar mentioned this pull request Dec 9, 2019
12 tasks
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
…pache#1205)

* fix(plugin-chart-echarts): x-filtering improvement for radar chart

* fix(plugin-chart-echarts): opacity constants

* fix(plugin-chart-echarts): improve constant

* fix(plugin-chart-echarts): place treemap constant
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
…pache#1205)

* fix(plugin-chart-echarts): x-filtering improvement for radar chart

* fix(plugin-chart-echarts): opacity constants

* fix(plugin-chart-echarts): improve constant

* fix(plugin-chart-echarts): place treemap constant
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
…pache#1205)

* fix(plugin-chart-echarts): x-filtering improvement for radar chart

* fix(plugin-chart-echarts): opacity constants

* fix(plugin-chart-echarts): improve constant

* fix(plugin-chart-echarts): place treemap constant
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
…pache#1205)

* fix(plugin-chart-echarts): x-filtering improvement for radar chart

* fix(plugin-chart-echarts): opacity constants

* fix(plugin-chart-echarts): improve constant

* fix(plugin-chart-echarts): place treemap constant
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 First shipped in 1.5.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 🚢 1.5.0 First shipped in 1.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants