Handle cookie banner version sync on updates

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-20 15:00:17 +04:00
parent c271938525
commit ddc97208e5
8 changed files with 118 additions and 3 deletions

View File

@@ -86,6 +86,14 @@ const publishMutation = graphql`
version
state
}
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;
@@ -108,7 +116,9 @@ export default function CookieBannerConfigLayout({ queryRef }: CookieBannerConfi
const banner = data.node;
const [commitActivate, isActivating] = useMutation<CookieBannerConfigLayoutActivateMutation>(activateMutation);
const [commitDeactivate, isDeactivating] = useMutation<CookieBannerConfigLayoutDeactivateMutation>(deactivateMutation);
const [commitDeactivate, isDeactivating] = useMutation<CookieBannerConfigLayoutDeactivateMutation>(
deactivateMutation,
);
const [commitPublish, isPublishing] = useMutation<CookieBannerConfigLayoutPublishMutation>(publishMutation);
const handleToggleState = () => {
@@ -164,7 +174,22 @@ export default function CookieBannerConfigLayout({ queryRef }: CookieBannerConfi
/>
<PageHeader
title={banner.name}
title={(
<div className="align-baseline">
{banner.name}
{banner.latestVersion?.version != null && (
<span className="font-mono text-base text-txt-secondary ml-2">
v
{banner.latestVersion.version}
{banner.latestVersion.state === "DRAFT" && (
<span className="text-xs font-sans">
&nbsp;(draft)
</span>
)}
</span>
)}
</div>
)}
description={banner.origin}
>
<Badge variant={banner.state === "ACTIVE" ? "success" : "danger"}>

View File

@@ -43,6 +43,11 @@ const updateBannerMutation = graphql`
privacyPolicyUrl
consentExpiryDays
consentMode
latestVersion {
id
version
state
}
}
}
}

View File

@@ -52,6 +52,14 @@ const createMutation = graphql`
updatedAt
}
}
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;

View File

@@ -50,6 +50,14 @@ const deleteCategoryMutation = graphql`
) {
deleteCookieCategory(input: $input) {
deletedCookieCategoryId @deleteEdge(connections: $connections)
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;
@@ -69,6 +77,14 @@ const updateCategoryMutation = graphql`
}
updatedAt
}
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;

View File

@@ -48,6 +48,14 @@ const updateCategoryMutation = graphql`
}
updatedAt
}
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;

View File

@@ -69,6 +69,14 @@ const updateCategoryMutation = graphql`
}
updatedAt
}
cookieBanner {
id
latestVersion {
id
version
state
}
}
}
}
`;