Files
redash/client/app/visualizations/pivot/Editor.jsx
Levko Kravets 713fd2d0fb Change visualizations import to be static (#4592)
* getredash/redash#4565 Change visualizations import to be static

* Move visualizations-related components to own folder
2020-01-28 12:48:38 +02:00

43 lines
1.3 KiB
JavaScript

import { merge } from "lodash";
import React from "react";
import { Section, Switch } from "@/components/visualizations/editor";
import { EditorPropTypes } from "@/visualizations/prop-types";
export default function Editor({ options, onOptionsChange }) {
const updateOptions = updates => {
onOptionsChange(merge({}, options, updates));
};
return (
<React.Fragment>
<Section>
<Switch
data-test="PivotEditor.HideControls"
id="pivot-show-controls"
defaultChecked={!options.controls.enabled}
onChange={enabled => updateOptions({ controls: { enabled: !enabled } })}>
Show Pivot Controls
</Switch>
</Section>
<Section>
<Switch
id="pivot-show-row-totals"
defaultChecked={options.rendererOptions.table.rowTotals}
onChange={rowTotals => updateOptions({ rendererOptions: { table: { rowTotals } } })}>
Show Row Totals
</Switch>
</Section>
<Section>
<Switch
id="pivot-show-column-totals"
defaultChecked={options.rendererOptions.table.colTotals}
onChange={colTotals => updateOptions({ rendererOptions: { table: { colTotals } } })}>
Show Column Totals
</Switch>
</Section>
</React.Fragment>
);
}
Editor.propTypes = EditorPropTypes;