From 972a2f9509568d8d1831abe5002fd66a1eaa83d0 Mon Sep 17 00:00:00 2001 From: Thom Heymann Date: Mon, 19 Jul 2021 10:29:10 +0100 Subject: [PATCH] Added suggestions from code review --- .../__snapshots__/customize_space.test.tsx.snap | 13 ++++++++++++- .../edit_space/customize_space/customize_space.tsx | 14 ++++++++++---- .../customize_space/customize_space_avatar.tsx | 7 +++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space.test.tsx.snap b/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space.test.tsx.snap index 4e436bb9a4b8fb..51943c7581273b 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space.test.tsx.snap +++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/__snapshots__/customize_space.test.tsx.snap @@ -51,7 +51,18 @@ exports[`renders correctly 1`] = ` helpText="The description appears on the space selection screen." isInvalid={false} label="Description" - labelAppend="Optional" + labelAppend={ + + + + } labelType="label" > { defaultMessage: 'Description', } )} - labelAppend={i18n.translate('xpack.spaces.management.manageSpacePage.optionalLabel', { - defaultMessage: 'Optional', - })} + labelAppend={ + + + + } helpText={i18n.translate( 'xpack.spaces.management.manageSpacePage.spaceDescriptionHelpText', { @@ -176,7 +182,7 @@ export class CustomizeSpace extends Component { { - private storeImageChanges(imageUrl: string) { + private storeImageChanges(imageUrl: string | undefined) { this.props.onChange({ ...this.props.space, imageUrl, @@ -80,7 +80,10 @@ export class CustomizeSpaceAvatar extends Component { }; private onFileUpload = (files: FileList | null) => { - if (files == null) return; + if (files == null || files.length === 0) { + this.storeImageChanges(undefined); + return; + } const file = files[0]; if (imageTypes.indexOf(file.type) > -1) { encode(file).then((dataurl: string) => this.handleImageUpload(dataurl));