Skip to content

Commit

Permalink
Added suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
thomheymann committed Jul 12, 2021
1 parent 7668cdb commit bc3df22
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 56 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export class CustomizeSpace extends Component<Props, State> {
defaultMessage: 'Description',
}
)}
labelAppend={i18n.translate('xpack.spaces.management.manageSpacePage.optionalLabel', {
defaultMessage: 'Optional',
})}
helpText={i18n.translate(
'xpack.spaces.management.manageSpacePage.spaceDescriptionHelpText',
{
Expand Down Expand Up @@ -170,7 +173,7 @@ export class CustomizeSpace extends Component<Props, State> {
defaultMessage: 'Choose how your space avatar appears across Kibana.',
})}
</p>
{space.avatarType === 'image' && space.imageUrl ? (
{space.avatarType === 'image' ? (
<Suspense fallback={<EuiLoadingSpinner />}>
<LazySpaceAvatar
space={{
Expand All @@ -181,27 +184,17 @@ export class CustomizeSpace extends Component<Props, State> {
size="xl"
/>
</Suspense>
) : space.avatarType !== 'image' && (space.name || space.initials) ? (
) : (
<Suspense fallback={<EuiLoadingSpinner />}>
<LazySpaceAvatar
space={{
name: '?',
...space,
imageUrl: undefined,
}}
size="xl"
/>
</Suspense>
) : (
<EuiAvatar
type="space"
name="?"
size="xl"
color={null}
style={{
background: euiThemeVars.euiColorLightShade,
color: euiThemeVars.euiTextSubduedColor,
}}
/>
)}
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class CustomizeSpaceAvatar extends Component<Props> {
avatarType: avatarType as FormValues['avatarType'],
})
}
buttonSize="m"
/>
</EuiFormRow>
{space.avatarType !== 'image' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiPageContent,
EuiPageContentBody,
EuiPageHeader,
EuiSpacer,
hexToHsv,
Expand Down Expand Up @@ -128,16 +129,12 @@ export class ManageSpacePage extends Component<Props, State> {
}

return (
<>
<EuiPageHeader
bottomBorder
pageTitle={this.getTitle()}
description={getSpacesFeatureDescription()}
/>
<EuiPageContentBody restrictWidth>
<EuiPageHeader pageTitle={this.getTitle()} description={getSpacesFeatureDescription()} />
<EuiSpacer size="l" />

{this.getForm()}
</>
</EuiPageContentBody>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,6 @@ describe('validateAvatarColor', () => {

expect(validator.validateAvatarColor(space)).toHaveProperty('isInvalid', true);
});

it('it does not validate image avatars', () => {
const space = {
avatarType: 'image' as 'image',
color: '',
};

expect(validator.validateAvatarColor(space)).toHaveProperty('isInvalid', false);
});
});

describe('validateAvatarImage', () => {
Expand Down
28 changes: 13 additions & 15 deletions x-pack/plugins/spaces/public/management/lib/validate_space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,20 @@ export class SpaceValidator {
return valid();
}

if (space.avatarType !== 'image') {
if (!space.color) {
return invalid(
i18n.translate('xpack.spaces.management.validateSpace.requiredColorErrorMessage', {
defaultMessage: 'Select a color.',
})
);
}
if (!space.color) {
return invalid(
i18n.translate('xpack.spaces.management.validateSpace.requiredColorErrorMessage', {
defaultMessage: 'Select a background color.',
})
);
}

if (!isValidHex(space.color)) {
return invalid(
i18n.translate('xpack.spaces.management.validateSpace.invalidColorErrorMessage', {
defaultMessage: 'Enter a valid HEX color code.',
})
);
}
if (!isValidHex(space.color)) {
return invalid(
i18n.translate('xpack.spaces.management.validateSpace.invalidColorErrorMessage', {
defaultMessage: 'Enter a valid HEX color code.',
})
);
}

return valid();
Expand Down

0 comments on commit bc3df22

Please sign in to comment.