@burdenoff/microfe-bigconsole 2026.1119.5 → 2026.1119.7

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.
@@ -1,192 +1,208 @@
1
- import { CreateExploreWidgetDocument as e, ExploreDashboardsDocument as t, ExplorePagesDocument as n } from "../../../generated/wspace-operations.js";
2
- import { exploreError as r, workspaceRequest as i } from "./useExploreRun.js";
3
- import { Control as a, controlClass as o } from "./VisualBuilder.js";
4
- import { useOptionalBigConsole as s } from "../../context/BigConsoleContext.js";
5
- import { SavedQueryWidget as c } from "./SavedQueryWidget.js";
1
+ import { BigConsoleAskAddToDashboardDocument as e, CreateExploreWidgetDocument as t, ExploreDashboardsDocument as n, ExplorePagesDocument as r } from "../../../generated/wspace-operations.js";
2
+ import { exploreError as i, workspaceRequest as a } from "./useExploreRun.js";
3
+ import { Control as o, controlClass as s } from "./VisualBuilder.js";
4
+ import { useOptionalBigConsole as c } from "../../context/BigConsoleContext.js";
5
+ import { SavedQueryWidget as l } from "./SavedQueryWidget.js";
6
6
  import "../../hooks/useActivePage.js";
7
- import { useEffect as l, useRef as u, useState as d } from "react";
8
- import { useApolloClient as f } from "@apollo/client/react";
9
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
+ import { useEffect as u, useRef as d, useState as f } from "react";
8
+ import { useApolloClient as p } from "@apollo/client/react";
9
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
10
  // src/bigconsole/components/explore/CreateQueryWidget.tsx
11
- function h({ savedId: h, name: g, workspaceId: _ }) {
12
- let v = f(), y = s(), [b, x] = d(""), [S, C] = d(""), [w, T] = d([]), [E, D] = d([]), [O, k] = d(g), [A, j] = d(""), [M, N] = d(""), [P, F] = d(""), [I, L] = d(null), [R, z] = d(null), [B, V] = d(null), [H, U] = d(null), W = JSON.stringify([
13
- b,
14
- B,
15
- H
16
- ]), G = W !== M, [K, q] = d(!1);
17
- l(() => {
18
- let e = new AbortController(), a = i(_, e.signal);
19
- return b ? v.query({
20
- query: n,
11
+ function g({ savedId: g, askSpec: _, name: v, workspaceId: y }) {
12
+ let b = p(), x = c(), [S, C] = f(""), [w, T] = f(""), [E, D] = f([]), [O, k] = f([]), [A, j] = f(v), [M, N] = f(""), [P, F] = f(""), [I, L] = f(""), [R, z] = f(null), [B, V] = f(null), [H, U] = f(null), [W, G] = f(null), K = JSON.stringify([
13
+ S,
14
+ H,
15
+ W
16
+ ]), q = K !== P, [J, Y] = f(!1);
17
+ u(() => {
18
+ let e = new AbortController(), t = a(y, e.signal);
19
+ return S ? b.query({
20
+ query: r,
21
21
  variables: {
22
- dashboardId: b,
23
- after: H
22
+ dashboardId: S,
23
+ after: W
24
24
  },
25
25
  fetchPolicy: "no-cache",
26
- context: a
26
+ context: t
27
27
  }).then(({ data: t }) => {
28
28
  if (e.signal.aborted) return;
29
29
  let n = t?.getDashboard?.pages;
30
30
  if (!n) throw Error("Missing pages");
31
- j(""), D((e) => [...H ? e : [], ...n.edges.map((e) => e.node)]), z(n.pageInfo.hasNextPage ? n.pageInfo.endCursor ?? null : null);
31
+ N(""), k((e) => [...W ? e : [], ...n.edges.map((e) => e.node)]), V(n.pageInfo.hasNextPage ? n.pageInfo.endCursor ?? null : null);
32
32
  }).catch((t) => {
33
- e.signal.aborted || j(r(t));
33
+ e.signal.aborted || N(i(t));
34
34
  }).finally(() => {
35
- e.signal.aborted || N(W);
36
- }) : v.query({
37
- query: t,
38
- variables: { after: B },
35
+ e.signal.aborted || F(K);
36
+ }) : b.query({
37
+ query: n,
38
+ variables: { after: H },
39
39
  fetchPolicy: "no-cache",
40
- context: a
40
+ context: t
41
41
  }).then(({ data: t }) => {
42
42
  if (e.signal.aborted) return;
43
43
  if (!t?.listDashboards) throw Error("Missing dashboards");
44
44
  let n = t.listDashboards;
45
- j(""), T((e) => [...B ? e : [], ...n.edges.map((e) => e.node)]), L(n.pageInfo.hasNextPage ? n.pageInfo.endCursor ?? null : null);
45
+ N(""), D((e) => [...H ? e : [], ...n.edges.map((e) => e.node)]), z(n.pageInfo.hasNextPage ? n.pageInfo.endCursor ?? null : null);
46
46
  }).catch((t) => {
47
- e.signal.aborted || j(r(t));
47
+ e.signal.aborted || N(i(t));
48
48
  }).finally(() => {
49
- e.signal.aborted || N(W);
49
+ e.signal.aborted || F(K);
50
50
  }), () => e.abort();
51
51
  }, [
52
- v,
53
- _,
54
52
  b,
55
- B,
53
+ y,
54
+ S,
56
55
  H,
57
- W
56
+ W,
57
+ K
58
58
  ]);
59
- let J = u(null);
60
- l(() => {
59
+ let X = d(null);
60
+ u(() => {
61
61
  let e = new AbortController();
62
- return J.current = e, () => e.abort();
62
+ return X.current = e, () => e.abort();
63
63
  }, []);
64
- async function Y() {
65
- let t = J.current;
66
- if (t && !t.signal.aborted && !K && O.trim() && S) {
67
- q(!0), j("");
64
+ async function Z() {
65
+ let n = X.current;
66
+ if (n && !n.signal.aborted && !J && A.trim() && w) {
67
+ Y(!0), N("");
68
68
  try {
69
- let { data: n } = await v.mutate({
70
- mutation: e,
71
- variables: {
72
- savedQueryId: h,
73
- title: O.trim(),
74
- pageId: S
75
- },
76
- fetchPolicy: "no-cache",
77
- context: i(_, t.signal)
78
- });
79
- if (t.signal.aborted) return;
80
- if (!n?.bigconsoleCreateExploreWidget) throw Error("Missing widget");
81
- F(n.bigconsoleCreateExploreWidget);
69
+ let r = a(y, n.signal), i;
70
+ if (_ !== void 0) {
71
+ let { data: t } = await b.mutate({
72
+ mutation: e,
73
+ variables: {
74
+ spec: _,
75
+ title: A.trim(),
76
+ pageId: w
77
+ },
78
+ fetchPolicy: "no-cache",
79
+ context: r
80
+ });
81
+ i = t?.bigconsoleAskAddToDashboard;
82
+ } else {
83
+ let { data: e } = await b.mutate({
84
+ mutation: t,
85
+ variables: {
86
+ savedQueryId: g ?? "",
87
+ title: A.trim(),
88
+ pageId: w
89
+ },
90
+ fetchPolicy: "no-cache",
91
+ context: r
92
+ });
93
+ i = e?.bigconsoleCreateExploreWidget;
94
+ }
95
+ if (n.signal.aborted) return;
96
+ if (!i) throw Error("Missing widget");
97
+ L(i);
82
98
  } catch (e) {
83
- t.signal.aborted || j(r(e));
99
+ n.signal.aborted || N(i(e));
84
100
  } finally {
85
- t.signal.aborted || q(!1);
101
+ n.signal.aborted || Y(!1);
86
102
  }
87
103
  }
88
104
  }
89
- return P ? /* @__PURE__ */ m("div", {
105
+ return I ? /* @__PURE__ */ h("div", {
90
106
  className: "space-y-2",
91
107
  children: [
92
- /* @__PURE__ */ p("p", {
108
+ /* @__PURE__ */ m("p", {
93
109
  role: "status",
94
110
  children: "Widget created."
95
111
  }),
96
- y && /* @__PURE__ */ p("button", {
112
+ x && /* @__PURE__ */ m("button", {
97
113
  type: "button",
98
114
  className: "underline",
99
- onClick: () => y.navigate(`/dashboards/${encodeURIComponent(b)}?page=${encodeURIComponent(S)}`),
115
+ onClick: () => x.navigate(`/dashboards/${encodeURIComponent(S)}?page=${encodeURIComponent(w)}`),
100
116
  children: "Open dashboard"
101
117
  }),
102
- /* @__PURE__ */ p(c, {
103
- id: P,
104
- title: O
118
+ /* @__PURE__ */ m(l, {
119
+ id: I,
120
+ title: A
105
121
  })
106
122
  ]
107
- }) : /* @__PURE__ */ m("fieldset", {
123
+ }) : /* @__PURE__ */ h("fieldset", {
108
124
  className: "space-y-2",
109
125
  children: [
110
- /* @__PURE__ */ p("legend", {
126
+ /* @__PURE__ */ m("legend", {
111
127
  className: "font-medium",
112
128
  children: "Create a dashboard widget"
113
129
  }),
114
- /* @__PURE__ */ m("div", {
130
+ /* @__PURE__ */ h("div", {
115
131
  className: "flex flex-wrap items-end gap-2",
116
132
  children: [
117
- /* @__PURE__ */ p(a, {
133
+ /* @__PURE__ */ m(o, {
118
134
  label: "Dashboard",
119
- children: /* @__PURE__ */ m("select", {
120
- className: o,
121
- value: b,
122
- disabled: K,
135
+ children: /* @__PURE__ */ h("select", {
136
+ className: s,
137
+ value: S,
138
+ disabled: J,
123
139
  onChange: (e) => {
124
- x(e.target.value), C(""), D([]), U(null), z(null);
140
+ C(e.target.value), T(""), k([]), G(null), V(null);
125
141
  },
126
- children: [/* @__PURE__ */ p("option", {
142
+ children: [/* @__PURE__ */ m("option", {
127
143
  value: "",
128
144
  children: "Choose dashboard"
129
- }), w.map((e) => /* @__PURE__ */ p("option", {
145
+ }), E.map((e) => /* @__PURE__ */ m("option", {
130
146
  value: e.id,
131
147
  children: e.name
132
148
  }, e.id))]
133
149
  })
134
150
  }),
135
- !b && I && /* @__PURE__ */ p("button", {
151
+ !S && R && /* @__PURE__ */ m("button", {
136
152
  type: "button",
137
- disabled: G,
138
- onClick: () => V(I),
153
+ disabled: q,
154
+ onClick: () => U(R),
139
155
  children: "More dashboards"
140
156
  }),
141
- b && /* @__PURE__ */ p(a, {
157
+ S && /* @__PURE__ */ m(o, {
142
158
  label: "Dashboard page",
143
- children: /* @__PURE__ */ m("select", {
159
+ children: /* @__PURE__ */ h("select", {
144
160
  className: "rounded border border-border-default bg-bg-surface px-2 py-1 text-sm text-text-primary",
145
- value: S,
146
- disabled: K,
147
- onChange: (e) => C(e.target.value),
148
- children: [/* @__PURE__ */ p("option", {
161
+ value: w,
162
+ disabled: J,
163
+ onChange: (e) => T(e.target.value),
164
+ children: [/* @__PURE__ */ m("option", {
149
165
  value: "",
150
166
  children: "Choose page"
151
- }), E.map((e) => /* @__PURE__ */ p("option", {
167
+ }), O.map((e) => /* @__PURE__ */ m("option", {
152
168
  value: e.id,
153
169
  children: e.name
154
170
  }, e.id))]
155
171
  })
156
172
  }),
157
- b && R && /* @__PURE__ */ p("button", {
173
+ S && B && /* @__PURE__ */ m("button", {
158
174
  type: "button",
159
- disabled: G,
160
- onClick: () => U(R),
175
+ disabled: q,
176
+ onClick: () => G(B),
161
177
  children: "More pages"
162
178
  }),
163
- /* @__PURE__ */ p(a, {
179
+ /* @__PURE__ */ m(o, {
164
180
  label: "Widget title",
165
- children: /* @__PURE__ */ p("input", {
166
- className: o,
167
- value: O,
168
- disabled: K,
169
- onChange: (e) => k(e.target.value)
181
+ children: /* @__PURE__ */ m("input", {
182
+ className: s,
183
+ value: A,
184
+ disabled: J,
185
+ onChange: (e) => j(e.target.value)
170
186
  })
171
187
  }),
172
- /* @__PURE__ */ p("button", {
188
+ /* @__PURE__ */ m("button", {
173
189
  type: "button",
174
- className: o,
175
- onClick: () => void Y(),
176
- disabled: K || !S || !O.trim(),
190
+ className: s,
191
+ onClick: () => void Z(),
192
+ disabled: J || !w || !A.trim(),
177
193
  children: "Create widget"
178
194
  })
179
195
  ]
180
196
  }),
181
- G && /* @__PURE__ */ p("p", {
197
+ q && /* @__PURE__ */ m("p", {
182
198
  role: "status",
183
199
  children: "Loading destinations…"
184
200
  }),
185
- A && /* @__PURE__ */ p("p", {
201
+ M && /* @__PURE__ */ m("p", {
186
202
  role: "alert",
187
- children: A
203
+ children: M
188
204
  })
189
205
  ]
190
206
  });
191
207
  }
192
- export { h as CreateQueryWidget };
208
+ export { g as CreateQueryWidget };
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ export declare const WidgetCatalogSection: FC;
3
+ export default WidgetCatalogSection;
@@ -0,0 +1,207 @@
1
+ import { BIGCONSOLE_PERMISSIONS as e } from "../../../constants/permissions.js";
2
+ import { useBigConsole as t } from "../../context/BigConsoleContext.js";
3
+ import "../../context/index.js";
4
+ import { useWidgetTypeCatalog as n } from "../../hooks/useWidgetTypeCatalog.js";
5
+ import { resolveBackendErrorMessage as r } from "../../utils/backendError.js";
6
+ import { isWidgetCatalogRowMuted as i, sortWidgetCatalogRows as a, widgetCatalogAction as o, widgetCatalogRowKey as s } from "../../utils/widgetCatalog.js";
7
+ import { useCallback as c, useMemo as l, useState as u } from "react";
8
+ import { usePermissions as d } from "@burdenoff/fe-libs/shared/providers/shell";
9
+ import { Blocks as f, ExternalLink as p } from "lucide-react";
10
+ import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
11
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
+ // src/bigconsole/components/settings/WidgetCatalogSection.tsx
13
+ var _ = "px-3 py-2 text-left align-middle text-body-sm", v = "px-3 py-2 text-left text-body-sm font-medium text-text-secondary", y = "rounded-button border border-border px-3 py-1 text-body-sm text-text-primary hover:border-action-primary-bg disabled:cursor-not-allowed disabled:opacity-60", b = () => {
14
+ let { hasPermission: t, isLoading: n } = d();
15
+ return n || !t(e.WIDGET_MANAGE_TYPES) ? null : /* @__PURE__ */ h(x, {});
16
+ }, x = () => {
17
+ let { t: e } = m(), { workspaceId: d, basePath: b } = t(), x = n(d, !0), [S, C] = u(null), w = l(() => a(x.rows), [x.rows]), T = `${b}/store${typeof window > "u" ? "" : window.location.search}`, { install: E, uninstall: D } = x, O = c(async (t, n) => {
18
+ C(null);
19
+ let i = n === "install" ? await E(t) : await D(t);
20
+ i && C(r(e, i));
21
+ }, [
22
+ E,
23
+ D,
24
+ e
25
+ ]), k = (t) => {
26
+ switch (t) {
27
+ case "AVAILABLE": return e("bigconsole.settings.widgetCatalog.status.available", "Available");
28
+ case "DEPRECATED": return e("bigconsole.settings.widgetCatalog.status.deprecated", "Deprecated");
29
+ case "DISABLED": return e("bigconsole.settings.widgetCatalog.status.disabled", "Disabled");
30
+ default: return t;
31
+ }
32
+ }, A = (t) => t === "STORE" ? e("bigconsole.settings.widgetCatalog.source.store", "Store") : e("bigconsole.settings.widgetCatalog.source.custom", "Custom"), j = (t) => {
33
+ let n = o(t), r = x.pendingKey === s(t), i = x.pendingKey !== null;
34
+ if (n === "store") return /* @__PURE__ */ g("a", {
35
+ href: T,
36
+ target: "_blank",
37
+ rel: "noopener noreferrer",
38
+ className: "inline-flex items-center gap-1 text-body-sm text-text-link hover:underline",
39
+ children: [t.installedInWorkspace ? e("bigconsole.settings.widgetCatalog.actions.manageInStore", "Manage in Store") : e("bigconsole.settings.widgetCatalog.actions.getFromStore", "Get from Store"), /* @__PURE__ */ h(p, {
40
+ "aria-hidden": "true",
41
+ size: 12
42
+ })]
43
+ });
44
+ if (n === "none") return /* @__PURE__ */ h("span", {
45
+ className: "text-body-sm text-text-muted",
46
+ children: e("bigconsole.settings.widgetCatalog.actions.unavailable", "Not installable")
47
+ });
48
+ let a = n === "install" ? r ? e("bigconsole.settings.widgetCatalog.actions.installing", "Installing…") : e("bigconsole.settings.widgetCatalog.actions.install", "Install") : r ? e("bigconsole.settings.widgetCatalog.actions.uninstalling", "Uninstalling…") : e("bigconsole.settings.widgetCatalog.actions.uninstall", "Uninstall");
49
+ return /* @__PURE__ */ h("button", {
50
+ type: "button",
51
+ className: y,
52
+ disabled: i,
53
+ "aria-busy": r,
54
+ "aria-label": `${a} ${t.name} ${t.widgetVersion}`,
55
+ onClick: () => void O(t, n),
56
+ children: a
57
+ });
58
+ };
59
+ return /* @__PURE__ */ g("section", {
60
+ "aria-labelledby": "bigconsole-widget-catalog-title",
61
+ "data-testid": "bigconsole-widget-catalog",
62
+ className: "mb-[var(--space-sectionGap)] rounded-card border border-border-seam bg-bg-surface p-[var(--space-cardPadding)] shadow-pop",
63
+ children: [
64
+ /* @__PURE__ */ g("div", {
65
+ className: "mb-4 flex flex-wrap items-start justify-between gap-form-gap",
66
+ children: [/* @__PURE__ */ g("div", {
67
+ className: "flex items-start gap-[var(--space-iconGap)]",
68
+ children: [/* @__PURE__ */ h(f, {
69
+ "aria-hidden": "true",
70
+ size: 20,
71
+ className: "mt-0.5 text-text-primary"
72
+ }), /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("h2", {
73
+ id: "bigconsole-widget-catalog-title",
74
+ className: "text-body-md font-semibold text-text-primary",
75
+ children: e("bigconsole.settings.widgetCatalog.title", "Widget catalog")
76
+ }), /* @__PURE__ */ h("p", {
77
+ className: "mt-1 text-body-sm text-text-muted",
78
+ children: e("bigconsole.settings.widgetCatalog.subtitle", "Custom and Store widget types registered for BigConsole. Installed types appear in this workspace’s widget palette.")
79
+ })] })]
80
+ }), /* @__PURE__ */ g("a", {
81
+ href: T,
82
+ target: "_blank",
83
+ rel: "noopener noreferrer",
84
+ className: "inline-flex items-center gap-1 text-body-sm text-text-link hover:underline",
85
+ children: [e("bigconsole.settings.widgetCatalog.browseStore", "Browse widget store"), /* @__PURE__ */ h(p, {
86
+ "aria-hidden": "true",
87
+ size: 12
88
+ })]
89
+ })]
90
+ }),
91
+ S && /* @__PURE__ */ h("p", {
92
+ role: "alert",
93
+ className: "mb-form-gap text-body-sm text-status-error-text",
94
+ children: S
95
+ }),
96
+ x.loadError ? /* @__PURE__ */ g("div", {
97
+ role: "alert",
98
+ className: "flex flex-wrap items-center gap-form-gap text-body-sm text-status-error-text",
99
+ children: [/* @__PURE__ */ g("span", { children: [
100
+ e("bigconsole.settings.widgetCatalog.loadFailed", "The widget catalog could not be loaded."),
101
+ " ",
102
+ r(e, x.loadError)
103
+ ] }), /* @__PURE__ */ h("button", {
104
+ type: "button",
105
+ className: y,
106
+ onClick: () => void x.reload(),
107
+ children: e("bigconsole.settings.widgetCatalog.retry", "Retry")
108
+ })]
109
+ }) : x.loading && w.length === 0 ? /* @__PURE__ */ h("p", {
110
+ role: "status",
111
+ className: "text-body-sm text-text-muted",
112
+ children: e("bigconsole.settings.widgetCatalog.loading", "Loading widget types…")
113
+ }) : w.length === 0 ? /* @__PURE__ */ h("p", {
114
+ className: "text-body-sm text-text-muted",
115
+ children: e("bigconsole.settings.widgetCatalog.empty", "No custom or Store widget types are registered yet. Browse the widget store to add one.")
116
+ }) : /* @__PURE__ */ h("div", {
117
+ className: "overflow-x-auto",
118
+ children: /* @__PURE__ */ g("table", {
119
+ className: "w-full min-w-[640px] border-collapse",
120
+ children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", {
121
+ className: "border-b border-border-seam",
122
+ children: [
123
+ /* @__PURE__ */ h("th", {
124
+ scope: "col",
125
+ className: v,
126
+ children: e("bigconsole.settings.widgetCatalog.columns.name", "Name")
127
+ }),
128
+ /* @__PURE__ */ h("th", {
129
+ scope: "col",
130
+ className: v,
131
+ children: e("bigconsole.settings.widgetCatalog.columns.category", "Category")
132
+ }),
133
+ /* @__PURE__ */ h("th", {
134
+ scope: "col",
135
+ className: v,
136
+ children: e("bigconsole.settings.widgetCatalog.columns.version", "Version")
137
+ }),
138
+ /* @__PURE__ */ h("th", {
139
+ scope: "col",
140
+ className: v,
141
+ children: e("bigconsole.settings.widgetCatalog.columns.source", "Source")
142
+ }),
143
+ /* @__PURE__ */ h("th", {
144
+ scope: "col",
145
+ className: v,
146
+ children: e("bigconsole.settings.widgetCatalog.columns.status", "Status")
147
+ }),
148
+ /* @__PURE__ */ h("th", {
149
+ scope: "col",
150
+ className: v,
151
+ children: /* @__PURE__ */ h("span", {
152
+ className: "sr-only",
153
+ children: e("bigconsole.settings.widgetCatalog.columns.action", "Action")
154
+ })
155
+ })
156
+ ]
157
+ }) }), /* @__PURE__ */ h("tbody", { children: w.map((t) => {
158
+ let n = i(t);
159
+ return /* @__PURE__ */ g("tr", {
160
+ "data-status": t.status,
161
+ className: `border-b border-border-seam last:border-b-0 ${n ? "opacity-60" : ""}`,
162
+ children: [
163
+ /* @__PURE__ */ g("td", {
164
+ className: _,
165
+ children: [/* @__PURE__ */ h("div", {
166
+ className: "font-medium text-text-primary",
167
+ children: t.name
168
+ }), t.author && /* @__PURE__ */ h("div", {
169
+ className: "text-xs text-text-muted",
170
+ children: e("bigconsole.settings.widgetCatalog.byAuthor", "by {{author}}", { author: t.author })
171
+ })]
172
+ }),
173
+ /* @__PURE__ */ h("td", {
174
+ className: `${_} text-text-secondary`,
175
+ children: t.category ?? e("bigconsole.settings.widgetCatalog.uncategorized", "Uncategorized")
176
+ }),
177
+ /* @__PURE__ */ h("td", {
178
+ className: `${_} text-text-secondary`,
179
+ children: t.widgetVersion
180
+ }),
181
+ /* @__PURE__ */ h("td", {
182
+ className: `${_} text-text-secondary`,
183
+ children: A(t.publishType)
184
+ }),
185
+ /* @__PURE__ */ g("td", {
186
+ className: _,
187
+ children: [/* @__PURE__ */ h("span", {
188
+ className: "text-text-secondary",
189
+ children: k(t.status)
190
+ }), t.installedInWorkspace && /* @__PURE__ */ h("span", {
191
+ className: "ml-2 rounded-pill bg-status-success-bg px-2 py-0.5 text-xs text-status-success-text",
192
+ children: e("bigconsole.settings.widgetCatalog.installed", "Installed")
193
+ })]
194
+ }),
195
+ /* @__PURE__ */ h("td", {
196
+ className: `${_} text-right`,
197
+ children: j(t)
198
+ })
199
+ ]
200
+ }, s(t));
201
+ }) })]
202
+ })
203
+ })
204
+ ]
205
+ });
206
+ };
207
+ export { b as WidgetCatalogSection, b as default };
@@ -58,6 +58,8 @@ var e = {
58
58
  NO_ACTIVE_WEBHOOK_MAPPINGS: "No active webhook mappings were found for this event.",
59
59
  WIDGET_NOT_ASSOCIATED_WITH_DASHBOARD: "That widget is not associated with a dashboard.",
60
60
  WIDGET_TYPE_NOT_REGISTERED: "That widget type is not registered. Register it before installing.",
61
+ WIDGET_TYPE_REQUIRES_STORE_INSTALL: "That widget type comes from the Store. Install it from the Store instead.",
62
+ WIDGET_TYPE_NOT_INSTALLABLE: "That widget type cannot be installed in its current status.",
61
63
  INVALID_PUBLISH_TYPE: "That publish type is not valid.",
62
64
  INVALID_REGISTRABLE_PUBLISH_TYPE: "That publish type cannot be registered.",
63
65
  INVALID_WIDGET_RENDERER: "That widget renderer is not valid.",
@@ -0,0 +1,14 @@
1
+ import { WidgetCatalogRow } from '../utils/widgetCatalog';
2
+ export interface UseWidgetTypeCatalogResult {
3
+ rows: WidgetCatalogRow[];
4
+ loading: boolean;
5
+ /** The load error, if the catalog could not be read. */
6
+ loadError: unknown;
7
+ /** Key (`type@version`) of the row whose install/uninstall is in flight. */
8
+ pendingKey: string | null;
9
+ reload: () => Promise<void>;
10
+ /** Resolves to null on success, or the error to show. */
11
+ install: (row: WidgetCatalogRow) => Promise<unknown>;
12
+ uninstall: (row: WidgetCatalogRow) => Promise<unknown>;
13
+ }
14
+ export declare function useWidgetTypeCatalog(workspaceId: string | undefined, enabled: boolean): UseWidgetTypeCatalogResult;
@@ -0,0 +1,79 @@
1
+ import { InstallWidgetTypeDocument as e, UninstallWidgetTypeDocument as t, WidgetTypeCatalogDocument as n } from "../../generated/wspace-operations.js";
2
+ import { widgetCatalogRowKey as r } from "../utils/widgetCatalog.js";
3
+ import { useCallback as i, useMemo as a, useState as o } from "react";
4
+ import { useApolloClient as s, useQuery as c } from "@apollo/client/react";
5
+ // src/bigconsole/hooks/useWidgetTypeCatalog.ts
6
+ function l(l, u) {
7
+ let d = s(), [f, p] = o(null), [m, h] = o({}), { data: g, dataState: _, loading: v, error: y, refetch: b } = c(n, {
8
+ skip: !u || !l,
9
+ fetchPolicy: "network-only",
10
+ notifyOnNetworkStatusChange: !0
11
+ }), x = _ === "complete" ? g?.widgetTypeCatalog : void 0, S = a(() => (x ?? []).map((e) => {
12
+ let t = m[r(e)];
13
+ return t === void 0 ? e : {
14
+ ...e,
15
+ installedInWorkspace: t
16
+ };
17
+ }), [x, m]), C = i(async () => {
18
+ h({}), await b();
19
+ }, [b]), w = i((e, t) => {
20
+ let n = r(e);
21
+ h((e) => ({
22
+ ...e,
23
+ [n]: t
24
+ }));
25
+ }, []), T = i(async (t) => {
26
+ if (!l) return null;
27
+ p(r(t));
28
+ try {
29
+ return await d.mutate({
30
+ mutation: e,
31
+ variables: { input: {
32
+ widgetType: t.widgetType,
33
+ widgetVersion: t.widgetVersion,
34
+ publishType: t.publishType,
35
+ workspaceId: l
36
+ } }
37
+ }), w(t, !0), null;
38
+ } catch (e) {
39
+ return e;
40
+ } finally {
41
+ p(null);
42
+ }
43
+ }, [
44
+ d,
45
+ w,
46
+ l
47
+ ]), E = i(async (e) => {
48
+ if (!l) return null;
49
+ p(r(e));
50
+ try {
51
+ return await d.mutate({
52
+ mutation: t,
53
+ variables: { input: {
54
+ widgetType: e.widgetType,
55
+ widgetVersion: e.widgetVersion,
56
+ workspaceId: l
57
+ } }
58
+ }), w(e, !1), null;
59
+ } catch (e) {
60
+ return e;
61
+ } finally {
62
+ p(null);
63
+ }
64
+ }, [
65
+ d,
66
+ w,
67
+ l
68
+ ]);
69
+ return {
70
+ rows: S,
71
+ loading: v,
72
+ loadError: y ?? null,
73
+ pendingKey: f,
74
+ reload: C,
75
+ install: T,
76
+ uninstall: E
77
+ };
78
+ }
79
+ export { l as useWidgetTypeCatalog };