From 6537613000bf28273e8106635cb9af98f6ab6e4d Mon Sep 17 00:00:00 2001 From: Victor Jack <67293106+thedon-dev@users.noreply.github.com> Date: Tue, 11 Aug 2026 14:31:58 +0100 Subject: [PATCH] fix: preserve landing page section content when toggled off (#838) * preserve section content when toggled off * Update types.ts * Remove comment on LandingPageLinks enabled property Removed comment about the default visibility of the section. --------- Co-authored-by: Rotimi Best --- README.md | 2 +- .../lib/features/org/utils/landing-page.ts | 7 ++ .../landingpage-editor/callout-section.svelte | 16 +-- .../landingpage-editor/embed-section.svelte | 115 +++++++++--------- .../landingpage-editor/links-section.svelte | 23 ++-- apps/dashboard/src/lib/utils/types/org.ts | 3 + packages/ui/README.md | 22 ++-- .../custom/org-landing-page/callout.svelte | 2 +- .../src/custom/org-landing-page/embed.svelte | 2 +- .../src/custom/org-landing-page/links.svelte | 2 +- .../custom/org-landing-page/saas/org.svelte | 6 +- .../ui/src/custom/org-landing-page/types.ts | 3 + 12 files changed, 102 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index 1f44e7ce..6d057128 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ The repository also contains shared packages under `packages/` (for example `pac PUBLIC_SERVER_URL="http://localhost:3002" PRIVATE_SERVER_URL="http://localhost:3002" # used by the SSR auth proxy — required, or login returns "API upstream not configured" PRIVATE_SERVER_KEY="" # must match the API (paste the value generated above) - PUBLIC_IS_SELFHOSTED=true + PUBLIC_IS_SELFHOSTED=false ``` - Running the background workers? Also create `apps/jobs/.env` (e.g. `cp apps/api/.env apps/jobs/.env`); it needs `REDIS_URL`. The `packages/db/.env` used by the DB scripts is set up in step 6. diff --git a/apps/dashboard/src/lib/features/org/utils/landing-page.ts b/apps/dashboard/src/lib/features/org/utils/landing-page.ts index 06866f30..c8c491f7 100644 --- a/apps/dashboard/src/lib/features/org/utils/landing-page.ts +++ b/apps/dashboard/src/lib/features/org/utils/landing-page.ts @@ -125,6 +125,7 @@ type LegacyLandingPageJson = { footerText?: string; theme?: OrgLandingPageTheme; embed?: { + enabled?: boolean; title?: string; description?: string; code?: string; @@ -138,6 +139,7 @@ type LegacyLandingPageJson = { sandbox?: string; }; callout?: { + enabled?: boolean; heading?: string; description?: string; action?: { @@ -413,6 +415,7 @@ function normalizeCallout(callout: NonNullable } return { + enabled: callout.enabled !== false, heading, description: normalizeText(callout.description, ''), action: { @@ -468,6 +471,7 @@ function normalizeLinks(raw: unknown): OrgLandingPageLinks | undefined { const classicLearnMoreLabel = normalizeText(raw.classicLearnMoreLabel, ''); return { + enabled: raw.enabled !== false, heading, description: description || undefined, boldVisitLabel: boldVisitLabel || undefined, @@ -541,6 +545,7 @@ export function normalizeLandingPageSettings(value: unknown): OrgLandingPageJson footer: resolveFooterConfig(landingPage), embed: landingPage.embed ? { + enabled: landingPage.embed.enabled !== false, title: normalizeText(landingPage.embed.title, 'Section title'), description: normalizeText(landingPage.embed.description, ''), code: normalizeEmbedCode(landingPage.embed), @@ -587,6 +592,7 @@ export function normalizeLandingPageSettings(value: unknown): OrgLandingPageJson footer: resolveFooterConfig(landingPage), embed: landingPage.embed ? { + enabled: landingPage.embed.enabled !== false, title: normalizeText(landingPage.embed.title, 'Section title'), description: normalizeText(landingPage.embed.description, ''), code: normalizeEmbedCode(landingPage.embed) @@ -624,6 +630,7 @@ export function normalizeLandingPageSettings(value: unknown): OrgLandingPageJson footer: resolveFooterConfig(landingPage), embed: landingPage.embed ? { + enabled: landingPage.embed.enabled !== false, title: normalizeText(landingPage.embed.title, 'Section title'), description: normalizeText(landingPage.embed.description, ''), code: normalizeEmbedCode(landingPage.embed), diff --git a/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/callout-section.svelte b/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/callout-section.svelte index 2aab3a38..f2c3fd9f 100644 --- a/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/callout-section.svelte +++ b/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/callout-section.svelte @@ -33,6 +33,7 @@ } const callout: OrgLandingPageCallout = { + enabled: true, heading: t.get('settings.landing_page.editor.callout.heading_default'), description: '', action: { @@ -51,16 +52,7 @@ } function setCalloutEnabled(enabled: boolean) { - if (!enabled) { - settings = { - ...settings, - callout: undefined - }; - markDirty(); - return; - } - - setter(ensureCallout(), 'callout'); + setter({ ...ensureCallout(), enabled }, 'callout'); } @@ -71,13 +63,13 @@
setCalloutEnabled(checked === true)} /> {$t('settings.landing_page.editor.callout.toggle')} - {#if settings.callout} + {#if settings.callout?.enabled}
{$t('settings.landing_page.editor.callout.heading')} diff --git a/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/embed-section.svelte b/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/embed-section.svelte index 1d93fbc0..5e6981bc 100644 --- a/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/embed-section.svelte +++ b/apps/dashboard/src/lib/features/settings/pages/landingpage-editor/embed-section.svelte @@ -34,6 +34,7 @@ } const embed = { + enabled: true, title: t.get('settings.landing_page.editor.embed.title'), description: '', code: '', @@ -50,16 +51,7 @@ } function setEmbedEnabled(enabled: boolean) { - if (!enabled) { - settings = { - ...settings, - embed: undefined - }; - markDirty(); - return; - } - - setter(ensureEmbed(), 'embed'); + setter({ ...ensureEmbed(), enabled }, 'embed'); } function updateSecondaryAction(label: string, href: string) { @@ -83,63 +75,68 @@
- setEmbedEnabled(checked === true)} /> + setEmbedEnabled(checked === true)} + /> {$t('settings.landing_page.editor.embed.toggle')} - {#if settings.embed} - -
- {$t('settings.landing_page.editor.embed.title')} - setter(text, 'embed.title')} + {#if settings.embed?.enabled} +
+ +
+ {$t('settings.landing_page.editor.embed.title')} + setter(text, 'embed.title')} + /> +
+ setter(event.currentTarget.value, 'embed.title')} /> -
- setter(event.currentTarget.value, 'embed.title')} - /> - + - -
- {$t('settings.landing_page.editor.embed.description')} - setter(text, 'embed.description')} + +
+ {$t('settings.landing_page.editor.embed.description')} + setter(text, 'embed.description')} + /> +
+