Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Make the control panel branding page editable (#2918)

Luke Vella88d9c5b390d7
diff --git a/apps/web/biome.json b/apps/web/biome.json
index d6dfe4f96..561e3e2c4 100644
--- a/apps/web/biome.json
+++ b/apps/web/biome.json
@@ -253,7 +253,6 @@
"src/app/*/(space)/settings/preferences/components/date-time-preferences.tsx",
"src/app/*/accept-invite/*/page.tsx",
"src/app/*/invite/*/page.tsx",
- "src/app/*/control-panel/settings/actions.ts",
"src/app/*/control-panel/users/page.tsx",
"src/app/*/e/*/components/rsvp-area.tsx"
],
@@ -296,7 +295,6 @@
"src/app/*/(space)/settings/profile/components/account-deletion-summary.tsx",
"src/app/*/(space)/settings/security/page.tsx",
"src/app/*/(space)/settings/spaces/page.tsx",
- "src/app/*/control-panel/branding/page.tsx",
"src/app/*/control-panel/license/page.tsx",
"src/app/*/control-panel/page.tsx",
"src/app/*/control-panel/settings/page.tsx",
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index d00f62adf..12f824444 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -97,9 +97,10 @@
"billingSubscriptionDescription": "Manage your current subscription plan.",
"branding": "Branding",
"brandingCardDescription": "How your space appears to you and the people you invite",
- "brandingDescription": "View your instance branding configuration",
+ "brandingGeneralDescription": "Set the name of your instance",
"brandingPreviewEventTitle": "Team Offsite",
"brandingPreviewLocation": "The Old Fire Station",
+ "brandingSettingsDescription": "Customize your instance branding",
"calendar": "Calendar",
"calendarDisconnectedError": "Failed to disconnect calendar",
"calendarDisconnectedSuccess": "Calendar disconnected successfully",
diff --git a/apps/web/src/app/[locale]/control-panel/branding/actions.ts b/apps/web/src/app/[locale]/control-panel/branding/actions.ts
new file mode 100644
index 000000000..422fb1f58
--- /dev/null
+++ b/apps/web/src/app/[locale]/control-panel/branding/actions.ts
@@ -0,0 +1,25 @@
+"use server";
+
+import { updateInstanceSettings } from "@/features/instance-settings/mutations";
+import { brandingSettingsSchema } from "@/features/instance-settings/schema";
+import { getWhiteLabelAddon } from "@/features/licensing/data";
+import { AppError } from "@/lib/errors/app-error";
+import { adminActionClient } from "@/lib/safe-action/server";
+
+export const updateBrandingSettingsAction = adminActionClient
+ .metadata({
+ actionName: "update_branding_settings",
+ })
+ .inputSchema(brandingSettingsSchema.partial())
+ .action(async ({ parsedInput }) => {
+ const hasWhiteLabelAddon = await getWhiteLabelAddon();
+
+ if (!hasWhiteLabelAddon) {
+ throw new AppError({
+ code: "PAYMENT_REQUIRED",
+ message: "Custom branding requires the white label add-on.",
+ });
+ }
+
+ await updateInstanceSettings(parsedInput);
+ });
diff --git a/apps/web/src/app/[locale]/control-panel/branding/components/app-name-field.tsx b/apps/web/src/app/[locale]/control-panel/branding/components/app-name-field.tsx
new file mode 100644
index 000000000..c601222e6
--- /dev/null
+++ b/apps/web/src/app/[locale]/control-panel/branding/components/app-name-field.tsx
@@ -0,0 +1,95 @@
+"use client";
+
+import { zodResolver } from "@hookform/resolvers/zod";
+import { FieldError } from "@rallly/ui/field";
+import {
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
+} from "@rallly/ui/input-group";
+import { toast } from "@rallly/ui/sonner";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip";
+import { CheckIcon } from "lucide-react";
+import { Controller, useForm } from "react-hook-form";
+import { brandingSettingsSchema } from "@/features/instance-settings/schema";
+import { Trans, useTranslation } from "@/i18n/client";
+import { useSafeAction } from "@/lib/safe-action/client";
+import { updateBrandingSettingsAction } from "../actions";
+
+const appNameSchema = brandingSettingsSchema.pick({ appName: true });
+
+export function AppNameField({
+ defaultValue,
+ disabled = false,
+}: {
+ defaultValue: string;
+ disabled?: boolean;
+}) {
+ const { t } = useTranslation();
+ const updateBranding = useSafeAction(updateBrandingSettingsAction);
+
+ const form = useForm({
+ resolver: zodResolver(appNameSchema),
+ defaultValues: {
+ appName: defaultValue,
+ },
+ });
+
+ return (
+ <form
+ onSubmit={form.handleSubmit(async (data) => {
+ const result = await updateBranding.executeAsync(data);
+
+ if (!result?.serverError && !result?.validationErrors) {
+ form.reset(data);
+ toast.success(t("saved", { defaultValue: "Saved" }));
+ }
+ })}
+ >
+ <Controller
+ control={form.control}
+ name="appName"
+ render={({ field, fieldState }) => (
+ <>
+ <InputGroup className="w-56">
+ <InputGroupInput
+ {...field}
+ id="app-name"
+ disabled={disabled}
+ aria-invalid={fieldState.invalid}
+ />
+ {/* Rendered only when there is something to save. A disabled
+ button here would trip InputGroup's `has-disabled:` styles
+ and grey out the whole field. */}
+ {form.formState.isDirty && !disabled ? (
+ <InputGroupAddon align="inline-end">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <InputGroupButton
+ type="submit"
+ size="icon-xs"
+ loading={updateBranding.isExecuting}
+ aria-label={t("save", { defaultValue: "Save" })}
+ >
+ <CheckIcon />
+ </InputGroupButton>
+ }
+ />
+ <TooltipContent>
+ <Trans i18nKey="save" defaults="Save" />
+ </TooltipContent>
+ </Tooltip>
+ </InputGroupAddon>
+ ) : null}
+ </InputGroup>
+ {fieldState.invalid ? (
+ <FieldError className="mt-1.5" errors={[fieldState.error]} />
+ ) : null}
+ </>
+ )}
+ />
+ </form>
+ );
+}
diff --git a/apps/web/src/app/[locale]/control-panel/branding/components/branding-settings.tsx b/apps/web/src/app/[locale]/control-panel/branding/components/branding-settings.tsx
new file mode 100644
index 000000000..9f4a2ca2f
--- /dev/null
+++ b/apps/web/src/app/[locale]/control-panel/branding/components/branding-settings.tsx
@@ -0,0 +1,398 @@
+import { Alert, AlertDescription } from "@rallly/ui/alert";
+import {
+ Field,
+ FieldContent,
+ FieldGroup,
+ FieldLabel,
+ FieldTitle,
+} from "@rallly/ui/field";
+import { CodeIcon, ContainerIcon, GemIcon } from "lucide-react";
+import { Trans } from "react-i18next/TransWithoutContext";
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionGroup,
+ PageSectionHeader,
+ PageSectionTitle,
+} from "@/components/page-layout";
+import { loadBrandingSettings } from "@/features/branding/loaders";
+import { getTranslation } from "@/i18n/server";
+import { AppNameField } from "./app-name-field";
+import { HideAttributionField } from "./hide-attribution-field";
+import { PrimaryColorField } from "./primary-color-field";
+
+async function ConfiguredByEnvironmentVariableAlert() {
+ const { t, i18n } = await getTranslation();
+ return (
+ <Alert variant="note">
+ <ContainerIcon />
+ <AlertDescription>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="configuredByEnvironmentVariable"
+ defaults="This setting has been configured by environment variable."
+ />
+ </AlertDescription>
+ </Alert>
+ );
+}
+
+async function SetEnvironmentVariableAlert({ variable }: { variable: string }) {
+ const { t, i18n } = await getTranslation();
+ return (
+ <Alert>
+ <CodeIcon />
+ <AlertDescription>
+ <p>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="setEnvironmentVariable"
+ defaults="This value can be changed by setting the <env /> environment variable."
+ components={{
+ env: <code className="font-mono text-sm">{variable}</code>,
+ }}
+ />
+ </p>
+ </AlertDescription>
+ </Alert>
+ );
+}
+
+export async function BrandingSettings() {
+ const {
+ hasWhiteLabelAddon,
+ appName,
+ primaryColor,
+ primaryColorDark,
+ hideAttribution,
+ logoUrlLight,
+ logoUrlDark,
+ logoIconUrl,
+ envConfigured,
+ } = await loadBrandingSettings();
+ const { t, i18n } = await getTranslation();
+
+ return (
+ <>
+ {!hasWhiteLabelAddon ? (
+ <Alert variant="primary">
+ <GemIcon />
+ <AlertDescription className="flex gap-2">
+ <p className="flex-1">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="customBrandingAlertDescription"
+ defaults="Custom branding is available to Enterprise license holders as a paid add-on."
+ />
+ </p>
+ <p>
+ <a
+ href="https://support.rallly.co/self-hosting/white-labeling"
+ target="_blank"
+ className="underline"
+ rel="noreferrer"
+ >
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="learnMore"
+ defaults="Learn more"
+ />
+ </a>
+ </p>
+ </AlertDescription>
+ </Alert>
+ ) : null}
+ <PageSectionGroup>
+ <PageSection variant="card">
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="general"
+ defaults="General"
+ />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="brandingGeneralDescription"
+ defaults="Set the name of your instance"
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldLabel htmlFor="app-name">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="appName"
+ defaults="App name"
+ />
+ </FieldLabel>
+ </FieldContent>
+ <AppNameField
+ defaultValue={appName}
+ disabled={!hasWhiteLabelAddon}
+ />
+ </Field>
+ {envConfigured.appName ? (
+ <ConfiguredByEnvironmentVariableAlert />
+ ) : null}
+ </Field>
+ </FieldGroup>
+ </PageSectionContent>
+ </PageSection>
+ <PageSection variant="card">
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="colors"
+ defaults="Colors"
+ />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="colorsDescription"
+ defaults="Primary colors used for theming"
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle id="primary-color-label">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="primaryColor"
+ defaults="Primary color"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <PrimaryColorField
+ field="primaryColor"
+ defaultValue={primaryColor}
+ disabled={!hasWhiteLabelAddon}
+ aria-labelledby="primary-color-label"
+ />
+ </Field>
+ {envConfigured.primaryColor ? (
+ <ConfiguredByEnvironmentVariableAlert />
+ ) : null}
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle id="primary-color-dark-label">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="primaryColorDark"
+ defaults="Primary color (dark mode)"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <PrimaryColorField
+ field="primaryColorDark"
+ defaultValue={primaryColorDark}
+ disabled={!hasWhiteLabelAddon}
+ aria-labelledby="primary-color-dark-label"
+ />
+ </Field>
+ {envConfigured.primaryColorDark ? (
+ <ConfiguredByEnvironmentVariableAlert />
+ ) : null}
+ </Field>
+ </FieldGroup>
+ </PageSectionContent>
+ </PageSection>
+ <PageSection variant="card">
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logos"
+ defaults="Logos"
+ />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logosDescription"
+ defaults="Logo images used throughout the application"
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logo"
+ defaults="Logo"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-white">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoUrlLight}
+ alt={t("logo", { ns: "app", defaultValue: "Logo" })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
+ </div>
+ </Field>
+ <SetEnvironmentVariableAlert variable="LOGO_URL" />
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logoDark"
+ defaults="Logo (dark mode)"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-gray-900">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoUrlDark}
+ alt={t("logoDark", {
+ ns: "app",
+ defaultValue: "Logo (dark mode)",
+ })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
+ </div>
+ </Field>
+ <SetEnvironmentVariableAlert variable="LOGO_URL_DARK" />
+ </Field>
+ <Field>
+ <Field orientation="responsive">
+ <FieldContent>
+ <FieldTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="logoIcon"
+ defaults="Logo icon"
+ />
+ </FieldTitle>
+ </FieldContent>
+ <div className="flex items-center">
+ <div className="flex size-16 items-center justify-center overflow-hidden rounded border bg-white">
+ {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
+ <img
+ src={logoIconUrl}
+ alt={t("logoIcon", {
+ ns: "app",
+ defaultValue: "Logo icon",
+ })}
+ className="max-h-full max-w-full object-contain p-2"
+ />
+ </div>
+ </div>
+ </Field>
+ <SetEnvironmentVariableAlert variable="LOGO_ICON_URL" />
+ </Field>
+ </FieldGroup>
+ </PageSectionContent>
+ </PageSection>
+ <PageSection variant="card">
+ <PageSectionHeader>
+ <PageSectionTitle>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="attribution"
+ defaults="Attribution"
+ />
+ </PageSectionTitle>
+ <PageSectionDescription>
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="attributionDescription"
+ defaults="Control the visibility of the attribution text"
+ />
+ </PageSectionDescription>
+ </PageSectionHeader>
+ <PageSectionContent>
+ <FieldGroup variant="divided">
+ <Field>
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldLabel htmlFor="hide-attribution">
+ <Trans
+ t={t}
+ i18n={i18n}
+ ns="app"
+ i18nKey="hideAttribution"
+ defaults="Hide attribution"
+ />
+ </FieldLabel>
+ </FieldContent>
+ <HideAttributionField
+ defaultValue={hideAttribution}
+ disabled={!hasWhiteLabelAddon}
+ />
+ </Field>
+ {envConfigured.hideAttribution ? (
+ <ConfiguredByEnvironmentVariableAlert />
+ ) : null}
+ </Field>
+ </FieldGroup>
+ </PageSectionContent>
+ </PageSection>
+ </PageSectionGroup>
+ </>
+ );
+}
diff --git a/apps/web/src/app/[locale]/control-panel/branding/components/hide-attribution-field.tsx b/apps/web/src/app/[locale]/control-panel/branding/components/hide-attribution-field.tsx
new file mode 100644
index 000000000..d6b93fb36
--- /dev/null
+++ b/apps/web/src/app/[locale]/control-panel/branding/components/hide-attribution-field.tsx
@@ -0,0 +1,46 @@
+"use client";
+
+import { toast } from "@rallly/ui/sonner";
+import { Switch } from "@rallly/ui/switch";
+import React from "react";
+import { useTranslation } from "@/i18n/client";
+import { useSafeAction } from "@/lib/safe-action/client";
+import { updateBrandingSettingsAction } from "../actions";
+
+export function HideAttributionField({
+ defaultValue,
+ disabled = false,
+}: {
+ defaultValue: boolean;
+ disabled?: boolean;
+}) {
+ const { t } = useTranslation();
+ const updateBranding = useSafeAction(updateBrandingSettingsAction);
+
+ // Optimistic value shown until the post-action router refresh delivers
+ // the updated settings; reverts automatically if the action fails.
+ const [hideAttribution, setOptimisticHideAttribution] =
+ React.useOptimistic(defaultValue);
+
+ const handleToggle = (newChecked: boolean) => {
+ React.startTransition(async () => {
+ setOptimisticHideAttribution(newChecked);
+ const result = await updateBranding.executeAsync({
+ hideAttribution: newChecked,
+ });
+
+ if (!result?.serverError && !result?.validationErrors) {
+ toast.success(t("saved", { defaultValue: "Saved" }));
+ }
+ });
+ };
+
+ return (
+ <Switch
+ id="hide-attribution"
+ checked={hideAttribution}
+ onCheckedChange={handleToggle}
+ disabled={disabled || updateBranding.isExecuting}
+ />
+ );
+}
diff --git a/apps/web/src/app/[locale]/control-panel/branding/components/primary-color-field.tsx b/apps/web/src/app/[locale]/control-panel/branding/components/primary-color-field.tsx
new file mode 100644
index 000000000..2e7f494cf
--- /dev/null
+++ b/apps/web/src/app/[locale]/control-panel/branding/components/primary-color-field.tsx
@@ -0,0 +1,85 @@
+"use client";
+
+import { ColorPicker, parseColor } from "@rallly/ui/color-picker";
+import { InputGroupButton } from "@rallly/ui/input-group";
+import { toast } from "@rallly/ui/sonner";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@rallly/ui/tooltip";
+import { CheckIcon } from "lucide-react";
+import React from "react";
+import { Trans, useTranslation } from "@/i18n/client";
+import { useSafeAction } from "@/lib/safe-action/client";
+import { updateBrandingSettingsAction } from "../actions";
+
+export function PrimaryColorField({
+ field,
+ defaultValue,
+ disabled = false,
+ "aria-labelledby": labelledBy,
+}: {
+ field: "primaryColor" | "primaryColorDark";
+ defaultValue: string;
+ disabled?: boolean;
+ "aria-labelledby"?: string;
+}) {
+ const { t } = useTranslation();
+ const updateBranding = useSafeAction(updateBrandingSettingsAction);
+ const [color, setColor] = React.useState(() => parseColor(defaultValue));
+ const hexColor = color.toString("hex");
+ // Stored values may differ in case from what the picker emits
+ const isDirty = hexColor.toLowerCase() !== defaultValue.toLowerCase();
+
+ if (disabled) {
+ // The color picker has no disabled state; show a static swatch instead
+ return (
+ <div className="flex items-center gap-2">
+ <div
+ className="size-8 rounded border"
+ style={{ backgroundColor: defaultValue }}
+ />
+ <span className="font-mono text-sm">{defaultValue}</span>
+ </div>
+ );
+ }
+
+ const handleSave = async () => {
+ const result = await updateBranding.executeAsync(
+ field === "primaryColor"
+ ? { primaryColor: hexColor }
+ : { primaryColorDark: hexColor },
+ );
+
+ if (!result?.serverError && !result?.validationErrors) {
+ toast.success(t("saved", { defaultValue: "Saved" }));
+ }
+ };
+
+ return (
+ <ColorPicker
+ className="w-44"
+ value={color}
+ onChange={setColor}
+ aria-labelledby={labelledBy}
+ actions={
+ isDirty ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <InputGroupButton
+ size="icon-xs"
+ onClick={handleSave}
+ loading={updateBranding.isExecuting}
+ aria-label={t("save", { defaultValue: "Save" })}
+ >
+ <CheckIcon />
+ </InputGroupButton>
+ }
+ />
+ <TooltipContent>
+ <Trans i18nKey="save" defaults="Save" />
+ </TooltipContent>
+ </Tooltip>
+ ) : null
+ }
+ />
+ );
+}
diff --git a/apps/web/src/app/[locale]/control-panel/branding/page.tsx b/apps/web/src/app/[locale]/control-panel/branding/page.tsx
index 9274e408c..8306fda30 100644
--- a/apps/web/src/app/[locale]/control-panel/branding/page.tsx
+++ b/apps/web/src/app/[locale]/control-panel/branding/page.tsx
@@ -1,24 +1,6 @@
-import { Alert, AlertDescription } from "@rallly/ui/alert";
-import {
- Field,
- FieldContent,
- FieldGroup,
- FieldLabel,
- FieldTitle,
-} from "@rallly/ui/field";
-import { Input } from "@rallly/ui/input";
-import { Switch } from "@rallly/ui/switch";
-import { CodeIcon, GemIcon } from "lucide-react";
import type { Metadata } from "next";
-import { Trans } from "react-i18next/TransWithoutContext";
-import {
- PageSection,
- PageSectionContent,
- PageSectionDescription,
- PageSectionGroup,
- PageSectionHeader,
- PageSectionTitle,
-} from "@/components/page-layout";
+import { Suspense } from "react";
+import { RouterLoadingIndicator } from "@/components/router-loading-indicator";
import {
SettingsPage,
SettingsPageContent,
@@ -26,402 +8,28 @@ import {
SettingsPageHeader,
SettingsPageTitle,
} from "@/components/settings-layout";
-import { getCustomBrandingConfig } from "@/features/branding/data";
-import { loadInstanceLicense } from "@/features/licensing/data";
+import { Trans } from "@/i18n/client";
import { getTranslation } from "@/i18n/server";
+import { BrandingSettings } from "./components/branding-settings";
-async function loadData() {
- const [license, brandingConfig] = await Promise.all([
- loadInstanceLicense(),
- getCustomBrandingConfig(),
- ]);
-
- return {
- primaryColorLight: brandingConfig.primaryColor.light,
- primaryColorDark: brandingConfig.primaryColor.dark,
- logoUrlLight: brandingConfig.logo.light,
- logoUrlDark: brandingConfig.logo.dark,
- hasWhiteLabelAddon: license?.whiteLabelAddon ?? false,
- logoIconUrl: brandingConfig.logoIcon,
- hideAttribution: brandingConfig.hideAttribution,
- appName: brandingConfig.appName,
- };
-}
-
-async function SetEnvironmentVariableAlert({ variable }: { variable: string }) {
- const { t, i18n } = await getTranslation();
- return (
- <Alert>
- <CodeIcon />
- <AlertDescription>
- <p>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="setEnvironmentVariable"
- defaults="This value can be changed by setting the <env /> environment variable."
- components={{
- env: <code className="font-mono text-sm">{variable}</code>,
- }}
- />
- </p>
- </AlertDescription>
- </Alert>
- );
-}
-
-export default async function BrandingPage() {
- const {
- primaryColorLight,
- primaryColorDark,
- logoUrlLight,
- logoUrlDark,
- logoIconUrl,
- hasWhiteLabelAddon,
- hideAttribution,
- appName,
- } = await loadData();
- const { t, i18n } = await getTranslation();
-
+export default function BrandingPage() {
return (
<SettingsPage>
<SettingsPageHeader>
<SettingsPageTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="branding"
- defaults="Branding"
- />
+ <Trans i18nKey="branding" defaults="Branding" />
</SettingsPageTitle>
<SettingsPageDescription>
<Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="brandingDescription"
- defaults="View your instance branding configuration"
+ i18nKey="brandingSettingsDescription"
+ defaults="Customize your instance branding"
/>
</SettingsPageDescription>
</SettingsPageHeader>
<SettingsPageContent>
- {!hasWhiteLabelAddon ? (
- <Alert variant="primary">
- <GemIcon />
- <AlertDescription className="flex gap-2">
- <p className="flex-1">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="customBrandingAlertDescription"
- defaults="Custom branding is available to Enterprise license holders as a paid add-on."
- />
- </p>
- <p>
- <a
- href="https://support.rallly.co/self-hosting/white-labeling"
- target="_blank"
- className="underline"
- rel="noreferrer"
- >
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="learnMore"
- defaults="Learn more"
- />
- </a>
- </p>
- </AlertDescription>
- </Alert>
- ) : null}
- <PageSectionGroup>
- <PageSection variant="card">
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="general"
- defaults="General"
- />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="brandingDescription"
- defaults="View your instance branding configuration"
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <FieldGroup variant="divided">
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldLabel htmlFor="app-name">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="appName"
- defaults="App name"
- />
- </FieldLabel>
- </FieldContent>
- <Input
- id="app-name"
- className="w-56"
- value={appName}
- readOnly
- />
- </Field>
- <SetEnvironmentVariableAlert variable="APP_NAME" />
- </Field>
- </FieldGroup>
- </PageSectionContent>
- </PageSection>
- <PageSection variant="card">
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="colors"
- defaults="Colors"
- />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="colorsDescription"
- defaults="Primary colors used for theming"
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <FieldGroup variant="divided">
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="primaryColor"
- defaults="Primary color"
- />
- </FieldTitle>
- </FieldContent>
- <div className="flex items-center gap-2">
- <div
- className="size-8 rounded border"
- style={{ backgroundColor: primaryColorLight }}
- />
- <span className="font-mono text-sm">
- {primaryColorLight}
- </span>
- </div>
- </Field>
- <SetEnvironmentVariableAlert variable="PRIMARY_COLOR" />
- </Field>
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="primaryColorDark"
- defaults="Primary color (dark mode)"
- />
- </FieldTitle>
- </FieldContent>
- <div className="flex items-center gap-2">
- <div
- className="size-8 rounded border"
- style={{ backgroundColor: primaryColorDark }}
- />
- <span className="font-mono text-sm">
- {primaryColorDark}
- </span>
- </div>
- </Field>
- <SetEnvironmentVariableAlert variable="PRIMARY_COLOR_DARK" />
- </Field>
- </FieldGroup>
- </PageSectionContent>
- </PageSection>
- <PageSection variant="card">
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logos"
- defaults="Logos"
- />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logosDescription"
- defaults="Logo images used throughout the application"
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <FieldGroup variant="divided">
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logo"
- defaults="Logo"
- />
- </FieldTitle>
- </FieldContent>
- <div className="flex items-center">
- <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-white">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoUrlLight}
- alt={t("logo", { ns: "app", defaultValue: "Logo" })}
- className="max-h-full max-w-full object-contain p-2"
- />
- </div>
- </div>
- </Field>
- <SetEnvironmentVariableAlert variable="LOGO_URL" />
- </Field>
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logoDark"
- defaults="Logo (dark mode)"
- />
- </FieldTitle>
- </FieldContent>
- <div className="flex items-center">
- <div className="flex w-48 items-center justify-center overflow-hidden rounded border bg-gray-900">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoUrlDark}
- alt={t("logoDark", {
- ns: "app",
- defaultValue: "Logo (dark mode)",
- })}
- className="max-h-full max-w-full object-contain p-2"
- />
- </div>
- </div>
- </Field>
- <SetEnvironmentVariableAlert variable="LOGO_URL_DARK" />
- </Field>
- <Field>
- <Field orientation="responsive">
- <FieldContent>
- <FieldTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="logoIcon"
- defaults="Logo icon"
- />
- </FieldTitle>
- </FieldContent>
- <div className="flex items-center">
- <div className="flex size-16 items-center justify-center overflow-hidden rounded border bg-white">
- {/* biome-ignore lint/performance/noImgElement: external URLs may not work with Next.js Image */}
- <img
- src={logoIconUrl}
- alt={t("logoIcon", {
- ns: "app",
- defaultValue: "Logo icon",
- })}
- className="max-h-full max-w-full object-contain p-2"
- />
- </div>
- </div>
- </Field>
- <SetEnvironmentVariableAlert variable="LOGO_ICON_URL" />
- </Field>
- </FieldGroup>
- </PageSectionContent>
- </PageSection>
- <PageSection variant="card">
- <PageSectionHeader>
- <PageSectionTitle>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="attribution"
- defaults="Attribution"
- />
- </PageSectionTitle>
- <PageSectionDescription>
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="attributionDescription"
- defaults="Control the visibility of the attribution text"
- />
- </PageSectionDescription>
- </PageSectionHeader>
- <PageSectionContent>
- <FieldGroup variant="divided">
- <Field>
- <Field orientation="horizontal">
- <FieldContent>
- <FieldLabel htmlFor="hide-attribution">
- <Trans
- t={t}
- i18n={i18n}
- ns="app"
- i18nKey="hideAttribution"
- defaults="Hide attribution"
- />
- </FieldLabel>
- </FieldContent>
- <Switch
- id="hide-attribution"
- checked={hideAttribution}
- disabled
- />
- </Field>
- <SetEnvironmentVariableAlert variable="HIDE_ATTRIBUTION" />
- </Field>
- </FieldGroup>
- </PageSectionContent>
- </PageSection>
- </PageSectionGroup>
+ <Suspense fallback={<RouterLoadingIndicator />}>
+ <BrandingSettings />
+ </Suspense>
</SettingsPageContent>
</SettingsPage>
);
diff --git a/apps/web/src/app/[locale]/control-panel/settings/actions.ts b/apps/web/src/app/[locale]/control-panel/settings/actions.ts
index 457690830..1c51ca7e5 100644
--- a/apps/web/src/app/[locale]/control-panel/settings/actions.ts
+++ b/apps/web/src/app/[locale]/control-panel/settings/actions.ts
@@ -1,8 +1,6 @@
"use server";
-import { prisma } from "@rallly/database";
-import { updateTag } from "next/cache";
-import { instanceSettingsTag } from "@/features/instance-settings/constants";
+import { updateInstanceSettings } from "@/features/instance-settings/mutations";
import { instanceSettingsSchema } from "@/features/instance-settings/schema";
import { adminActionClient } from "@/lib/safe-action/server";
@@ -12,12 +10,5 @@ export const updateInstanceSettingsAction = adminActionClient
})
.inputSchema(instanceSettingsSchema)
.action(async ({ parsedInput }) => {
- await prisma.instanceSettings.update({
- where: {
- id: 1,
- },
- data: parsedInput,
- });
-
- updateTag(instanceSettingsTag);
+ await updateInstanceSettings(parsedInput);
});
diff --git a/apps/web/src/features/branding/loaders.ts b/apps/web/src/features/branding/loaders.ts
new file mode 100644
index 000000000..be5e8be84
--- /dev/null
+++ b/apps/web/src/features/branding/loaders.ts
@@ -0,0 +1,53 @@
+import "server-only";
+
+import { cache } from "react";
+import { env } from "@/env";
+import { getInstanceSettings } from "@/features/instance-settings/data";
+import { loadInstanceLicense } from "@/features/licensing/data";
+import { DEFAULT_PRIMARY_COLOR } from "./constants";
+import { getCustomBrandingConfig } from "./data";
+import { getPrimaryColorVars } from "./utils";
+
+/**
+ * Raw branding values for the control panel branding page. Editable fields
+ * expose the stored value (db, then env, then default) rather than the
+ * contrast-adjusted output of `resolveBrandingConfig`, so inputs reflect
+ * what will be saved. `envConfigured` marks fields that are driven by an
+ * environment variable because no database value has been set yet.
+ */
+export const loadBrandingSettings = cache(async () => {
+ const [license, db, resolved] = await Promise.all([
+ loadInstanceLicense(),
+ getInstanceSettings(),
+ getCustomBrandingConfig(),
+ ]);
+
+ const primaryColor =
+ db.primaryColor ?? env.PRIMARY_COLOR ?? DEFAULT_PRIMARY_COLOR;
+ const primaryColorDark =
+ db.primaryColorDark ??
+ env.PRIMARY_COLOR_DARK ??
+ getPrimaryColorVars(primaryColor).dark;
+
+ return {
+ hasWhiteLabelAddon: license?.whiteLabelAddon ?? false,
+ appName: db.appName ?? env.APP_NAME,
+ primaryColor,
+ primaryColorDark,
+ hideAttribution: db.hideAttribution ?? env.HIDE_ATTRIBUTION === "true",
+ logoUrlLight: resolved.logo.light,
+ logoUrlDark: resolved.logo.dark,
+ logoIconUrl: resolved.logoIcon,
+ // Checked against process.env because the parsed env applies defaults
+ // (APP_NAME, HIDE_ATTRIBUTION), which would read as operator-set
+ envConfigured: {
+ appName: db.appName === null && Boolean(process.env.APP_NAME),
+ primaryColor:
+ db.primaryColor === null && Boolean(process.env.PRIMARY_COLOR),
+ primaryColorDark:
+ db.primaryColorDark === null && Boolean(process.env.PRIMARY_COLOR_DARK),
+ hideAttribution:
+ db.hideAttribution === null && Boolean(process.env.HIDE_ATTRIBUTION),
+ },
+ };
+});
diff --git a/apps/web/src/features/instance-settings/mutations.ts b/apps/web/src/features/instance-settings/mutations.ts
new file mode 100644
index 000000000..bae32c834
--- /dev/null
+++ b/apps/web/src/features/instance-settings/mutations.ts
@@ -0,0 +1,23 @@
+import "server-only";
+
+import { prisma } from "@rallly/database";
+import { updateTag } from "next/cache";
+import { instanceSettingsTag } from "./constants";
+
+export async function updateInstanceSettings(data: {
+ disableUserRegistration?: boolean;
+ appName?: string;
+ primaryColor?: string;
+ primaryColorDark?: string;
+ hideAttribution?: boolean;
+}) {
+ // The id 1 row is seeded by migration, so it always exists
+ await prisma.instanceSettings.update({
+ where: {
+ id: 1,
+ },
+ data,
+ });
+
+ updateTag(instanceSettingsTag);
+}
diff --git a/apps/web/src/features/instance-settings/schema.ts b/apps/web/src/features/instance-settings/schema.ts
index ffbb79a93..ea7a24093 100644
--- a/apps/web/src/features/instance-settings/schema.ts
+++ b/apps/web/src/features/instance-settings/schema.ts
@@ -5,3 +5,12 @@ export const instanceSettingsSchema = z.object({
});
export type InstanceSettings = z.infer<typeof instanceSettingsSchema>;
+
+export const brandingSettingsSchema = z.object({
+ appName: z.string().trim().min(1).max(100),
+ primaryColor: z.string().regex(/^#[0-9a-fA-F]{6}$/, "Invalid hex color"),
+ primaryColorDark: z.string().regex(/^#[0-9a-fA-F]{6}$/, "Invalid hex color"),
+ hideAttribution: z.boolean(),
+});
+
+export type BrandingSettings = z.infer<typeof brandingSettingsSchema>;