Files
redash/client/app/visualizations/counter/Editor/FormatSettings.jsx
Arik Fraimovich 56d3be2248 Prettier all the Javascript code & GitHub Action (#4433)
* Prettier all the JS files

* Add GitHub Action to autoformat code pushed to master

* Fix eslint violation due to formatting.

* Remove GitHub actions for styling

* Add restyled.io config
2019-12-11 17:05:38 +02:00

84 lines
2.6 KiB
JavaScript

import React from "react";
import { Section, Input, InputNumber, Switch } from "@/components/visualizations/editor";
import { EditorPropTypes } from "@/visualizations";
import { isValueNumber } from "../utils";
export default function FormatSettings({ options, data, onOptionsChange }) {
const inputsEnabled = isValueNumber(data.rows, options);
return (
<React.Fragment>
<Section>
<InputNumber
layout="horizontal"
label="Formatting Decimal Place"
className="w-100"
data-test="Counter.Formatting.DecimalPlace"
defaultValue={options.stringDecimal}
disabled={!inputsEnabled}
onChange={stringDecimal => onOptionsChange({ stringDecimal })}
/>
</Section>
<Section>
<Input
layout="horizontal"
label="Formatting Decimal Character"
className="w-100"
data-test="Counter.Formatting.DecimalCharacter"
defaultValue={options.stringDecChar}
disabled={!inputsEnabled}
onChange={e => onOptionsChange({ stringDecChar: e.target.value })}
/>
</Section>
<Section>
<Input
layout="horizontal"
label="Formatting Thousands Separator"
className="w-100"
data-test="Counter.Formatting.ThousandsSeparator"
defaultValue={options.stringThouSep}
disabled={!inputsEnabled}
onChange={e => onOptionsChange({ stringThouSep: e.target.value })}
/>
</Section>
<Section>
<Input
layout="horizontal"
label="Formatting String Prefix"
className="w-100"
data-test="Counter.Formatting.StringPrefix"
defaultValue={options.stringPrefix}
disabled={!inputsEnabled}
onChange={e => onOptionsChange({ stringPrefix: e.target.value })}
/>
</Section>
<Section>
<Input
layout="horizontal"
label="Formatting String Suffix"
className="w-100"
data-test="Counter.Formatting.StringSuffix"
defaultValue={options.stringSuffix}
disabled={!inputsEnabled}
onChange={e => onOptionsChange({ stringSuffix: e.target.value })}
/>
</Section>
<Section>
<Switch
data-test="Counter.Formatting.FormatTargetValue"
defaultChecked={options.formatTargetValue}
onChange={formatTargetValue => onOptionsChange({ formatTargetValue })}>
Format Target Value
</Switch>
</Section>
</React.Fragment>
);
}
FormatSettings.propTypes = EditorPropTypes;