@burdenoff/microfe-store 2026.614.1 → 2026.616.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.
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useStore as e } from "../providers/StoreProvider.js";
|
|
2
2
|
import { useCallback as t, useEffect as n, useReducer as r, useState as i } from "react";
|
|
3
|
-
import { AlertCircle as a, Building2 as o, CheckCircle as s, Info as c, Loader2 as l,
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { graphqlFetch as
|
|
3
|
+
import { AlertCircle as a, Building2 as o, CheckCircle as s, Info as c, Loader2 as l, X as u } from "lucide-react";
|
|
4
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
import { graphqlFetch as m } from "@burdenoff/fe-libs/shared/graphql";
|
|
6
6
|
//#region src/components/InstallAppModal.tsx
|
|
7
|
-
var
|
|
7
|
+
var h = "query MyWorkspaces { myWorkspaces { items { id name slug type status organizationId } total } }", g = "mutation InstallWorkspaceApps($workspaceIds: [ID!]!, $input: InstallWorkspaceAppInput!) { installWorkspaceApps(workspaceIds: $workspaceIds, input: $input) { successCount failedCount results { success workspaceId error } } }", _ = "mutation RecordAppInstallation($input: RecordAppInstallationInput!) { recordAppInstallation(input: $input) { id status workspaceId version } }", v = "mutation InstallPurchasedApp($orderId: ID, $productId: String!, $workspaceId: String!) { installPurchasedApp(orderId: $orderId, productId: $productId, workspaceId: $workspaceId) { success alreadyInstalled installation { id productId workspaceId status version } error message } }", y = "mutation CreateProductEntitlement($input: CreateProductEntitlementInput!) { createProductEntitlement(input: $input) { id status productId workspaceId } }", b = new Set([
|
|
8
8
|
"VIBEMODULE",
|
|
9
9
|
"NODE",
|
|
10
10
|
"CONSOLE",
|
|
11
11
|
"DASHBOARD",
|
|
12
12
|
"PARSER",
|
|
13
13
|
"DATASINK"
|
|
14
|
-
]),
|
|
14
|
+
]), x = {
|
|
15
15
|
ALREADY_INSTALLED: "This app is already installed in the selected workspace.",
|
|
16
16
|
QUOTA_EXCEEDED: "Installation limit reached. Please upgrade your plan or contact support.",
|
|
17
17
|
PERMISSION_DENIED: "You do not have permission to install apps in this workspace.",
|
|
@@ -20,19 +20,19 @@ var g = "query MyWorkspaces { myWorkspaces { items { id name slug type status or
|
|
|
20
20
|
ENTITLEMENT_EXPIRED: "Your license for this app has expired.",
|
|
21
21
|
UNSUPPORTED_TYPE: "This product type cannot be installed in the selected workspace."
|
|
22
22
|
};
|
|
23
|
-
function
|
|
24
|
-
for (let [t, n] of Object.entries(
|
|
23
|
+
function S(e) {
|
|
24
|
+
for (let [t, n] of Object.entries(x)) if (e.toUpperCase().includes(t)) return n;
|
|
25
25
|
return "Installation failed. Please try again or contact support.";
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var C = {
|
|
28
28
|
selectedWorkspace: null,
|
|
29
29
|
installing: !1,
|
|
30
30
|
installError: null,
|
|
31
31
|
installInfo: null
|
|
32
32
|
};
|
|
33
|
-
function
|
|
33
|
+
function w(e, t) {
|
|
34
34
|
switch (t.type) {
|
|
35
|
-
case "reset": return
|
|
35
|
+
case "reset": return C;
|
|
36
36
|
case "selectWorkspace": return {
|
|
37
37
|
...e,
|
|
38
38
|
selectedWorkspace: t.workspaceId
|
|
@@ -58,14 +58,14 @@ function T(e, t) {
|
|
|
58
58
|
default: return e;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function T(r) {
|
|
62
62
|
let { authToken: a } = e(), [o, s] = i([]), [c, l] = i(!1), [u, d] = i(null), f = t(async () => {
|
|
63
63
|
if (!r) {
|
|
64
64
|
l(!0), d(null);
|
|
65
65
|
try {
|
|
66
|
-
let e = await
|
|
66
|
+
let e = await m({
|
|
67
67
|
gateway: "global",
|
|
68
|
-
query:
|
|
68
|
+
query: h,
|
|
69
69
|
authToken: a || void 0
|
|
70
70
|
});
|
|
71
71
|
if (e.errors?.length) throw Error(e.errors[0]?.message ?? "GraphQL error");
|
|
@@ -86,19 +86,19 @@ function E(r) {
|
|
|
86
86
|
refetch: f
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
var
|
|
90
|
-
let { authToken:
|
|
91
|
-
if (!
|
|
92
|
-
let e =
|
|
89
|
+
var E = ({ isOpen: t, onClose: n, app: i, orderId: h, purchaseState: x = "free", onInstallSuccess: E, onInstallError: D }) => {
|
|
90
|
+
let { authToken: O, user: k } = e(), [A, j] = r(w, C), { selectedWorkspace: M, installing: N, installError: P, installInfo: F } = A, { workspaces: I, loading: L, error: R } = T(!t), z = I.filter((e) => e.status === "ACTIVE"), B = async () => {
|
|
91
|
+
if (!M) return;
|
|
92
|
+
let e = z.find((e) => e.id === M);
|
|
93
93
|
if (!e) return;
|
|
94
|
-
let t =
|
|
95
|
-
|
|
94
|
+
let t = k?.id;
|
|
95
|
+
j({ type: "startInstall" });
|
|
96
96
|
try {
|
|
97
|
-
if (!
|
|
97
|
+
if (!h && x !== "purchased") {
|
|
98
98
|
if (!t) throw Error("Unable to identify the current user for license creation");
|
|
99
|
-
await
|
|
99
|
+
await m({
|
|
100
100
|
gateway: "global",
|
|
101
|
-
query:
|
|
101
|
+
query: y,
|
|
102
102
|
variables: { input: {
|
|
103
103
|
productId: i.id,
|
|
104
104
|
purchasedBy: t,
|
|
@@ -108,50 +108,50 @@ var D = ({ isOpen: t, onClose: n, app: i, orderId: g, purchaseState: S = "free",
|
|
|
108
108
|
productType: i.type
|
|
109
109
|
}
|
|
110
110
|
} },
|
|
111
|
-
authToken:
|
|
111
|
+
authToken: O || void 0
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
let r = await
|
|
114
|
+
let r = await m({
|
|
115
115
|
gateway: "global",
|
|
116
|
-
query:
|
|
116
|
+
query: v,
|
|
117
117
|
variables: {
|
|
118
|
-
orderId:
|
|
118
|
+
orderId: h ?? null,
|
|
119
119
|
productId: i.id,
|
|
120
120
|
workspaceId: e.id
|
|
121
121
|
},
|
|
122
|
-
authToken:
|
|
122
|
+
authToken: O || void 0
|
|
123
123
|
});
|
|
124
124
|
if (r.errors?.length) throw Error(r.errors[0]?.message ?? "Installation failed");
|
|
125
125
|
let a = r.data?.installPurchasedApp;
|
|
126
|
-
if (a?.success) a.alreadyInstalled ?
|
|
126
|
+
if (a?.success) a.alreadyInstalled ? j({
|
|
127
127
|
type: "setInfo",
|
|
128
128
|
info: a.message || "Already installed on this workspace"
|
|
129
|
-
}) : (
|
|
129
|
+
}) : (E?.(e.id, e.name), n());
|
|
130
130
|
else {
|
|
131
131
|
let e = a?.error || "Installation failed";
|
|
132
|
-
|
|
132
|
+
j({
|
|
133
133
|
type: "setError",
|
|
134
|
-
error:
|
|
135
|
-
}),
|
|
134
|
+
error: S(e)
|
|
135
|
+
}), D?.(Error(e));
|
|
136
136
|
}
|
|
137
137
|
} catch (e) {
|
|
138
138
|
let t = e instanceof Error ? e.message : "Installation failed";
|
|
139
|
-
|
|
139
|
+
j({
|
|
140
140
|
type: "setError",
|
|
141
|
-
error:
|
|
142
|
-
}),
|
|
141
|
+
error: S(t)
|
|
142
|
+
}), D?.(Error(t));
|
|
143
143
|
} finally {
|
|
144
|
-
|
|
144
|
+
j({ type: "finishInstall" });
|
|
145
145
|
}
|
|
146
|
-
},
|
|
147
|
-
if (!
|
|
148
|
-
let e =
|
|
146
|
+
}, V = async () => {
|
|
147
|
+
if (!M) return;
|
|
148
|
+
let e = z.find((e) => e.id === M);
|
|
149
149
|
if (e) {
|
|
150
|
-
|
|
150
|
+
j({ type: "startInstall" });
|
|
151
151
|
try {
|
|
152
|
-
let t = await
|
|
152
|
+
let t = await m({
|
|
153
153
|
gateway: "workspace",
|
|
154
|
-
query:
|
|
154
|
+
query: g,
|
|
155
155
|
variables: {
|
|
156
156
|
workspaceIds: [e.id],
|
|
157
157
|
input: {
|
|
@@ -165,15 +165,15 @@ var D = ({ isOpen: t, onClose: n, app: i, orderId: g, purchaseState: S = "free",
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
|
-
authToken:
|
|
168
|
+
authToken: O || void 0
|
|
169
169
|
});
|
|
170
170
|
if (t.errors?.length) throw Error(t.errors[0]?.message ?? "Installation failed");
|
|
171
171
|
let r = t.data?.installWorkspaceApps;
|
|
172
172
|
if (r?.successCount && r.successCount > 0) {
|
|
173
173
|
try {
|
|
174
|
-
await
|
|
174
|
+
await m({
|
|
175
175
|
gateway: "global",
|
|
176
|
-
query:
|
|
176
|
+
query: _,
|
|
177
177
|
variables: { input: {
|
|
178
178
|
productId: i.id,
|
|
179
179
|
workspaceId: e.id,
|
|
@@ -188,155 +188,155 @@ var D = ({ isOpen: t, onClose: n, app: i, orderId: g, purchaseState: S = "free",
|
|
|
188
188
|
type: i.type
|
|
189
189
|
}
|
|
190
190
|
} },
|
|
191
|
-
authToken:
|
|
191
|
+
authToken: O || void 0
|
|
192
192
|
});
|
|
193
193
|
} catch {}
|
|
194
|
-
|
|
194
|
+
E?.(e.id, e.name), n();
|
|
195
195
|
} else {
|
|
196
196
|
let e = r?.results?.[0]?.error || "Installation failed";
|
|
197
|
-
|
|
197
|
+
j({
|
|
198
198
|
type: "setError",
|
|
199
|
-
error:
|
|
200
|
-
}),
|
|
199
|
+
error: S(e)
|
|
200
|
+
}), D?.(Error(e));
|
|
201
201
|
}
|
|
202
202
|
} catch (e) {
|
|
203
203
|
let t = e instanceof Error ? e.message : "Installation failed";
|
|
204
|
-
|
|
204
|
+
j({
|
|
205
205
|
type: "setError",
|
|
206
|
-
error:
|
|
207
|
-
}),
|
|
206
|
+
error: S(t)
|
|
207
|
+
}), D?.(Error(t));
|
|
208
208
|
} finally {
|
|
209
|
-
|
|
209
|
+
j({ type: "finishInstall" });
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
return t ? /* @__PURE__ */
|
|
213
|
+
return t ? /* @__PURE__ */ p("div", {
|
|
214
214
|
className: "fixed inset-0 z-50 flex items-center justify-center",
|
|
215
|
-
children: [/* @__PURE__ */
|
|
215
|
+
children: [/* @__PURE__ */ f("button", {
|
|
216
216
|
type: "button",
|
|
217
217
|
"aria-label": "Close modal",
|
|
218
218
|
className: "absolute inset-0 bg-bg-overlay/50 backdrop-blur-sm",
|
|
219
219
|
onClick: n
|
|
220
|
-
}), /* @__PURE__ */
|
|
220
|
+
}), /* @__PURE__ */ p("dialog", {
|
|
221
221
|
open: !0,
|
|
222
222
|
"aria-modal": "true",
|
|
223
223
|
"aria-labelledby": "install-app-modal-title",
|
|
224
224
|
className: "relative z-10 mx-4 w-full max-w-lg rounded-2xl border border-border-default bg-bg-surface shadow-2xl",
|
|
225
225
|
children: [
|
|
226
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ p("div", {
|
|
227
227
|
className: "flex items-center justify-between border-b border-border-default px-6 py-4",
|
|
228
|
-
children: [/* @__PURE__ */
|
|
228
|
+
children: [/* @__PURE__ */ p("div", {
|
|
229
229
|
className: "flex items-center gap-3",
|
|
230
|
-
children: [i.icon ? /* @__PURE__ */
|
|
230
|
+
children: [i.icon ? /* @__PURE__ */ f("img", {
|
|
231
231
|
src: i.icon,
|
|
232
232
|
alt: i.name,
|
|
233
233
|
className: "size-10 rounded-lg object-cover"
|
|
234
|
-
}) : /* @__PURE__ */
|
|
234
|
+
}) : /* @__PURE__ */ f("div", {
|
|
235
235
|
className: "flex size-10 items-center justify-center rounded-lg bg-bg-sunken text-lg font-bold text-text-muted",
|
|
236
236
|
children: i.name.charAt(0)
|
|
237
|
-
}), /* @__PURE__ */
|
|
237
|
+
}), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h2", {
|
|
238
238
|
id: "install-app-modal-title",
|
|
239
239
|
className: "text-lg font-semibold text-text-primary",
|
|
240
240
|
children: "Install App"
|
|
241
|
-
}), /* @__PURE__ */
|
|
241
|
+
}), /* @__PURE__ */ f("p", {
|
|
242
242
|
className: "text-sm text-text-muted",
|
|
243
243
|
children: i.name
|
|
244
244
|
})] })]
|
|
245
|
-
}), /* @__PURE__ */
|
|
245
|
+
}), /* @__PURE__ */ f("button", {
|
|
246
246
|
type: "button",
|
|
247
247
|
onClick: n,
|
|
248
248
|
"aria-label": "Close install dialog",
|
|
249
249
|
className: "cursor-pointer rounded-lg p-2 text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
250
|
-
children: /* @__PURE__ */
|
|
250
|
+
children: /* @__PURE__ */ f(u, { className: "size-5" })
|
|
251
251
|
})]
|
|
252
252
|
}),
|
|
253
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ p("div", {
|
|
254
254
|
className: "px-6 py-4",
|
|
255
|
-
children: [/* @__PURE__ */
|
|
255
|
+
children: [/* @__PURE__ */ f("p", {
|
|
256
256
|
className: "mb-4 text-text-secondary",
|
|
257
257
|
children: "Select the workspace where you want to install this app:"
|
|
258
|
-
}), /* @__PURE__ */
|
|
258
|
+
}), /* @__PURE__ */ f("div", {
|
|
259
259
|
className: "max-h-72 overflow-y-auto rounded-lg border border-border-default",
|
|
260
|
-
children:
|
|
260
|
+
children: L ? /* @__PURE__ */ f("div", {
|
|
261
261
|
className: "flex items-center justify-center py-12",
|
|
262
|
-
children: /* @__PURE__ */
|
|
263
|
-
}) :
|
|
262
|
+
children: /* @__PURE__ */ f(l, { className: "size-8 animate-spin text-text-muted" })
|
|
263
|
+
}) : R ? /* @__PURE__ */ p("div", {
|
|
264
264
|
className: "flex flex-col items-center justify-center py-12 text-center",
|
|
265
265
|
children: [
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
-
/* @__PURE__ */
|
|
266
|
+
/* @__PURE__ */ f(a, { className: "mb-2 size-8 text-status-error-text" }),
|
|
267
|
+
/* @__PURE__ */ f("p", {
|
|
268
268
|
className: "text-sm text-status-error-text",
|
|
269
269
|
children: "Failed to load workspaces"
|
|
270
270
|
}),
|
|
271
|
-
/* @__PURE__ */
|
|
271
|
+
/* @__PURE__ */ f("p", {
|
|
272
272
|
className: "text-xs text-text-muted mt-1",
|
|
273
|
-
children:
|
|
273
|
+
children: R.message
|
|
274
274
|
})
|
|
275
275
|
]
|
|
276
|
-
}) :
|
|
276
|
+
}) : z.length === 0 ? /* @__PURE__ */ p("div", {
|
|
277
277
|
className: "flex flex-col items-center justify-center py-12 text-center",
|
|
278
|
-
children: [/* @__PURE__ */
|
|
278
|
+
children: [/* @__PURE__ */ f(o, { className: "mb-2 size-8 text-text-muted" }), /* @__PURE__ */ f("p", {
|
|
279
279
|
className: "text-sm text-text-muted",
|
|
280
280
|
children: "No workspaces available"
|
|
281
281
|
})]
|
|
282
|
-
}) : /* @__PURE__ */
|
|
282
|
+
}) : /* @__PURE__ */ f("div", {
|
|
283
283
|
className: "divide-y divide-border-default",
|
|
284
|
-
children:
|
|
284
|
+
children: z.map((e) => /* @__PURE__ */ p("button", {
|
|
285
285
|
type: "button",
|
|
286
|
-
onClick: () =>
|
|
286
|
+
onClick: () => j({
|
|
287
287
|
type: "selectWorkspace",
|
|
288
288
|
workspaceId: e.id
|
|
289
289
|
}),
|
|
290
|
-
className: `w-full cursor-pointer flex items-center gap-3 px-4 py-3 text-left transition-colors ${
|
|
290
|
+
className: `w-full cursor-pointer flex items-center gap-3 px-4 py-3 text-left transition-colors ${M === e.id ? "bg-action-primary-bg/10" : "transition-colors hover:bg-bg-sunken"}`,
|
|
291
291
|
children: [
|
|
292
|
-
/* @__PURE__ */
|
|
293
|
-
className:
|
|
294
|
-
children:
|
|
292
|
+
/* @__PURE__ */ f("div", {
|
|
293
|
+
className: "flex size-10 items-center justify-center rounded-lg bg-action-primary-bg/10 text-text-link",
|
|
294
|
+
children: /* @__PURE__ */ f(o, { className: "size-5" })
|
|
295
295
|
}),
|
|
296
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ p("div", {
|
|
297
297
|
className: "flex-1 min-w-0",
|
|
298
|
-
children: [/* @__PURE__ */
|
|
298
|
+
children: [/* @__PURE__ */ f("p", {
|
|
299
299
|
className: "font-medium text-text-primary truncate",
|
|
300
300
|
children: e.name
|
|
301
|
-
}), /* @__PURE__ */
|
|
302
|
-
className: "text-xs text-text-muted",
|
|
303
|
-
children: [
|
|
304
|
-
})]
|
|
301
|
+
}), e.slug ? /* @__PURE__ */ p("p", {
|
|
302
|
+
className: "text-xs text-text-muted truncate",
|
|
303
|
+
children: ["/", e.slug]
|
|
304
|
+
}) : null]
|
|
305
305
|
}),
|
|
306
|
-
|
|
306
|
+
M === e.id && /* @__PURE__ */ f(s, { className: "size-5 flex-shrink-0 text-action-primary-bg" })
|
|
307
307
|
]
|
|
308
308
|
}, e.id))
|
|
309
309
|
})
|
|
310
310
|
})]
|
|
311
311
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
312
|
+
/* @__PURE__ */ p("div", {
|
|
313
313
|
className: "border-t border-border-default px-6 py-4",
|
|
314
314
|
children: [
|
|
315
|
-
|
|
315
|
+
F && /* @__PURE__ */ p("div", {
|
|
316
316
|
className: "mb-3 flex items-center gap-2 rounded-lg bg-status-info-bg-subtle px-3 py-2 text-sm text-status-info-text",
|
|
317
|
-
children: [/* @__PURE__ */
|
|
317
|
+
children: [/* @__PURE__ */ f(c, { className: "size-4 flex-shrink-0" }), /* @__PURE__ */ f("span", { children: F })]
|
|
318
318
|
}),
|
|
319
|
-
|
|
319
|
+
P && /* @__PURE__ */ p("div", {
|
|
320
320
|
className: "mb-3 flex items-center gap-2 rounded-lg bg-status-error-bg-subtle/10 px-3 py-2 text-sm text-status-error-text",
|
|
321
|
-
children: [/* @__PURE__ */
|
|
321
|
+
children: [/* @__PURE__ */ f(a, { className: "size-4 flex-shrink-0" }), /* @__PURE__ */ f("span", { children: P })]
|
|
322
322
|
}),
|
|
323
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ p("div", {
|
|
324
324
|
className: "flex items-center justify-end gap-3",
|
|
325
|
-
children: [/* @__PURE__ */
|
|
325
|
+
children: [/* @__PURE__ */ f("button", {
|
|
326
326
|
type: "button",
|
|
327
327
|
onClick: n,
|
|
328
|
-
disabled:
|
|
328
|
+
disabled: N,
|
|
329
329
|
className: "cursor-pointer rounded-lg border border-border-default px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50",
|
|
330
330
|
children: "Cancel"
|
|
331
|
-
}), /* @__PURE__ */
|
|
331
|
+
}), /* @__PURE__ */ f("button", {
|
|
332
332
|
type: "button",
|
|
333
333
|
onClick: async () => {
|
|
334
334
|
let e = i.type?.toUpperCase() ?? "";
|
|
335
|
-
|
|
335
|
+
x === "purchased" || h || b.has(e) ? await B() : await V();
|
|
336
336
|
},
|
|
337
|
-
disabled: !
|
|
337
|
+
disabled: !M || N,
|
|
338
338
|
className: "cursor-pointer rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-opacity hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2",
|
|
339
|
-
children:
|
|
339
|
+
children: N ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(l, { className: "size-4 animate-spin" }), "Installing…"] }) : "Install App"
|
|
340
340
|
})]
|
|
341
341
|
})
|
|
342
342
|
]
|
|
@@ -346,6 +346,6 @@ var D = ({ isOpen: t, onClose: n, app: i, orderId: g, purchaseState: S = "free",
|
|
|
346
346
|
}) : null;
|
|
347
347
|
};
|
|
348
348
|
//#endregion
|
|
349
|
-
export {
|
|
349
|
+
export { E as InstallAppModal };
|
|
350
350
|
|
|
351
351
|
//# sourceMappingURL=InstallAppModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstallAppModal.js","names":[],"sources":["../../src/components/InstallAppModal.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useState, useEffect, useCallback, useReducer } from 'react';\nimport { X, Loader2, Building2, User, CheckCircle, AlertCircle, Info } from 'lucide-react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useStore } from '../providers/StoreProvider';\n\n// Local type definitions for workspace operations\ninterface Workspace {\n id: string;\n name: string;\n slug: string;\n type?: string;\n status?: string;\n organizationId?: string;\n}\n\ninterface WorkspaceList {\n items: Workspace[];\n total: number;\n}\n\ninterface InstallWorkspaceAppsResult {\n successCount: number;\n failedCount: number;\n results: Array<{\n success: boolean;\n workspaceId: string;\n app?: unknown;\n error?: string;\n }>;\n}\n\n// String queries for graphqlFetch\nconst MY_WORKSPACES_STRING = `query MyWorkspaces { myWorkspaces { items { id name slug type status organizationId } total } }`;\nconst INSTALL_WORKSPACE_APPS_STRING = `mutation InstallWorkspaceApps($workspaceIds: [ID!]!, $input: InstallWorkspaceAppInput!) { installWorkspaceApps(workspaceIds: $workspaceIds, input: $input) { successCount failedCount results { success workspaceId error } } }`;\nconst RECORD_APP_INSTALLATION_STRING = `mutation RecordAppInstallation($input: RecordAppInstallationInput!) { recordAppInstallation(input: $input) { id status workspaceId version } }`;\nconst INSTALL_PURCHASED_APP_STRING = `mutation InstallPurchasedApp($orderId: ID, $productId: String!, $workspaceId: String!) { installPurchasedApp(orderId: $orderId, productId: $productId, workspaceId: $workspaceId) { success alreadyInstalled installation { id productId workspaceId status version } error message } }`;\nconst CREATE_PRODUCT_ENTITLEMENT_STRING = `mutation CreateProductEntitlement($input: CreateProductEntitlementInput!) { createProductEntitlement(input: $input) { id status productId workspaceId } }`;\nconst STORE_DISTRIBUTED_TYPES = new Set([\n 'VIBEMODULE',\n 'NODE',\n 'CONSOLE',\n 'DASHBOARD',\n 'PARSER',\n 'DATASINK',\n]);\n\nconst INSTALL_ERROR_MESSAGES: Record<string, string> = {\n ALREADY_INSTALLED: 'This app is already installed in the selected workspace.',\n QUOTA_EXCEEDED: 'Installation limit reached. Please upgrade your plan or contact support.',\n PERMISSION_DENIED: 'You do not have permission to install apps in this workspace.',\n NOT_FOUND: 'The app or workspace could not be found.',\n WORKSPACE_INACTIVE: 'The selected workspace is inactive.',\n ENTITLEMENT_EXPIRED: 'Your license for this app has expired.',\n UNSUPPORTED_TYPE: 'This product type cannot be installed in the selected workspace.',\n};\n\nfunction mapInstallError(raw: string): string {\n for (const [code, message] of Object.entries(INSTALL_ERROR_MESSAGES)) {\n if (raw.toUpperCase().includes(code)) return message;\n }\n return 'Installation failed. Please try again or contact support.';\n}\n\ninterface InstallState {\n selectedWorkspace: string | null;\n installing: boolean;\n installError: string | null;\n installInfo: string | null;\n}\n\ntype InstallAction =\n | { type: 'reset' }\n | { type: 'selectWorkspace'; workspaceId: string }\n | { type: 'startInstall' }\n | { type: 'finishInstall' }\n | { type: 'setError'; error: string }\n | { type: 'setInfo'; info: string };\n\nconst initialInstallState: InstallState = {\n selectedWorkspace: null,\n installing: false,\n installError: null,\n installInfo: null,\n};\n\nfunction installReducer(state: InstallState, action: InstallAction): InstallState {\n switch (action.type) {\n case 'reset':\n return initialInstallState;\n case 'selectWorkspace':\n return { ...state, selectedWorkspace: action.workspaceId };\n case 'startInstall':\n return { ...state, installing: true, installError: null, installInfo: null };\n case 'finishInstall':\n return { ...state, installing: false };\n case 'setError':\n return { ...state, installError: action.error };\n case 'setInfo':\n return { ...state, installInfo: action.info };\n default:\n return state;\n }\n}\n\nexport interface AppInfo {\n id: string;\n name: string;\n slug?: string;\n icon?: string;\n type?: string;\n version?: string;\n}\n\ninterface InstallAppModalProps {\n isOpen: boolean;\n onClose: () => void;\n app: AppInfo;\n orderId?: string | null; // For purchased apps from orders page\n purchaseState?: 'free' | 'purchased';\n onInstallSuccess?: (workspaceId: string, workspaceName: string) => void;\n onInstallError?: (error: Error) => void;\n}\n\ninterface UseWorkspacesResult {\n workspaces: Workspace[];\n loading: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n// NOTE: Inline Apollo clients removed. All GraphQL calls now use graphqlFetch\n// from fe-libs which automatically resolves gateway URLs and injects auth + locale headers.\n\n/**\n * Hook to fetch user's workspaces using graphqlFetch from fe-libs\n */\nfunction useWorkspaces(skip: boolean): UseWorkspacesResult {\n const { authToken } = useStore();\n const [workspaces, setWorkspaces] = useState<Workspace[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchWorkspaces = useCallback(async () => {\n if (skip) return;\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await graphqlFetch<{ myWorkspaces: WorkspaceList }>({\n gateway: 'global',\n query: MY_WORKSPACES_STRING,\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'GraphQL error');\n }\n\n setWorkspaces(result.data?.myWorkspaces?.items || []);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to fetch workspaces'));\n } finally {\n setLoading(false);\n }\n }, [authToken, skip]);\n\n useEffect(() => {\n fetchWorkspaces();\n }, [fetchWorkspaces]);\n\n return {\n workspaces,\n loading,\n error,\n refetch: fetchWorkspaces,\n };\n}\n\n/**\n * InstallAppModal component\n *\n * Modal for selecting a workspace to install an app into\n */\nexport const InstallAppModal: FC<InstallAppModalProps> = ({\n isOpen,\n onClose,\n app,\n orderId,\n purchaseState = 'free',\n onInstallSuccess,\n onInstallError,\n}) => {\n const { authToken, user } = useStore();\n const [installState, dispatchInstall] = useReducer(installReducer, initialInstallState);\n const { selectedWorkspace, installing, installError, installInfo } = installState;\n\n const { workspaces, loading, error } = useWorkspaces(!isOpen);\n\n // Filter workspaces by status (only show active)\n const filteredWorkspaces = workspaces.filter((ws) => ws.status === 'ACTIVE');\n\n /**\n * Install purchased app via Store Service (NEW FLOW)\n * Used when installing from orders page or any already-purchased product\n */\n const handleInstallFromStore = async () => {\n if (!selectedWorkspace) return;\n\n const workspace = filteredWorkspaces.find((ws) => ws.id === selectedWorkspace);\n if (!workspace) return;\n const purchasedBy = user?.id;\n\n dispatchInstall({ type: 'startInstall' });\n\n try {\n if (!orderId && purchaseState !== 'purchased') {\n if (!purchasedBy) {\n throw new Error('Unable to identify the current user for license creation');\n }\n\n await graphqlFetch({\n gateway: 'global',\n query: CREATE_PRODUCT_ENTITLEMENT_STRING,\n variables: {\n input: {\n productId: app.id,\n purchasedBy,\n workspaceId: workspace.id,\n metadata: {\n source: 'store-ui',\n productType: app.type,\n },\n },\n },\n authToken: authToken || undefined,\n });\n }\n\n // Call Store Service to install the purchased app\n const result = await graphqlFetch<{\n installPurchasedApp: {\n success: boolean;\n alreadyInstalled?: boolean;\n installation?: {\n id: string;\n productId: string;\n workspaceId: string;\n status: string;\n version: string;\n };\n error?: string;\n message?: string;\n };\n }>({\n gateway: 'global', // Store Service\n query: INSTALL_PURCHASED_APP_STRING,\n variables: {\n orderId: orderId ?? null,\n productId: app.id,\n workspaceId: workspace.id,\n },\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'Installation failed');\n }\n\n const installResult = result.data?.installPurchasedApp;\n\n if (installResult?.success) {\n if (installResult.alreadyInstalled) {\n dispatchInstall({\n type: 'setInfo',\n info: installResult.message || 'Already installed on this workspace',\n });\n } else {\n onInstallSuccess?.(workspace.id, workspace.name);\n onClose();\n }\n } else {\n const rawMsg = installResult?.error || 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n }\n } catch (err) {\n const rawMsg = err instanceof Error ? err.message : 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n } finally {\n dispatchInstall({ type: 'finishInstall' });\n }\n };\n\n /**\n * Install app via Workspace Service (LEGACY FLOW)\n * Used for free apps or when installing without order\n */\n const handleInstallViaWorkspace = async () => {\n if (!selectedWorkspace) return;\n\n const workspace = filteredWorkspaces.find((ws) => ws.id === selectedWorkspace);\n if (!workspace) return;\n\n dispatchInstall({ type: 'startInstall' });\n\n try {\n // Step 1: Install to workspace service via graphqlFetch\n const installVars = {\n workspaceIds: [workspace.id],\n input: {\n appName: app.slug || app.name.toLowerCase().replace(/\\s+/g, '-'),\n displayName: app.name,\n version: app.version || '1.0.0',\n type: app.type || 'app',\n manifest: {\n productId: app.id,\n icon: app.icon,\n },\n },\n };\n\n const result = await graphqlFetch<{\n installWorkspaceApps: InstallWorkspaceAppsResult;\n }>({\n gateway: 'workspace',\n query: INSTALL_WORKSPACE_APPS_STRING,\n variables: installVars,\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'Installation failed');\n }\n\n const installResult = result.data?.installWorkspaceApps;\n if (installResult?.successCount && installResult.successCount > 0) {\n // Step 2: Record installation in store service (for tracking)\n try {\n await graphqlFetch({\n gateway: 'global',\n query: RECORD_APP_INSTALLATION_STRING,\n variables: {\n input: {\n productId: app.id,\n workspaceId: workspace.id,\n workspaceName: workspace.name,\n workspaceType: workspace.type,\n organizationId: workspace.organizationId,\n version: app.version || '1.0.0',\n manifest: {\n productId: app.id,\n icon: app.icon,\n slug: app.slug,\n type: app.type,\n },\n },\n },\n authToken: authToken || undefined,\n });\n } catch {\n // Non-fatal: workspace installation succeeded; store record will sync later.\n }\n\n onInstallSuccess?.(workspace.id, workspace.name);\n onClose();\n } else {\n const rawMsg = installResult?.results?.[0]?.error || 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n }\n } catch (err) {\n const rawMsg = err instanceof Error ? err.message : 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n } finally {\n dispatchInstall({ type: 'finishInstall' });\n }\n };\n\n /**\n * Main install handler - routes to appropriate install function\n */\n const handleInstall = async () => {\n const appType = app.type?.toUpperCase() ?? '';\n\n if (purchaseState === 'purchased' || orderId || STORE_DISTRIBUTED_TYPES.has(appType)) {\n // Purchased products install through the store service.\n await handleInstallFromStore();\n } else {\n // Free products install through the workspace service.\n await handleInstallViaWorkspace();\n }\n };\n\n if (!isOpen) return null;\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n {/* Backdrop */}\n <button\n type=\"button\"\n aria-label=\"Close modal\"\n className=\"absolute inset-0 bg-bg-overlay/50 backdrop-blur-sm\"\n onClick={onClose}\n />\n\n {/* Modal */}\n <dialog\n open\n aria-modal=\"true\"\n aria-labelledby=\"install-app-modal-title\"\n className=\"relative z-10 mx-4 w-full max-w-lg rounded-2xl border border-border-default bg-bg-surface shadow-2xl\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between border-b border-border-default px-6 py-4\">\n <div className=\"flex items-center gap-3\">\n {app.icon ? (\n <img src={app.icon} alt={app.name} className=\"size-10 rounded-lg object-cover\" />\n ) : (\n <div className=\"flex size-10 items-center justify-center rounded-lg bg-bg-sunken text-lg font-bold text-text-muted\">\n {app.name.charAt(0)}\n </div>\n )}\n <div>\n <h2 id=\"install-app-modal-title\" className=\"text-lg font-semibold text-text-primary\">\n Install App\n </h2>\n <p className=\"text-sm text-text-muted\">{app.name}</p>\n </div>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close install dialog\"\n className=\"cursor-pointer rounded-lg p-2 text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <X className=\"size-5\" />\n </button>\n </div>\n\n {/* Content */}\n <div className=\"px-6 py-4\">\n <p className=\"mb-4 text-text-secondary\">\n Select the workspace where you want to install this app:\n </p>\n\n {/* Workspace List */}\n <div className=\"max-h-72 overflow-y-auto rounded-lg border border-border-default\">\n {loading ? (\n <div className=\"flex items-center justify-center py-12\">\n <Loader2 className=\"size-8 animate-spin text-text-muted\" />\n </div>\n ) : error ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <AlertCircle className=\"mb-2 size-8 text-status-error-text\" />\n <p className=\"text-sm text-status-error-text\">Failed to load workspaces</p>\n <p className=\"text-xs text-text-muted mt-1\">{error.message}</p>\n </div>\n ) : filteredWorkspaces.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <Building2 className=\"mb-2 size-8 text-text-muted\" />\n <p className=\"text-sm text-text-muted\">No workspaces available</p>\n </div>\n ) : (\n <div className=\"divide-y divide-border-default\">\n {filteredWorkspaces.map((workspace) => (\n <button\n type=\"button\"\n key={workspace.id}\n onClick={() =>\n dispatchInstall({ type: 'selectWorkspace', workspaceId: workspace.id })\n }\n className={`w-full cursor-pointer flex items-center gap-3 px-4 py-3 text-left transition-colors ${\n selectedWorkspace === workspace.id\n ? 'bg-action-primary-bg/10'\n : 'transition-colors hover:bg-bg-sunken'\n }`}\n >\n {/* Workspace Icon */}\n <div\n className={`flex size-10 items-center justify-center rounded-lg ${\n workspace.type === 'user'\n ? 'bg-status-info-bg-subtle text-status-info-text'\n : 'bg-action-primary-bg/10 text-text-link'\n }`}\n >\n {workspace.type === 'user' ? (\n <User className=\"size-5\" />\n ) : (\n <Building2 className=\"size-5\" />\n )}\n </div>\n\n {/* Workspace Info */}\n <div className=\"flex-1 min-w-0\">\n <p className=\"font-medium text-text-primary truncate\">{workspace.name}</p>\n <p className=\"text-xs text-text-muted\">\n {workspace.type === 'user' ? 'Personal' : 'Team'} workspace\n </p>\n </div>\n\n {/* Selection Indicator */}\n {selectedWorkspace === workspace.id && (\n <CheckCircle className=\"size-5 flex-shrink-0 text-action-primary-bg\" />\n )}\n </button>\n ))}\n </div>\n )}\n </div>\n </div>\n\n {/* Footer */}\n <div className=\"border-t border-border-default px-6 py-4\">\n {/* Already-installed info */}\n {installInfo && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-status-info-bg-subtle px-3 py-2 text-sm text-status-info-text\">\n <Info className=\"size-4 flex-shrink-0\" />\n <span>{installInfo}</span>\n </div>\n )}\n {/* Error message */}\n {installError && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-status-error-bg-subtle/10 px-3 py-2 text-sm text-status-error-text\">\n <AlertCircle className=\"size-4 flex-shrink-0\" />\n <span>{installError}</span>\n </div>\n )}\n <div className=\"flex items-center justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n disabled={installing}\n className=\"cursor-pointer rounded-lg border border-border-default px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={handleInstall}\n disabled={!selectedWorkspace || installing}\n className=\"cursor-pointer rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-opacity hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2\"\n >\n {installing ? (\n <>\n <Loader2 className=\"size-4 animate-spin\" />\n Installing…\n </>\n ) : (\n 'Install App'\n )}\n </button>\n </div>\n </div>\n </dialog>\n </div>\n );\n};\n"],"mappings":";;;;;;AAiCA,IAAM,IAAuB,mGACvB,IAAgC,mOAChC,IAAiC,kJACjC,IAA+B,2RAC/B,IAAoC,6JACpC,IAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,EAEI,IAAiD;CACrD,mBAAmB;CACnB,gBAAgB;CAChB,mBAAmB;CACnB,WAAW;CACX,oBAAoB;CACpB,qBAAqB;CACrB,kBAAkB;CACnB;AAED,SAAS,EAAgB,GAAqB;AAC5C,MAAK,IAAM,CAAC,GAAM,MAAY,OAAO,QAAQ,EAAuB,CAClE,KAAI,EAAI,aAAa,CAAC,SAAS,EAAK,CAAE,QAAO;AAE/C,QAAO;;AAkBT,IAAM,IAAoC;CACxC,mBAAmB;CACnB,YAAY;CACZ,cAAc;CACd,aAAa;CACd;AAED,SAAS,EAAe,GAAqB,GAAqC;AAChF,SAAQ,EAAO,MAAf;EACE,KAAK,QACH,QAAO;EACT,KAAK,kBACH,QAAO;GAAE,GAAG;GAAO,mBAAmB,EAAO;GAAa;EAC5D,KAAK,eACH,QAAO;GAAE,GAAG;GAAO,YAAY;GAAM,cAAc;GAAM,aAAa;GAAM;EAC9E,KAAK,gBACH,QAAO;GAAE,GAAG;GAAO,YAAY;GAAO;EACxC,KAAK,WACH,QAAO;GAAE,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A,EACT,kBAAC,UAAD;QACE,MAAK;QACL,SA7JU,YAAY;SAChC,IAAM,IAAU,EAAI,MAAM,aAAa,IAAI;AAE3C,SAAI,MAAkB,eAAe,KAAW,EAAwB,IAAI,EAAQ,GAElF,MAAM,GAAwB,GAG9B,MAAM,GAA2B;;QAsJzB,UAAU,CAAC,KAAqB;QAChC,WAAU;kBAET,IACC,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD,EAAS,WAAU,uBAAwB,CAAA,EAAA,cAE1C,EAAA,CAAA,GAEH;QAEK,CAAA,CACL;;MACF;;IACC;KACL;MAjKY"}
|
|
1
|
+
{"version":3,"file":"InstallAppModal.js","names":[],"sources":["../../src/components/InstallAppModal.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useState, useEffect, useCallback, useReducer } from 'react';\nimport { X, Loader2, Building2, CheckCircle, AlertCircle, Info } from 'lucide-react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useStore } from '../providers/StoreProvider';\n\n// Local type definitions for workspace operations\ninterface Workspace {\n id: string;\n name: string;\n slug: string;\n type?: string;\n status?: string;\n organizationId?: string;\n}\n\ninterface WorkspaceList {\n items: Workspace[];\n total: number;\n}\n\ninterface InstallWorkspaceAppsResult {\n successCount: number;\n failedCount: number;\n results: Array<{\n success: boolean;\n workspaceId: string;\n app?: unknown;\n error?: string;\n }>;\n}\n\n// String queries for graphqlFetch\nconst MY_WORKSPACES_STRING = `query MyWorkspaces { myWorkspaces { items { id name slug type status organizationId } total } }`;\nconst INSTALL_WORKSPACE_APPS_STRING = `mutation InstallWorkspaceApps($workspaceIds: [ID!]!, $input: InstallWorkspaceAppInput!) { installWorkspaceApps(workspaceIds: $workspaceIds, input: $input) { successCount failedCount results { success workspaceId error } } }`;\nconst RECORD_APP_INSTALLATION_STRING = `mutation RecordAppInstallation($input: RecordAppInstallationInput!) { recordAppInstallation(input: $input) { id status workspaceId version } }`;\nconst INSTALL_PURCHASED_APP_STRING = `mutation InstallPurchasedApp($orderId: ID, $productId: String!, $workspaceId: String!) { installPurchasedApp(orderId: $orderId, productId: $productId, workspaceId: $workspaceId) { success alreadyInstalled installation { id productId workspaceId status version } error message } }`;\nconst CREATE_PRODUCT_ENTITLEMENT_STRING = `mutation CreateProductEntitlement($input: CreateProductEntitlementInput!) { createProductEntitlement(input: $input) { id status productId workspaceId } }`;\nconst STORE_DISTRIBUTED_TYPES = new Set([\n 'VIBEMODULE',\n 'NODE',\n 'CONSOLE',\n 'DASHBOARD',\n 'PARSER',\n 'DATASINK',\n]);\n\nconst INSTALL_ERROR_MESSAGES: Record<string, string> = {\n ALREADY_INSTALLED: 'This app is already installed in the selected workspace.',\n QUOTA_EXCEEDED: 'Installation limit reached. Please upgrade your plan or contact support.',\n PERMISSION_DENIED: 'You do not have permission to install apps in this workspace.',\n NOT_FOUND: 'The app or workspace could not be found.',\n WORKSPACE_INACTIVE: 'The selected workspace is inactive.',\n ENTITLEMENT_EXPIRED: 'Your license for this app has expired.',\n UNSUPPORTED_TYPE: 'This product type cannot be installed in the selected workspace.',\n};\n\nfunction mapInstallError(raw: string): string {\n for (const [code, message] of Object.entries(INSTALL_ERROR_MESSAGES)) {\n if (raw.toUpperCase().includes(code)) return message;\n }\n return 'Installation failed. Please try again or contact support.';\n}\n\ninterface InstallState {\n selectedWorkspace: string | null;\n installing: boolean;\n installError: string | null;\n installInfo: string | null;\n}\n\ntype InstallAction =\n | { type: 'reset' }\n | { type: 'selectWorkspace'; workspaceId: string }\n | { type: 'startInstall' }\n | { type: 'finishInstall' }\n | { type: 'setError'; error: string }\n | { type: 'setInfo'; info: string };\n\nconst initialInstallState: InstallState = {\n selectedWorkspace: null,\n installing: false,\n installError: null,\n installInfo: null,\n};\n\nfunction installReducer(state: InstallState, action: InstallAction): InstallState {\n switch (action.type) {\n case 'reset':\n return initialInstallState;\n case 'selectWorkspace':\n return { ...state, selectedWorkspace: action.workspaceId };\n case 'startInstall':\n return { ...state, installing: true, installError: null, installInfo: null };\n case 'finishInstall':\n return { ...state, installing: false };\n case 'setError':\n return { ...state, installError: action.error };\n case 'setInfo':\n return { ...state, installInfo: action.info };\n default:\n return state;\n }\n}\n\nexport interface AppInfo {\n id: string;\n name: string;\n slug?: string;\n icon?: string;\n type?: string;\n version?: string;\n}\n\ninterface InstallAppModalProps {\n isOpen: boolean;\n onClose: () => void;\n app: AppInfo;\n orderId?: string | null; // For purchased apps from orders page\n purchaseState?: 'free' | 'purchased';\n onInstallSuccess?: (workspaceId: string, workspaceName: string) => void;\n onInstallError?: (error: Error) => void;\n}\n\ninterface UseWorkspacesResult {\n workspaces: Workspace[];\n loading: boolean;\n error: Error | null;\n refetch: () => void;\n}\n\n// NOTE: Inline Apollo clients removed. All GraphQL calls now use graphqlFetch\n// from fe-libs which automatically resolves gateway URLs and injects auth + locale headers.\n\n/**\n * Hook to fetch user's workspaces using graphqlFetch from fe-libs\n */\nfunction useWorkspaces(skip: boolean): UseWorkspacesResult {\n const { authToken } = useStore();\n const [workspaces, setWorkspaces] = useState<Workspace[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchWorkspaces = useCallback(async () => {\n if (skip) return;\n\n setLoading(true);\n setError(null);\n\n try {\n const result = await graphqlFetch<{ myWorkspaces: WorkspaceList }>({\n gateway: 'global',\n query: MY_WORKSPACES_STRING,\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'GraphQL error');\n }\n\n setWorkspaces(result.data?.myWorkspaces?.items || []);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to fetch workspaces'));\n } finally {\n setLoading(false);\n }\n }, [authToken, skip]);\n\n useEffect(() => {\n fetchWorkspaces();\n }, [fetchWorkspaces]);\n\n return {\n workspaces,\n loading,\n error,\n refetch: fetchWorkspaces,\n };\n}\n\n/**\n * InstallAppModal component\n *\n * Modal for selecting a workspace to install an app into\n */\nexport const InstallAppModal: FC<InstallAppModalProps> = ({\n isOpen,\n onClose,\n app,\n orderId,\n purchaseState = 'free',\n onInstallSuccess,\n onInstallError,\n}) => {\n const { authToken, user } = useStore();\n const [installState, dispatchInstall] = useReducer(installReducer, initialInstallState);\n const { selectedWorkspace, installing, installError, installInfo } = installState;\n\n const { workspaces, loading, error } = useWorkspaces(!isOpen);\n\n // Filter workspaces by status (only show active)\n const filteredWorkspaces = workspaces.filter((ws) => ws.status === 'ACTIVE');\n\n /**\n * Install purchased app via Store Service (NEW FLOW)\n * Used when installing from orders page or any already-purchased product\n */\n const handleInstallFromStore = async () => {\n if (!selectedWorkspace) return;\n\n const workspace = filteredWorkspaces.find((ws) => ws.id === selectedWorkspace);\n if (!workspace) return;\n const purchasedBy = user?.id;\n\n dispatchInstall({ type: 'startInstall' });\n\n try {\n if (!orderId && purchaseState !== 'purchased') {\n if (!purchasedBy) {\n throw new Error('Unable to identify the current user for license creation');\n }\n\n await graphqlFetch({\n gateway: 'global',\n query: CREATE_PRODUCT_ENTITLEMENT_STRING,\n variables: {\n input: {\n productId: app.id,\n purchasedBy,\n workspaceId: workspace.id,\n metadata: {\n source: 'store-ui',\n productType: app.type,\n },\n },\n },\n authToken: authToken || undefined,\n });\n }\n\n // Call Store Service to install the purchased app\n const result = await graphqlFetch<{\n installPurchasedApp: {\n success: boolean;\n alreadyInstalled?: boolean;\n installation?: {\n id: string;\n productId: string;\n workspaceId: string;\n status: string;\n version: string;\n };\n error?: string;\n message?: string;\n };\n }>({\n gateway: 'global', // Store Service\n query: INSTALL_PURCHASED_APP_STRING,\n variables: {\n orderId: orderId ?? null,\n productId: app.id,\n workspaceId: workspace.id,\n },\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'Installation failed');\n }\n\n const installResult = result.data?.installPurchasedApp;\n\n if (installResult?.success) {\n if (installResult.alreadyInstalled) {\n dispatchInstall({\n type: 'setInfo',\n info: installResult.message || 'Already installed on this workspace',\n });\n } else {\n onInstallSuccess?.(workspace.id, workspace.name);\n onClose();\n }\n } else {\n const rawMsg = installResult?.error || 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n }\n } catch (err) {\n const rawMsg = err instanceof Error ? err.message : 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n } finally {\n dispatchInstall({ type: 'finishInstall' });\n }\n };\n\n /**\n * Install app via Workspace Service (LEGACY FLOW)\n * Used for free apps or when installing without order\n */\n const handleInstallViaWorkspace = async () => {\n if (!selectedWorkspace) return;\n\n const workspace = filteredWorkspaces.find((ws) => ws.id === selectedWorkspace);\n if (!workspace) return;\n\n dispatchInstall({ type: 'startInstall' });\n\n try {\n // Step 1: Install to workspace service via graphqlFetch\n const installVars = {\n workspaceIds: [workspace.id],\n input: {\n appName: app.slug || app.name.toLowerCase().replace(/\\s+/g, '-'),\n displayName: app.name,\n version: app.version || '1.0.0',\n type: app.type || 'app',\n manifest: {\n productId: app.id,\n icon: app.icon,\n },\n },\n };\n\n const result = await graphqlFetch<{\n installWorkspaceApps: InstallWorkspaceAppsResult;\n }>({\n gateway: 'workspace',\n query: INSTALL_WORKSPACE_APPS_STRING,\n variables: installVars,\n authToken: authToken || undefined,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message ?? 'Installation failed');\n }\n\n const installResult = result.data?.installWorkspaceApps;\n if (installResult?.successCount && installResult.successCount > 0) {\n // Step 2: Record installation in store service (for tracking)\n try {\n await graphqlFetch({\n gateway: 'global',\n query: RECORD_APP_INSTALLATION_STRING,\n variables: {\n input: {\n productId: app.id,\n workspaceId: workspace.id,\n workspaceName: workspace.name,\n workspaceType: workspace.type,\n organizationId: workspace.organizationId,\n version: app.version || '1.0.0',\n manifest: {\n productId: app.id,\n icon: app.icon,\n slug: app.slug,\n type: app.type,\n },\n },\n },\n authToken: authToken || undefined,\n });\n } catch {\n // Non-fatal: workspace installation succeeded; store record will sync later.\n }\n\n onInstallSuccess?.(workspace.id, workspace.name);\n onClose();\n } else {\n const rawMsg = installResult?.results?.[0]?.error || 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n }\n } catch (err) {\n const rawMsg = err instanceof Error ? err.message : 'Installation failed';\n const errorMsg = mapInstallError(rawMsg);\n dispatchInstall({ type: 'setError', error: errorMsg });\n onInstallError?.(new Error(rawMsg));\n } finally {\n dispatchInstall({ type: 'finishInstall' });\n }\n };\n\n /**\n * Main install handler - routes to appropriate install function\n */\n const handleInstall = async () => {\n const appType = app.type?.toUpperCase() ?? '';\n\n if (purchaseState === 'purchased' || orderId || STORE_DISTRIBUTED_TYPES.has(appType)) {\n // Purchased products install through the store service.\n await handleInstallFromStore();\n } else {\n // Free products install through the workspace service.\n await handleInstallViaWorkspace();\n }\n };\n\n if (!isOpen) return null;\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n {/* Backdrop */}\n <button\n type=\"button\"\n aria-label=\"Close modal\"\n className=\"absolute inset-0 bg-bg-overlay/50 backdrop-blur-sm\"\n onClick={onClose}\n />\n\n {/* Modal */}\n <dialog\n open\n aria-modal=\"true\"\n aria-labelledby=\"install-app-modal-title\"\n className=\"relative z-10 mx-4 w-full max-w-lg rounded-2xl border border-border-default bg-bg-surface shadow-2xl\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between border-b border-border-default px-6 py-4\">\n <div className=\"flex items-center gap-3\">\n {app.icon ? (\n <img src={app.icon} alt={app.name} className=\"size-10 rounded-lg object-cover\" />\n ) : (\n <div className=\"flex size-10 items-center justify-center rounded-lg bg-bg-sunken text-lg font-bold text-text-muted\">\n {app.name.charAt(0)}\n </div>\n )}\n <div>\n <h2 id=\"install-app-modal-title\" className=\"text-lg font-semibold text-text-primary\">\n Install App\n </h2>\n <p className=\"text-sm text-text-muted\">{app.name}</p>\n </div>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close install dialog\"\n className=\"cursor-pointer rounded-lg p-2 text-text-muted transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <X className=\"size-5\" />\n </button>\n </div>\n\n {/* Content */}\n <div className=\"px-6 py-4\">\n <p className=\"mb-4 text-text-secondary\">\n Select the workspace where you want to install this app:\n </p>\n\n {/* Workspace List */}\n <div className=\"max-h-72 overflow-y-auto rounded-lg border border-border-default\">\n {loading ? (\n <div className=\"flex items-center justify-center py-12\">\n <Loader2 className=\"size-8 animate-spin text-text-muted\" />\n </div>\n ) : error ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <AlertCircle className=\"mb-2 size-8 text-status-error-text\" />\n <p className=\"text-sm text-status-error-text\">Failed to load workspaces</p>\n <p className=\"text-xs text-text-muted mt-1\">{error.message}</p>\n </div>\n ) : filteredWorkspaces.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <Building2 className=\"mb-2 size-8 text-text-muted\" />\n <p className=\"text-sm text-text-muted\">No workspaces available</p>\n </div>\n ) : (\n <div className=\"divide-y divide-border-default\">\n {filteredWorkspaces.map((workspace) => (\n <button\n type=\"button\"\n key={workspace.id}\n onClick={() =>\n dispatchInstall({ type: 'selectWorkspace', workspaceId: workspace.id })\n }\n className={`w-full cursor-pointer flex items-center gap-3 px-4 py-3 text-left transition-colors ${\n selectedWorkspace === workspace.id\n ? 'bg-action-primary-bg/10'\n : 'transition-colors hover:bg-bg-sunken'\n }`}\n >\n {/* Workspace Icon */}\n <div className=\"flex size-10 items-center justify-center rounded-lg bg-action-primary-bg/10 text-text-link\">\n <Building2 className=\"size-5\" />\n </div>\n\n {/* Workspace Info */}\n <div className=\"flex-1 min-w-0\">\n <p className=\"font-medium text-text-primary truncate\">{workspace.name}</p>\n {workspace.slug ? (\n <p className=\"text-xs text-text-muted truncate\">/{workspace.slug}</p>\n ) : null}\n </div>\n\n {/* Selection Indicator */}\n {selectedWorkspace === workspace.id && (\n <CheckCircle className=\"size-5 flex-shrink-0 text-action-primary-bg\" />\n )}\n </button>\n ))}\n </div>\n )}\n </div>\n </div>\n\n {/* Footer */}\n <div className=\"border-t border-border-default px-6 py-4\">\n {/* Already-installed info */}\n {installInfo && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-status-info-bg-subtle px-3 py-2 text-sm text-status-info-text\">\n <Info className=\"size-4 flex-shrink-0\" />\n <span>{installInfo}</span>\n </div>\n )}\n {/* Error message */}\n {installError && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-status-error-bg-subtle/10 px-3 py-2 text-sm text-status-error-text\">\n <AlertCircle className=\"size-4 flex-shrink-0\" />\n <span>{installError}</span>\n </div>\n )}\n <div className=\"flex items-center justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n disabled={installing}\n className=\"cursor-pointer rounded-lg border border-border-default px-4 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={handleInstall}\n disabled={!selectedWorkspace || installing}\n className=\"cursor-pointer rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-opacity hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2\"\n >\n {installing ? (\n <>\n <Loader2 className=\"size-4 animate-spin\" />\n Installing…\n </>\n ) : (\n 'Install App'\n )}\n </button>\n </div>\n </div>\n </dialog>\n </div>\n );\n};\n"],"mappings":";;;;;;AAiCA,IAAM,IAAuB,mGACvB,IAAgC,mOAChC,IAAiC,kJACjC,IAA+B,2RAC/B,IAAoC,6JACpC,IAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,EAEI,IAAiD;CACrD,mBAAmB;CACnB,gBAAgB;CAChB,mBAAmB;CACnB,WAAW;CACX,oBAAoB;CACpB,qBAAqB;CACrB,kBAAk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