From dae28ceb6d533d17b451eacf79dd5a7e823cebd3 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 3 Jun 2020 13:10:09 -0700 Subject: [PATCH] [Ingest Manager] Remove default namespace toggle (#66298) (#68148) * Remove default namespace toggle * Fix i18n * Add namespace validation Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- .../agent_config/components/config_form.tsx | 75 ++++++++----------- .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 3 files changed, 31 insertions(+), 46 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..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; }; @@ -73,7 +82,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 +178,28 @@ 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 })} + /> +