Fixed so that we can not change base threshold

pull/14907/head
Hugo Häggmark 6 years ago
parent aaaf3f7ff1
commit 0b1aea905a
  1. 15
      packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.test.tsx
  2. 4
      packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx

@ -111,6 +111,21 @@ describe('Remove threshold', () => {
});
describe('change threshold value', () => {
it('should not change threshold at index 0', () => {
const thresholds = [
{ index: 0, value: -Infinity, color: '#7EB26D' },
{ index: 1, value: 50, color: '#EAB839' },
{ index: 2, value: 75, color: '#6ED0E0' },
];
const instance = setup({ thresholds });
const mockEvent = { target: { value: 12 } };
instance.onChangeThresholdValue(mockEvent, thresholds[0]);
expect(instance.state.thresholds).toEqual(thresholds);
});
it('should update value', () => {
const instance = setup();
const thresholds = [

@ -91,6 +91,10 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
};
onChangeThresholdValue = (event: any, threshold: Threshold) => {
if (threshold.index === 0) {
return;
}
const { thresholds } = this.state;
const newThresholds = thresholds.map(t => {

Loading…
Cancel
Save