Rename categories to consentCategories
Exclude the UNCATEGORISED category at the SQL level so the admin cookie/display/translations pages only see consent-relevant categories. Removes dead client-side UNCATEGORISED filters that are no longer needed. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -31,8 +31,8 @@ export const cookieBannerCookiesPageQuery = graphql`
|
||||
__typename
|
||||
... on CookieBanner {
|
||||
id
|
||||
categories(first: 50, orderBy: { field: RANK, direction: ASC })
|
||||
@connection(key: "CookieBannerCookiesPage_categories")
|
||||
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC })
|
||||
@connection(key: "CookieBannerCookiesPage_consentCategories")
|
||||
@required(action: THROW) {
|
||||
__id
|
||||
edges {
|
||||
@@ -86,8 +86,8 @@ export default function CookieBannerCookiesPage({
|
||||
}
|
||||
|
||||
const banner = data.node;
|
||||
const connectionId = banner.categories.__id;
|
||||
const categories = banner.categories.edges.map(e => e.node);
|
||||
const connectionId = banner.consentCategories.__id;
|
||||
const categories = banner.consentCategories.edges.map(e => e.node);
|
||||
const sorted = [...categories].sort((a, b) => a.rank - b.rank);
|
||||
|
||||
const [deleteCategory]
|
||||
|
||||
@@ -80,7 +80,7 @@ export const categorySectionFragment = graphql`
|
||||
}
|
||||
}
|
||||
cookieBanner @required(action: THROW) {
|
||||
categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
|
||||
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
@@ -451,7 +451,7 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps)
|
||||
});
|
||||
};
|
||||
|
||||
const allCategories = category.cookieBanner.categories.edges.map(e => e.node) ?? [];
|
||||
const allCategories = category.cookieBanner.consentCategories.edges.map(e => e.node) ?? [];
|
||||
const siblingCategories = allCategories.filter(c => c.id !== category.id);
|
||||
|
||||
const handleMoveCookie = (patternId: string, targetCategoryId: string) => {
|
||||
|
||||
@@ -25,8 +25,8 @@ import type { CategoryListReorderMutation } from "#/__generated__/core/CategoryL
|
||||
const categoryListFragment = graphql`
|
||||
fragment CategoryList_cookieBanner on CookieBanner {
|
||||
id
|
||||
categories(first: 50, orderBy: { field: RANK, direction: ASC })
|
||||
@connection(key: "CategoryList_categories")
|
||||
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC })
|
||||
@connection(key: "CategoryList_consentCategories")
|
||||
@required(action: THROW) {
|
||||
__id
|
||||
edges {
|
||||
@@ -87,8 +87,8 @@ export function CategoryList({ cookieBannerKey }: CategoryListProps) {
|
||||
const confirm = useConfirm();
|
||||
|
||||
const banner = useFragment(categoryListFragment, cookieBannerKey);
|
||||
const connectionId = banner.categories.__id;
|
||||
const categories = banner.categories.edges.map(e => e.node);
|
||||
const connectionId = banner.consentCategories.__id;
|
||||
const categories = banner.consentCategories.edges.map(e => e.node);
|
||||
|
||||
const [deleteCategory] = useMutation<CategoryListDeleteMutation>(deleteCategoryMutation);
|
||||
const [reorderCategory] = useMutation<CategoryListReorderMutation>(reorderCategoryMutation);
|
||||
|
||||
@@ -36,7 +36,7 @@ export const cookieBannerTranslationsPageQuery = graphql`
|
||||
language
|
||||
translations
|
||||
}
|
||||
categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
|
||||
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
@@ -101,14 +101,14 @@ export default function CookieBannerTranslationsPage({
|
||||
|
||||
const categories = useMemo(
|
||||
() =>
|
||||
banner.categories.edges.map(e => ({
|
||||
banner.consentCategories.edges.map(e => ({
|
||||
id: e.node.id,
|
||||
name: e.node.name,
|
||||
slug: e.node.slug,
|
||||
description: e.node.description,
|
||||
kind: e.node.kind,
|
||||
})),
|
||||
[banner.categories],
|
||||
[banner.consentCategories],
|
||||
);
|
||||
|
||||
const necessaryCategoryName = useMemo(
|
||||
|
||||
@@ -42,8 +42,6 @@ export function PanelTranslationSection({
|
||||
const buttonSave = useWatch({ control, name: "button_save" });
|
||||
const categoryTranslations = useWatch({ control, name: "categories" });
|
||||
|
||||
const visibleCategories = categories.filter(c => c.kind !== "UNCATEGORISED");
|
||||
|
||||
const translatedNecessaryName = (() => {
|
||||
const necessaryCat = categories.find(c => c.kind === "NECESSARY");
|
||||
if (!necessaryCat) return necessaryCategoryName;
|
||||
@@ -157,13 +155,13 @@ export function PanelTranslationSection({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{visibleCategories.length > 0 && (
|
||||
{categories.length > 0 && (
|
||||
<div className="space-y-4">
|
||||
<h4 className="text-sm font-medium text-txt-secondary">
|
||||
{__("Category names")}
|
||||
</h4>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{visibleCategories.map(cat => (
|
||||
{categories.map(cat => (
|
||||
<Card key={cat.id} className="border p-4 space-y-3">
|
||||
<div className="text-sm text-txt-secondary">
|
||||
{cat.name}
|
||||
|
||||
@@ -99,7 +99,6 @@ export function TranslationEditor({
|
||||
|
||||
const catDefaults: CategoryTranslations = {};
|
||||
for (const cat of categories) {
|
||||
if (cat.kind === "UNCATEGORISED") continue;
|
||||
const existing = existingCategoryTranslations?.[cat.id];
|
||||
catDefaults[cat.id] = {
|
||||
name: existing?.name ?? "",
|
||||
|
||||
Reference in New Issue
Block a user