From 3d790597c7cf1e984ea2e037b80c120ce0b145b5 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Shahbazi Date: Wed, 25 Sep 2024 12:12:39 +0330 Subject: [PATCH 1/3] Temporarily disable the "Download" button in gallery --- modules/Gallery/DownloadLink.module.scss | 5 +++++ modules/Gallery/DownloadLink.tsx | 9 +++++++-- modules/Gallery/Gallery.tsx | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/Gallery/DownloadLink.module.scss b/modules/Gallery/DownloadLink.module.scss index 7309eb67b..30a0c75aa 100644 --- a/modules/Gallery/DownloadLink.module.scss +++ b/modules/Gallery/DownloadLink.module.scss @@ -7,3 +7,8 @@ height: 1rem; margin-left: $spacing-1; } + +.disabled { + pointer-events: none; + opacity: 0.5; +} diff --git a/modules/Gallery/DownloadLink.tsx b/modules/Gallery/DownloadLink.tsx index 92328de98..e6d291ec6 100644 --- a/modules/Gallery/DownloadLink.tsx +++ b/modules/Gallery/DownloadLink.tsx @@ -3,6 +3,7 @@ import { DOWNLOAD, useAnalytics } from '@prezly/analytics-nextjs'; import type { Locale } from '@prezly/theme-kit-nextjs'; import { translations } from '@prezly/theme-kit-nextjs'; +import classNames from 'classnames'; import { FormattedMessage } from '@/adapters/client'; import { ButtonLink } from '@/components/Button'; @@ -13,9 +14,10 @@ import styles from './DownloadLink.module.scss'; interface Props { localeCode: Locale.Code; href: string; + disabled: boolean; } -export function DownloadLink({ localeCode, href }: Props) { +export function DownloadLink({ localeCode, href, disabled }: Props) { const { track } = useAnalytics(); function handleClick() { @@ -24,10 +26,13 @@ export function DownloadLink({ localeCode, href }: Props) { return ( diff --git a/modules/Gallery/Gallery.tsx b/modules/Gallery/Gallery.tsx index b8f8ba698..ed32e54f9 100644 --- a/modules/Gallery/Gallery.tsx +++ b/modules/Gallery/Gallery.tsx @@ -29,7 +29,9 @@ export function Gallery({ localeCode, gallery, href, withSharingIcons }: Props)
- {downloadUrl && } + {downloadUrl && ( + + )} {withSharingIcons && }
From 5073b4c9a32cfae77990cc4ccb25d8d2c2b0724c Mon Sep 17 00:00:00 2001 From: Mohammad Ali Shahbazi Date: Wed, 25 Sep 2024 12:25:07 +0330 Subject: [PATCH 2/3] Disable navigation on link as well --- modules/Gallery/DownloadLink.module.scss | 1 - modules/Gallery/DownloadLink.tsx | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Gallery/DownloadLink.module.scss b/modules/Gallery/DownloadLink.module.scss index 30a0c75aa..8cbd5ec1e 100644 --- a/modules/Gallery/DownloadLink.module.scss +++ b/modules/Gallery/DownloadLink.module.scss @@ -9,6 +9,5 @@ } .disabled { - pointer-events: none; opacity: 0.5; } diff --git a/modules/Gallery/DownloadLink.tsx b/modules/Gallery/DownloadLink.tsx index e6d291ec6..5ca9cecbb 100644 --- a/modules/Gallery/DownloadLink.tsx +++ b/modules/Gallery/DownloadLink.tsx @@ -29,7 +29,8 @@ export function DownloadLink({ localeCode, href, disabled }: Props) { title={disabled ? 'Temporarily disabled due to system maintenance' : undefined} variation="primary" forceRefresh - href={href} + // eslint-disable-next-line no-script-url + href={disabled ? 'javascript:void(0)' : href} className={classNames(styles.link, { [styles.disabled]: disabled, })} From 1d91fe956e9a37bcd53c57b5a93ccbed8915bda0 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Shahbazi Date: Wed, 25 Sep 2024 12:28:21 +0330 Subject: [PATCH 3/3] Add `cursor: not-allowed` in disabled state --- modules/Gallery/DownloadLink.module.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/Gallery/DownloadLink.module.scss b/modules/Gallery/DownloadLink.module.scss index 8cbd5ec1e..9c2f414c1 100644 --- a/modules/Gallery/DownloadLink.module.scss +++ b/modules/Gallery/DownloadLink.module.scss @@ -10,4 +10,5 @@ .disabled { opacity: 0.5; + cursor: not-allowed; }