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

fix: 🐛 Switching off titles #231

Merged
merged 1 commit into from
Dec 16, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/actions/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export const DRAG_START_HANDLER = 'DRAG_START_HANDLER';

export const DROP_HANDLER = 'DROP_HANDLER';

export const CHANGE_CHART_TITLE = 'CHANGE_CHART_TITLE';

export const CHANGE_CHART_SUBTITLE = 'CHANGE_CHART_SUBTITLE';

export const SET_LOADING = 'SET_LOADING';

export const SELECT_SAVED_QUERY = 'SELECT_SAVED_QUERY';
Expand Down
12 changes: 0 additions & 12 deletions lib/actions/rootActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ export const dropHandler = newElement => ({
newElement
});

export const changeChartTitle = (title, index) => ({
type: actions.CHANGE_CHART_TITLE,
title,
index
});

export const changeChartSubitle = (subtitle, index) => ({
type: actions.CHANGE_CHART_SUBTITLE,
subtitle,
index
});

export const setLoading = index => ({
type: actions.SET_LOADING,
index
Expand Down
5 changes: 4 additions & 1 deletion lib/builder/components/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class Chart extends Component {
!_.isEqual(this.props.point, nextProps.point) ||
!_.isEqual(this.props.choropleth, nextProps.choropleth) ||
!_.isEqual(this.props.heatmap, nextProps.heatmap) ||
!_.isEqual(this.props.funnel, nextProps.funnel)
!_.isEqual(this.props.funnel, nextProps.funnel) ||
this.props.title !== nextProps.title ||
this.props.subtitle !== nextProps.subtitle ||
!_.isEqual(this.props.axis, nextProps.axis)
) {
return true;
}
Expand Down
97 changes: 0 additions & 97 deletions lib/builder/components/ChartContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import {
changeChartTitle,
changeChartSubitle,
loadSavedQuery,
savedQueryError,
setLoading
Expand Down Expand Up @@ -166,77 +164,16 @@ class ChartContainer extends Component {

render() {
const {
chartTitle,
chartSubtitle,
index,
legend,
sparkline,
stacking,
isLoading,
dryRun,
version,
error,
showPoints,
pointsSize,
mapChoropleth,
borderChoropleth,
borderSizeChoropleth,
slidersChoropleth,
slidersHeatmap,
heatmapTooltipValue,
template,
id,
charts_theme
} = this.props;
const { loading, results, type } = this.state;
if (
chartTitle === undefined &&
results &&
results.metadata &&
results.metadata.display_name
) {
const displayName = results.metadata.display_name;
this.props.changeChartTitle(displayName, index);
}

const pointSettings = {
show: showPoints ? !!showPoints.value : true,
r: pointsSize ? pointsSize.value : 2.5
};

const choroplethSettings = {
map: mapChoropleth ? mapChoropleth.value : 'world',
borders: {
show: borderChoropleth ? borderChoropleth.value : true,
size: borderSizeChoropleth ? borderSizeChoropleth.value : 0.5
},
showSlider: slidersChoropleth ? slidersChoropleth.value : false
};

const heatmapSettings = {
showSlider: slidersHeatmap ? slidersHeatmap.value : false,
simpleTooltip: heatmapTooltipValue ? heatmapTooltipValue.value : false
};

const title =
template && template['title.show'] ? template['title.text'] : false;
const subtitle =
template && template['subtitle.show'] ? template['subtitle.text'] : false;
const legendAlignment =
template['legend.layout'] === 'top' ||
template['legend.layout'] === 'bottom'
? template['legend.position.horizontal']
: template['legend.position.vertical'];
const legendOptions = {
show: template['legend.show'],
position: template['legend.layout'],
alignment: legendAlignment
};
const data = template['series.label.show'] ? { labels: true } : false;
const point = {
show: template['series.points.show'],
r: template['series.points.size']
};
const chartOptions =
charts_theme &&
charts_theme[index] !== undefined &&
Expand All @@ -245,38 +182,6 @@ class ChartContainer extends Component {
: {};
return (
<React.Fragment>
{(((version === 'editor' || (version === 'viewer' && chartTitle)) &&
(chartOptions &&
chartOptions.theme &&
chartOptions.theme.title_show)) ||
(template && template.theme && template.theme.title_show)) && (
<div className="chart-title">
<input
type="text"
value={chartTitle || ''}
onChange={e => this.props.changeChartTitle(e.target.value, index)}
placeholder="Enter your title..."
readOnly={version === 'viewer'}
/>
</div>
)}
{(((version === 'editor' || (version === 'viewer' && chartSubtitle)) &&
(chartOptions &&
chartOptions.theme &&
chartOptions.theme.subtitle_show)) ||
(template && template.theme && template.theme.subtitle_show)) && (
<div className="chart-subtitle">
<input
type="text"
value={chartSubtitle || ''}
onChange={e =>
this.props.changeChartSubitle(e.target.value, index)
}
placeholder="Enter your subtitle..."
readOnly={version === 'viewer'}
/>
</div>
)}
{Object.keys(chartOptions).length ? (
<CustomChartTheme
theme={chartOptions.theme}
Expand Down Expand Up @@ -343,8 +248,6 @@ const mapStateToProps = state => {

const mapDispatchToProps = {
loadSavedQuery,
changeChartTitle,
changeChartSubitle,
savedQueryError,
setLoading
};
Expand Down
40 changes: 0 additions & 40 deletions lib/reducers/rootReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,46 +411,6 @@ const appReducer = (state = defaultData, action) => {
draggedType: {},
settingsVisible: dashboardInfo.data.items.length
};
case actionTypes.CHANGE_CHART_TITLE:
return {
...state,
dashboardInfo: {
...dashboardInfo,
data: {
...dashboardInfo.data,
items: [
...dashboardInfo.data.items.map((el, i) =>
action.index === i
? {
...el,
chartTitle: action.title
}
: el
)
]
}
}
};
case actionTypes.CHANGE_CHART_SUBTITLE:
return {
...state,
dashboardInfo: {
...dashboardInfo,
data: {
...dashboardInfo.data,
items: [
...dashboardInfo.data.items.map((el, i) =>
action.index === i
? {
...el,
chartSubtitle: action.subtitle
}
: el
)
]
}
}
};
case actionTypes.RESIZE_CHART:
return {
...state,
Expand Down
Loading