From ce450da904b5389d715b9d075a4d2c6b9d08b0f2 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Thu, 16 Jan 2020 21:06:51 -0800 Subject: [PATCH] allow empty values to be set in the auto form (#9198) --- .../src/components/auto-form/auto-form.tsx | 15 +++++++++++---- .../coordinator-dynamic-config-dialog.tsx | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/web-console/src/components/auto-form/auto-form.tsx b/web-console/src/components/auto-form/auto-form.tsx index 110bf491dafa..66dffded4265 100644 --- a/web-console/src/components/auto-form/auto-form.tsx +++ b/web-console/src/components/auto-form/auto-form.tsx @@ -45,6 +45,7 @@ export interface Field { | 'json' | 'interval'; defaultValue?: any; + emptyValue?: any; suggestions?: Functor; placeholder?: string; min?: number; @@ -99,10 +100,16 @@ export class AutoForm> extends React.PureComponent const { model } = this.props; if (!model) return; - const newModel = - typeof newValue === 'undefined' - ? deepDelete(model, field.name) - : deepSet(model, field.name, newValue); + let newModel: T; + if (typeof newValue === 'undefined') { + if (typeof field.emptyValue === 'undefined') { + newModel = deepDelete(model, field.name); + } else { + newModel = deepSet(model, field.name, field.emptyValue); + } + } else { + newModel = deepSet(model, field.name, newValue); + } this.modelChange(newModel); }; diff --git a/web-console/src/dialogs/coordinator-dynamic-config-dialog/coordinator-dynamic-config-dialog.tsx b/web-console/src/dialogs/coordinator-dynamic-config-dialog/coordinator-dynamic-config-dialog.tsx index 8d82c0c3c5b6..044e7eab122b 100644 --- a/web-console/src/dialogs/coordinator-dynamic-config-dialog/coordinator-dynamic-config-dialog.tsx +++ b/web-console/src/dialogs/coordinator-dynamic-config-dialog/coordinator-dynamic-config-dialog.tsx @@ -180,6 +180,7 @@ export class CoordinatorDynamicConfigDialog extends React.PureComponent< { name: 'killDataSourceWhitelist', type: 'string-array', + emptyValue: [], info: ( <> List of dataSources for which kill tasks are sent if property{' '} @@ -191,6 +192,7 @@ export class CoordinatorDynamicConfigDialog extends React.PureComponent< { name: 'killPendingSegmentsSkipList', type: 'string-array', + emptyValue: [], info: ( <> List of dataSources for which pendingSegments are NOT cleaned up if property{' '} @@ -259,6 +261,7 @@ export class CoordinatorDynamicConfigDialog extends React.PureComponent< { name: 'decommissioningNodes', type: 'string-array', + emptyValue: [], info: ( <> List of historical services to 'decommission'. Coordinator will not assign new