From 3e32f1b56085e4d7205fc059b7d7e0cafd22253b Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Tue, 12 May 2020 12:55:22 -0700 Subject: [PATCH 1/3] Remove default namespace toggle --- .../agent_config/components/config_form.tsx | 66 +++++++------------ 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx index 30996931ba67a..cfa4e09fd6006 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx @@ -73,7 +73,6 @@ export const AgentConfigForm: React.FunctionComponent = ({ onDelete = () => {}, }) => { const [touchedFields, setTouchedFields] = useState<{ [key: string]: boolean }>({}); - const [showNamespace, setShowNamespace] = useState(!!agentConfig.namespace); const fields: Array<{ name: 'name' | 'description' | 'namespace'; label: JSX.Element; @@ -170,49 +169,34 @@ export const AgentConfigForm: React.FunctionComponent = ({ /> } > - } - checked={showNamespace} - onChange={() => { - setShowNamespace(!showNamespace); - if (showNamespace) { - updateAgentConfig({ namespace: '' }); - } - }} - /> - {showNamespace && ( - <> - - - { - updateAgentConfig({ namespace: value }); - }} - onChange={(selectedOptions) => { - updateAgentConfig({ - namespace: (selectedOptions.length ? selectedOptions[0] : '') as string, - }); - }} - isInvalid={Boolean(touchedFields.namespace && validation.namespace)} - onBlur={() => setTouchedFields({ ...touchedFields, namespace: true })} - /> - - - )} + > + { + updateAgentConfig({ namespace: value }); + }} + onChange={(selectedOptions) => { + updateAgentConfig({ + namespace: (selectedOptions.length ? selectedOptions[0] : '') as string, + }); + }} + isInvalid={Boolean(touchedFields.namespace && validation.namespace)} + onBlur={() => setTouchedFields({ ...touchedFields, namespace: true })} + /> + Date: Tue, 12 May 2020 13:59:57 -0700 Subject: [PATCH 2/3] Fix i18n --- x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 2 files changed, 2 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 4522a641d6dd9..f1314eea94965 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8116,7 +8116,6 @@ "xpack.ingestManager.agentConfigForm.nameRequiredErrorMessage": "エージェント構成名が必要です", "xpack.ingestManager.agentConfigForm.namespaceFieldDescription": "この構成を使用するデータソースにデフォルトの名前空間を適用します。データソースはその独自の名前空間を指定できます。", "xpack.ingestManager.agentConfigForm.namespaceFieldLabel": "デフォルト名前空間", - "xpack.ingestManager.agentConfigForm.namespaceUseDefaultsFieldLabel": "デフォルト名前空間を使用する", "xpack.ingestManager.agentConfigForm.systemMonitoringFieldLabel": "オプション", "xpack.ingestManager.agentConfigForm.systemMonitoringText": "システムメトリックを収集", "xpack.ingestManager.agentConfigForm.systemMonitoringTooltipText": "このオプションを有効にすると、システムメトリックと情報を収集するデータソースで構成をブートストラップできます。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index bceded8ea3bbb..07d0f579df414 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8120,7 +8120,6 @@ "xpack.ingestManager.agentConfigForm.nameRequiredErrorMessage": "“代理配置名称”必填", "xpack.ingestManager.agentConfigForm.namespaceFieldDescription": "将默认命名空间应用于使用此配置的数据源。数据源可以指定自己的命名空间。", "xpack.ingestManager.agentConfigForm.namespaceFieldLabel": "默认命名空间", - "xpack.ingestManager.agentConfigForm.namespaceUseDefaultsFieldLabel": "使用默认命名空间", "xpack.ingestManager.agentConfigForm.systemMonitoringFieldLabel": "可选", "xpack.ingestManager.agentConfigForm.systemMonitoringText": "收集系统指标", "xpack.ingestManager.agentConfigForm.systemMonitoringTooltipText": "启用此选项可使用收集系统指标和信息的数据源启动您的配置。", From 560bc839c05c7d71cada5a88ad1a7f04e283b1a8 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 1 Jun 2020 17:58:55 -0700 Subject: [PATCH 3/3] Add namespace validation --- .../agent_config/components/config_form.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx index cfa4e09fd6006..73ddd567c515b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx @@ -50,6 +50,15 @@ export const agentConfigFormValidation = ( ]; } + if (!agentConfig.namespace?.trim()) { + errors.namespace = [ + , + ]; + } + return errors; }; @@ -173,12 +182,6 @@ export const AgentConfigForm: React.FunctionComponent = ({ fullWidth error={touchedFields.namespace && validation.namespace ? validation.namespace : null} isInvalid={Boolean(touchedFields.namespace && validation.namespace)} - helpText={ - - } >