Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs onboarding] Error handling in configureLogs step #162241

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { isEmpty } from 'lodash';
import React, { useState } from 'react';
import { useWizard } from '.';
import { OptionalFormRow } from '../../../shared/optional_form_row';
Expand All @@ -37,6 +38,7 @@ import { BackButton } from './back_button';
import { getFilename, replaceSpecialChars } from './get_filename';

export function ConfigureLogs() {
const [datasetNameTouched, setDatasetNameTouched] = useState(false);
const { euiTheme } = useEuiTheme();
const xsFontSize = useEuiFontSize('xs').fontSize;

Expand Down Expand Up @@ -86,6 +88,13 @@ export function ConfigureLogs() {
}
}

const isDatasetNameInvalid = datasetNameTouched && isEmpty(datasetName);

const datasetNameError = i18n.translate(
'xpack.observability_onboarding.configureLogs.dataset.error',
{ defaultMessage: 'A dataset name is required.' }
);

return (
<StepPanel
title={i18n.translate(
Expand Down Expand Up @@ -205,6 +214,8 @@ export function ConfigureLogs() {
"Pick a name for your logs. All lowercase, max 100 chars, special characters will be replaced with '_'.",
}
)}
isInvalid={isDatasetNameInvalid}
error={datasetNameError}
>
<EuiFieldText
placeholder={i18n.translate(
Expand All @@ -217,6 +228,8 @@ export function ConfigureLogs() {
onChange={(event) =>
setDatasetName(replaceSpecialChars(event.target.value))
}
isInvalid={isDatasetNameInvalid}
onInput={() => setDatasetNameTouched(true)}
/>
</EuiFormRow>
<EuiSpacer size="m" />
Expand Down