Skip to content

Commit

Permalink
[Workspace]Fix error message missed in workspace creator name input (#…
Browse files Browse the repository at this point in the history
…8738) (#8824)

* Fix error message missed in workspace creator name input



* Changeset file for PR #8738 created/updated

---------



(cherry picked from commit 1b3e60c)

Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 9092308 commit 0d691dc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8738.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace]Fix error message missed in workspace creator name input ([#8738](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8738))
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ import {
} from '@elastic/eui';
import { EuiColorPickerOutput } from '@elastic/eui/src/components/color_picker/color_picker';
import { i18n } from '@osd/i18n';
import { WorkspaceDescriptionField, WorkspaceNameField } from '../workspace_form';
import {
WorkspaceDescriptionField,
WorkspaceNameField,
WorkspaceFormErrors,
} from '../workspace_form';
import { generateRightSidebarScrollProps, RightSidebarScrollField } from './utils';

interface CreatorDetailsPanelProps {
color?: string;
name?: string;
description?: string;
formErrors?: Pick<WorkspaceFormErrors, 'name' | 'color'>;
onColorChange: (text: string, output: EuiColorPickerOutput) => void;
onNameChange: (name: string) => void;
onDescriptionChange: (description: string) => void;
Expand All @@ -34,6 +39,7 @@ export const CreatorDetailsPanel = ({
color,
name,
description,
formErrors,
onColorChange,
onNameChange,
onDescriptionChange,
Expand Down Expand Up @@ -68,6 +74,8 @@ export const CreatorDetailsPanel = ({
defaultMessage: 'Color',
})}
{...generateRightSidebarScrollProps(RightSidebarScrollField.Color)}
error={formErrors?.color?.message}
isInvalid={!!formErrors?.color}
>
<EuiColorPicker
color={color}
Expand Down Expand Up @@ -101,6 +109,7 @@ export const CreatorDetailsPanel = ({
}
)}
showDescription={false}
error={formErrors?.name?.message}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('WorkspaceCreator', () => {
});

it('should not create workspace when name is empty', async () => {
const { getByTestId } = render(<WorkspaceCreator />);
const { getByTestId, getByText } = render(<WorkspaceCreator />);

// Ensure workspace create form rendered
await waitFor(() => {
Expand All @@ -219,6 +219,7 @@ describe('WorkspaceCreator', () => {
},
});
fireEvent.click(getByTestId('workspaceForm-bottomBar-createButton'));
expect(getByText('Name is required. Enter a name.')).toBeInTheDocument();
expect(workspaceClientCreate).not.toHaveBeenCalled();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const WorkspaceCreatorForm = (props: WorkspaceCreatorFormProps) => {
onNameChange={setName}
onColorChange={handleColorChange}
onDescriptionChange={setDescription}
formErrors={formErrors}
/>
<EuiSpacer size="m" />
<div {...generateRightSidebarScrollProps(RightSidebarScrollField.UseCase)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
WorkspaceFormProps,
WorkspaceFormDataState,
WorkspacePermissionSetting,
WorkspaceFormErrors,
} from './types';
export {
WorkspaceOperationType,
Expand Down

0 comments on commit 0d691dc

Please sign in to comment.