@cosmicdrift/kumiko-document-designer 0.396.0 → 0.398.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ export declare const PDF_TEMPLATE_EDITOR_SCREEN_ID: "pdf-template-editor";
7
7
  export declare const MAIL_EDITOR_SCREEN_ID: "mail-editor";
8
8
  export declare const TEMPLATES_NAV_ID: "templates";
9
9
  export declare const PLATFORM_TEMPLATES_NAV_ID: "platform-templates";
10
+ export declare const MANAGED_PAGES_FEATURE_NAME: "managed-pages";
10
11
  export declare const BRANDING_SCREEN_QN: "managed-pages:screen:branding-settings";
11
12
  export declare const BRANDING_QUERY_QN: "managed-pages:query:branding";
12
13
  export declare const USER_ME_QUERY_QN: "user:query:user:me";
@@ -8,6 +8,7 @@ export const PDF_TEMPLATE_EDITOR_SCREEN_ID = "pdf-template-editor";
8
8
  export const MAIL_EDITOR_SCREEN_ID = "mail-editor";
9
9
  export const TEMPLATES_NAV_ID = "templates";
10
10
  export const PLATFORM_TEMPLATES_NAV_ID = "platform-templates";
11
+ export const MANAGED_PAGES_FEATURE_NAME = "managed-pages";
11
12
  export const BRANDING_SCREEN_QN = "managed-pages:screen:branding-settings";
12
13
  export const BRANDING_QUERY_QN = "managed-pages:query:branding";
13
14
  // Pinned like the branding names: the user features' constants are not exported to the web barrel.
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useAppFeatures, useNav, usePrimitives, useTranslation, } from "@cosmicdrift/kumiko-renderer";
3
- import { BRANDING_SCREEN_QN } from "./constants.js";
3
+ import { BRANDING_SCREEN_QN, MANAGED_PAGES_FEATURE_NAME } from "./constants.js";
4
4
  import { isHexColor, LAYOUT_ACCENT_LINES, LAYOUT_BUTTON_STYLES, LAYOUT_FONTS, LAYOUT_WIDTHS, } from "./layout-meta.js";
5
5
  import { layoutUsers } from "./layout-users.js";
6
6
  import { PLACEHOLDER_SYMBOL, SYSTEM_PLACEHOLDER_TYPE, systemPlaceholderLabel, } from "./mail-draft.js";
@@ -24,7 +24,7 @@ export function BrandingRail({ data, unavailable, }) {
24
24
  const nav = useNav();
25
25
  const features = useAppFeatures();
26
26
  const { Link } = usePrimitives();
27
- const hasBrandingScreen = features.some((feature) => feature.featureName === "managed-pages" &&
27
+ const hasBrandingScreen = features.some((feature) => feature.featureName === MANAGED_PAGES_FEATURE_NAME &&
28
28
  feature.screens.some((screen) => screen.id === BRANDING_SCREEN_SHORT_ID));
29
29
  const notSet = t("documentDesigner.branding.notSet");
30
30
  const value = (text) => text === undefined || text === "" ? notSet : text;
@@ -0,0 +1,3 @@
1
+ import { type UseQueryResult } from "@cosmicdrift/kumiko-renderer";
2
+ import type { BrandingView } from "./layout-types.ts";
3
+ export declare function useBranding(): UseQueryResult<BrandingView>;
@@ -0,0 +1,8 @@
1
+ import { useAppFeatures, useQuery } from "@cosmicdrift/kumiko-renderer";
2
+ import { BRANDING_QUERY_QN, MANAGED_PAGES_FEATURE_NAME } from "./constants.js";
3
+ // Branding belongs to managed-pages. In an app without it the query has no handler, so every
4
+ // editor open would log a 404; the editors show branding as unavailable instead.
5
+ export function useBranding() {
6
+ const mounted = useAppFeatures().some((feature) => feature.featureName === MANAGED_PAGES_FEATURE_NAME);
7
+ return useQuery(BRANDING_QUERY_QN, {}, { enabled: mounted });
8
+ }
@@ -1,5 +1,5 @@
1
1
  import { type EditorTab, type Region, type Translate } from "./layout-editor-logic.ts";
2
- import type { BrandingView, LayoutKind, LayoutSourceView, LayoutValidation, TenantOverrideCounts } from "./layout-types.ts";
2
+ import type { LayoutKind, LayoutSourceView, LayoutValidation, TenantOverrideCounts } from "./layout-types.ts";
3
3
  import type { OverviewRowView } from "./overview-row.ts";
4
4
  export type LayoutEditorBodyProps = {
5
5
  readonly kind: LayoutKind;
@@ -35,7 +35,7 @@ export declare function useLayoutEditorState(props: LayoutEditorBodyProps, t: Tr
35
35
  setPendingKind: import("react").Dispatch<import("react").SetStateAction<LayoutKind | null>>;
36
36
  saveError: string | null;
37
37
  setSaveError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
38
- branding: import("@cosmicdrift/kumiko-renderer").UseQueryResult<BrandingView>;
38
+ branding: import("@cosmicdrift/kumiko-renderer").UseQueryResult<import("./layout-types.ts").BrandingView>;
39
39
  mjmlMode: boolean;
40
40
  appearanceFromMjml: boolean;
41
41
  dirty: boolean;
@@ -1,10 +1,10 @@
1
1
  import { TemplateResolverHandlers, TemplateResolverQueries, } from "@cosmicdrift/kumiko-bundled-features/template-resolver/web";
2
2
  import { useMutation, useQuery } from "@cosmicdrift/kumiko-renderer";
3
3
  import { useState } from "react";
4
- import { BRANDING_QUERY_QN } from "./constants.js";
5
4
  import { accentLineShown, appearanceFlags, footerMessageOf, initialTab, layoutBlocks, layoutContent, layoutDirty, layoutSaveFlags, resourcePreviewsOf, saveLayout, shownRowOf, } from "./layout-editor-logic.js";
6
5
  import { appearanceOf } from "./layout-meta.js";
7
6
  import { systemLabelMap } from "./mail-draft.js";
7
+ import { useBranding } from "./use-branding.js";
8
8
  import { useDebouncedValue } from "./use-debounced-value.js";
9
9
  // Server-side validation compiles the whole layout (mjml), so wait for a pause in typing.
10
10
  const VALIDATE_DEBOUNCE_MS = 400;
@@ -26,7 +26,7 @@ export function useLayoutEditorState(props, t) {
26
26
  const upsertTenant = useMutation(TemplateResolverHandlers.upsertTenant);
27
27
  const upsertSystem = useMutation(TemplateResolverHandlers.upsertSystem);
28
28
  const publishSystem = useMutation(TemplateResolverHandlers.publishSystem);
29
- const branding = useQuery(BRANDING_QUERY_QN, {});
29
+ const branding = useBranding();
30
30
  const mjmlMode = tab === "mjml";
31
31
  const { appearanceFromMjml, appearanceEditable, appearanceValid } = appearanceFlags({
32
32
  isMail,
@@ -2,13 +2,13 @@ import { TemplateResolverQueries } from "@cosmicdrift/kumiko-bundled-features/te
2
2
  import { useQuery, useUserRoles } from "@cosmicdrift/kumiko-renderer";
3
3
  import { RendererPuppeteerClientQueries } from "@cosmicdrift/kumiko-renderer-puppeteer-client/qualified-names";
4
4
  import { useEffect, useMemo, useRef, useState } from "react";
5
- import { BRANDING_QUERY_QN } from "./constants.js";
6
5
  import { systemLabelMap, variableLabelMap } from "./mail-draft.js";
7
6
  import { draftFromDetail, imageLabelSource, NO_VARIABLES, snapshotOf, textVariablesOf, } from "./pdf-editor-draft.js";
8
7
  import { visibleSystemPlaceholders } from "./pdf-left-rail.js";
9
8
  import { serializePdfMeta } from "./pdf-meta.js";
10
9
  import { localesOf, parseJsonObject, pickRow, resolveLocale } from "./template-rows.js";
11
10
  import { DOCUMENT_PDF_KIND, PDF_LAYOUT_KIND, } from "./types.js";
11
+ import { useBranding } from "./use-branding.js";
12
12
  import { useFilesCapability } from "./use-files-capability.js";
13
13
  import { useInsertTargets } from "./use-insert-targets.js";
14
14
  import { useOverviewRows } from "./use-overview-rows.js";
@@ -104,7 +104,7 @@ function usePdfServerQueries(input) {
104
104
  const layout = previewQuery.error === null ? (previewQuery.data?.layout ?? null) : null;
105
105
  const layouts = useOverviewRows(PDF_LAYOUT_KIND);
106
106
  // The built-in "logo" resource of a layout is the tenant's branding logo.
107
- const branding = useQuery(BRANDING_QUERY_QN, {});
107
+ const branding = useBranding();
108
108
  const brandingLogoFile = branding.data?.logoFile ?? "";
109
109
  const statusQuery = useQuery(RendererPuppeteerClientQueries.status, {});
110
110
  const showOrigin = scope === "system";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-document-designer",
3
- "version": "0.396.0",
3
+ "version": "0.398.0",
4
4
  "description": "Document designer for Kumiko: template overview, layout editor (mail layout, PDF letterhead) and the PDF template editor.",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -20,15 +20,15 @@
20
20
  "./web/styles.css": "./src/web/styles.css"
21
21
  },
22
22
  "dependencies": {
23
- "@cosmicdrift/kumiko-bundled-features": "0.396.0",
24
- "@cosmicdrift/kumiko-framework": "0.396.0",
25
- "@cosmicdrift/kumiko-renderer": "0.396.0",
26
- "@cosmicdrift/kumiko-renderer-puppeteer-client": "0.396.0",
27
- "@cosmicdrift/kumiko-types": "0.396.0",
23
+ "@cosmicdrift/kumiko-bundled-features": "0.398.0",
24
+ "@cosmicdrift/kumiko-framework": "0.398.0",
25
+ "@cosmicdrift/kumiko-renderer": "0.398.0",
26
+ "@cosmicdrift/kumiko-renderer-puppeteer-client": "0.398.0",
27
+ "@cosmicdrift/kumiko-types": "0.398.0",
28
28
  "react": "^19.2.6"
29
29
  },
30
30
  "devDependencies": {
31
- "@testing-library/react": "^16.3.2",
31
+ "@testing-library/react": "^16.3.3",
32
32
  "@types/react": "^19.2.14"
33
33
  },
34
34
  "repository": {
package/src/changes.json CHANGED
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.397.0",
4
+ "type": "fix",
5
+ "title": "Editors skip the branding query without managed-pages",
6
+ "detail": "The layout editor and the PDF template editor queried managed-pages:query:branding unconditionally. In an app without managed-pages that query has no handler and answered 404 each time an editor opened. They now check the app schema for managed-pages first and show branding as unavailable without asking."
7
+ },
2
8
  {
3
9
  "version": "0.390.0",
4
10
  "type": "improvement",