Skip to content

Commit

Permalink
[Ingest Manager] Remove default namespace toggle (elastic#66298)
Browse files Browse the repository at this point in the history
* Remove default namespace toggle

* Fix i18n

* Add namespace validation

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
jen-huang and elasticmachine committed Jun 3, 2020
1 parent ebccb36 commit 932caca
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ export const agentConfigFormValidation = (
];
}

if (!agentConfig.namespace?.trim()) {
errors.namespace = [
<FormattedMessage
id="xpack.ingestManager.agentConfigForm.namespaceRequiredErrorMessage"
defaultMessage="A namespace is required"
/>,
];
}

return errors;
};

Expand All @@ -73,7 +82,6 @@ export const AgentConfigForm: React.FunctionComponent<Props> = ({
onDelete = () => {},
}) => {
const [touchedFields, setTouchedFields] = useState<{ [key: string]: boolean }>({});
const [showNamespace, setShowNamespace] = useState<boolean>(!!agentConfig.namespace);
const fields: Array<{
name: 'name' | 'description' | 'namespace';
label: JSX.Element;
Expand Down Expand Up @@ -170,49 +178,28 @@ export const AgentConfigForm: React.FunctionComponent<Props> = ({
/>
}
>
<EuiSwitch
showLabel={true}
label={
<FormattedMessage
id="xpack.ingestManager.agentConfigForm.namespaceUseDefaultsFieldLabel"
defaultMessage="Use default namespace"
/>
}
checked={showNamespace}
onChange={() => {
setShowNamespace(!showNamespace);
if (showNamespace) {
updateAgentConfig({ namespace: '' });
}
}}
/>
{showNamespace && (
<>
<EuiSpacer size="m" />
<EuiFormRow
fullWidth
error={touchedFields.namespace && validation.namespace ? validation.namespace : null}
isInvalid={Boolean(touchedFields.namespace && validation.namespace)}
>
<EuiComboBox
fullWidth
singleSelection
noSuggestions
selectedOptions={agentConfig.namespace ? [{ label: agentConfig.namespace }] : []}
onCreateOption={(value: string) => {
updateAgentConfig({ namespace: value });
}}
onChange={(selectedOptions) => {
updateAgentConfig({
namespace: (selectedOptions.length ? selectedOptions[0] : '') as string,
});
}}
isInvalid={Boolean(touchedFields.namespace && validation.namespace)}
onBlur={() => setTouchedFields({ ...touchedFields, namespace: true })}
/>
</EuiFormRow>
</>
)}
<EuiFormRow
fullWidth
error={touchedFields.namespace && validation.namespace ? validation.namespace : null}
isInvalid={Boolean(touchedFields.namespace && validation.namespace)}
>
<EuiComboBox
fullWidth
singleSelection
noSuggestions
selectedOptions={agentConfig.namespace ? [{ label: agentConfig.namespace }] : []}
onCreateOption={(value: string) => {
updateAgentConfig({ namespace: value });
}}
onChange={(selectedOptions) => {
updateAgentConfig({
namespace: (selectedOptions.length ? selectedOptions[0] : '') as string,
});
}}
isInvalid={Boolean(touchedFields.namespace && validation.namespace)}
onBlur={() => setTouchedFields({ ...touchedFields, namespace: true })}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
<EuiDescribedFormGroup
title={
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -8121,7 +8121,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": "このオプションを有効にすると、システムメトリックと情報を収集するデータソースで構成をブートストラップできます。",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8125,7 +8125,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": "启用此选项可使用收集系统指标和信息的数据源启动您的配置。",
Expand Down

0 comments on commit 932caca

Please sign in to comment.