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

[Workspace]Fix error message missed in workspace creator name input #8738

Merged
Show file tree
Hide file tree
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
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
Loading