@burdenoff/microfe-cosmicintersection 2026.1101.1 → 2026.1101.2
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/cosmicintersection/api/tagsApi.d.ts +100 -0
- package/dist/cosmicintersection/api/tagsApi.d.ts.map +1 -0
- package/dist/cosmicintersection/api/tagsApi.js +110 -0
- package/dist/cosmicintersection/api/tagsApi.js.map +1 -0
- package/dist/cosmicintersection/components/EntityTagsField.d.ts +5 -5
- package/dist/cosmicintersection/components/EntityTagsField.js.map +1 -1
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts +27 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts.map +1 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js +141 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js.map +1 -0
- package/dist/cosmicintersection/components/index.d.ts +1 -0
- package/dist/cosmicintersection/components/index.d.ts.map +1 -1
- package/dist/cosmicintersection/components/index.js +6 -5
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts +49 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts.map +1 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js +86 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js.map +1 -0
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js +75 -74
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js +115 -106
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js +103 -101
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js +141 -139
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js +213 -211
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js +110 -107
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js.map +1 -1
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts +12 -0
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { notify as e } from "../lib/toast.js";
|
|
2
|
+
import { AVAILABLE_COS_TAGS as t, COS_ENTITY_TAGS as n, CREATE_COS_TAG as r, REPLACE_COS_ENTITY_TAGS as i, SEARCH_COS_TAGS as a, diffEntityTagLabels as o, findTagByLabel as s, labelsMissingFromAssignments as c, nextEntityTagIds as l, normalizeTagLabel as u } from "../api/tagsApi.js";
|
|
3
|
+
import { useCallback as d, useState as f } from "react";
|
|
4
|
+
import { useApolloClient as p } from "@apollo/client/react";
|
|
5
|
+
//#region src/cosmicintersection/hooks/useEntityTagSync.ts
|
|
6
|
+
var m = "The labels were saved. Workspace tag assignments were not changed; manage them from the Tags page.", h = 25;
|
|
7
|
+
function g(g) {
|
|
8
|
+
let _ = p(), [v, y] = f(0), b = d(async (d, f, p = []) => {
|
|
9
|
+
if (!d) return !1;
|
|
10
|
+
let v = o(p, f);
|
|
11
|
+
if (v.added.length === 0 && v.removed.length === 0) return !0;
|
|
12
|
+
let { removed: y } = v, b = null;
|
|
13
|
+
try {
|
|
14
|
+
let [e, o] = await Promise.all([_.query({
|
|
15
|
+
query: t,
|
|
16
|
+
variables: { limit: 200 },
|
|
17
|
+
fetchPolicy: "network-only"
|
|
18
|
+
}), _.query({
|
|
19
|
+
query: n,
|
|
20
|
+
variables: { input: {
|
|
21
|
+
entityType: g,
|
|
22
|
+
entityId: d
|
|
23
|
+
} },
|
|
24
|
+
fetchPolicy: "network-only"
|
|
25
|
+
})]), p = e.data?.availableCosTags ?? [], m = o.data?.cosEntityTags ?? [], v = c(f, m, p), x = async (e) => s(p, e) || s((await _.query({
|
|
26
|
+
query: a,
|
|
27
|
+
variables: {
|
|
28
|
+
query: e,
|
|
29
|
+
limit: h
|
|
30
|
+
},
|
|
31
|
+
fetchPolicy: "network-only"
|
|
32
|
+
})).data?.searchCosTags ?? [], e), S = new Set(m.map((e) => e.tagInfo?.label).filter((e) => !!e).map(u)), C = [];
|
|
33
|
+
for (let e of y) {
|
|
34
|
+
if (S.has(u(e))) continue;
|
|
35
|
+
let t = await x(e);
|
|
36
|
+
t && C.push(t.id);
|
|
37
|
+
}
|
|
38
|
+
let w = [], T = !1;
|
|
39
|
+
for (let e of v) try {
|
|
40
|
+
let t = await x(e);
|
|
41
|
+
if (t) {
|
|
42
|
+
w.push(t.id);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
let n = (await _.mutate({
|
|
46
|
+
mutation: r,
|
|
47
|
+
variables: { input: { label: e } }
|
|
48
|
+
})).data?.createCosTag?.id;
|
|
49
|
+
if (!n) throw Error(`Tag "${e}" could not be created`);
|
|
50
|
+
w.push(n), T = !0;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
b ??= e;
|
|
53
|
+
}
|
|
54
|
+
await _.mutate({
|
|
55
|
+
mutation: i,
|
|
56
|
+
variables: { input: {
|
|
57
|
+
entityType: g,
|
|
58
|
+
entityId: d,
|
|
59
|
+
tagIds: l(m, y, C, w)
|
|
60
|
+
} },
|
|
61
|
+
refetchQueries: T ? [{
|
|
62
|
+
query: t,
|
|
63
|
+
variables: { limit: 200 }
|
|
64
|
+
}] : []
|
|
65
|
+
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
b ??= e;
|
|
68
|
+
}
|
|
69
|
+
return b === null ? !0 : (e.warning("Saved, but workspace tags were not updated", b instanceof Error ? `${b.message}. ${m}` : m), !1);
|
|
70
|
+
}, [_, g]);
|
|
71
|
+
return {
|
|
72
|
+
syncTags: d(async (e, t, n = []) => {
|
|
73
|
+
y((e) => e + 1);
|
|
74
|
+
try {
|
|
75
|
+
return await b(e, t, n);
|
|
76
|
+
} finally {
|
|
77
|
+
y((e) => e - 1);
|
|
78
|
+
}
|
|
79
|
+
}, [b]),
|
|
80
|
+
syncing: v > 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { m as RETRY_HINT, g as useEntityTagSync };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=useEntityTagSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEntityTagSync.js","names":[],"sources":["../../../src/cosmicintersection/hooks/useEntityTagSync.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\nimport { useApolloClient } from '@apollo/client/react';\n\nimport {\n AVAILABLE_COS_TAGS,\n COS_ENTITY_TAGS,\n CREATE_COS_TAG,\n REPLACE_COS_ENTITY_TAGS,\n SEARCH_COS_TAGS,\n WORKSPACE_TAG_LIMIT,\n diffEntityTagLabels,\n findTagByLabel,\n labelsMissingFromAssignments,\n nextEntityTagIds,\n normalizeTagLabel,\n type AvailableCosTagsData,\n type CosEntityTagsData,\n type CosTagEntityType,\n type CosWorkspaceTag,\n type CreateCosTagData,\n type ReplaceCosEntityTagsData,\n type SearchCosTagsData,\n} from '../api/tagsApi';\nimport { notify } from '../lib/toast';\n\n/** What a user can do after a failed sync; changes are not replayed automatically. */\nexport const RETRY_HINT =\n 'The labels were saved. Workspace tag assignments were not changed; manage them from the Tags page.';\n\n/** How many server-side search hits are checked for an exact label match. */\nconst SEARCH_LIMIT = 25;\n\n/**\n * Apply the tag labels a form added or removed to an entity's workspace tag\n * assignments.\n *\n * Call the returned `syncTags(entityId, labels, previousLabels)` right after\n * the entity's own create/update mutation succeeds (the entity and its inline\n * `tags` array are already saved by then). Pass the labels the entity was\n * loaded with, captured before the mutation (an empty array on create).\n *\n * - Unchanged labels do nothing: there is no network call and assignments made\n * from another surface are never touched.\n * - When the labels changed, every label the form holds that is not assigned\n * yet is resolved against the workspace taxonomy. Labels missing from\n * the capped suggestion page are looked up with `searchCosTags` before\n * anything is created, so a large workspace never gets a duplicate tag.\n * Labels with no match are created (create-on-select).\n * - Removed labels drop only their own assignment, resolved by the label of\n * the assignment or, when that projection is missing, by looking the label\n * up in the taxonomy. Every other current assignment is kept.\n *\n * Best-effort by design: the entity is already persisted, so a tags-svc\n * failure must never block the form. When some new tags were created before\n * a later one failed, the ones that succeeded are still assigned. A failure\n * surfaces one warning and resolves `false`, so the page can skip its success\n * toast.\n *\n * The entity's inline `tags` array stays the source of truth for the labels;\n * assignments are never reconciled to exactly that set, because that would\n * drop tags assigned from other surfaces. So a change whose sync failed is not\n * replayed later. Adding a label again re-applies it on the next tag edit\n * (missing labels are backfilled), while a failed removal has to be repeated\n * from the workspace Tags page. The warning says so instead of promising an\n * automatic retry.\n */\nexport interface EntityTagSync {\n /** Apply the form's label changes to the entity's workspace tag assignments. */\n syncTags: (\n entityId: string,\n labels: readonly string[],\n previousLabels?: readonly string[]\n ) => Promise<boolean>;\n /**\n * True while a sync is in flight. Forms add it to their saving state so the\n * submit button stays disabled between the entity mutation and navigation,\n * which prevents a second submit from creating a duplicate entity.\n */\n syncing: boolean;\n}\n\nexport function useEntityTagSync(entityType: CosTagEntityType): EntityTagSync {\n const client = useApolloClient();\n const [pending, setPending] = useState(0);\n\n const run = useCallback(\n async (\n entityId: string,\n labels: readonly string[],\n previousLabels: readonly string[] = []\n ): Promise<boolean> => {\n if (!entityId) return false;\n const diff = diffEntityTagLabels(previousLabels, labels);\n if (diff.added.length === 0 && diff.removed.length === 0) return true;\n const { removed } = diff;\n\n let failure: unknown = null;\n try {\n const [taxonomy, assignments] = await Promise.all([\n client.query<AvailableCosTagsData, { limit: number }>({\n query: AVAILABLE_COS_TAGS,\n variables: { limit: WORKSPACE_TAG_LIMIT },\n fetchPolicy: 'network-only',\n }),\n client.query<\n CosEntityTagsData,\n { input: { entityType: CosTagEntityType; entityId: string } }\n >({\n query: COS_ENTITY_TAGS,\n variables: { input: { entityType, entityId } },\n fetchPolicy: 'network-only',\n }),\n ]);\n const workspaceTags: CosWorkspaceTag[] = taxonomy.data?.availableCosTags ?? [];\n const current = assignments.data?.cosEntityTags ?? [];\n // Every kept label that is not assigned yet, not only the newly typed\n // ones: this also backfills labels saved before structured tags\n // existed, and re-applies labels a previous failed sync missed.\n const added = labelsMissingFromAssignments(labels, current, workspaceTags);\n\n const resolve = async (label: string): Promise<CosWorkspaceTag | undefined> => {\n const known = findTagByLabel(workspaceTags, label);\n if (known) return known;\n const search = await client.query<SearchCosTagsData, { query: string; limit: number }>({\n query: SEARCH_COS_TAGS,\n variables: { query: label, limit: SEARCH_LIMIT },\n fetchPolicy: 'network-only',\n });\n return findTagByLabel(search.data?.searchCosTags ?? [], label);\n };\n\n // Removed labels usually match an assignment's tagInfo label. When the\n // projection is missing, resolve the label to an id (searching beyond\n // the capped taxonomy page) so the assignment is still dropped.\n const projected = new Set(\n current\n .map((assignment) => assignment.tagInfo?.label)\n .filter((label): label is string => Boolean(label))\n .map(normalizeTagLabel)\n );\n const removedTagIds: string[] = [];\n for (const label of removed) {\n if (projected.has(normalizeTagLabel(label))) continue;\n const tag = await resolve(label);\n if (tag) removedTagIds.push(tag.id);\n }\n\n const addedTagIds: string[] = [];\n let created = false;\n for (const label of added) {\n try {\n const existing = await resolve(label);\n if (existing) {\n addedTagIds.push(existing.id);\n continue;\n }\n const result = await client.mutate<CreateCosTagData, { input: { label: string } }>({\n mutation: CREATE_COS_TAG,\n variables: { input: { label } },\n });\n const id = result.data?.createCosTag?.id;\n if (!id) throw new Error(`Tag \"${label}\" could not be created`);\n addedTagIds.push(id);\n created = true;\n } catch (error) {\n // Keep going: the tags resolved so far are still assigned below.\n failure ??= error;\n }\n }\n\n await client.mutate<\n ReplaceCosEntityTagsData,\n { input: { entityType: CosTagEntityType; entityId: string; tagIds: string[] } }\n >({\n mutation: REPLACE_COS_ENTITY_TAGS,\n variables: {\n input: {\n entityType,\n entityId,\n tagIds: nextEntityTagIds(current, removed, removedTagIds, addedTagIds),\n },\n },\n refetchQueries: created\n ? [{ query: AVAILABLE_COS_TAGS, variables: { limit: WORKSPACE_TAG_LIMIT } }]\n : [],\n });\n } catch (error) {\n failure ??= error;\n }\n\n if (failure === null) return true;\n notify.warning(\n 'Saved, but workspace tags were not updated',\n failure instanceof Error ? `${failure.message}. ${RETRY_HINT}` : RETRY_HINT\n );\n return false;\n },\n [client, entityType]\n );\n\n const syncTags = useCallback(\n async (\n entityId: string,\n labels: readonly string[],\n previousLabels: readonly string[] = []\n ): Promise<boolean> => {\n setPending((count) => count + 1);\n try {\n return await run(entityId, labels, previousLabels);\n } finally {\n setPending((count) => count - 1);\n }\n },\n [run]\n );\n\n return { syncTags, syncing: pending > 0 };\n}\n"],"mappings":";;;;;AA0BA,IAAa,IACX,sGAGI,IAAe;AAmDrB,SAAgB,EAAiB,GAA6C;CAC5E,IAAM,IAAS,EAAgB,GACzB,CAAC,GAAS,KAAc,EAAS,CAAC,GAElC,IAAM,EACV,OACE,GACA,GACA,IAAoC,CAAC,MAChB;EACrB,IAAI,CAAC,GAAU,OAAO;EACtB,IAAM,IAAO,EAAoB,GAAgB,CAAM;EACvD,IAAI,EAAK,MAAM,WAAW,KAAK,EAAK,QAAQ,WAAW,GAAG,OAAO;EACjE,IAAM,EAAE,eAAY,GAEhB,IAAmB;EACvB,IAAI;GACF,IAAM,CAAC,GAAU,KAAe,MAAM,QAAQ,IAAI,CAChD,EAAO,MAA+C;IACpD,OAAO;IACP,WAAW,EAAE,OAAA,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UAAU;IACV,WAAW,EACT,OAAO;KACL;KACA;KACA,QAAQ,EAAiB,GAAS,GAAS,GAAe,CAAW;IACvE,EACF;IACA,gBAAgB,IACZ,CAAC;KAAE,OAAO;KAAoB,WAAW,EAAE,OAAA,IAA2B;IAAE,CAAC,IACzE,CAAC;GACP,CAAC;EACH,SAAS,GAAO;GACd,MAAY;EACd;EAOA,OALI,MAAY,OAAa,MAC7B,EAAO,QACL,8CACA,aAAmB,QAAQ,GAAG,EAAQ,QAAQ,IAAI,MAAe,CACnE,GACO;CACT,GACA,CAAC,GAAQ,CAAU,CACrB;CAkBA,OAAO;EAAE,UAhBQ,EACf,OACE,GACA,GACA,IAAoC,CAAC,MAChB;GACrB,GAAY,MAAU,IAAQ,CAAC;GAC/B,IAAI;IACF,OAAO,MAAM,EAAI,GAAU,GAAQ,CAAc;GACnD,UAAU;IACR,GAAY,MAAU,IAAQ,CAAC;GACjC;EACF,GACA,CAAC,CAAG,CAGG;EAAU,SAAS,IAAU;CAAE;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionFormPage.d.ts","sourceRoot":"","sources":["../../../../src/cosmicintersection/pages/collections/CollectionFormPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollectionFormPage.d.ts","sourceRoot":"","sources":["../../../../src/cosmicintersection/pages/collections/CollectionFormPage.tsx"],"names":[],"mappings":"AAmCA,MAAM,CAAC,OAAO,UAAU,kBAAkB,gCAkJzC"}
|
|
@@ -3,25 +3,26 @@ import { notify as t } from "../../lib/toast.js";
|
|
|
3
3
|
import { useCosCollectionQuery as n, useCosCreateCollectionMutation as r, useCosUpdateCollectionMutation as i } from "../../api/cosmicApi.js";
|
|
4
4
|
import { LoadingState as a } from "../../components/LoadingState.js";
|
|
5
5
|
import { EntityFormShell as o } from "../../components/EntityFormShell.js";
|
|
6
|
-
import {
|
|
6
|
+
import { WorkspaceTagsPicker as s } from "../../components/WorkspaceTagsPicker.js";
|
|
7
7
|
import "../../components/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { useEntityTagSync as c } from "../../hooks/useEntityTagSync.js";
|
|
9
|
+
import { useMemo as l, useState as u } from "react";
|
|
10
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
import { useParams as p } from "react-router";
|
|
12
|
+
import { Input as m, Switch as h, Textarea as g } from "@burdenoff/fe-libs/ui";
|
|
12
13
|
//#region src/cosmicintersection/pages/collections/CollectionFormPage.tsx
|
|
13
|
-
var
|
|
14
|
+
var _ = {
|
|
14
15
|
name: "",
|
|
15
16
|
slug: "",
|
|
16
17
|
description: "",
|
|
17
18
|
isPublic: !1,
|
|
18
19
|
tags: []
|
|
19
|
-
},
|
|
20
|
-
function
|
|
21
|
-
let { id:
|
|
22
|
-
if (
|
|
23
|
-
let e =
|
|
24
|
-
|
|
20
|
+
}, v = "block space-y-1.5 text-sm", y = "font-medium text-text-primary";
|
|
21
|
+
function b() {
|
|
22
|
+
let { id: b = "" } = p(), x = l(() => !!b, [b]), { navigate: S } = e(), { data: C, loading: w } = n(b), [T, { loading: E }] = r(), [D, { loading: O }] = i(), [k, A] = u(_), { syncTags: j, syncing: M } = c("COSMICINTERSECTION_COLLECTION"), [N, P] = u(null);
|
|
23
|
+
if (x && C?.cosCollection && N !== C.cosCollection.id) {
|
|
24
|
+
let e = C.cosCollection;
|
|
25
|
+
P(e.id), A({
|
|
25
26
|
name: e.name ?? "",
|
|
26
27
|
slug: e.slug ?? "",
|
|
27
28
|
description: e.description ?? "",
|
|
@@ -29,116 +30,116 @@ function y() {
|
|
|
29
30
|
tags: e.tags ?? []
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
let
|
|
33
|
-
|
|
33
|
+
let F = (e, t) => {
|
|
34
|
+
A((n) => ({
|
|
34
35
|
...n,
|
|
35
36
|
[e]: t
|
|
36
37
|
}));
|
|
37
|
-
},
|
|
38
|
-
if (e.preventDefault(), !
|
|
38
|
+
}, I = E || O || M, L = async (e) => {
|
|
39
|
+
if (e.preventDefault(), !k.name.trim()) {
|
|
39
40
|
t.error("Name is required", "Give this collection a recognizable name.");
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
if (
|
|
43
|
+
if (x) {
|
|
43
44
|
let e = {
|
|
44
|
-
name:
|
|
45
|
-
slug:
|
|
46
|
-
description:
|
|
47
|
-
isPublic:
|
|
48
|
-
tags:
|
|
49
|
-
};
|
|
50
|
-
(await
|
|
51
|
-
id:
|
|
45
|
+
name: k.name.trim(),
|
|
46
|
+
slug: k.slug.trim() || void 0,
|
|
47
|
+
description: k.description.trim() || void 0,
|
|
48
|
+
isPublic: k.isPublic,
|
|
49
|
+
tags: k.tags
|
|
50
|
+
}, n = C?.cosCollection?.tags ?? [];
|
|
51
|
+
(await D({ variables: {
|
|
52
|
+
id: b,
|
|
52
53
|
input: e
|
|
53
|
-
} })).data?.cosUpdateCollection?.id && (t.success("Collection updated"),
|
|
54
|
+
} })).data?.cosUpdateCollection?.id && (await j(b, k.tags, n) && t.success("Collection updated"), S(`collections/${b}`));
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
let n = {
|
|
57
|
-
name:
|
|
58
|
-
slug:
|
|
59
|
-
description:
|
|
60
|
-
isPublic:
|
|
61
|
-
tags:
|
|
62
|
-
}, r = (await
|
|
63
|
-
r?.id && (t.success("Collection created"),
|
|
58
|
+
name: k.name.trim(),
|
|
59
|
+
slug: k.slug.trim() || void 0,
|
|
60
|
+
description: k.description.trim() || void 0,
|
|
61
|
+
isPublic: k.isPublic,
|
|
62
|
+
tags: k.tags
|
|
63
|
+
}, r = (await T({ variables: { input: n } })).data?.cosCreateCollection;
|
|
64
|
+
r?.id && (await j(r.id, k.tags) && t.success("Collection created"), S(`collections/${r.id}`));
|
|
64
65
|
};
|
|
65
|
-
return
|
|
66
|
-
title:
|
|
66
|
+
return x && w && !C?.cosCollection ? /* @__PURE__ */ d(a, { label: "Loading collection…" }) : /* @__PURE__ */ f(o, {
|
|
67
|
+
title: x ? "Edit collection" : "New collection",
|
|
67
68
|
description: "Group related datasets into a shareable, themed collection.",
|
|
68
69
|
purpose: "Collections curate datasets by mission, survey or research theme so collaborators can browse a coherent set instead of a flat list. Mark a collection public to make it discoverable across the workspace.",
|
|
69
|
-
backLabel:
|
|
70
|
-
onBack: () => x
|
|
71
|
-
onSubmit: (e) => void
|
|
72
|
-
submitLabel:
|
|
73
|
-
saving:
|
|
70
|
+
backLabel: x ? "Back to collection" : "Back to collections",
|
|
71
|
+
onBack: () => S(x ? `collections/${b}` : "collections"),
|
|
72
|
+
onSubmit: (e) => void L(e),
|
|
73
|
+
submitLabel: x ? "Save collection" : "Create collection",
|
|
74
|
+
saving: I,
|
|
74
75
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ f("div", {
|
|
76
77
|
className: "grid grid-cols-1 gap-4 md:grid-cols-2",
|
|
77
|
-
children: [/* @__PURE__ */
|
|
78
|
-
className:
|
|
79
|
-
children: [/* @__PURE__ */
|
|
80
|
-
className:
|
|
78
|
+
children: [/* @__PURE__ */ f("label", {
|
|
79
|
+
className: v,
|
|
80
|
+
children: [/* @__PURE__ */ d("span", {
|
|
81
|
+
className: y,
|
|
81
82
|
children: "Name"
|
|
82
|
-
}), /* @__PURE__ */
|
|
83
|
-
value:
|
|
84
|
-
onChange: (e) =>
|
|
83
|
+
}), /* @__PURE__ */ d(m, {
|
|
84
|
+
value: k.name,
|
|
85
|
+
onChange: (e) => F("name", e.target.value),
|
|
85
86
|
placeholder: "e.g. Kepler Mission Data",
|
|
86
87
|
required: !0
|
|
87
88
|
})]
|
|
88
|
-
}), /* @__PURE__ */
|
|
89
|
-
className:
|
|
89
|
+
}), /* @__PURE__ */ f("label", {
|
|
90
|
+
className: v,
|
|
90
91
|
children: [
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
className:
|
|
92
|
+
/* @__PURE__ */ d("span", {
|
|
93
|
+
className: y,
|
|
93
94
|
children: "Slug"
|
|
94
95
|
}),
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
value:
|
|
97
|
-
onChange: (e) =>
|
|
96
|
+
/* @__PURE__ */ d(m, {
|
|
97
|
+
value: k.slug,
|
|
98
|
+
onChange: (e) => F("slug", e.target.value),
|
|
98
99
|
placeholder: "kepler-mission"
|
|
99
100
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ d("span", {
|
|
101
102
|
className: "text-xs text-text-secondary",
|
|
102
103
|
children: "Optional URL-friendly identifier for sharing."
|
|
103
104
|
})
|
|
104
105
|
]
|
|
105
106
|
})]
|
|
106
107
|
}),
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
className:
|
|
109
|
-
children: [/* @__PURE__ */
|
|
110
|
-
className:
|
|
108
|
+
/* @__PURE__ */ f("label", {
|
|
109
|
+
className: v,
|
|
110
|
+
children: [/* @__PURE__ */ d("span", {
|
|
111
|
+
className: y,
|
|
111
112
|
children: "Description"
|
|
112
|
-
}), /* @__PURE__ */
|
|
113
|
-
value:
|
|
114
|
-
onChange: (e) =>
|
|
113
|
+
}), /* @__PURE__ */ d(g, {
|
|
114
|
+
value: k.description,
|
|
115
|
+
onChange: (e) => F("description", e.target.value),
|
|
115
116
|
rows: 3,
|
|
116
117
|
placeholder: "What this collection groups together and who it is for."
|
|
117
118
|
})]
|
|
118
119
|
}),
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ f("div", {
|
|
120
121
|
className: "flex items-center justify-between gap-4 rounded-card border border-border-default bg-bg-sunken px-4 py-3",
|
|
121
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("p", {
|
|
122
123
|
className: "text-sm font-medium text-text-primary",
|
|
123
124
|
children: "Public collection"
|
|
124
|
-
}), /* @__PURE__ */
|
|
125
|
+
}), /* @__PURE__ */ d("p", {
|
|
125
126
|
className: "text-xs text-text-secondary",
|
|
126
127
|
children: "Make this collection discoverable across the workspace."
|
|
127
|
-
})] }), /* @__PURE__ */
|
|
128
|
-
checked:
|
|
129
|
-
onCheckedChange: (e) =>
|
|
128
|
+
})] }), /* @__PURE__ */ d(h, {
|
|
129
|
+
checked: k.isPublic,
|
|
130
|
+
onCheckedChange: (e) => F("isPublic", e),
|
|
130
131
|
"aria-label": "Public collection"
|
|
131
132
|
})]
|
|
132
133
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
value:
|
|
135
|
-
onChange: (e) =>
|
|
136
|
-
disabled:
|
|
134
|
+
/* @__PURE__ */ d(s, {
|
|
135
|
+
value: k.tags,
|
|
136
|
+
onChange: (e) => F("tags", e),
|
|
137
|
+
disabled: I
|
|
137
138
|
})
|
|
138
139
|
]
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
//#endregion
|
|
142
|
-
export {
|
|
143
|
+
export { b as default };
|
|
143
144
|
|
|
144
145
|
//# sourceMappingURL=CollectionFormPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionFormPage.js","names":[],"sources":["../../../../src/cosmicintersection/pages/collections/CollectionFormPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport { Input, Switch, Textarea } from '@burdenoff/fe-libs/ui';\n\nimport {\n useCosCollectionQuery,\n useCosCreateCollectionMutation,\n useCosUpdateCollectionMutation,\n type CosCreateCollectionInput,\n type CosUpdateCollectionInput,\n} from '../../api/cosmicApi';\nimport { EntityFormShell,
|
|
1
|
+
{"version":3,"file":"CollectionFormPage.js","names":[],"sources":["../../../../src/cosmicintersection/pages/collections/CollectionFormPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { useParams } from 'react-router';\nimport { Input, Switch, Textarea } from '@burdenoff/fe-libs/ui';\n\nimport {\n useCosCollectionQuery,\n useCosCreateCollectionMutation,\n useCosUpdateCollectionMutation,\n type CosCreateCollectionInput,\n type CosUpdateCollectionInput,\n} from '../../api/cosmicApi';\nimport { EntityFormShell, LoadingState, WorkspaceTagsPicker } from '../../components';\nimport { useEntityTagSync } from '../../hooks/useEntityTagSync';\nimport { useCosmicIntersection } from '../../context/CosmicIntersectionContext';\nimport { notify } from '../../lib/toast';\n\ninterface CollectionFormState {\n name: string;\n slug: string;\n description: string;\n isPublic: boolean;\n tags: string[];\n}\n\nconst INITIAL_STATE: CollectionFormState = {\n name: '',\n slug: '',\n description: '',\n isPublic: false,\n tags: [],\n};\n\nconst fieldLabelClass = 'block space-y-1.5 text-sm';\nconst fieldSpanClass = 'font-medium text-text-primary';\n\nexport default function CollectionFormPage() {\n const { id = '' } = useParams<{ id: string }>();\n const isEdit = useMemo(() => Boolean(id), [id]);\n const { navigate } = useCosmicIntersection();\n\n const { data, loading: loadingCollection } = useCosCollectionQuery(id);\n const [createCollection, { loading: creating }] = useCosCreateCollectionMutation();\n const [updateCollection, { loading: updating }] = useCosUpdateCollectionMutation();\n\n const [form, setForm] = useState<CollectionFormState>(INITIAL_STATE);\n const { syncTags, syncing: syncingTags } = useEntityTagSync('COSMICINTERSECTION_COLLECTION');\n\n // Hydrate once the collection loads in edit mode. Derive-state-during-render\n // (keyed on the loaded id) rather than an effect, per platform lint.\n const [loadedId, setLoadedId] = useState<string | null>(null);\n if (isEdit && data?.cosCollection && loadedId !== data.cosCollection.id) {\n const collection = data.cosCollection;\n setLoadedId(collection.id);\n setForm({\n name: collection.name ?? '',\n slug: collection.slug ?? '',\n description: collection.description ?? '',\n isPublic: collection.isPublic,\n tags: collection.tags ?? [],\n });\n }\n\n const onChange = <K extends keyof CollectionFormState>(\n field: K,\n value: CollectionFormState[K]\n ) => {\n setForm((prev) => ({ ...prev, [field]: value }));\n };\n\n const saving = creating || updating || syncingTags;\n\n const onSubmit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n\n if (!form.name.trim()) {\n notify.error('Name is required', 'Give this collection a recognizable name.');\n return;\n }\n\n if (isEdit) {\n const input: CosUpdateCollectionInput = {\n name: form.name.trim(),\n slug: form.slug.trim() || undefined,\n description: form.description.trim() || undefined,\n isPublic: form.isPublic,\n tags: form.tags,\n };\n // Captured before the mutation: its response refreshes the cached collection.\n const previousTags = data?.cosCollection?.tags ?? [];\n const response = await updateCollection({ variables: { id, input } });\n if (response.data?.cosUpdateCollection?.id) {\n if (await syncTags(id, form.tags, previousTags)) notify.success('Collection updated');\n navigate(`collections/${id}`);\n }\n return;\n }\n\n const input: CosCreateCollectionInput = {\n name: form.name.trim(),\n slug: form.slug.trim() || undefined,\n description: form.description.trim() || undefined,\n isPublic: form.isPublic,\n tags: form.tags,\n };\n const response = await createCollection({ variables: { input } });\n const created = response.data?.cosCreateCollection;\n if (created?.id) {\n if (await syncTags(created.id, form.tags)) notify.success('Collection created');\n navigate(`collections/${created.id}`);\n }\n };\n\n if (isEdit && loadingCollection && !data?.cosCollection) {\n return <LoadingState label=\"Loading collection…\" />;\n }\n\n return (\n <EntityFormShell\n title={isEdit ? 'Edit collection' : 'New collection'}\n description=\"Group related datasets into a shareable, themed collection.\"\n purpose=\"Collections curate datasets by mission, survey or research theme so collaborators can browse a coherent set instead of a flat list. Mark a collection public to make it discoverable across the workspace.\"\n backLabel={isEdit ? 'Back to collection' : 'Back to collections'}\n onBack={() => navigate(isEdit ? `collections/${id}` : 'collections')}\n onSubmit={(event) => void onSubmit(event)}\n submitLabel={isEdit ? 'Save collection' : 'Create collection'}\n saving={saving}\n >\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n <label className={fieldLabelClass}>\n <span className={fieldSpanClass}>Name</span>\n <Input\n value={form.name}\n onChange={(event) => onChange('name', event.target.value)}\n placeholder=\"e.g. Kepler Mission Data\"\n required\n />\n </label>\n <label className={fieldLabelClass}>\n <span className={fieldSpanClass}>Slug</span>\n <Input\n value={form.slug}\n onChange={(event) => onChange('slug', event.target.value)}\n placeholder=\"kepler-mission\"\n />\n <span className=\"text-xs text-text-secondary\">\n Optional URL-friendly identifier for sharing.\n </span>\n </label>\n </div>\n\n <label className={fieldLabelClass}>\n <span className={fieldSpanClass}>Description</span>\n <Textarea\n value={form.description}\n onChange={(event) => onChange('description', event.target.value)}\n rows={3}\n placeholder=\"What this collection groups together and who it is for.\"\n />\n </label>\n\n <div className=\"flex items-center justify-between gap-4 rounded-card border border-border-default bg-bg-sunken px-4 py-3\">\n <div>\n <p className=\"text-sm font-medium text-text-primary\">Public collection</p>\n <p className=\"text-xs text-text-secondary\">\n Make this collection discoverable across the workspace.\n </p>\n </div>\n <Switch\n checked={form.isPublic}\n onCheckedChange={(checked) => onChange('isPublic', checked)}\n aria-label=\"Public collection\"\n />\n </div>\n\n <WorkspaceTagsPicker\n value={form.tags}\n onChange={(tags) => onChange('tags', tags)}\n disabled={saving}\n />\n </EntityFormShell>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAM,IAAqC;CACzC,MAAM;CACN,MAAM;CACN,aAAa;CACb,UAAU;CACV,MAAM,CAAC;AACT,GAEM,IAAkB,6BAClB,IAAiB;AAEvB,SAAwB,IAAqB;CAC3C,IAAM,EAAE,QAAK,OAAO,EAA0B,GACxC,IAAS,QAAc,EAAQ,GAAK,CAAC,CAAE,CAAC,GACxC,EAAE,gBAAa,EAAsB,GAErC,EAAE,SAAM,SAAS,MAAsB,EAAsB,CAAE,GAC/D,CAAC,GAAkB,EAAE,SAAS,OAAc,EAA+B,GAC3E,CAAC,GAAkB,EAAE,SAAS,OAAc,EAA+B,GAE3E,CAAC,GAAM,KAAW,EAA8B,CAAa,GAC7D,EAAE,aAAU,SAAS,MAAgB,EAAiB,+BAA+B,GAIrF,CAAC,GAAU,KAAe,EAAwB,IAAI;CAC5D,IAAI,KAAU,GAAM,iBAAiB,MAAa,EAAK,cAAc,IAAI;EACvE,IAAM,IAAa,EAAK;EAExB,AADA,EAAY,EAAW,EAAE,GACzB,EAAQ;GACN,MAAM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CAAO;KAC1D,cAAW;IACZ,CAAA,CACE;;GAEL,kBAAC,GAAD;IACE,OAAO,EAAK;IACZ,WAAW,MAAS,EAAS,QAAQ,CAAI;IACzC,UAAU;GACX,CAAA;EACc;;AAErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasetDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/cosmicintersection/pages/datasets/DatasetDetailPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatasetDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/cosmicintersection/pages/datasets/DatasetDetailPage.tsx"],"names":[],"mappings":"AAmJA,MAAM,CAAC,OAAO,UAAU,iBAAiB,gCAspBxC"}
|