Skip to content

Commit e7178a9

Browse files
committed
feat: add FF_BUSINESS feature flag for PostGuard for Business
Wire up window.APP_CONFIG (from Terraform ConfigMap) to control visibility of the Business nav link, landing page section, and footer link. The flag is read at runtime from config.js, which is overridden per environment in deployed clusters.
1 parent b9a2f80 commit e7178a9

6 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8" />
55
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<script src="%sveltekit.assets%/config.js"></script>
78
%sveltekit.head%
89
</head>
910
<body>

src/lib/components/Header.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import Hamburger from '$lib/components/header/Hamburger.svelte'
88
import { page } from '$app/state';
99
import ThemeSwitcher from './ThemeSwitcher.svelte'
10+
import { FF_BUSINESS } from '$lib/env'
1011
11-
let items = [
12+
const allItems = [
1213
{ name: 'fs', route: '/fileshare' },
1314
{ name: 'about', route: '/about' },
1415
{ name: 'blog', route: '/blog' },
@@ -17,6 +18,8 @@
1718
{ name: 'docs', route: 'https://docs.postguard.eu' },
1819
]
1920
21+
let items = FF_BUSINESS ? allItems : allItems.filter(i => i.name !== 'business')
22+
2023
function isSelected(route: String) {
2124
return page.url.pathname === route;
2225
}

src/lib/env.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ export const UPLOAD_CHUNK_SIZE = Number(requireEnv('VITE_UPLOAD_CHUNK_SIZE'));
1313
export const FILEREAD_CHUNK_SIZE = Number(requireEnv('VITE_FILEREAD_CHUNK_SIZE'));
1414
export const APP_NAME = requireEnv('VITE_APP_NAME');
1515
export const APP_VERSION = requireEnv('VITE_APP_VERSION');
16+
17+
/** Runtime config injected by config.js (Terraform ConfigMap in deployed environments). */
18+
function runtimeConfig(): Record<string, unknown> {
19+
return (globalThis as any).APP_CONFIG ?? {};
20+
}
21+
22+
export const FF_BUSINESS = runtimeConfig().FF_BUSINESS === true;

src/routes/(marketing)/+layout.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { isLoading } from 'svelte-i18n'
44
import { _ } from 'svelte-i18n'
55
import { onMount } from 'svelte'
6+
import { FF_BUSINESS } from '$lib/env'
67
78
let { children } = $props()
89
let contactEl = $state<HTMLAnchorElement>()
@@ -46,7 +47,7 @@
4647
<ul>
4748
<li><a href="mailto:" bind:this={contactEl} data-name="info" data-domain="postguard.eu">{$_('footer.contact')}</a></li>
4849
<li><a href="https://github.com/encryption4all">GitHub</a></li>
49-
<li><a href="https://business.postguard.eu">PostGuard for Business</a></li>
50+
{#if FF_BUSINESS}<li><a href="https://business.postguard.eu">PostGuard for Business</a></li>{/if}
5051
</ul>
5152
</div>
5253
</div>

src/routes/(marketing)/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { onMount } from 'svelte'
33
import { _ } from 'svelte-i18n'
44
import SEO from '$lib/components/SEO.svelte'
5+
import { FF_BUSINESS } from '$lib/env'
56
67
let contactEl: HTMLAnchorElement
78
@@ -54,6 +55,7 @@
5455
</div>
5556
</section>
5657

58+
{#if FF_BUSINESS}
5759
<section class="business">
5860
<div class="business-content">
5961
<h2>{$_('landing.businessTitle')}</h2>
@@ -90,6 +92,7 @@
9092
<a href="mailto:" bind:this={contactEl} data-name="info" data-domain="postguard.eu" class="business-cta">{$_('landing.businessCta')}</a>
9193
</div>
9294
</section>
95+
{/if}
9396
</div>
9497

9598
<style lang="scss">

static/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Runtime configuration — overridden by Terraform ConfigMap in deployed environments.
2+
// Values here are defaults for local development.
3+
window.APP_CONFIG = {
4+
FF_BUSINESS: true,
5+
};

0 commit comments

Comments
 (0)