From 9511fa3bd409c8e35919857a769e0e2017488260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Mon, 20 Apr 2026 16:22:19 +0400 Subject: [PATCH] Review fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- .../_components/CategoryList.tsx | 2 +- .../cookies/CookieBannerCookiesPage.tsx | 2 +- .../theme/CookieBannerThemePage.tsx | 23 -- .../theme/_components/ThemePreview.tsx | 277 ------------------ .../api/console/v1/cookie_banner_resolvers.go | 2 +- .../console/v1/graphql/cookie_banner.graphql | 6 +- .../console/v1/graphql/organization.graphql | 2 +- 7 files changed, 7 insertions(+), 307 deletions(-) delete mode 100644 apps/console/src/pages/organizations/cookie-banners/configuration/theme/CookieBannerThemePage.tsx delete mode 100644 apps/console/src/pages/organizations/cookie-banners/configuration/theme/_components/ThemePreview.tsx diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/_components/CategoryList.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/_components/CategoryList.tsx index 5cdfe25d7..1d2087d73 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/_components/CategoryList.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/_components/CategoryList.tsx @@ -28,7 +28,7 @@ import { CategoryDialog } from "./CategoryDialog"; const categoryListFragment = graphql` fragment CategoryList_cookieBanner on CookieBanner { id - categories(first: 50, orderBy: { field: RANK, direction: ASC }) { + categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) { __id edges { node { diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/CookieBannerCookiesPage.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/CookieBannerCookiesPage.tsx index c52e03ad8..8cbe2460d 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/CookieBannerCookiesPage.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/CookieBannerCookiesPage.tsx @@ -30,7 +30,7 @@ export const cookieBannerCookiesPageQuery = graphql` __typename ... on CookieBanner { id - categories(first: 50, orderBy: { field: RANK, direction: ASC }) { + categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) { __id edges { node { diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/theme/CookieBannerThemePage.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/theme/CookieBannerThemePage.tsx deleted file mode 100644 index 5fa11d2c7..000000000 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/theme/CookieBannerThemePage.tsx +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2026 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -import { ThemePreview } from "./_components/ThemePreview"; - -export default function CookieBannerThemePage() { - return ( -
- -
- ); -} diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/theme/_components/ThemePreview.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/theme/_components/ThemePreview.tsx deleted file mode 100644 index 19decec3e..000000000 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/theme/_components/ThemePreview.tsx +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) 2026 Probo Inc . -// -// Permission to use, copy, modify, and/or distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -// PERFORMANCE OF THIS SOFTWARE. - -import { useTranslate } from "@probo/i18n"; -import { Button, Card, Field, Input, useToast } from "@probo/ui"; -import { useCallback, useMemo, useState } from "react"; - -type CSSVariable = { - key: string; - label: string; - defaultValue: string; - type: "color" | "text"; -}; - -const CSS_VARIABLES: CSSVariable[] = [ - { key: "--probo-bg", label: "Background", defaultValue: "#ffffff", type: "color" }, - { key: "--probo-text", label: "Text", defaultValue: "#1a1a1a", type: "color" }, - { key: "--probo-text-secondary", label: "Text Secondary", defaultValue: "#555555", type: "color" }, - { key: "--probo-border", label: "Border", defaultValue: "#e0e0e0", type: "color" }, - { key: "--probo-accent", label: "Accent", defaultValue: "#1a1a1a", type: "color" }, - { key: "--probo-accent-text", label: "Accent Text", defaultValue: "#ffffff", type: "color" }, - { key: "--probo-radius", label: "Border Radius", defaultValue: "12px", type: "text" }, - { key: "--probo-btn-radius", label: "Button Radius", defaultValue: "8px", type: "text" }, - { key: "--probo-font-size", label: "Font Size", defaultValue: "14px", type: "text" }, - { key: "--probo-font-family", label: "Font Family", defaultValue: "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif", type: "text" }, - { key: "--probo-shadow", label: "Shadow", defaultValue: "0 4px 24px rgba(0, 0, 0, 0.12)", type: "text" }, -]; - -function buildCSSSnippet(values: Record): string { - const overrides = CSS_VARIABLES - .filter(v => values[v.key] !== v.defaultValue) - .map(v => ` ${v.key}: ${values[v.key]};`); - - if (overrides.length === 0) { - return "/* Using default theme — no overrides needed */"; - } - - return `probo-cookie-banner {\n${overrides.join("\n")}\n}`; -} - -export function ThemePreview() { - const { __ } = useTranslate(); - const { toast } = useToast(); - - const [values, setValues] = useState>(() => { - const initial: Record = {}; - for (const v of CSS_VARIABLES) { - initial[v.key] = v.defaultValue; - } - return initial; - }); - - const setValue = useCallback((key: string, value: string) => { - setValues(prev => ({ ...prev, [key]: value })); - }, []); - - const handleReset = useCallback(() => { - const initial: Record = {}; - for (const v of CSS_VARIABLES) { - initial[v.key] = v.defaultValue; - } - setValues(initial); - }, []); - - const cssSnippet = useMemo(() => buildCSSSnippet(values), [values]); - - const handleCopyCSS = () => { - void navigator.clipboard.writeText(cssSnippet); - toast({ - title: __("Copied"), - description: __("CSS snippet copied to clipboard"), - variant: "success", - }); - }; - - const previewStyle = useMemo(() => { - const style: Record = {}; - for (const v of CSS_VARIABLES) { - style[v.key] = values[v.key]; - } - return style; - }, [values]); - - const colorVariables = CSS_VARIABLES.filter(v => v.type === "color"); - const textVariables = CSS_VARIABLES.filter(v => v.type === "text"); - - return ( -
-
-

{__("Theme")}

- -
- - -
-
- {colorVariables.map(v => ( -
- -
- setValue(v.key, e.target.value)} - className="h-8 w-10 shrink-0 cursor-pointer rounded border border-border-mid bg-transparent p-0.5" - /> - setValue(v.key, e.target.value)} - /> -
-
- ))} -
- -
- {textVariables.map(v => ( - - setValue(v.key, e.target.value)} - /> - - ))} -
-
-
- -

{__("Preview")}

- - -
- -
-
- -
-

{__("CSS Snippet")}

- -
- - -
-          {cssSnippet}
-        
-
-
- ); -} - -function BannerPreview() { - return ( -
-

- Cookie Preferences -

-

- We use cookies to improve your experience and analyze site traffic. - {" "} - e.preventDefault()} - style={{ - color: "var(--probo-accent, #1a1a1a)", - textDecoration: "underline", - }} - > - Privacy Policy - -

-
- - - -
-
- ); -} diff --git a/pkg/server/api/console/v1/cookie_banner_resolvers.go b/pkg/server/api/console/v1/cookie_banner_resolvers.go index 79f67cee3..ed8004730 100644 --- a/pkg/server/api/console/v1/cookie_banner_resolvers.go +++ b/pkg/server/api/console/v1/cookie_banner_resolvers.go @@ -478,7 +478,7 @@ func (r *mutationResolver) DeleteCookieCategory(ctx context.Context, input types return &types.DeleteCookieCategoryPayload{ DeletedCookieCategoryID: input.CookieCategoryID, - CookieBanner: types.NewCookieBanner(banner), + CookieBanner: types.NewCookieBanner(banner), }, nil } diff --git a/pkg/server/api/console/v1/graphql/cookie_banner.graphql b/pkg/server/api/console/v1/graphql/cookie_banner.graphql index abaf84bfa..bdd5b296a 100644 --- a/pkg/server/api/console/v1/graphql/cookie_banner.graphql +++ b/pkg/server/api/console/v1/graphql/cookie_banner.graphql @@ -67,7 +67,7 @@ type CookieBanner implements Node { consentExpiryDays: Int! consentMode: CookieConsentMode! - organization: Organization! @goField(forceResolver: true) + organization: Organization @goField(forceResolver: true) categories( first: Int @@ -75,7 +75,7 @@ type CookieBanner implements Node { last: Int before: CursorKey orderBy: CookieCategoryOrder - ): CookieCategoryConnection! @goField(forceResolver: true) + ): CookieCategoryConnection @goField(forceResolver: true) latestVersion: CookieBannerVersion @goField(forceResolver: true) @@ -87,7 +87,7 @@ type CookieBanner implements Node { type CookieCategory implements Node { id: ID! - cookieBanner: CookieBanner! @goField(forceResolver: true) + cookieBanner: CookieBanner @goField(forceResolver: true) name: String! description: String! required: Boolean! diff --git a/pkg/server/api/console/v1/graphql/organization.graphql b/pkg/server/api/console/v1/graphql/organization.graphql index 191c05cb3..1db67b72a 100644 --- a/pkg/server/api/console/v1/graphql/organization.graphql +++ b/pkg/server/api/console/v1/graphql/organization.graphql @@ -312,7 +312,7 @@ type Organization implements Node { last: Int before: CursorKey orderBy: CookieBannerOrder - ): CookieBannerConnection! @goField(forceResolver: true) + ): CookieBannerConnection @goField(forceResolver: true) vendors( first: Int