@burdenoff/microfe-timecampus 2026.1107.6 → 2026.1109.1
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/generated/global-types.d.ts +1019 -85
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +1219 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +1731 -1483
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +5568 -171
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +7 -5
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/timecampus/AdminRoot.d.ts.map +1 -1
- package/dist/timecampus/AdminRoot.js +1 -1
- package/dist/timecampus/AdminRoot.js.map +1 -1
- package/dist/timecampus/AdminRoutes.d.ts.map +1 -1
- package/dist/timecampus/AdminRoutes.js +24 -4
- package/dist/timecampus/AdminRoutes.js.map +1 -1
- package/dist/timecampus/TimeCampusRoutes.d.ts.map +1 -1
- package/dist/timecampus/TimeCampusRoutes.js +11 -7
- package/dist/timecampus/TimeCampusRoutes.js.map +1 -1
- package/dist/timecampus/adminPaths.d.ts +7 -0
- package/dist/timecampus/adminPaths.d.ts.map +1 -0
- package/dist/timecampus/adminPaths.js +6 -0
- package/dist/timecampus/adminPaths.js.map +1 -0
- package/dist/timecampus/index.d.ts +1 -0
- package/dist/timecampus/index.d.ts.map +1 -1
- package/dist/timecampus/index.js +8 -7
- package/dist/timecampus/pages/admin/AdminPage.d.ts.map +1 -1
- package/dist/timecampus/pages/admin/AdminPage.js +263 -251
- package/dist/timecampus/pages/admin/AdminPage.js.map +1 -1
- package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js +4 -4
- package/dist/timecampus/pages/extend/AppletDeveloperPage.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js +252 -134
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js.map +1 -1
- package/dist/timecampus/pages/extend/AppletReviewPage.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/AppletReviewPage.js +143 -130
- package/dist/timecampus/pages/extend/AppletReviewPage.js.map +1 -1
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.d.ts +2 -0
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.d.ts.map +1 -0
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js +330 -0
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js.map +1 -0
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js +167 -104
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js.map +1 -1
- package/dist/timecampus/pages/extend/appletPublishingHelpers.d.ts +30 -0
- package/dist/timecampus/pages/extend/appletPublishingHelpers.d.ts.map +1 -1
- package/dist/timecampus/pages/extend/appletPublishingHelpers.js +27 -1
- package/dist/timecampus/pages/extend/appletPublishingHelpers.js.map +1 -1
- package/dist/timecampus/pages/time-approval/TimeApprovalPage.js +4 -4
- package/package.json +1 -1
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { useTimeCampusNavigate as e } from "../../providers/TimeCampusProvider.js";
|
|
2
2
|
import { formatDate as t } from "../../utils/helpers.js";
|
|
3
|
-
import {
|
|
4
|
-
import { StatusBadge as
|
|
5
|
-
import { Modal as
|
|
6
|
-
import { appletCategoryLabel as
|
|
7
|
-
import { errorText as
|
|
8
|
-
import { scopeLabel as
|
|
9
|
-
import { useState as
|
|
10
|
-
import { Code as
|
|
11
|
-
import { Fragment as
|
|
12
|
-
import { GlassCard as
|
|
3
|
+
import { useInstallMarketplaceAppletMutation as n, useInstallThirdPartyAppletMutation as r, useListMarketplaceAppletsQuery as i, useListStoreAppletsQuery as a, useUninstallMarketplaceAppletMutation as o, useUninstallThirdPartyAppletMutation as s } from "../../../generated/wspace-operations.js";
|
|
4
|
+
import { StatusBadge as c } from "../../components/StatusBadge.js";
|
|
5
|
+
import { Modal as l } from "../../components/Modal.js";
|
|
6
|
+
import { appletCategoryLabel as u, catalogueIcon as d } from "./extendHelpers.js";
|
|
7
|
+
import { errorText as f } from "./appletPublishingHelpers.js";
|
|
8
|
+
import { scopeLabel as p } from "./appletBridge.js";
|
|
9
|
+
import { useState as m } from "react";
|
|
10
|
+
import { Code as h, Download as g, ShieldCheck as _, Trash2 as v } from "lucide-react";
|
|
11
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
12
|
+
import { GlassCard as S } from "@burdenoff/fe-libs/ui";
|
|
13
13
|
//#region src/timecampus/pages/extend/ThirdPartyAppletsSection.tsx
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
let [i, a] =
|
|
17
|
-
return /* @__PURE__ */
|
|
14
|
+
var C = ["ListStoreApplets", "GetWidgetDashboard"], w = ["ListMarketplaceApplets", "GetWidgetDashboard"], T = "inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50", E = "inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50";
|
|
15
|
+
function D({ applet: e, busy: t, onCancel: n, onConfirm: r }) {
|
|
16
|
+
let [i, a] = m(() => e.installed ? [...e.grantedScopes] : [...e.requestedScopes]), o = (e) => a((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
17
|
+
return /* @__PURE__ */ b(l, {
|
|
18
18
|
open: !0,
|
|
19
19
|
onClose: n,
|
|
20
20
|
title: e.installed ? `Data access for ${e.name}` : `Install ${e.name}`,
|
|
21
21
|
description: "Third-party widgets run in a sandbox and only receive the data you grant here.",
|
|
22
|
-
footer: /* @__PURE__ */
|
|
22
|
+
footer: /* @__PURE__ */ x("div", {
|
|
23
23
|
className: "flex justify-end gap-2",
|
|
24
|
-
children: [/* @__PURE__ */
|
|
24
|
+
children: [/* @__PURE__ */ b("button", {
|
|
25
25
|
type: "button",
|
|
26
|
-
className:
|
|
26
|
+
className: E,
|
|
27
27
|
onClick: n,
|
|
28
28
|
children: "Cancel"
|
|
29
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ b("button", {
|
|
30
30
|
type: "button",
|
|
31
|
-
className:
|
|
31
|
+
className: T,
|
|
32
32
|
disabled: t,
|
|
33
33
|
onClick: () => r(i),
|
|
34
34
|
children: t ? "Saving…" : e.installed ? "Save access" : "Install"
|
|
35
35
|
})]
|
|
36
36
|
}),
|
|
37
|
-
children: e.requestedScopes.length === 0 ? /* @__PURE__ */
|
|
37
|
+
children: e.requestedScopes.length === 0 ? /* @__PURE__ */ b("p", {
|
|
38
38
|
className: "text-sm text-text-secondary",
|
|
39
39
|
children: "This applet does not ask for any TimeCampus data."
|
|
40
|
-
}) : /* @__PURE__ */
|
|
40
|
+
}) : /* @__PURE__ */ x("fieldset", {
|
|
41
41
|
className: "flex flex-col gap-2",
|
|
42
|
-
children: [/* @__PURE__ */
|
|
42
|
+
children: [/* @__PURE__ */ x("legend", {
|
|
43
43
|
className: "mb-1 text-sm font-medium text-text-primary",
|
|
44
44
|
children: [e.name, " asks to read:"]
|
|
45
|
-
}), e.requestedScopes.map((e) => /* @__PURE__ */
|
|
45
|
+
}), e.requestedScopes.map((e) => /* @__PURE__ */ x("label", {
|
|
46
46
|
className: "flex items-start gap-2 text-sm text-text-secondary",
|
|
47
|
-
children: [/* @__PURE__ */
|
|
47
|
+
children: [/* @__PURE__ */ b("input", {
|
|
48
48
|
type: "checkbox",
|
|
49
49
|
className: "mt-0.5",
|
|
50
50
|
checked: i.includes(e),
|
|
51
|
-
onChange: () =>
|
|
52
|
-
"aria-label":
|
|
53
|
-
}), /* @__PURE__ */
|
|
54
|
-
|
|
51
|
+
onChange: () => o(e),
|
|
52
|
+
"aria-label": p(e)
|
|
53
|
+
}), /* @__PURE__ */ x("span", { children: [
|
|
54
|
+
p(e),
|
|
55
55
|
" ",
|
|
56
|
-
/* @__PURE__ */
|
|
56
|
+
/* @__PURE__ */ b("code", {
|
|
57
57
|
className: "text-xs text-text-tertiary",
|
|
58
58
|
children: e
|
|
59
59
|
})
|
|
@@ -62,56 +62,60 @@ function C({ applet: e, busy: t, onCancel: n, onConfirm: r }) {
|
|
|
62
62
|
})
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
let
|
|
67
|
-
return /* @__PURE__ */
|
|
65
|
+
function O({ applet: e, busy: n, onInstall: r, onUninstall: i }) {
|
|
66
|
+
let a = d(e.icon);
|
|
67
|
+
return /* @__PURE__ */ x(S, {
|
|
68
68
|
treatment: "glass",
|
|
69
69
|
className: "flex h-full flex-col gap-3 p-5",
|
|
70
|
-
"data-testid": `store-applet-card-${e.key}`,
|
|
70
|
+
"data-testid": e.source === "MARKETPLACE" ? `marketplace-applet-card-${e.key}` : `store-applet-card-${e.key}`,
|
|
71
71
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ x("div", {
|
|
73
73
|
className: "flex items-start gap-3",
|
|
74
74
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ b("div", {
|
|
76
76
|
className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
|
|
77
|
-
children: /* @__PURE__ */
|
|
77
|
+
children: /* @__PURE__ */ b(a, {
|
|
78
78
|
className: "h-5 w-5",
|
|
79
79
|
"aria-hidden": "true"
|
|
80
80
|
})
|
|
81
81
|
}),
|
|
82
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ x("div", {
|
|
83
83
|
className: "min-w-0 flex-1",
|
|
84
84
|
children: [
|
|
85
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ x("p", {
|
|
86
86
|
className: "text-xs font-medium uppercase tracking-wide text-text-tertiary",
|
|
87
87
|
children: [
|
|
88
|
-
|
|
88
|
+
u(e.category),
|
|
89
89
|
" · v",
|
|
90
90
|
e.version
|
|
91
91
|
]
|
|
92
92
|
}),
|
|
93
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ b("h3", {
|
|
94
94
|
className: "truncate text-base font-semibold text-text-primary",
|
|
95
95
|
children: e.name
|
|
96
96
|
}),
|
|
97
|
-
e.developerName && /* @__PURE__ */
|
|
97
|
+
e.developerName && /* @__PURE__ */ x("p", {
|
|
98
98
|
className: "text-xs text-text-tertiary",
|
|
99
|
-
children: [
|
|
99
|
+
children: [
|
|
100
|
+
"By ",
|
|
101
|
+
e.developerName,
|
|
102
|
+
e.source === "MARKETPLACE" ? " · platform certified" : ""
|
|
103
|
+
]
|
|
100
104
|
})
|
|
101
105
|
]
|
|
102
106
|
}),
|
|
103
|
-
e.installed && /* @__PURE__ */
|
|
107
|
+
e.installed && /* @__PURE__ */ b(c, {
|
|
104
108
|
label: "Installed",
|
|
105
109
|
variant: "success",
|
|
106
110
|
dot: !0
|
|
107
111
|
})
|
|
108
112
|
]
|
|
109
113
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ b("p", {
|
|
111
115
|
className: "flex-1 text-sm text-text-secondary",
|
|
112
116
|
children: e.description
|
|
113
117
|
}),
|
|
114
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ x("p", {
|
|
115
119
|
className: "text-xs text-text-tertiary",
|
|
116
120
|
children: [
|
|
117
121
|
"Adds ",
|
|
@@ -122,39 +126,39 @@ function w({ applet: e, busy: n, onInstall: r, onUninstall: i }) {
|
|
|
122
126
|
e.installed && e.installedAt ? ` · installed ${t(e.installedAt)}` : ""
|
|
123
127
|
]
|
|
124
128
|
}),
|
|
125
|
-
e.installed && e.ungrantedScopes.length > 0 && /* @__PURE__ */
|
|
129
|
+
e.installed && e.ungrantedScopes.length > 0 && /* @__PURE__ */ b("p", {
|
|
126
130
|
className: "text-xs text-status-warning-text",
|
|
127
131
|
children: "A newer version asks for more data access."
|
|
128
132
|
}),
|
|
129
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ b("div", {
|
|
130
134
|
className: "flex flex-wrap gap-2",
|
|
131
|
-
children: e.installed ? /* @__PURE__ */
|
|
135
|
+
children: e.installed ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x("button", {
|
|
132
136
|
type: "button",
|
|
133
|
-
className:
|
|
137
|
+
className: E,
|
|
134
138
|
onClick: r,
|
|
135
139
|
disabled: n,
|
|
136
140
|
"aria-label": `Data access for ${e.name}`,
|
|
137
|
-
children: [/* @__PURE__ */ _
|
|
141
|
+
children: [/* @__PURE__ */ b(_, {
|
|
138
142
|
className: "h-4 w-4",
|
|
139
143
|
"aria-hidden": "true"
|
|
140
144
|
}), "Data access"]
|
|
141
|
-
}), /* @__PURE__ */
|
|
145
|
+
}), /* @__PURE__ */ x("button", {
|
|
142
146
|
type: "button",
|
|
143
|
-
className:
|
|
147
|
+
className: E,
|
|
144
148
|
onClick: i,
|
|
145
149
|
disabled: n,
|
|
146
150
|
"aria-label": `Remove ${e.name}`,
|
|
147
|
-
children: [/* @__PURE__ */
|
|
151
|
+
children: [/* @__PURE__ */ b(v, {
|
|
148
152
|
className: "h-4 w-4",
|
|
149
153
|
"aria-hidden": "true"
|
|
150
154
|
}), "Remove"]
|
|
151
|
-
})] }) : /* @__PURE__ */
|
|
155
|
+
})] }) : /* @__PURE__ */ x("button", {
|
|
152
156
|
type: "button",
|
|
153
|
-
className:
|
|
157
|
+
className: T,
|
|
154
158
|
onClick: r,
|
|
155
159
|
disabled: n,
|
|
156
160
|
"aria-label": `Install ${e.name}`,
|
|
157
|
-
children: [/* @__PURE__ */
|
|
161
|
+
children: [/* @__PURE__ */ b(g, {
|
|
158
162
|
className: "h-4 w-4",
|
|
159
163
|
"aria-hidden": "true"
|
|
160
164
|
}), "Install"]
|
|
@@ -163,105 +167,164 @@ function w({ applet: e, busy: n, onInstall: r, onUninstall: i }) {
|
|
|
163
167
|
]
|
|
164
168
|
});
|
|
165
169
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
170
|
+
var k = [{
|
|
171
|
+
key: "workspace",
|
|
172
|
+
label: "Workspace applets"
|
|
173
|
+
}, {
|
|
174
|
+
key: "marketplace",
|
|
175
|
+
label: "Marketplace"
|
|
176
|
+
}];
|
|
177
|
+
function A(e) {
|
|
178
|
+
let { data: t, loading: n, error: i } = a({ skip: e }), [o] = r({ refetchQueries: C }), [c] = s({ refetchQueries: C });
|
|
179
|
+
return {
|
|
180
|
+
applets: t?.timeCampusStoreApplets ?? [],
|
|
181
|
+
loading: n && !t,
|
|
182
|
+
error: i,
|
|
183
|
+
install: (e, t) => o({ variables: {
|
|
184
|
+
id: e,
|
|
185
|
+
grantedScopes: t
|
|
186
|
+
} }),
|
|
187
|
+
uninstall: (e) => c({ variables: { id: e } })
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function j(e) {
|
|
191
|
+
let { data: t, loading: r, error: a } = i({ skip: e }), [s] = n({ refetchQueries: w }), [c] = o({ refetchQueries: w });
|
|
192
|
+
return {
|
|
193
|
+
applets: t?.timeCampusMarketplaceApplets ?? [],
|
|
194
|
+
loading: r && !t,
|
|
195
|
+
error: a,
|
|
196
|
+
install: (e, t) => s({ variables: {
|
|
197
|
+
id: e,
|
|
198
|
+
grantedScopes: t
|
|
199
|
+
} }),
|
|
200
|
+
uninstall: (e) => c({ variables: { id: e } })
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function M({ workspaceId: t, addToast: n }) {
|
|
204
|
+
let r = e(), [i, a] = m("workspace"), [o, s] = m(null), [c, l] = m(null), u = A(!t || i !== "workspace"), d = j(!t || i !== "marketplace"), p = i === "workspace" ? u : d, { applets: g, loading: v, error: y } = p, S = async (e, t) => {
|
|
205
|
+
l(e.id);
|
|
169
206
|
try {
|
|
170
|
-
await
|
|
171
|
-
id: e.id,
|
|
172
|
-
grantedScopes: t
|
|
173
|
-
} }), c(null), a({
|
|
207
|
+
await p.install(e.id, t), s(null), n({
|
|
174
208
|
title: e.installed ? `Data access for ${e.name} saved` : `${e.name} installed`,
|
|
175
209
|
description: "Its widgets are available in My Widgets.",
|
|
176
210
|
variant: "success"
|
|
177
211
|
});
|
|
178
212
|
} catch (e) {
|
|
179
|
-
|
|
180
|
-
title:
|
|
213
|
+
n({
|
|
214
|
+
title: f(e),
|
|
181
215
|
variant: "error"
|
|
182
216
|
});
|
|
183
217
|
} finally {
|
|
184
|
-
|
|
218
|
+
l(null);
|
|
185
219
|
}
|
|
186
|
-
},
|
|
187
|
-
|
|
220
|
+
}, C = async (e) => {
|
|
221
|
+
l(e.id);
|
|
188
222
|
try {
|
|
189
|
-
await
|
|
223
|
+
await p.uninstall(e.id), n({
|
|
190
224
|
title: `${e.name} removed`,
|
|
191
225
|
variant: "success"
|
|
192
226
|
});
|
|
193
227
|
} catch (e) {
|
|
194
|
-
|
|
195
|
-
title:
|
|
228
|
+
n({
|
|
229
|
+
title: f(e),
|
|
196
230
|
variant: "error"
|
|
197
231
|
});
|
|
198
232
|
} finally {
|
|
199
|
-
|
|
233
|
+
l(null);
|
|
200
234
|
}
|
|
235
|
+
}, w = (e) => {
|
|
236
|
+
s(null), a(e);
|
|
201
237
|
};
|
|
202
|
-
return /* @__PURE__ */
|
|
238
|
+
return /* @__PURE__ */ x("section", {
|
|
203
239
|
className: "mt-8",
|
|
204
240
|
"aria-labelledby": "workspace-applets-heading",
|
|
205
241
|
children: [
|
|
206
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ x("div", {
|
|
207
243
|
className: "mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",
|
|
208
|
-
children: [/* @__PURE__ */
|
|
244
|
+
children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("h2", {
|
|
209
245
|
id: "workspace-applets-heading",
|
|
210
246
|
className: "text-base font-semibold text-text-primary",
|
|
211
|
-
children: "
|
|
212
|
-
}), /* @__PURE__ */
|
|
247
|
+
children: "Third-party applets"
|
|
248
|
+
}), /* @__PURE__ */ x("p", {
|
|
213
249
|
className: "text-sm text-text-secondary",
|
|
214
|
-
children:
|
|
215
|
-
|
|
250
|
+
children: [
|
|
251
|
+
i === "workspace" ? "Applets built by developers in this workspace and certified by a reviewer." : "Applets from developers in any workspace, certified by the TimeCampus platform team.",
|
|
252
|
+
" ",
|
|
253
|
+
"They run sandboxed and only see the data you grant."
|
|
254
|
+
]
|
|
255
|
+
})] }), /* @__PURE__ */ x("div", {
|
|
216
256
|
className: "flex flex-wrap gap-2",
|
|
217
|
-
children: [/* @__PURE__ */
|
|
257
|
+
children: [/* @__PURE__ */ x("button", {
|
|
218
258
|
type: "button",
|
|
219
|
-
className:
|
|
220
|
-
onClick: () =>
|
|
221
|
-
children: [/* @__PURE__ */
|
|
259
|
+
className: E,
|
|
260
|
+
onClick: () => r("/applets/developer"),
|
|
261
|
+
children: [/* @__PURE__ */ b(h, {
|
|
222
262
|
className: "h-4 w-4",
|
|
223
263
|
"aria-hidden": "true"
|
|
224
264
|
}), "Build an applet"]
|
|
225
|
-
}), /* @__PURE__ */
|
|
265
|
+
}), /* @__PURE__ */ x("button", {
|
|
226
266
|
type: "button",
|
|
227
|
-
className:
|
|
228
|
-
onClick: () =>
|
|
229
|
-
children: [/* @__PURE__ */ _
|
|
267
|
+
className: E,
|
|
268
|
+
onClick: () => r("/applets/review"),
|
|
269
|
+
children: [/* @__PURE__ */ b(_, {
|
|
230
270
|
className: "h-4 w-4",
|
|
231
271
|
"aria-hidden": "true"
|
|
232
272
|
}), "Review queue"]
|
|
233
273
|
})]
|
|
234
274
|
})]
|
|
235
275
|
}),
|
|
236
|
-
|
|
276
|
+
/* @__PURE__ */ b("div", {
|
|
277
|
+
className: "mb-4 inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5",
|
|
278
|
+
role: "tablist",
|
|
279
|
+
"aria-label": "Applet source",
|
|
280
|
+
children: k.map(({ key: e, label: t }) => {
|
|
281
|
+
let n = i === e;
|
|
282
|
+
return /* @__PURE__ */ b("button", {
|
|
283
|
+
type: "button",
|
|
284
|
+
role: "tab",
|
|
285
|
+
"aria-selected": n,
|
|
286
|
+
onClick: () => w(e),
|
|
287
|
+
"data-testid": `applet-store-tab-${e}`,
|
|
288
|
+
className: n ? "rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm" : "rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary",
|
|
289
|
+
children: t
|
|
290
|
+
}, e);
|
|
291
|
+
})
|
|
292
|
+
}),
|
|
293
|
+
v ? /* @__PURE__ */ b("p", {
|
|
237
294
|
className: "text-sm text-text-secondary",
|
|
238
295
|
children: "Loading…"
|
|
239
|
-
}) : y ? /* @__PURE__ */
|
|
296
|
+
}) : y ? /* @__PURE__ */ x("p", {
|
|
240
297
|
className: "text-sm text-text-secondary",
|
|
241
|
-
children: [
|
|
242
|
-
|
|
298
|
+
children: [
|
|
299
|
+
"Couldn't load ",
|
|
300
|
+
i === "workspace" ? "workspace" : "marketplace",
|
|
301
|
+
" ",
|
|
302
|
+
"applets: ",
|
|
303
|
+
y.message
|
|
304
|
+
]
|
|
305
|
+
}) : g.length === 0 ? /* @__PURE__ */ b("p", {
|
|
243
306
|
className: "text-sm text-text-secondary",
|
|
244
|
-
"data-testid":
|
|
245
|
-
children: "No workspace applets are published yet. Developers can build one from a manifest and submit it for review."
|
|
246
|
-
}) : /* @__PURE__ */
|
|
307
|
+
"data-testid": `${i}-applets-empty`,
|
|
308
|
+
children: i === "workspace" ? "No workspace applets are published yet. Developers can build one from a manifest and submit it for review." : "No marketplace applets are certified yet. A developer can offer a published workspace applet to every workspace from the Applet Developer page."
|
|
309
|
+
}) : /* @__PURE__ */ b("div", {
|
|
247
310
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4",
|
|
248
|
-
children:
|
|
311
|
+
children: g.map((e) => /* @__PURE__ */ b(O, {
|
|
249
312
|
applet: e,
|
|
250
|
-
busy:
|
|
251
|
-
onInstall: () =>
|
|
252
|
-
onUninstall: () =>
|
|
313
|
+
busy: c === e.id,
|
|
314
|
+
onInstall: () => s(e),
|
|
315
|
+
onUninstall: () => C(e)
|
|
253
316
|
}, e.id))
|
|
254
317
|
}),
|
|
255
|
-
|
|
256
|
-
applet:
|
|
257
|
-
busy:
|
|
258
|
-
onCancel: () =>
|
|
259
|
-
onConfirm: (e) =>
|
|
318
|
+
o && /* @__PURE__ */ b(D, {
|
|
319
|
+
applet: o,
|
|
320
|
+
busy: c === o.id,
|
|
321
|
+
onCancel: () => s(null),
|
|
322
|
+
onConfirm: (e) => S(o, e)
|
|
260
323
|
})
|
|
261
324
|
]
|
|
262
325
|
});
|
|
263
326
|
}
|
|
264
327
|
//#endregion
|
|
265
|
-
export {
|
|
328
|
+
export { M as ThirdPartyAppletsSection };
|
|
266
329
|
|
|
267
330
|
//# sourceMappingURL=ThirdPartyAppletsSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThirdPartyAppletsSection.js","names":[],"sources":["../../../../src/timecampus/pages/extend/ThirdPartyAppletsSection.tsx"],"sourcesContent":["/**\n * Workspace applets in the applet store (BOFF-10827).\n *\n * Third-party applets that a reviewer published in this workspace. Installing\n * one asks the admin which of its requested data scopes to grant; its widgets\n * then appear in My Widgets, rendered in a sandboxed iframe that only sees the\n * granted scopes.\n */\nimport { useState } from \"react\";\nimport { Code, Download, ShieldCheck, Trash2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { Modal } from \"../../components/Modal\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { formatDate } from \"../../utils/helpers\";\nimport { useTimeCampusNavigate } from \"../../providers/TimeCampusProvider\";\nimport {\n useInstallThirdPartyAppletMutation,\n useListStoreAppletsQuery,\n useUninstallThirdPartyAppletMutation,\n type StoreAppletFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport { appletCategoryLabel, catalogueIcon } from \"./extendHelpers\";\nimport { scopeLabel } from \"./appletBridge\";\nimport { errorText } from \"./appletPublishingHelpers\";\n\nconst REFRESH_QUERIES = [\"ListStoreApplets\", \"GetWidgetDashboard\"];\nconst primaryButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst outlineButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50\";\n\ntype Toast = (toast: {\n title: string;\n description?: string;\n variant: \"success\" | \"error\";\n}) => void;\n\nfunction ConsentDialog({\n applet,\n busy,\n onCancel,\n onConfirm,\n}: {\n applet: StoreAppletFieldsFragment;\n busy: boolean;\n onCancel: () => void;\n onConfirm: (scopes: string[]) => void;\n}) {\n // A new install offers everything the applet asks for; changing access\n // starts from what was granted before.\n const [granted, setGranted] = useState<string[]>(() =>\n applet.installed ? [...applet.grantedScopes] : [...applet.requestedScopes],\n );\n const toggle = (scope: string) =>\n setGranted((current) =>\n current.includes(scope)\n ? current.filter((item) => item !== scope)\n : [...current, scope],\n );\n return (\n <Modal\n open\n onClose={onCancel}\n title={\n applet.installed\n ? `Data access for ${applet.name}`\n : `Install ${applet.name}`\n }\n description=\"Third-party widgets run in a sandbox and only receive the data you grant here.\"\n footer={\n <div className=\"flex justify-end gap-2\">\n <button type=\"button\" className={outlineButton} onClick={onCancel}>\n Cancel\n </button>\n <button\n type=\"button\"\n className={primaryButton}\n disabled={busy}\n onClick={() => onConfirm(granted)}\n >\n {busy ? \"Saving…\" : applet.installed ? \"Save access\" : \"Install\"}\n </button>\n </div>\n }\n >\n {applet.requestedScopes.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n This applet does not ask for any TimeCampus data.\n </p>\n ) : (\n <fieldset className=\"flex flex-col gap-2\">\n <legend className=\"mb-1 text-sm font-medium text-text-primary\">\n {applet.name} asks to read:\n </legend>\n {applet.requestedScopes.map((scope) => (\n <label\n key={scope}\n className=\"flex items-start gap-2 text-sm text-text-secondary\"\n >\n <input\n type=\"checkbox\"\n className=\"mt-0.5\"\n checked={granted.includes(scope)}\n onChange={() => toggle(scope)}\n aria-label={scopeLabel(scope)}\n />\n <span>\n {scopeLabel(scope)}{\" \"}\n <code className=\"text-xs text-text-tertiary\">{scope}</code>\n </span>\n </label>\n ))}\n </fieldset>\n )}\n </Modal>\n );\n}\n\nfunction StoreAppletCard({\n applet,\n busy,\n onInstall,\n onUninstall,\n}: {\n applet: StoreAppletFieldsFragment;\n busy: boolean;\n onInstall: () => void;\n onUninstall: () => void;\n}) {\n const Icon = catalogueIcon(applet.icon);\n return (\n <GlassCard\n treatment=\"glass\"\n className=\"flex h-full flex-col gap-3 p-5\"\n data-testid={`store-applet-card-${applet.key}`}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" aria-hidden=\"true\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n {appletCategoryLabel(applet.category)} · v{applet.version}\n </p>\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {applet.name}\n </h3>\n {applet.developerName && (\n <p className=\"text-xs text-text-tertiary\">\n By {applet.developerName}\n </p>\n )}\n </div>\n {applet.installed && (\n <StatusBadge label=\"Installed\" variant=\"success\" dot />\n )}\n </div>\n <p className=\"flex-1 text-sm text-text-secondary\">{applet.description}</p>\n <p className=\"text-xs text-text-tertiary\">\n Adds {applet.widgetKeys.length} widget\n {applet.widgetKeys.length === 1 ? \"\" : \"s\"} to My Widgets\n {applet.installed && applet.installedAt\n ? ` · installed ${formatDate(applet.installedAt)}`\n : \"\"}\n </p>\n {applet.installed && applet.ungrantedScopes.length > 0 && (\n <p className=\"text-xs text-status-warning-text\">\n A newer version asks for more data access.\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {applet.installed ? (\n <>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Data access for ${applet.name}`}\n >\n <ShieldCheck className=\"h-4 w-4\" aria-hidden=\"true\" />\n Data access\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onUninstall}\n disabled={busy}\n aria-label={`Remove ${applet.name}`}\n >\n <Trash2 className=\"h-4 w-4\" aria-hidden=\"true\" />\n Remove\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Install ${applet.name}`}\n >\n <Download className=\"h-4 w-4\" aria-hidden=\"true\" />\n Install\n </button>\n )}\n </div>\n </GlassCard>\n );\n}\n\nexport function ThirdPartyAppletsSection({\n workspaceId,\n addToast,\n}: {\n workspaceId: string;\n addToast: Toast;\n}) {\n const navigate = useTimeCampusNavigate();\n const [consentFor, setConsentFor] =\n useState<StoreAppletFieldsFragment | null>(null);\n const [busyId, setBusyId] = useState<string | null>(null);\n const { data, loading, error } = useListStoreAppletsQuery({\n skip: !workspaceId,\n });\n const [install] = useInstallThirdPartyAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n const [uninstall] = useUninstallThirdPartyAppletMutation({\n refetchQueries: REFRESH_QUERIES,\n });\n const applets: StoreAppletFieldsFragment[] =\n data?.timeCampusStoreApplets ?? [];\n\n const confirmInstall = async (\n applet: StoreAppletFieldsFragment,\n scopes: string[],\n ) => {\n setBusyId(applet.id);\n try {\n await install({ variables: { id: applet.id, grantedScopes: scopes } });\n setConsentFor(null);\n addToast({\n title: applet.installed\n ? `Data access for ${applet.name} saved`\n : `${applet.name} installed`,\n description: \"Its widgets are available in My Widgets.\",\n variant: \"success\",\n });\n } catch (err) {\n addToast({ title: errorText(err), variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const remove = async (applet: StoreAppletFieldsFragment) => {\n setBusyId(applet.id);\n try {\n await uninstall({ variables: { id: applet.id } });\n addToast({ title: `${applet.name} removed`, variant: \"success\" });\n } catch (err) {\n addToast({ title: errorText(err), variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n return (\n <section className=\"mt-8\" aria-labelledby=\"workspace-applets-heading\">\n <div className=\"mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h2\n id=\"workspace-applets-heading\"\n className=\"text-base font-semibold text-text-primary\"\n >\n Workspace applets\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Applets built by developers in this workspace and certified by a\n reviewer. They run sandboxed and only see the data you grant.\n </p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n className={outlineButton}\n onClick={() => navigate(\"/applets/developer\")}\n >\n <Code className=\"h-4 w-4\" aria-hidden=\"true\" />\n Build an applet\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={() => navigate(\"/applets/review\")}\n >\n <ShieldCheck className=\"h-4 w-4\" aria-hidden=\"true\" />\n Review queue\n </button>\n </div>\n </div>\n {loading && !data ? (\n <p className=\"text-sm text-text-secondary\">Loading…</p>\n ) : error ? (\n <p className=\"text-sm text-text-secondary\">\n Couldn't load workspace applets: {error.message}\n </p>\n ) : applets.length === 0 ? (\n <p\n className=\"text-sm text-text-secondary\"\n data-testid=\"workspace-applets-empty\"\n >\n No workspace applets are published yet. Developers can build one from\n a manifest and submit it for review.\n </p>\n ) : (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4\">\n {applets.map((applet) => (\n <StoreAppletCard\n key={applet.id}\n applet={applet}\n busy={busyId === applet.id}\n onInstall={() => setConsentFor(applet)}\n onUninstall={() => remove(applet)}\n />\n ))}\n </div>\n )}\n {consentFor && (\n <ConsentDialog\n applet={consentFor}\n busy={busyId === consentFor.id}\n onCancel={() => setConsentFor(null)}\n onConfirm={(scopes) => confirmInstall(consentFor, scopes)}\n />\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,IAAM,IAAkB,CAAC,oBAAoB,oBAAoB,GAC3D,IACJ,8LACI,IACJ;AAQF,SAAS,EAAc,EACrB,WACA,SACA,aACA,gBAMC;CAGD,IAAM,CAAC,GAAS,KAAc,QAC5B,EAAO,YAAY,CAAC,GAAG,EAAO,aAAa,IAAI,CAAC,GAAG,EAAO,eAAe,CAC3E,GACM,KAAU,MACd,GAAY,MACV,EAAQ,SAAS,CAAK,IAClB,EAAQ,QAAQ,MAAS,MAAS,CAAK,IACvC,CAAC,GAAG,GAAS,CAAK,CACxB;CACF,OACE,kBAAC,GAAD;EACE,MAAA;EACA,SAAS;EACT,OACE,EAAO,YACH,mBAAmB,EAAO,SAC1B,WAAW,EAAO;EAExB,aAAY;EACZ,QACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,UAAD;IAAQ,MAAK;IAAS,WAAW;IAAe,SAAS;IAAU,UAAA;GAE3D,CAAA,GACR,kBAAC,UAAD;IACE,MAAK;IACL,WAAW;IACX,UAAU;IACV,eAAe,EAAU,CAAO;IAE/B,UAAA,IAAO,YAAY,EAAO,YAAY,gBAAgB;GACjD,CAAA,CACL;;EAGN,UAAA,EAAO,gBAAgB,WAAW,IACjC,kBAAC,KAAD;GAAG,WAAU;GAA8B,UAAA;EAExC,CAAA,IAEH,kBAAC,YAAD;GAAU,WAAU;GAApB,UAAA,CACE,kBAAC,UAAD;IAAQ,WAAU;IAAlB,UAAA,CACG,EAAO,MAAK,gBACP;GACP,CAAA,GAAA,EAAO,gBAAgB,KAAK,MAC3B,kBAAC,SAAD;IAEE,WAAU;IAFZ,UAAA,CAIE,kBAAC,SAA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KAAW,CAAC,IACX,kBAAC,KAAD;IAAG,WAAU;IAA8B,UAAA;GAAW,CAAA,IACpD,IACF,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA,CAA2C,qCACP,EAAM,OACvC;GACD,CAAA,IAAA,EAAQ,WAAW,IACrB,kBAAC,KAAD;IACE,WAAU;IACV,eAAY;IACb,UAAA;GAGE,CAAA,IAEH,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAA,EAAQ,KAAK,MACZ,kBAAC,GAAD;KAEU;KACR,MAAM,MAAW,EAAO;KACxB,iBAAiB,EAAc,CAAM;KACrC,mBAAmB,EAAO,CAAM;IACjC,GALM,EAAO,EAKb,CACF;GACE,CAAA;GAEN,KACC,kBAAC,GAAD;IACE,QAAQ;IACR,MAAM,MAAW,EAAW;IAC5B,gBAAgB,EAAc,IAAI;IAClC,YAAY,MAAW,EAAe,GAAY,CAAM;GACzD,CAAA;EAEI;;AAEb"}
|
|
1
|
+
{"version":3,"file":"ThirdPartyAppletsSection.js","names":[],"sources":["../../../../src/timecampus/pages/extend/ThirdPartyAppletsSection.tsx"],"sourcesContent":["/**\n * Third-party applets in the applet store.\n *\n * Two tabs share one card, consent dialog and sandbox runtime:\n * - Workspace applets (BOFF-10827): applets a reviewer published in this\n * workspace.\n * - Marketplace (BOFF-10901): applets developers in any workspace offered\n * publicly and the platform certified.\n * Installing one asks the admin which of its requested data scopes to grant;\n * its widgets then appear in My Widgets, rendered in a sandboxed iframe that\n * only sees the granted scopes.\n */\nimport { useState } from \"react\";\nimport { Code, Download, ShieldCheck, Trash2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { Modal } from \"../../components/Modal\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { formatDate } from \"../../utils/helpers\";\nimport { useTimeCampusNavigate } from \"../../providers/TimeCampusProvider\";\nimport {\n useInstallMarketplaceAppletMutation,\n useInstallThirdPartyAppletMutation,\n useListMarketplaceAppletsQuery,\n useListStoreAppletsQuery,\n useUninstallMarketplaceAppletMutation,\n useUninstallThirdPartyAppletMutation,\n type StoreAppletFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport { appletCategoryLabel, catalogueIcon } from \"./extendHelpers\";\nimport { scopeLabel } from \"./appletBridge\";\nimport { errorText } from \"./appletPublishingHelpers\";\n\nconst WORKSPACE_REFRESH = [\"ListStoreApplets\", \"GetWidgetDashboard\"];\nconst MARKETPLACE_REFRESH = [\"ListMarketplaceApplets\", \"GetWidgetDashboard\"];\nconst primaryButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst outlineButton =\n \"inline-flex items-center justify-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-surface-hover disabled:opacity-50\";\n\ntype Toast = (toast: {\n title: string;\n description?: string;\n variant: \"success\" | \"error\";\n}) => void;\n\nfunction ConsentDialog({\n applet,\n busy,\n onCancel,\n onConfirm,\n}: {\n applet: StoreAppletFieldsFragment;\n busy: boolean;\n onCancel: () => void;\n onConfirm: (scopes: string[]) => void;\n}) {\n // A new install offers everything the applet asks for; changing access\n // starts from what was granted before.\n const [granted, setGranted] = useState<string[]>(() =>\n applet.installed ? [...applet.grantedScopes] : [...applet.requestedScopes],\n );\n const toggle = (scope: string) =>\n setGranted((current) =>\n current.includes(scope)\n ? current.filter((item) => item !== scope)\n : [...current, scope],\n );\n return (\n <Modal\n open\n onClose={onCancel}\n title={\n applet.installed\n ? `Data access for ${applet.name}`\n : `Install ${applet.name}`\n }\n description=\"Third-party widgets run in a sandbox and only receive the data you grant here.\"\n footer={\n <div className=\"flex justify-end gap-2\">\n <button type=\"button\" className={outlineButton} onClick={onCancel}>\n Cancel\n </button>\n <button\n type=\"button\"\n className={primaryButton}\n disabled={busy}\n onClick={() => onConfirm(granted)}\n >\n {busy ? \"Saving…\" : applet.installed ? \"Save access\" : \"Install\"}\n </button>\n </div>\n }\n >\n {applet.requestedScopes.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n This applet does not ask for any TimeCampus data.\n </p>\n ) : (\n <fieldset className=\"flex flex-col gap-2\">\n <legend className=\"mb-1 text-sm font-medium text-text-primary\">\n {applet.name} asks to read:\n </legend>\n {applet.requestedScopes.map((scope) => (\n <label\n key={scope}\n className=\"flex items-start gap-2 text-sm text-text-secondary\"\n >\n <input\n type=\"checkbox\"\n className=\"mt-0.5\"\n checked={granted.includes(scope)}\n onChange={() => toggle(scope)}\n aria-label={scopeLabel(scope)}\n />\n <span>\n {scopeLabel(scope)}{\" \"}\n <code className=\"text-xs text-text-tertiary\">{scope}</code>\n </span>\n </label>\n ))}\n </fieldset>\n )}\n </Modal>\n );\n}\n\nfunction StoreAppletCard({\n applet,\n busy,\n onInstall,\n onUninstall,\n}: {\n applet: StoreAppletFieldsFragment;\n busy: boolean;\n onInstall: () => void;\n onUninstall: () => void;\n}) {\n const Icon = catalogueIcon(applet.icon);\n return (\n <GlassCard\n treatment=\"glass\"\n className=\"flex h-full flex-col gap-3 p-5\"\n data-testid={\n applet.source === \"MARKETPLACE\"\n ? `marketplace-applet-card-${applet.key}`\n : `store-applet-card-${applet.key}`\n }\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" aria-hidden=\"true\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-tertiary\">\n {appletCategoryLabel(applet.category)} · v{applet.version}\n </p>\n <h3 className=\"truncate text-base font-semibold text-text-primary\">\n {applet.name}\n </h3>\n {applet.developerName && (\n <p className=\"text-xs text-text-tertiary\">\n By {applet.developerName}\n {applet.source === \"MARKETPLACE\" ? \" · platform certified\" : \"\"}\n </p>\n )}\n </div>\n {applet.installed && (\n <StatusBadge label=\"Installed\" variant=\"success\" dot />\n )}\n </div>\n <p className=\"flex-1 text-sm text-text-secondary\">{applet.description}</p>\n <p className=\"text-xs text-text-tertiary\">\n Adds {applet.widgetKeys.length} widget\n {applet.widgetKeys.length === 1 ? \"\" : \"s\"} to My Widgets\n {applet.installed && applet.installedAt\n ? ` · installed ${formatDate(applet.installedAt)}`\n : \"\"}\n </p>\n {applet.installed && applet.ungrantedScopes.length > 0 && (\n <p className=\"text-xs text-status-warning-text\">\n A newer version asks for more data access.\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {applet.installed ? (\n <>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Data access for ${applet.name}`}\n >\n <ShieldCheck className=\"h-4 w-4\" aria-hidden=\"true\" />\n Data access\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={onUninstall}\n disabled={busy}\n aria-label={`Remove ${applet.name}`}\n >\n <Trash2 className=\"h-4 w-4\" aria-hidden=\"true\" />\n Remove\n </button>\n </>\n ) : (\n <button\n type=\"button\"\n className={primaryButton}\n onClick={onInstall}\n disabled={busy}\n aria-label={`Install ${applet.name}`}\n >\n <Download className=\"h-4 w-4\" aria-hidden=\"true\" />\n Install\n </button>\n )}\n </div>\n </GlassCard>\n );\n}\n\ntype StoreTab = \"workspace\" | \"marketplace\";\n\nconst TABS: Array<{ key: StoreTab; label: string }> = [\n { key: \"workspace\", label: \"Workspace applets\" },\n { key: \"marketplace\", label: \"Marketplace\" },\n];\n\n/** What each tab needs from the API; both tabs render the same cards. */\ninterface StoreSource {\n applets: StoreAppletFieldsFragment[];\n loading: boolean;\n error: Error | undefined;\n install: (id: string, grantedScopes: string[]) => Promise<unknown>;\n uninstall: (id: string) => Promise<unknown>;\n}\n\nfunction useWorkspaceSource(skip: boolean): StoreSource {\n const { data, loading, error } = useListStoreAppletsQuery({ skip });\n const [install] = useInstallThirdPartyAppletMutation({\n refetchQueries: WORKSPACE_REFRESH,\n });\n const [uninstall] = useUninstallThirdPartyAppletMutation({\n refetchQueries: WORKSPACE_REFRESH,\n });\n return {\n applets: data?.timeCampusStoreApplets ?? [],\n loading: loading && !data,\n error,\n install: (id, grantedScopes) =>\n install({ variables: { id, grantedScopes } }),\n uninstall: (id) => uninstall({ variables: { id } }),\n };\n}\n\nfunction useMarketplaceSource(skip: boolean): StoreSource {\n const { data, loading, error } = useListMarketplaceAppletsQuery({ skip });\n const [install] = useInstallMarketplaceAppletMutation({\n refetchQueries: MARKETPLACE_REFRESH,\n });\n const [uninstall] = useUninstallMarketplaceAppletMutation({\n refetchQueries: MARKETPLACE_REFRESH,\n });\n return {\n applets: data?.timeCampusMarketplaceApplets ?? [],\n loading: loading && !data,\n error,\n install: (id, grantedScopes) =>\n install({ variables: { id, grantedScopes } }),\n uninstall: (id) => uninstall({ variables: { id } }),\n };\n}\n\nexport function ThirdPartyAppletsSection({\n workspaceId,\n addToast,\n}: {\n workspaceId: string;\n addToast: Toast;\n}) {\n const navigate = useTimeCampusNavigate();\n const [tab, setTab] = useState<StoreTab>(\"workspace\");\n const [consentFor, setConsentFor] =\n useState<StoreAppletFieldsFragment | null>(null);\n const [busyId, setBusyId] = useState<string | null>(null);\n const workspace = useWorkspaceSource(!workspaceId || tab !== \"workspace\");\n const marketplace = useMarketplaceSource(\n !workspaceId || tab !== \"marketplace\",\n );\n const source = tab === \"workspace\" ? workspace : marketplace;\n const { applets, loading, error } = source;\n\n const confirmInstall = async (\n applet: StoreAppletFieldsFragment,\n scopes: string[],\n ) => {\n setBusyId(applet.id);\n try {\n await source.install(applet.id, scopes);\n setConsentFor(null);\n addToast({\n title: applet.installed\n ? `Data access for ${applet.name} saved`\n : `${applet.name} installed`,\n description: \"Its widgets are available in My Widgets.\",\n variant: \"success\",\n });\n } catch (err) {\n addToast({ title: errorText(err), variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const remove = async (applet: StoreAppletFieldsFragment) => {\n setBusyId(applet.id);\n try {\n await source.uninstall(applet.id);\n addToast({ title: `${applet.name} removed`, variant: \"success\" });\n } catch (err) {\n addToast({ title: errorText(err), variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const switchTab = (next: StoreTab) => {\n setConsentFor(null);\n setTab(next);\n };\n\n return (\n <section className=\"mt-8\" aria-labelledby=\"workspace-applets-heading\">\n <div className=\"mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h2\n id=\"workspace-applets-heading\"\n className=\"text-base font-semibold text-text-primary\"\n >\n Third-party applets\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {tab === \"workspace\"\n ? \"Applets built by developers in this workspace and certified by a reviewer.\"\n : \"Applets from developers in any workspace, certified by the TimeCampus platform team.\"}{\" \"}\n They run sandboxed and only see the data you grant.\n </p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n className={outlineButton}\n onClick={() => navigate(\"/applets/developer\")}\n >\n <Code className=\"h-4 w-4\" aria-hidden=\"true\" />\n Build an applet\n </button>\n <button\n type=\"button\"\n className={outlineButton}\n onClick={() => navigate(\"/applets/review\")}\n >\n <ShieldCheck className=\"h-4 w-4\" aria-hidden=\"true\" />\n Review queue\n </button>\n </div>\n </div>\n <div\n className=\"mb-4 inline-flex w-fit items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5\"\n role=\"tablist\"\n aria-label=\"Applet source\"\n >\n {TABS.map(({ key, label }) => {\n const active = tab === key;\n return (\n <button\n key={key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => switchTab(key)}\n data-testid={`applet-store-tab-${key}`}\n className={\n active\n ? \"rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm\"\n : \"rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary\"\n }\n >\n {label}\n </button>\n );\n })}\n </div>\n {loading ? (\n <p className=\"text-sm text-text-secondary\">Loading…</p>\n ) : error ? (\n <p className=\"text-sm text-text-secondary\">\n Couldn't load {tab === \"workspace\" ? \"workspace\" : \"marketplace\"}{\" \"}\n applets: {error.message}\n </p>\n ) : applets.length === 0 ? (\n <p\n className=\"text-sm text-text-secondary\"\n data-testid={`${tab}-applets-empty`}\n >\n {tab === \"workspace\"\n ? \"No workspace applets are published yet. Developers can build one from a manifest and submit it for review.\"\n : \"No marketplace applets are certified yet. A developer can offer a published workspace applet to every workspace from the Applet Developer page.\"}\n </p>\n ) : (\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4\">\n {applets.map((applet) => (\n <StoreAppletCard\n key={applet.id}\n applet={applet}\n busy={busyId === applet.id}\n onInstall={() => setConsentFor(applet)}\n onUninstall={() => remove(applet)}\n />\n ))}\n </div>\n )}\n {consentFor && (\n <ConsentDialog\n applet={consentFor}\n busy={busyId === consentFor.id}\n onCancel={() => setConsentFor(null)}\n onConfirm={(scopes) => confirmInstall(consentFor, scopes)}\n />\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,IAAM,IAAoB,CAAC,oBAAoB,oBAAoB,GAC7D,IAAsB,CAAC,0BAA0B,oBAAoB,GACrE,IACJ,8LACI,IACJ;AAQF,SAAS,EAAc,EACrB,WACA,SACA,aACA,gBAMC;CAGD,IAAM,CAAC,GAAS,KAAc,QAC5B,EAAO,YAAY,CAAC,GAAG,EAAO,aAAa,IAAI,CAAC,GAAG,EAAO,eAAe,CAC3E,GACM,KAAU,MACd,GAAY,MACV,EAAQ,SAAS,CAAK,IAClB,EAAQ,QAAQ,MAAS,MAAS,CAAK,IACvC,CAAC,GAAG,GAAS,CAAK,CACxB;CACF,OACE,kBAAC,GAAD;EACE,MAAA;EACA,SAAS;EACT,OACE,EAAO,YACH,mBAAmB,EAAO,SAC1B,WAAW,EAAO;EAExB,aAAY;EACZ,QACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAAC,UAAD;IAAQ,MAAK;IA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declare function manifestWidgets(manifest: unknown): Array<{
|
|
|
33
33
|
export declare function manifestEntryPoint(manifest: unknown): string | null;
|
|
34
34
|
/** The absolute URL a widget loads from, or the raw path when the manifest data cannot be resolved. */
|
|
35
35
|
export declare function widgetUrl(path: string, entryPoint: string | null): string;
|
|
36
|
+
/** The bits of an applet the marketplace panel decides on (BOFF-10901). */
|
|
37
|
+
export interface MarketplaceOfferInput {
|
|
38
|
+
status: string;
|
|
39
|
+
liveVersion?: {
|
|
40
|
+
version: string;
|
|
41
|
+
} | null;
|
|
42
|
+
marketplace?: {
|
|
43
|
+
latestSubmission: {
|
|
44
|
+
version: string;
|
|
45
|
+
status: string;
|
|
46
|
+
};
|
|
47
|
+
liveSubmission?: {
|
|
48
|
+
version: string;
|
|
49
|
+
} | null;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
52
|
+
export type MarketplaceOffer = {
|
|
53
|
+
canOffer: true;
|
|
54
|
+
version: string;
|
|
55
|
+
} | {
|
|
56
|
+
canOffer: false;
|
|
57
|
+
reason: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Whether the developer can offer the applet's live workspace version to the
|
|
61
|
+
* public marketplace now, and why not otherwise. Mirrors the service rules:
|
|
62
|
+
* only a workspace-published version, one submission in certification at a
|
|
63
|
+
* time, and never a version that is already certified.
|
|
64
|
+
*/
|
|
65
|
+
export declare function marketplaceOffer(applet: MarketplaceOfferInput): MarketplaceOffer;
|
|
36
66
|
//# sourceMappingURL=appletPublishingHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appletPublishingHelpers.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/extend/appletPublishingHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,YAAY,GACtB,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"appletPublishingHelpers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E;AAED,uGAAuG;AACvG,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAOzE;AAED,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE;QACZ,gBAAgB,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QACtD,cAAc,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;KAC7C,GAAG,IAAI,CAAC;CACV;AAED,MAAM,MAAM,gBAAgB,GAC1B;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,qBAAqB,GAC5B,gBAAgB,CAsBlB"}
|
|
@@ -23,6 +23,14 @@ var e = {
|
|
|
23
23
|
SUPERSEDED: {
|
|
24
24
|
label: "Superseded",
|
|
25
25
|
variant: "muted"
|
|
26
|
+
},
|
|
27
|
+
CERTIFIED: {
|
|
28
|
+
label: "Certified",
|
|
29
|
+
variant: "success"
|
|
30
|
+
},
|
|
31
|
+
WITHDRAWN: {
|
|
32
|
+
label: "Withdrawn",
|
|
33
|
+
variant: "muted"
|
|
26
34
|
}
|
|
27
35
|
};
|
|
28
36
|
function t(t) {
|
|
@@ -114,7 +122,25 @@ function u(e, t) {
|
|
|
114
122
|
return e;
|
|
115
123
|
}
|
|
116
124
|
}
|
|
125
|
+
function d(e) {
|
|
126
|
+
let t = e.liveVersion;
|
|
127
|
+
if (e.status !== "PUBLISHED" || !t) return {
|
|
128
|
+
canOffer: !1,
|
|
129
|
+
reason: "Publish a version in this workspace first."
|
|
130
|
+
};
|
|
131
|
+
let n = e.marketplace;
|
|
132
|
+
return n?.latestSubmission.status === "IN_REVIEW" ? {
|
|
133
|
+
canOffer: !1,
|
|
134
|
+
reason: `v${n.latestSubmission.version} is waiting for platform certification.`
|
|
135
|
+
} : n?.liveSubmission?.version === t.version ? {
|
|
136
|
+
canOffer: !1,
|
|
137
|
+
reason: `v${t.version} is already certified. Publish a newer version to offer it.`
|
|
138
|
+
} : {
|
|
139
|
+
canOffer: !0,
|
|
140
|
+
version: t.version
|
|
141
|
+
};
|
|
142
|
+
}
|
|
117
143
|
//#endregion
|
|
118
|
-
export { t as appletStatus, s as errorText, l as manifestEntryPoint, a as manifestForNextVersion, r as manifestText, c as manifestWidgets, i as nextPatchVersion, n as parseManifestText, o as starterManifest, u as widgetUrl };
|
|
144
|
+
export { t as appletStatus, s as errorText, l as manifestEntryPoint, a as manifestForNextVersion, r as manifestText, c as manifestWidgets, d as marketplaceOffer, i as nextPatchVersion, n as parseManifestText, o as starterManifest, u as widgetUrl };
|
|
119
145
|
|
|
120
146
|
//# sourceMappingURL=appletPublishingHelpers.js.map
|