Skip to content

Commit

Permalink
Address PR comments and fix use case scroll
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Aug 23, 2024
1 parent ec88ce7 commit 930ec5e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ export const WorkspaceCreatorForm = (props: WorkspaceCreatorFormProps) => {
})}
</h5>
</EuiTitle>
<WorkspaceUseCase
value={formData.useCase}
onChange={handleUseCaseChange}
formErrors={formErrors}
availableUseCases={availableUseCases}
/>
<div {...generateRightSidebarScrollProps(RightSidebarScrollField.UseCase)}>
<WorkspaceUseCase
value={formData.useCase}
onChange={handleUseCaseChange}
formErrors={formErrors}
availableUseCases={availableUseCases}
/>
</div>
<EuiSpacer size="m" />
<div {...generateRightSidebarScrollProps(RightSidebarScrollField.Name)} />
<WorkspaceNameField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ import { WorkspaceFormDataState } from '../forms';
import { WorkspaceUseCase } from '../../types';
import { RightSidebarScrollField, RIGHT_SIDEBAR_SCROLL_KEY } from './utils';

const SCROLL_FIELDS = {
[RightSidebarScrollField.UseCase]: i18n.translate('workspace.form.summary.panel.useCase.title', {
defaultMessage: 'Use case',
}),
[RightSidebarScrollField.Name]: i18n.translate('workspace.form.summary.panel.name.title', {
defaultMessage: 'Name',
}),
[RightSidebarScrollField.Description]: i18n.translate(
'workspace.form.summary.panel.description.title',
{
defaultMessage: 'Description',
}
),
[RightSidebarScrollField.Color]: i18n.translate('workspace.form.summary.panel.color.title', {
defaultMessage: 'Accent color',
}),
[RightSidebarScrollField.DataSource]: i18n.translate(
'workspace.form.summary.panel.dataSources.title',
{
defaultMessage: 'Data sources',
}
),
[RightSidebarScrollField.Member]: i18n.translate('workspace.form.summary.panel.members.title', {
defaultMessage: 'Members',
}),
};

export const FieldSummaryItem = ({
field,
children,
Expand All @@ -35,47 +62,12 @@ export const FieldSummaryItem = ({
element?.scrollIntoView({ behavior: 'smooth', block: 'center' });
}, [field]);

const renderTitle = () => {
return {
[RightSidebarScrollField.UseCase]: i18n.translate(
'workspace.form.summary.panel.useCase.title',
{
defaultMessage: 'Use case',
}
),
[RightSidebarScrollField.Name]: i18n.translate('workspace.form.summary.panel.name.title', {
defaultMessage: 'Name',
}),
[RightSidebarScrollField.Description]: i18n.translate(
'workspace.form.summary.panel.description.title',
{
defaultMessage: 'Description',
}
),
[RightSidebarScrollField.Color]: i18n.translate('workspace.form.summary.panel.color.title', {
defaultMessage: 'Accent color',
}),
[RightSidebarScrollField.DataSource]: i18n.translate(
'workspace.form.summary.panel.dataSources.title',
{
defaultMessage: 'Data sources',
}
),
[RightSidebarScrollField.Member]: i18n.translate(
'workspace.form.summary.panel.members.title',
{
defaultMessage: 'Members',
}
),
}[field];
};

return (
<>
<EuiText size="xs">
<h5>
<EuiLink color="text" onClick={handleTitleClick}>
<u>{renderTitle()}</u>
<u>{SCROLL_FIELDS[field]}</u>
</EuiLink>
</h5>
</EuiText>
Expand Down

0 comments on commit 930ec5e

Please sign in to comment.