From f7875be88ffdf1ee5828adb9bc1c21cf360e3100 Mon Sep 17 00:00:00 2001 From: Charley_Campbell Date: Mon, 18 Mar 2024 12:11:31 +0000 Subject: [PATCH] Removing deprecated fields tabletDesktop and wide to replace with tablet and desktop --- app/models/BannerDesign.scala | 36 +++---------------- .../bannerDesigns/HeaderImageEditor.tsx | 30 +++++++--------- .../bannerDesigns/ImageEditor.tsx | 33 +---------------- .../bannerDesigns/utils/defaults.ts | 4 --- public/src/models/bannerDesign.ts | 8 ++--- 5 files changed, 19 insertions(+), 92 deletions(-) diff --git a/app/models/BannerDesign.scala b/app/models/BannerDesign.scala index 2af105e5..16e07ac7 100644 --- a/app/models/BannerDesign.scala +++ b/app/models/BannerDesign.scala @@ -18,38 +18,18 @@ object BannerDesignStatus { case class HeaderImage( mobileUrl: String, - tabletDesktopUrl: String, // deprecated - wideUrl: String, // deprecated - - tabletUrl: Option[String], // new - desktopUrl: Option[String], // new - + tabletUrl: String, + desktopUrl: String, altText: String ) -object HeaderImage { - import io.circe.generic.auto._ - implicit val encoder = Encoder[HeaderImage] - - // Modify the Decoder to use existing values for the new fields - val normalDecoder = Decoder[HeaderImage] - implicit val decoder = normalDecoder.map(image => { - val tabletUrl = image.tabletUrl.getOrElse(image.tabletDesktopUrl) - val desktopUrl = image.desktopUrl.getOrElse(image.wideUrl) - image.copy(tabletUrl = Some(tabletUrl), desktopUrl = Some(desktopUrl)) - }) -} sealed trait BannerDesignVisual object BannerDesignVisual { case class Image( kind: String = "Image", mobileUrl: String, - tabletDesktopUrl: String, // deprecated - wideUrl: String, // deprecated - - tabletUrl: Option[String], // new - desktopUrl: Option[String], // new - + tabletUrl: String, + desktopUrl: String, altText: String ) extends BannerDesignVisual @@ -66,14 +46,6 @@ object BannerDesignVisual { import io.circe.generic.extras.auto._ implicit val customConfig: Configuration = Configuration.default.withDiscriminator("kind") - // Modify the Decoder to use existing values for the new fields - val normalImageDecoder = Decoder[Image] - implicit val imageDecoder = normalImageDecoder.map(image => { - val tabletUrl = image.tabletUrl.getOrElse(image.tabletDesktopUrl) - val desktopUrl = image.desktopUrl.getOrElse(image.wideUrl) - image.copy(tabletUrl = Some(tabletUrl), desktopUrl = Some(desktopUrl)) - }) - implicit val encoder = Encoder[BannerDesignVisual] implicit val decoder = Decoder[BannerDesignVisual] } diff --git a/public/src/components/channelManagement/bannerDesigns/HeaderImageEditor.tsx b/public/src/components/channelManagement/bannerDesigns/HeaderImageEditor.tsx index c8c3683d..8e784e10 100644 --- a/public/src/components/channelManagement/bannerDesigns/HeaderImageEditor.tsx +++ b/public/src/components/channelManagement/bannerDesigns/HeaderImageEditor.tsx @@ -11,8 +11,6 @@ const imageUrlValidation = { export const DEFAULT_HEADER_IMAGE_SETTINGS: BannerDesignHeaderImage = { mobileUrl: '', - tabletDesktopUrl: '', - wideUrl: '', tabletUrl: '', desktopUrl: '', altText: '', @@ -33,8 +31,6 @@ export const HeaderImageEditor: React.FC = ({ }: Props) => { const defaultValues: BannerDesignHeaderImage = { mobileUrl: headerImage?.mobileUrl ?? '', - tabletDesktopUrl: headerImage?.tabletDesktopUrl ?? '', - wideUrl: headerImage?.wideUrl ?? '', tabletUrl: headerImage?.tabletUrl ?? '', desktopUrl: headerImage?.desktopUrl ?? '', altText: headerImage?.altText ?? '', @@ -48,26 +44,24 @@ export const HeaderImageEditor: React.FC = ({ useEffect(() => { const isValid = Object.keys(errors).length === 0; onValidationChange('BannerHeaderImage', isValid); - }, [errors.mobileUrl, errors.tabletDesktopUrl, errors.wideUrl, errors.altText]); + }, [errors.mobileUrl, errors.tabletUrl, errors.desktopUrl, errors.altText]); useEffect(() => { reset(defaultValues); }, [ defaultValues.mobileUrl, - defaultValues.tabletDesktopUrl, - defaultValues.wideUrl, + defaultValues.tabletUrl, + defaultValues.desktopUrl, defaultValues.altText, ]); const onSubmit = ({ mobileUrl, - tabletDesktopUrl, - wideUrl, tabletUrl, desktopUrl, altText, }: BannerDesignHeaderImage): void => { - onChange({ mobileUrl, tabletDesktopUrl, wideUrl, tabletUrl, desktopUrl, altText }); + onChange({ mobileUrl, tabletUrl, desktopUrl, altText }); }; const onRadioGroupChange = (event: React.ChangeEvent): void => { @@ -121,11 +115,11 @@ export const HeaderImageEditor: React.FC = ({ required: EMPTY_ERROR_HELPER_TEXT, pattern: imageUrlValidation, })} - error={errors?.tabletDesktopUrl !== undefined} - helperText={errors?.tabletDesktopUrl?.message} + error={errors?.tabletUrl !== undefined} + helperText={errors?.tabletUrl?.message} onBlur={handleSubmit(onSubmit)} - name="tabletDesktopUrl" - label="Header Image URL (Tablet & Desktop)" + name="tabletUrl" + label="Header Image URL (Tablet)" margin="normal" variant="outlined" disabled={isDisabled} @@ -136,11 +130,11 @@ export const HeaderImageEditor: React.FC = ({ required: EMPTY_ERROR_HELPER_TEXT, pattern: imageUrlValidation, })} - error={errors?.wideUrl !== undefined} - helperText={errors?.wideUrl?.message} + error={errors?.desktopUrl !== undefined} + helperText={errors?.desktopUrl?.message} onBlur={handleSubmit(onSubmit)} - name="wideUrl" - label="Header Image URL (Wide)" + name="desktopUrl" + label="Header Image URL (Dekstop and above)" margin="normal" variant="outlined" disabled={isDisabled} diff --git a/public/src/components/channelManagement/bannerDesigns/ImageEditor.tsx b/public/src/components/channelManagement/bannerDesigns/ImageEditor.tsx index ad3b31d4..458166ba 100644 --- a/public/src/components/channelManagement/bannerDesigns/ImageEditor.tsx +++ b/public/src/components/channelManagement/bannerDesigns/ImageEditor.tsx @@ -56,36 +56,6 @@ export const ImageEditor: React.FC = ({ disabled={isDisabled} fullWidth /> - - = ({ helperText={errors?.desktopUrl?.message} onBlur={handleSubmit(onChange)} name="desktopUrl" - label="Banner Image URL (Desktop)" + label="Banner Image URL (Desktop and above)" margin="normal" variant="outlined" disabled={isDisabled} fullWidth /> -