Skip to content

Commit

Permalink
Merge pull request opensearch-project#56 from abasatwar/feature/gauge…
Browse files Browse the repository at this point in the history
…_chart

pr issue fixed for min limit in gauge input, tooltip added for thresh…
  • Loading branch information
abasatwar authored Jul 28, 2022
2 parents ef13bd5 + 32c815f commit 7a68db8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const ConfigPanelOptionGauge = ({
handleConfigChange,
}: any) => {
const { Gauge = {} } = visualizations?.data?.rawVizData;
const isReadOnly = !(
Gauge?.dataConfig?.dimensions?.length && Gauge?.dataConfig?.dimensions[0]?.name != ''
);
const dimensions = Gauge?.dataConfig?.dimensions
? Gauge.dataConfig.dimensions.filter((i) => i.name !== '')
: [];
const [numberOfGauges, setNumberOfGauges] = useState<number>(
DefaultGaugeChartParameters.DisplayDefaultGauges
);
Expand All @@ -37,6 +37,7 @@ export const ConfigPanelOptionGauge = ({
setNumberOfGauges(Number(e.target.value));
}}
value={numberOfGauges}
min={DefaultGaugeChartParameters.DisplayDefaultGauges}
onBlur={() => {
const newPanelOptions = {
...panelOptionsValues,
Expand All @@ -45,7 +46,7 @@ export const ConfigPanelOptionGauge = ({
handleConfigChange(newPanelOptions);
}}
placeholder={'Number of gauges'}
readOnly={isReadOnly}
readOnly={!dimensions.length}
/>
</EuiFormRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EuiFlexItem,
EuiFieldText,
htmlIdGenerator,
EuiToolTip,
} from '@elastic/eui';
import { isEmpty } from 'lodash';

Expand All @@ -35,6 +36,15 @@ export const ConfigThresholds = ({
props,
}: any) => {
const addButtonText = '+ Add threshold';
const AddButtonTextWrapper = () =>
props?.maxLimit && !isEmpty(vizState) && vizState.length === props.maxLimit ? (
<EuiToolTip position="top" content="Only one threshold can be applied">
<>{addButtonText}</>
</EuiToolTip>
) : (
<>{addButtonText}</>
);

const getThresholdUnit = () => {
return {
thid: htmlIdGenerator('thr')(),
Expand Down Expand Up @@ -92,7 +102,7 @@ export const ConfigThresholds = ({
isDisabled: !isEmpty(vizState) && vizState.length === props.maxLimit,
})}
>
{addButtonText}
<AddButtonTextWrapper />
</EuiButton>
<EuiSpacer size="s" />
{!isEmpty(vizState) &&
Expand Down

0 comments on commit 7a68db8

Please sign in to comment.