camox 0.66.0 → 0.67.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.
- package/dist/features/content/components/MissingFromLocale.js +1 -1
- package/dist/features/page/UnplacedLayoutContent.js +141 -0
- package/dist/features/preview/components/ItemFieldsEditor.js +50 -44
- package/dist/features/preview/components/SelectionEditor.js +284 -231
- package/dist/features/preview/components/contentFieldSchema.js +5 -1
- package/dist/features/runtime/pageApp.js +24 -10
- package/dist/features/runtime/runtime.d.ts +13 -0
- package/dist/features/runtime/runtime.js +58 -2
- package/dist/features/studio/components/ContentFindings.js +397 -0
- package/dist/features/studio/components/Patrol.js +52 -34
- package/dist/features/studio/components/ReviewDraftSheet.js +4 -4
- package/dist/features/studio/components/Squareling.js +0 -9
- package/dist/features/studio/findingSentence.js +3 -5
- package/dist/features/studio/patrollerBio.js +0 -1
- package/dist/features/studio/reportSentence.js +0 -5
- package/dist/features/studio/workingSentence.js +0 -4
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
|
@@ -9,6 +9,7 @@ import { CoreCamoxProvider } from "../provider/CoreCamoxProvider.js";
|
|
|
9
9
|
import { CuratedPageContent } from "../page/CuratedPageContent.js";
|
|
10
10
|
import { DerivedPageContent } from "../page/DerivedPageContent.js";
|
|
11
11
|
import { UnplacedBlockContent } from "../page/UnplacedBlockContent.js";
|
|
12
|
+
import { UnplacedLayoutContent } from "../page/UnplacedLayoutContent.js";
|
|
12
13
|
import { EditingFallbackSlot } from "./editingFallback.js";
|
|
13
14
|
import { PageNavigationProvider } from "./pageNavigation.js";
|
|
14
15
|
import { RuntimeChromeSlot } from "./runtimeChromeLoader.js";
|
|
@@ -252,9 +253,9 @@ function _temp2() {
|
|
|
252
253
|
function _temp() {
|
|
253
254
|
return true;
|
|
254
255
|
}
|
|
255
|
-
/** The page's blocks, read-only, or the look document's
|
|
256
|
+
/** The page's blocks, read-only, or the look document's unplaced block or Layout. */
|
|
256
257
|
function PageContent(t0) {
|
|
257
|
-
const $ = c(
|
|
258
|
+
const $ = c(9);
|
|
258
259
|
const { camoxApp, input } = t0;
|
|
259
260
|
if (input.lookBlock) {
|
|
260
261
|
let t1;
|
|
@@ -265,24 +266,37 @@ function PageContent(t0) {
|
|
|
265
266
|
} else t1 = $[1];
|
|
266
267
|
return t1;
|
|
267
268
|
}
|
|
268
|
-
if (input.
|
|
269
|
+
if (input.lookLayout) {
|
|
269
270
|
let t1;
|
|
270
|
-
if ($[2] !== camoxApp || $[3] !== input.
|
|
271
|
-
t1 = /* @__PURE__ */ jsx(
|
|
271
|
+
if ($[2] !== camoxApp || $[3] !== input.lookLayout) {
|
|
272
|
+
t1 = /* @__PURE__ */ jsx(UnplacedLayoutContent, {
|
|
272
273
|
camoxApp,
|
|
273
|
-
|
|
274
|
+
lookLayout: input.lookLayout
|
|
274
275
|
});
|
|
275
276
|
$[2] = camoxApp;
|
|
276
|
-
$[3] = input.
|
|
277
|
+
$[3] = input.lookLayout;
|
|
277
278
|
$[4] = t1;
|
|
278
279
|
} else t1 = $[4];
|
|
279
280
|
return t1;
|
|
280
281
|
}
|
|
282
|
+
if (input.derived) {
|
|
283
|
+
let t1;
|
|
284
|
+
if ($[5] !== camoxApp || $[6] !== input.derived) {
|
|
285
|
+
t1 = /* @__PURE__ */ jsx(DerivedPageContent, {
|
|
286
|
+
camoxApp,
|
|
287
|
+
derived: input.derived
|
|
288
|
+
});
|
|
289
|
+
$[5] = camoxApp;
|
|
290
|
+
$[6] = input.derived;
|
|
291
|
+
$[7] = t1;
|
|
292
|
+
} else t1 = $[7];
|
|
293
|
+
return t1;
|
|
294
|
+
}
|
|
281
295
|
let t1;
|
|
282
|
-
if ($[
|
|
296
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
283
297
|
t1 = /* @__PURE__ */ jsx(CuratedPageContent, {});
|
|
284
|
-
$[
|
|
285
|
-
} else t1 = $[
|
|
298
|
+
$[8] = t1;
|
|
299
|
+
} else t1 = $[8];
|
|
286
300
|
return t1;
|
|
287
301
|
}
|
|
288
302
|
function StudioLoadError() {
|
|
@@ -6,6 +6,7 @@ import { AnalyticsProviders } from "./analytics.js";
|
|
|
6
6
|
import { RuntimeOwnedRouteKind } from "./runtimeRoutes.js";
|
|
7
7
|
import { StudioRenderInput } from "./studioApp.js";
|
|
8
8
|
import { DraftRead, MemberProject, PageHead, createServerApiClient } from "../routes/pageRuntime.js";
|
|
9
|
+
import { LookPlaceholderHeight } from "@camox/api-contract/drafts";
|
|
9
10
|
import { UseHeadInput } from "unhead/types";
|
|
10
11
|
//#region src/features/runtime/runtime.d.ts
|
|
11
12
|
/** The studio's own routes, rather than a page or the Canvas. */
|
|
@@ -39,6 +40,18 @@ export interface PageRenderInput extends DraftRead {
|
|
|
39
40
|
* instead of a page. Its block bundle is in the dehydrated state.
|
|
40
41
|
*/
|
|
41
42
|
lookBlock?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The look document's Layout Definition mode: the curated Layout it shows around no page, its
|
|
45
|
+
* blocks' bundles in the dehydrated state, with a placeholder `placeholder` tall where a page's
|
|
46
|
+
* content goes.
|
|
47
|
+
*/
|
|
48
|
+
lookLayout?: {
|
|
49
|
+
layoutId: string;
|
|
50
|
+
layout: Awaited<ReturnType<ReturnType<typeof createServerApiClient>["layouts"]["getUnplaced"]>>["layout"];
|
|
51
|
+
placeholder: LookPlaceholderHeight;
|
|
52
|
+
path: string;
|
|
53
|
+
projectName: string;
|
|
54
|
+
};
|
|
42
55
|
/**
|
|
43
56
|
* Whether this is the look document (ADR 0032), whose client only shows the draft: it asks
|
|
44
57
|
* nothing about a session and offers no sign-in, which would add requests to its captures.
|
|
@@ -27,7 +27,7 @@ import { getPageBlockTypes } from "./pageBlockTypes.js";
|
|
|
27
27
|
import { withPageUrls } from "./structuredData.js";
|
|
28
28
|
import { curatedPageDescription, pageRecords, placedBlockNodes, withStructuredData } from "./pageGraph.js";
|
|
29
29
|
import { createProjectLogoResponse, projectLogo } from "./projectLogo.js";
|
|
30
|
-
import { DRAFT_SEARCH_PARAM, LOCALE_HEADER, LOOK_BLOCK_DEFINITION_PARAM, LOOK_CONTENT_PARAM, LOOK_LOCALE_PARAM, LOOK_PATH_PARAM, LOOK_SETTINGS_PARAM, UNPLACED_BLOCK_ID } from "@camox/api-contract/drafts";
|
|
30
|
+
import { DRAFT_SEARCH_PARAM, LOCALE_HEADER, LOOK_BLOCKS_PARAM, LOOK_BLOCK_DEFINITION_PARAM, LOOK_CONTENT_PARAM, LOOK_LAYOUT_DEFINITION_PARAM, LOOK_LOCALE_PARAM, LOOK_PATH_PARAM, LOOK_PLACEHOLDER_HEIGHTS, LOOK_PLACEHOLDER_PARAM, LOOK_SETTINGS_PARAM, UNPLACED_BLOCK_ID } from "@camox/api-contract/drafts";
|
|
31
31
|
import { QueryClient, dehydrate } from "@tanstack/react-query";
|
|
32
32
|
import { createHead, renderSSRHead } from "@unhead/react/server";
|
|
33
33
|
|
|
@@ -571,6 +571,7 @@ async function createLookDocumentResponse(request, options) {
|
|
|
571
571
|
if (!lookToken || !draftId || !apiUrl || !authenticationUrl || !projectUuid || !renderPage) return lookNotFound();
|
|
572
572
|
const tag = searchParams.get(LOOK_LOCALE_PARAM)?.toLowerCase();
|
|
573
573
|
const blockDefinition = searchParams.get(LOOK_BLOCK_DEFINITION_PARAM);
|
|
574
|
+
const layoutDefinition = searchParams.get(LOOK_LAYOUT_DEFINITION_PARAM);
|
|
574
575
|
const queryClient = new QueryClient();
|
|
575
576
|
let locales;
|
|
576
577
|
let locale;
|
|
@@ -590,7 +591,7 @@ async function createLookDocumentResponse(request, options) {
|
|
|
590
591
|
projectUuid,
|
|
591
592
|
queryClient
|
|
592
593
|
};
|
|
593
|
-
shown = blockDefinition ? await lookAtBlockDefinition(request, options, reading, blockDefinition) : await lookAtPage(request, options, reading);
|
|
594
|
+
shown = layoutDefinition ? await lookAtLayoutDefinition(request, options, reading, layoutDefinition) : blockDefinition ? await lookAtBlockDefinition(request, options, reading, blockDefinition) : await lookAtPage(request, options, reading);
|
|
594
595
|
} catch (error) {
|
|
595
596
|
if (isAuthSessionError(error) || isNotFoundError(error)) return lookNotFound();
|
|
596
597
|
throw error;
|
|
@@ -806,6 +807,61 @@ async function lookAtBlockDefinition(request, options, reading, type) {
|
|
|
806
807
|
lookBlock: UNPLACED_BLOCK_ID
|
|
807
808
|
};
|
|
808
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* The look document's Layout Definition mode: the curated Layout `layoutId` around no page, its
|
|
812
|
+
* blocks with their default content and Block Settings and the overrides the URL gives merged on,
|
|
813
|
+
* by the API, which checks them against their schemas and refuses a Singleton or Derived Layout,
|
|
814
|
+
* answering its message. Where a page's content goes, a labelled placeholder as tall as the URL
|
|
815
|
+
* says. Its path is the Locale's home, which links resolve against.
|
|
816
|
+
*/
|
|
817
|
+
async function lookAtLayoutDefinition(request, options, reading, layoutId) {
|
|
818
|
+
const { apiUrl, lookToken, draftId, locale, projectUuid, queryClient } = reading;
|
|
819
|
+
const { searchParams } = new URL(request.url);
|
|
820
|
+
const blocks = overrideParam(searchParams, LOOK_BLOCKS_PARAM);
|
|
821
|
+
if (!blocks.ok) return lookRefused(blocks.error);
|
|
822
|
+
const placeholder = searchParams.get(LOOK_PLACEHOLDER_PARAM) ?? LOOK_PLACEHOLDER_HEIGHTS[0];
|
|
823
|
+
if (!LOOK_PLACEHOLDER_HEIGHTS.includes(placeholder)) return lookRefused(`The placeholder is ${LOOK_PLACEHOLDER_HEIGHTS.join(" or ")}.`);
|
|
824
|
+
const studioCache = createServerStudioCache(queryClient, {
|
|
825
|
+
apiUrl,
|
|
826
|
+
lookToken,
|
|
827
|
+
locale
|
|
828
|
+
});
|
|
829
|
+
const inDraft = { in: draftId };
|
|
830
|
+
let shared;
|
|
831
|
+
try {
|
|
832
|
+
[shared] = await Promise.all([createServerApiClient(apiUrl, {
|
|
833
|
+
lookToken,
|
|
834
|
+
draftId,
|
|
835
|
+
locale
|
|
836
|
+
}).layouts.getUnplaced({
|
|
837
|
+
projectUuid,
|
|
838
|
+
layoutId,
|
|
839
|
+
blocks: blocks.value
|
|
840
|
+
}), studioCache.ensure(reads.pageList({ projectUuid }), inDraft).catch(() => null)]);
|
|
841
|
+
} catch (error) {
|
|
842
|
+
if (isBadRequestError(error)) return lookRefused(error.message);
|
|
843
|
+
throw error;
|
|
844
|
+
}
|
|
845
|
+
studioCache.land(reads.layoutStructure({
|
|
846
|
+
projectUuid,
|
|
847
|
+
layoutId
|
|
848
|
+
}), shared, inDraft);
|
|
849
|
+
const pathname = localizedPath("/", locale);
|
|
850
|
+
return {
|
|
851
|
+
head: {},
|
|
852
|
+
href: lookHref(request, options, pathname, draftId).href,
|
|
853
|
+
layoutIdentity: null,
|
|
854
|
+
loaderData: null,
|
|
855
|
+
pathname,
|
|
856
|
+
lookLayout: {
|
|
857
|
+
layoutId,
|
|
858
|
+
layout: shared.layout,
|
|
859
|
+
placeholder,
|
|
860
|
+
path: pathname,
|
|
861
|
+
projectName: shared.projectName
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
}
|
|
809
865
|
/** Whether an API error refused the request's input, such as an override its schema refuses. */
|
|
810
866
|
function isBadRequestError(error) {
|
|
811
867
|
const { code, status } = error ?? {};
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { useCurrentDraftId } from "../../../lib/draft-scope.js";
|
|
2
|
+
import { useViewLocale } from "../../../lib/view-locale-context.js";
|
|
3
|
+
import { AuthContext } from "../../../lib/auth.js";
|
|
4
|
+
import { reads, useReadQuery } from "../../../lib/studio-reads.js";
|
|
5
|
+
import { patrolMutations } from "../../../lib/queries.js";
|
|
6
|
+
import { studioStore } from "../studioStore.js";
|
|
7
|
+
import { askAgentMessage, dismissLabel, findingSentenceInPlace, fixLabel } from "../findingSentence.js";
|
|
8
|
+
import { useShowInCanvas } from "../showInCanvas.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { useMutation } from "@tanstack/react-query";
|
|
13
|
+
import { Button } from "@camox/ui/button";
|
|
14
|
+
import { CircleAlert } from "lucide-react";
|
|
15
|
+
import { toast } from "@camox/ui/toaster";
|
|
16
|
+
import { Alert, AlertDescription, AlertTitle } from "@camox/ui/alert";
|
|
17
|
+
|
|
18
|
+
//#region src/features/studio/components/ContentFindings.tsx
|
|
19
|
+
/** The open findings of the Patrol viewed in a subject, in the locale viewed. */
|
|
20
|
+
function useContentFindings(subject) {
|
|
21
|
+
const $ = c(22);
|
|
22
|
+
const { projectUuid } = React.useContext(AuthContext);
|
|
23
|
+
let t0;
|
|
24
|
+
if ($[0] !== projectUuid) {
|
|
25
|
+
t0 = reads.project({ projectUuid });
|
|
26
|
+
$[0] = projectUuid;
|
|
27
|
+
$[1] = t0;
|
|
28
|
+
} else t0 = $[1];
|
|
29
|
+
const { data: project } = useReadQuery(t0);
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[2] !== project?.id) {
|
|
32
|
+
t1 = reads.patrol({ projectId: project?.id ?? 0 });
|
|
33
|
+
$[2] = project?.id;
|
|
34
|
+
$[3] = t1;
|
|
35
|
+
} else t1 = $[3];
|
|
36
|
+
const t2 = project !== void 0 && subject !== null;
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[4] !== t2) {
|
|
39
|
+
t3 = { enabled: t2 };
|
|
40
|
+
$[4] = t2;
|
|
41
|
+
$[5] = t3;
|
|
42
|
+
} else t3 = $[5];
|
|
43
|
+
const { data: view } = useReadQuery(t1, t3);
|
|
44
|
+
const viewed = useViewLocale().locale;
|
|
45
|
+
let t4;
|
|
46
|
+
if ($[6] !== project?.id) {
|
|
47
|
+
t4 = reads.localeList({ projectId: project?.id ?? 0 });
|
|
48
|
+
$[6] = project?.id;
|
|
49
|
+
$[7] = t4;
|
|
50
|
+
} else t4 = $[7];
|
|
51
|
+
const t5 = project !== void 0 && subject !== null;
|
|
52
|
+
let t6;
|
|
53
|
+
if ($[8] !== t5) {
|
|
54
|
+
t6 = { enabled: t5 };
|
|
55
|
+
$[8] = t5;
|
|
56
|
+
$[9] = t6;
|
|
57
|
+
} else t6 = $[9];
|
|
58
|
+
const { data: locales } = useReadQuery(t4, t6);
|
|
59
|
+
let t7;
|
|
60
|
+
if ($[10] !== locales || $[11] !== viewed.isDefault || $[12] !== viewed.tag) {
|
|
61
|
+
t7 = viewed.isDefault ? locales?.find(_temp)?.tag ?? viewed.tag : viewed.tag;
|
|
62
|
+
$[10] = locales;
|
|
63
|
+
$[11] = viewed.isDefault;
|
|
64
|
+
$[12] = viewed.tag;
|
|
65
|
+
$[13] = t7;
|
|
66
|
+
} else t7 = $[13];
|
|
67
|
+
const tag = t7;
|
|
68
|
+
let t8;
|
|
69
|
+
if ($[14] !== subject || $[15] !== tag || $[16] !== view?.patrollers) {
|
|
70
|
+
t8 = subject === null ? [] : (view?.patrollers ?? []).flatMap((patroller) => patroller.findings.filter((finding) => finding.subject.entity === subject.entity && finding.subject.id === subject.id && finding.locale === tag).map((finding_0) => ({
|
|
71
|
+
...finding_0,
|
|
72
|
+
role: patroller.role
|
|
73
|
+
})));
|
|
74
|
+
$[14] = subject;
|
|
75
|
+
$[15] = tag;
|
|
76
|
+
$[16] = view?.patrollers;
|
|
77
|
+
$[17] = t8;
|
|
78
|
+
} else t8 = $[17];
|
|
79
|
+
const findings = t8;
|
|
80
|
+
const t9 = project?.id;
|
|
81
|
+
const t10 = view?.patrolDraft ?? null;
|
|
82
|
+
let t11;
|
|
83
|
+
if ($[18] !== findings || $[19] !== t10 || $[20] !== t9) {
|
|
84
|
+
t11 = {
|
|
85
|
+
projectId: t9,
|
|
86
|
+
patrolDraft: t10,
|
|
87
|
+
findings
|
|
88
|
+
};
|
|
89
|
+
$[18] = findings;
|
|
90
|
+
$[19] = t10;
|
|
91
|
+
$[20] = t9;
|
|
92
|
+
$[21] = t11;
|
|
93
|
+
} else t11 = $[21];
|
|
94
|
+
return t11;
|
|
95
|
+
}
|
|
96
|
+
function _temp(locale) {
|
|
97
|
+
return locale.isDefault;
|
|
98
|
+
}
|
|
99
|
+
/** What a field's row says of its findings, such as "2 findings", or nothing without any. */
|
|
100
|
+
function findingsHint(view, field) {
|
|
101
|
+
const count = view.findings.filter((finding) => finding.field === field).length;
|
|
102
|
+
if (count === 0) return void 0;
|
|
103
|
+
return count === 1 ? "1 finding" : `${count} findings`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The findings in one field of a subject, as `useContentFindings` reads them, under that field's
|
|
107
|
+
* editor. Without `field`, those in none of `fields`: about the subject as a whole.
|
|
108
|
+
*/
|
|
109
|
+
function ContentFindings(t0) {
|
|
110
|
+
const $ = c(20);
|
|
111
|
+
const { view, field, fields, className } = t0;
|
|
112
|
+
const { projectId, patrolDraft, findings } = view;
|
|
113
|
+
let t1;
|
|
114
|
+
let t2;
|
|
115
|
+
let t3;
|
|
116
|
+
let t4;
|
|
117
|
+
if ($[0] !== className || $[1] !== field || $[2] !== fields || $[3] !== findings || $[4] !== patrolDraft || $[5] !== projectId) {
|
|
118
|
+
t4 = Symbol.for("react.early_return_sentinel");
|
|
119
|
+
bb0: {
|
|
120
|
+
let t5;
|
|
121
|
+
if ($[10] !== field || $[11] !== fields) {
|
|
122
|
+
t5 = (finding) => field === void 0 ? !fields.includes(finding.field) : finding.field === field;
|
|
123
|
+
$[10] = field;
|
|
124
|
+
$[11] = fields;
|
|
125
|
+
$[12] = t5;
|
|
126
|
+
} else t5 = $[12];
|
|
127
|
+
const shown = findings.filter(t5);
|
|
128
|
+
if (projectId === void 0 || shown.length === 0) {
|
|
129
|
+
t4 = null;
|
|
130
|
+
break bb0;
|
|
131
|
+
}
|
|
132
|
+
t1 = true;
|
|
133
|
+
t2 = className ?? "space-y-2 px-2 pb-4";
|
|
134
|
+
let t6;
|
|
135
|
+
if ($[13] !== patrolDraft || $[14] !== projectId) {
|
|
136
|
+
t6 = (finding_0) => /* @__PURE__ */ jsx(FindingAlert, {
|
|
137
|
+
projectId,
|
|
138
|
+
finding: finding_0,
|
|
139
|
+
patrolDraft
|
|
140
|
+
}, finding_0.id);
|
|
141
|
+
$[13] = patrolDraft;
|
|
142
|
+
$[14] = projectId;
|
|
143
|
+
$[15] = t6;
|
|
144
|
+
} else t6 = $[15];
|
|
145
|
+
t3 = shown.map(t6);
|
|
146
|
+
}
|
|
147
|
+
$[0] = className;
|
|
148
|
+
$[1] = field;
|
|
149
|
+
$[2] = fields;
|
|
150
|
+
$[3] = findings;
|
|
151
|
+
$[4] = patrolDraft;
|
|
152
|
+
$[5] = projectId;
|
|
153
|
+
$[6] = t1;
|
|
154
|
+
$[7] = t2;
|
|
155
|
+
$[8] = t3;
|
|
156
|
+
$[9] = t4;
|
|
157
|
+
} else {
|
|
158
|
+
t1 = $[6];
|
|
159
|
+
t2 = $[7];
|
|
160
|
+
t3 = $[8];
|
|
161
|
+
t4 = $[9];
|
|
162
|
+
}
|
|
163
|
+
if (t4 !== Symbol.for("react.early_return_sentinel")) return t4;
|
|
164
|
+
let t5;
|
|
165
|
+
if ($[16] !== t1 || $[17] !== t2 || $[18] !== t3) {
|
|
166
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
167
|
+
"data-content-findings": t1,
|
|
168
|
+
className: t2,
|
|
169
|
+
children: t3
|
|
170
|
+
});
|
|
171
|
+
$[16] = t1;
|
|
172
|
+
$[17] = t2;
|
|
173
|
+
$[18] = t3;
|
|
174
|
+
$[19] = t5;
|
|
175
|
+
} else t5 = $[19];
|
|
176
|
+
return t5;
|
|
177
|
+
}
|
|
178
|
+
function FindingAlert(t0) {
|
|
179
|
+
const $ = c(44);
|
|
180
|
+
const { projectId, finding, patrolDraft } = t0;
|
|
181
|
+
const draftId = useCurrentDraftId();
|
|
182
|
+
let t1;
|
|
183
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t1 = {
|
|
185
|
+
...patrolMutations.applyFix(),
|
|
186
|
+
onSuccess: _temp2,
|
|
187
|
+
onError: _temp3
|
|
188
|
+
};
|
|
189
|
+
$[0] = t1;
|
|
190
|
+
} else t1 = $[0];
|
|
191
|
+
const applyFix = useMutation(t1);
|
|
192
|
+
let t2;
|
|
193
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
194
|
+
t2 = {
|
|
195
|
+
...patrolMutations.dismissFinding(),
|
|
196
|
+
onError: _temp4
|
|
197
|
+
};
|
|
198
|
+
$[1] = t2;
|
|
199
|
+
} else t2 = $[1];
|
|
200
|
+
const dismiss = useMutation(t2);
|
|
201
|
+
const busy = applyFix.isPending || dismiss.isPending;
|
|
202
|
+
const fixesHere = draftId !== null && (!finding.live || draftId === patrolDraft?.id);
|
|
203
|
+
let t3;
|
|
204
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
205
|
+
t3 = /* @__PURE__ */ jsx(CircleAlert, {});
|
|
206
|
+
$[2] = t3;
|
|
207
|
+
} else t3 = $[2];
|
|
208
|
+
let t4;
|
|
209
|
+
if ($[3] !== finding) {
|
|
210
|
+
t4 = findingSentenceInPlace(finding);
|
|
211
|
+
$[3] = finding;
|
|
212
|
+
$[4] = t4;
|
|
213
|
+
} else t4 = $[4];
|
|
214
|
+
let t5;
|
|
215
|
+
if ($[5] !== t4) {
|
|
216
|
+
t5 = /* @__PURE__ */ jsx(AlertTitle, {
|
|
217
|
+
className: "text-xs font-normal",
|
|
218
|
+
children: t4
|
|
219
|
+
});
|
|
220
|
+
$[5] = t4;
|
|
221
|
+
$[6] = t5;
|
|
222
|
+
} else t5 = $[6];
|
|
223
|
+
let t6;
|
|
224
|
+
if ($[7] !== finding.role) {
|
|
225
|
+
t6 = /* @__PURE__ */ jsx("p", { children: finding.role });
|
|
226
|
+
$[7] = finding.role;
|
|
227
|
+
$[8] = t6;
|
|
228
|
+
} else t6 = $[8];
|
|
229
|
+
let t7;
|
|
230
|
+
if ($[9] !== applyFix || $[10] !== busy || $[11] !== finding.fix || $[12] !== finding.id || $[13] !== fixesHere || $[14] !== projectId) {
|
|
231
|
+
t7 = fixesHere && finding.fix && /* @__PURE__ */ jsx(Button, {
|
|
232
|
+
variant: "outline",
|
|
233
|
+
size: "xs",
|
|
234
|
+
disabled: busy,
|
|
235
|
+
onClick: () => applyFix.mutate({
|
|
236
|
+
projectId,
|
|
237
|
+
findingId: finding.id
|
|
238
|
+
}),
|
|
239
|
+
children: fixLabel(finding.fix)
|
|
240
|
+
});
|
|
241
|
+
$[9] = applyFix;
|
|
242
|
+
$[10] = busy;
|
|
243
|
+
$[11] = finding.fix;
|
|
244
|
+
$[12] = finding.id;
|
|
245
|
+
$[13] = fixesHere;
|
|
246
|
+
$[14] = projectId;
|
|
247
|
+
$[15] = t7;
|
|
248
|
+
} else t7 = $[15];
|
|
249
|
+
let t8;
|
|
250
|
+
if ($[16] !== finding || $[17] !== fixesHere) {
|
|
251
|
+
t8 = fixesHere && /* @__PURE__ */ jsx(Button, {
|
|
252
|
+
variant: "outline",
|
|
253
|
+
size: "xs",
|
|
254
|
+
onClick: () => studioStore.trigger.askAgent({ text: askAgentMessage(finding, finding.role) }),
|
|
255
|
+
children: "Ask the agent"
|
|
256
|
+
});
|
|
257
|
+
$[16] = finding;
|
|
258
|
+
$[17] = fixesHere;
|
|
259
|
+
$[18] = t8;
|
|
260
|
+
} else t8 = $[18];
|
|
261
|
+
let t9;
|
|
262
|
+
if ($[19] !== draftId || $[20] !== finding || $[21] !== patrolDraft) {
|
|
263
|
+
t9 = draftId === null && patrolDraft && /* @__PURE__ */ jsx(OpenInPatrolDraft, {
|
|
264
|
+
finding,
|
|
265
|
+
patrolDraft
|
|
266
|
+
});
|
|
267
|
+
$[19] = draftId;
|
|
268
|
+
$[20] = finding;
|
|
269
|
+
$[21] = patrolDraft;
|
|
270
|
+
$[22] = t9;
|
|
271
|
+
} else t9 = $[22];
|
|
272
|
+
let t10;
|
|
273
|
+
if ($[23] !== dismiss || $[24] !== finding.id || $[25] !== projectId) {
|
|
274
|
+
t10 = () => dismiss.mutate({
|
|
275
|
+
projectId,
|
|
276
|
+
findingId: finding.id
|
|
277
|
+
});
|
|
278
|
+
$[23] = dismiss;
|
|
279
|
+
$[24] = finding.id;
|
|
280
|
+
$[25] = projectId;
|
|
281
|
+
$[26] = t10;
|
|
282
|
+
} else t10 = $[26];
|
|
283
|
+
let t11;
|
|
284
|
+
if ($[27] !== finding.about) {
|
|
285
|
+
t11 = dismissLabel(finding.about);
|
|
286
|
+
$[27] = finding.about;
|
|
287
|
+
$[28] = t11;
|
|
288
|
+
} else t11 = $[28];
|
|
289
|
+
let t12;
|
|
290
|
+
if ($[29] !== busy || $[30] !== t10 || $[31] !== t11) {
|
|
291
|
+
t12 = /* @__PURE__ */ jsx(Button, {
|
|
292
|
+
variant: "ghost",
|
|
293
|
+
size: "xs",
|
|
294
|
+
disabled: busy,
|
|
295
|
+
onClick: t10,
|
|
296
|
+
children: t11
|
|
297
|
+
});
|
|
298
|
+
$[29] = busy;
|
|
299
|
+
$[30] = t10;
|
|
300
|
+
$[31] = t11;
|
|
301
|
+
$[32] = t12;
|
|
302
|
+
} else t12 = $[32];
|
|
303
|
+
let t13;
|
|
304
|
+
if ($[33] !== t12 || $[34] !== t7 || $[35] !== t8 || $[36] !== t9) {
|
|
305
|
+
t13 = /* @__PURE__ */ jsxs("span", {
|
|
306
|
+
className: "mt-1.5 flex flex-wrap gap-1",
|
|
307
|
+
children: [
|
|
308
|
+
t7,
|
|
309
|
+
t8,
|
|
310
|
+
t9,
|
|
311
|
+
t12
|
|
312
|
+
]
|
|
313
|
+
});
|
|
314
|
+
$[33] = t12;
|
|
315
|
+
$[34] = t7;
|
|
316
|
+
$[35] = t8;
|
|
317
|
+
$[36] = t9;
|
|
318
|
+
$[37] = t13;
|
|
319
|
+
} else t13 = $[37];
|
|
320
|
+
let t14;
|
|
321
|
+
if ($[38] !== t13 || $[39] !== t6) {
|
|
322
|
+
t14 = /* @__PURE__ */ jsxs(AlertDescription, {
|
|
323
|
+
className: "text-xs",
|
|
324
|
+
children: [t6, t13]
|
|
325
|
+
});
|
|
326
|
+
$[38] = t13;
|
|
327
|
+
$[39] = t6;
|
|
328
|
+
$[40] = t14;
|
|
329
|
+
} else t14 = $[40];
|
|
330
|
+
let t15;
|
|
331
|
+
if ($[41] !== t14 || $[42] !== t5) {
|
|
332
|
+
t15 = /* @__PURE__ */ jsxs(Alert, {
|
|
333
|
+
"data-content-finding": true,
|
|
334
|
+
variant: "warning",
|
|
335
|
+
className: "px-3 py-2",
|
|
336
|
+
children: [
|
|
337
|
+
t3,
|
|
338
|
+
t5,
|
|
339
|
+
t14
|
|
340
|
+
]
|
|
341
|
+
});
|
|
342
|
+
$[41] = t14;
|
|
343
|
+
$[42] = t5;
|
|
344
|
+
$[43] = t15;
|
|
345
|
+
} else t15 = $[43];
|
|
346
|
+
return t15;
|
|
347
|
+
}
|
|
348
|
+
function _temp4(error_0) {
|
|
349
|
+
return toast.error(error_0.message || "Could not dismiss it");
|
|
350
|
+
}
|
|
351
|
+
function _temp3(error) {
|
|
352
|
+
return toast.error(error.message || "Could not apply the fix");
|
|
353
|
+
}
|
|
354
|
+
function _temp2(t0) {
|
|
355
|
+
const { applied } = t0;
|
|
356
|
+
if (!applied) toast.info("The link changed since it was checked, so it's being checked again.");
|
|
357
|
+
}
|
|
358
|
+
/** Opens the Patrol Draft on a Live finding's field, as the Canvas shows it there. */
|
|
359
|
+
function OpenInPatrolDraft(t0) {
|
|
360
|
+
const $ = c(9);
|
|
361
|
+
const { finding, patrolDraft } = t0;
|
|
362
|
+
const showInCanvas = useShowInCanvas();
|
|
363
|
+
const { place } = finding;
|
|
364
|
+
if (place?.kind !== "page") return null;
|
|
365
|
+
let t1;
|
|
366
|
+
if ($[0] !== finding.field || $[1] !== finding.fieldKind || $[2] !== finding.locale || $[3] !== patrolDraft.id || $[4] !== place.blockId || $[5] !== place.itemId || $[6] !== place.pageId || $[7] !== showInCanvas) {
|
|
367
|
+
t1 = /* @__PURE__ */ jsx(Button, {
|
|
368
|
+
variant: "outline",
|
|
369
|
+
size: "xs",
|
|
370
|
+
onClick: () => void showInCanvas({
|
|
371
|
+
pageId: place.pageId,
|
|
372
|
+
locale: finding.locale,
|
|
373
|
+
blockId: place.blockId,
|
|
374
|
+
itemId: place.itemId,
|
|
375
|
+
field: {
|
|
376
|
+
name: finding.field,
|
|
377
|
+
kind: finding.fieldKind
|
|
378
|
+
},
|
|
379
|
+
draft: patrolDraft.id
|
|
380
|
+
}),
|
|
381
|
+
children: "Open the Patrol Draft"
|
|
382
|
+
});
|
|
383
|
+
$[0] = finding.field;
|
|
384
|
+
$[1] = finding.fieldKind;
|
|
385
|
+
$[2] = finding.locale;
|
|
386
|
+
$[3] = patrolDraft.id;
|
|
387
|
+
$[4] = place.blockId;
|
|
388
|
+
$[5] = place.itemId;
|
|
389
|
+
$[6] = place.pageId;
|
|
390
|
+
$[7] = showInCanvas;
|
|
391
|
+
$[8] = t1;
|
|
392
|
+
} else t1 = $[8];
|
|
393
|
+
return t1;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
//#endregion
|
|
397
|
+
export { ContentFindings, findingsHint, useContentFindings };
|