-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created store and reducers * Added spec * Modifications based on comments
- Loading branch information
Showing
13 changed files
with
419 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
caravel/assets/javascripts/explorev2/actions/exploreActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
export const SET_DATASOURCE = 'SET_DATASOURCE'; | ||
export const SET_VIZTYPE = 'SET_VIZTYPE'; | ||
export const SET_TIME_FILTER = 'SET_TIME_FILTER'; | ||
export const SET_GROUPBY = 'SET_GROUPBY'; | ||
export const ADD_COLUMN = 'ADD_COLUMN'; | ||
export const REMOVE_COLUMN = 'REMOVE_COLUMN'; | ||
export const ADD_ORDERING = 'ADD_ORDERING'; | ||
export const REMOVE_ORDERING = 'REMOVE_ORDERING'; | ||
export const SET_TIME_STAMP = 'SET_TIME_STAMP'; | ||
export const SET_ROW_LIMIT = 'SET_ROW_LIMIT'; | ||
export const TOGGLE_SEARCHBOX = 'TOGGLE_SEARCHBOX'; | ||
export const SET_SQL = 'SET_SQL'; | ||
export const ADD_FILTER = 'ADD_FILTER'; | ||
export const SET_FILTER = 'SET_FILTER'; | ||
export const REMOVE_FILTER = 'REMOVE_FILTER'; | ||
|
||
export function setDatasource(datasourceId) { | ||
return { type: SET_DATASOURCE, datasourceId }; | ||
} | ||
|
||
export function setVizType(vizType) { | ||
return { type: SET_VIZTYPE, vizType }; | ||
} | ||
|
||
export function setTimeFilter(timeFilter) { | ||
return { type: SET_TIME_FILTER, timeFilter }; | ||
} | ||
|
||
export function setGroupBy(groupBy) { | ||
return { type: SET_GROUPBY, groupBy }; | ||
} | ||
|
||
export function addColumn(column) { | ||
return { type: ADD_COLUMN, column }; | ||
} | ||
|
||
export function removeColumn(column) { | ||
return { type: REMOVE_COLUMN, column }; | ||
} | ||
|
||
export function addOrdering(ordering) { | ||
return { type: ADD_ORDERING, ordering }; | ||
} | ||
|
||
export function removeOrdering(ordering) { | ||
return { type: REMOVE_ORDERING, ordering }; | ||
} | ||
|
||
export function setTimeStamp(timeStampFormat) { | ||
return { type: SET_TIME_STAMP, timeStampFormat }; | ||
} | ||
|
||
export function setRowLimit(rowLimit) { | ||
return { type: SET_ROW_LIMIT, rowLimit }; | ||
} | ||
|
||
export function toggleSearchBox(searchBox) { | ||
return { type: TOGGLE_SEARCHBOX, searchBox }; | ||
} | ||
|
||
export function setSQL(sql) { | ||
return { type: SET_SQL, sql }; | ||
} | ||
|
||
export function addFilter(filter) { | ||
return { type: ADD_FILTER, filter }; | ||
} | ||
|
||
export function removeFilter(filter) { | ||
return { type: REMOVE_FILTER, filter }; | ||
} |
17 changes: 8 additions & 9 deletions
17
caravel/assets/javascripts/explorev2/components/ChartContainer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import React from 'react'; | ||
import { Panel } from 'react-bootstrap'; | ||
|
||
export default class ChartContainer extends React.Component { | ||
render() { | ||
return ( | ||
<Panel header="Chart title"> | ||
chart goes here | ||
</Panel> | ||
); | ||
} | ||
} | ||
const ChartContainer = function () { | ||
return ( | ||
<Panel header="Chart title"> | ||
chart goes here | ||
</Panel> | ||
); | ||
}; | ||
export default ChartContainer; |
17 changes: 8 additions & 9 deletions
17
caravel/assets/javascripts/explorev2/components/ControlPanelsContainer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import React from 'react'; | ||
import { Panel } from 'react-bootstrap'; | ||
|
||
export default class ControlPanelsContainer extends React.Component { | ||
render() { | ||
return ( | ||
<Panel> | ||
control panels here | ||
</Panel> | ||
); | ||
} | ||
} | ||
const ControlPanelsContainer = function () { | ||
return ( | ||
<Panel> | ||
control panels here | ||
</Panel> | ||
); | ||
}; | ||
export default ControlPanelsContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
caravel/assets/javascripts/explorev2/reducers/exploreReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import * as actions from '../actions/exploreActions'; | ||
import { addToArr, removeFromArr } from '../../../utils/reducerUtils'; | ||
|
||
export const exploreReducer = function (state, action) { | ||
const actionHandlers = { | ||
[actions.SET_DATASOURCE]() { | ||
return Object.assign({}, state, { datasourceId: action.datasourceId }); | ||
}, | ||
[actions.SET_VIZTYPE]() { | ||
return Object.assign({}, state, { vizType: action.vizType }); | ||
}, | ||
[actions.SET_TIME_FILTER]() { | ||
return Object.assign({}, state, { timeFilter: action.timeFilter }); | ||
}, | ||
[actions.SET_GROUPBY]() { | ||
return Object.assign({}, state, { groupBy: action.groupBy }); | ||
}, | ||
[actions.ADD_COLUMN]() { | ||
return Object.assign({}, state, { columns: [...state.columns, action.column] }); | ||
}, | ||
[actions.REMOVE_COLUMN]() { | ||
const newColumns = []; | ||
state.columns.forEach((c) => { | ||
if (c !== action.column) { | ||
newColumns.push(c); | ||
} | ||
}); | ||
return Object.assign({}, state, { columns: newColumns }); | ||
}, | ||
[actions.ADD_ORDERING]() { | ||
return Object.assign({}, state, { orderings: [...state.orderings, action.ordering] }); | ||
}, | ||
[actions.REMOVE_ORDERING]() { | ||
const newOrderings = []; | ||
state.orderings.forEach((o) => { | ||
if (o !== action.ordering) { | ||
newOrderings.push(o); | ||
} | ||
}); | ||
return Object.assign({}, state, { orderings: newOrderings }); | ||
}, | ||
[actions.SET_TIME_STAMP]() { | ||
return Object.assign({}, state, { timeStampFormat: action.timeStampFormat }); | ||
}, | ||
[actions.SET_ROW_LIMIT]() { | ||
return Object.assign({}, state, { rowLimit: action.rowLimit }); | ||
}, | ||
[actions.TOGGLE_SEARCHBOX]() { | ||
return Object.assign({}, state, { searchBox: action.searchBox }); | ||
}, | ||
[actions.SET_SQL]() { | ||
return Object.assign({}, state, { SQL: action.sql }); | ||
}, | ||
[actions.ADD_FILTER]() { | ||
return addToArr(state, 'filters', action.filter); | ||
}, | ||
[actions.REMOVE_FILTER]() { | ||
return removeFromArr(state, 'filters', action.filter); | ||
}, | ||
}; | ||
if (action.type in actionHandlers) { | ||
return actionHandlers[action.type](); | ||
} | ||
return state; | ||
}; |
Oops, something went wrong.