@elevasis/ui 1.19.0 → 1.20.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/api/index.js +2 -2
- package/dist/auth/index.js +3 -3
- package/dist/charts/index.css +14 -0
- package/dist/charts/index.js +8 -6
- package/dist/{chunk-7ATCF6UL.js → chunk-3DIU726S.js} +11 -4
- package/dist/chunk-4SY4EQSK.js +68 -0
- package/dist/{chunk-2Z7LYTIX.js → chunk-AQ5MQDSS.js} +30 -17
- package/dist/chunk-AWMZCYKH.js +639 -0
- package/dist/{chunk-BVNAC4SQ.js → chunk-C7AD6N23.js} +38 -48
- package/dist/{chunk-ZFCG5SHW.js → chunk-COTI2QPO.js} +1 -1
- package/dist/{chunk-WAPZN2U3.js → chunk-EMN755L5.js} +7 -41
- package/dist/{chunk-LBY7FVFD.js → chunk-ERVB3QJQ.js} +31 -715
- package/dist/chunk-GBMNCNHX.js +105 -0
- package/dist/{chunk-MBZDE6UT.js → chunk-IOKL7BKE.js} +9 -1
- package/dist/{chunk-35UWYH2A.js → chunk-JFRG2JJE.js} +8 -2
- package/dist/chunk-JIABC3AE.js +2622 -0
- package/dist/chunk-JZEXFQ6N.js +671 -0
- package/dist/chunk-LGKLC5MG.js +44 -0
- package/dist/chunk-MG3NF7QL.js +63 -0
- package/dist/{chunk-KBLGVZBD.js → chunk-NNKKBSJN.js} +2 -22
- package/dist/{chunk-JNBHUCKW.js → chunk-NVOCKXUQ.js} +1 -1
- package/dist/chunk-OFAXUZPZ.js +2411 -0
- package/dist/chunk-PDHTXPSF.js +12 -0
- package/dist/chunk-QJ2S46NI.js +23 -0
- package/dist/{chunk-NUULWBAD.js → chunk-R3R367QY.js} +1 -1
- package/dist/{chunk-UANJP5P7.js → chunk-R7WLWGPO.js} +5 -5
- package/dist/{chunk-CC3SDRIF.js → chunk-RWQIFKMJ.js} +1 -1
- package/dist/chunk-UMFPUM7Q.js +1281 -0
- package/dist/{chunk-KNJKCD73.js → chunk-VLTVZXP6.js} +4 -4
- package/dist/chunk-WWEMNIHW.js +37 -0
- package/dist/{chunk-UTWJZEOJ.js → chunk-XOTN3X3Z.js} +3 -3
- package/dist/components/index.css +14 -0
- package/dist/components/index.d.ts +41 -7
- package/dist/components/index.js +564 -5023
- package/dist/components/navigation/index.js +2 -63
- package/dist/features/auth/index.css +579 -0
- package/dist/features/auth/index.d.ts +2557 -0
- package/dist/features/auth/index.js +125 -0
- package/dist/features/dashboard/index.css +579 -0
- package/dist/features/dashboard/index.d.ts +244 -0
- package/dist/features/dashboard/index.js +650 -0
- package/dist/features/monitoring/index.css +579 -0
- package/dist/features/monitoring/index.d.ts +121 -0
- package/dist/features/monitoring/index.js +538 -0
- package/dist/features/operations/index.css +14 -0
- package/dist/features/operations/index.d.ts +1675 -2
- package/dist/features/operations/index.js +2148 -28
- package/dist/features/settings/index.css +579 -0
- package/dist/features/settings/index.d.ts +2589 -0
- package/dist/features/settings/index.js +1437 -0
- package/dist/hooks/index.css +14 -0
- package/dist/hooks/index.d.ts +29 -11
- package/dist/hooks/index.js +13 -13
- package/dist/hooks/published.css +14 -0
- package/dist/hooks/published.d.ts +29 -11
- package/dist/hooks/published.js +12 -12
- package/dist/index.css +14 -0
- package/dist/index.d.ts +41 -12
- package/dist/index.js +15 -15
- package/dist/initialization/index.js +2 -2
- package/dist/layout/index.d.ts +7 -1
- package/dist/layout/index.js +7 -5
- package/dist/organization/index.js +2 -2
- package/dist/provider/index.css +14 -0
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +10 -10
- package/dist/provider/published.d.ts +1 -1
- package/dist/provider/published.js +6 -6
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +3 -3
- package/dist/theme/presets/__tests__/getPreset.test.d.ts +2 -0
- package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +1 -0
- package/dist/theme/presets/__tests__/getPreset.test.js +92 -0
- package/dist/theme/presets/cyber-volt.d.ts +12 -0
- package/dist/theme/presets/cyber-volt.d.ts.map +1 -0
- package/dist/theme/presets/cyber-volt.js +70 -0
- package/dist/theme/presets/regal.d.ts +8 -0
- package/dist/theme/presets/regal.d.ts.map +1 -0
- package/dist/theme/presets/regal.js +69 -0
- package/dist/theme/presets/rose-gold.d.ts +12 -0
- package/dist/theme/presets/rose-gold.d.ts.map +1 -0
- package/dist/theme/presets/rose-gold.js +76 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.ts +12 -1
- package/dist/utils/index.js +1 -1
- package/dist/zustand/index.d.ts +80 -0
- package/dist/zustand/index.js +105 -0
- package/package.json +55 -4
- package/dist/chunk-2YW3LDFT.js +0 -1542
- package/dist/theme/presets/cyber-void.d.ts +0 -12
- package/dist/theme/presets/cyber-void.d.ts.map +0 -1
- package/dist/theme/presets/cyber-void.js +0 -75
- package/dist/{chunk-DVKEEY5J.js → chunk-TUXTSEAF.js} +1 -1
- package/dist/{chunk-U2522LSW.js → chunk-V7XHGJQZ.js} +1 -1
|
@@ -0,0 +1,1437 @@
|
|
|
1
|
+
import { useAvailablePresets } from '../../chunk-COTI2QPO.js';
|
|
2
|
+
import { OrganizationMembershipsList, WebhookUrlDisplayModal, MembershipFeaturePanel, MembershipStatusBadge, getCredentialSchema, OAuthConnectModal, buildCredentialValue } from '../../chunk-JZEXFQ6N.js';
|
|
3
|
+
import '../../chunk-PDHTXPSF.js';
|
|
4
|
+
import { CustomModal } from '../../chunk-GBMNCNHX.js';
|
|
5
|
+
import { PageTitleCaption, EmptyState, CardHeader, ListSkeleton, StatCard } from '../../chunk-AWMZCYKH.js';
|
|
6
|
+
import '../../chunk-NNKKBSJN.js';
|
|
7
|
+
import { AppShellLoader } from '../../chunk-WWEMNIHW.js';
|
|
8
|
+
import '../../chunk-QJ2S46NI.js';
|
|
9
|
+
import { useUserMemberships, useUpdateWebhookEndpoint, useDeleteWebhookEndpoint, useCreateWebhookEndpoint, useListWebhookEndpoints, useUpdateMemberConfig, useOrganizationMembers, useUpdateCredential, CredentialSchemas, showErrorNotification } from '../../chunk-XOTN3X3Z.js';
|
|
10
|
+
import { useResources } from '../../chunk-AQ5MQDSS.js';
|
|
11
|
+
import '../../chunk-NJJ3NQ7B.js';
|
|
12
|
+
import '../../chunk-LXHZYSMQ.js';
|
|
13
|
+
import '../../chunk-MHW43EOH.js';
|
|
14
|
+
import '../../chunk-F6RBK7NJ.js';
|
|
15
|
+
import '../../chunk-ELJIFLCB.js';
|
|
16
|
+
import '../../chunk-L4XXM55J.js';
|
|
17
|
+
import '../../chunk-SLVC5OJ2.js';
|
|
18
|
+
import '../../chunk-RNP5R5I3.js';
|
|
19
|
+
import '../../chunk-VLTVZXP6.js';
|
|
20
|
+
import '../../chunk-R3R367QY.js';
|
|
21
|
+
import '../../chunk-SZHARWKU.js';
|
|
22
|
+
import '../../chunk-OFAXUZPZ.js';
|
|
23
|
+
import '../../chunk-3DIU726S.js';
|
|
24
|
+
import '../../chunk-R7WLWGPO.js';
|
|
25
|
+
import '../../chunk-NVOCKXUQ.js';
|
|
26
|
+
import '../../chunk-V7XHGJQZ.js';
|
|
27
|
+
import '../../chunk-QJ2KCHKX.js';
|
|
28
|
+
import { formatDateTime, OAUTH_POPUP_CHECK_INTERVAL, OAUTH_FLOW_TIMEOUT } from '../../chunk-IOKL7BKE.js';
|
|
29
|
+
import '../../chunk-RWQIFKMJ.js';
|
|
30
|
+
import '../../chunk-ALA56RGZ.js';
|
|
31
|
+
import { useInitialization } from '../../chunk-TUXTSEAF.js';
|
|
32
|
+
import '../../chunk-DD3CCMCZ.js';
|
|
33
|
+
import { useElevasisServices } from '../../chunk-QEPXAWE2.js';
|
|
34
|
+
import '../../chunk-BRJ3QZ4E.js';
|
|
35
|
+
import '../../chunk-Q7DJKLEN.js';
|
|
36
|
+
import { Paper, Stack, Group, ThemeIcon, Text, Code, CopyButton, Tooltip, ActionIcon, Button, Alert, useMantineColorScheme, SimpleGrid, UnstyledButton, Card, Title, Badge, TextInput, Switch, Table, Divider, Select, Textarea, Center, Loader, PasswordInput } from '@mantine/core';
|
|
37
|
+
import { IconUser, IconCheck, IconCopy, IconMail, IconRefresh, IconAlertCircle, IconBuilding, IconPalette, IconSun, IconEye, IconSparkles, IconTrendingUp, IconSearch, IconWebhook, IconExclamationMark, IconPencil, IconClock, IconPlayerPause, IconPlayerPlay, IconTrash, IconAlertTriangle, IconPlus, IconActivity, IconUsers, IconSettings, IconBrandDropbox, IconRocket, IconBrandGithub, IconBrandGmail, IconBrandGoogleDrive, IconPlug, IconBrandSlack, IconMoon, IconDeviceDesktop } from '@tabler/icons-react';
|
|
38
|
+
import { notifications } from '@mantine/notifications';
|
|
39
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
40
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
41
|
+
import { useRef, useEffect, useMemo, useState, useCallback } from 'react';
|
|
42
|
+
import { create } from 'zustand';
|
|
43
|
+
import { useForm } from '@mantine/form';
|
|
44
|
+
|
|
45
|
+
// ../core/src/integrations/oauth/provider-registry.ts
|
|
46
|
+
var OAUTH_PROVIDERS = {
|
|
47
|
+
"google-sheets": {
|
|
48
|
+
id: "google-sheets",
|
|
49
|
+
name: "Google Sheets",
|
|
50
|
+
authUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
51
|
+
tokenUrl: "https://oauth2.googleapis.com/token",
|
|
52
|
+
authParams: {
|
|
53
|
+
access_type: "offline",
|
|
54
|
+
// Required for refresh token
|
|
55
|
+
prompt: "consent"
|
|
56
|
+
// Force consent to get refresh token on reconnect
|
|
57
|
+
},
|
|
58
|
+
tokenExchange: "form-encoded",
|
|
59
|
+
scopes: ["https://www.googleapis.com/auth/spreadsheets"]
|
|
60
|
+
},
|
|
61
|
+
dropbox: {
|
|
62
|
+
id: "dropbox",
|
|
63
|
+
name: "Dropbox",
|
|
64
|
+
authUrl: "https://www.dropbox.com/oauth2/authorize",
|
|
65
|
+
tokenUrl: "https://api.dropboxapi.com/oauth2/token",
|
|
66
|
+
authParams: {
|
|
67
|
+
token_access_type: "offline"
|
|
68
|
+
// Required for refresh token
|
|
69
|
+
},
|
|
70
|
+
tokenExchange: "form-encoded",
|
|
71
|
+
scopes: ["files.content.write", "files.content.read", "files.metadata.write"]
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
function AccountSettings({
|
|
75
|
+
user,
|
|
76
|
+
userProfile,
|
|
77
|
+
profileLoading,
|
|
78
|
+
onRefetchProfile,
|
|
79
|
+
onNavigate
|
|
80
|
+
}) {
|
|
81
|
+
const { apiRequest } = useElevasisServices();
|
|
82
|
+
const userConfig = userProfile?.config;
|
|
83
|
+
const hasCompletedOnboarding = userConfig?.onboarding?.completed;
|
|
84
|
+
const resetWelcomeFlow = useMutation({
|
|
85
|
+
mutationFn: async () => {
|
|
86
|
+
return apiRequest("/users/me", {
|
|
87
|
+
method: "PATCH",
|
|
88
|
+
body: JSON.stringify({
|
|
89
|
+
config: {
|
|
90
|
+
onboarding: {
|
|
91
|
+
completed: false,
|
|
92
|
+
completedAt: null,
|
|
93
|
+
role: null,
|
|
94
|
+
primaryUseCase: null,
|
|
95
|
+
experienceLevel: null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
onSuccess: async () => {
|
|
102
|
+
notifications.show({
|
|
103
|
+
title: "Welcome Flow Reset",
|
|
104
|
+
message: "Redirecting to the welcome flow...",
|
|
105
|
+
color: "teal"
|
|
106
|
+
});
|
|
107
|
+
await onRefetchProfile();
|
|
108
|
+
onNavigate("/welcome");
|
|
109
|
+
},
|
|
110
|
+
onError: (err) => {
|
|
111
|
+
notifications.show({
|
|
112
|
+
title: "Error",
|
|
113
|
+
message: err instanceof Error ? err.message : "Failed to reset welcome flow",
|
|
114
|
+
color: "red"
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const { data: memberships = [], isLoading, error } = useUserMemberships(user?.id || "");
|
|
119
|
+
const handleEditRole = (_membershipId) => {
|
|
120
|
+
notifications.show({
|
|
121
|
+
title: "Edit Role",
|
|
122
|
+
message: "Role editing functionality coming soon",
|
|
123
|
+
color: "blue"
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const handleLeaveOrganization = (_membershipId) => {
|
|
127
|
+
notifications.show({
|
|
128
|
+
title: "Leave Organization",
|
|
129
|
+
message: "Leave organization functionality coming soon",
|
|
130
|
+
color: "orange"
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
134
|
+
/* @__PURE__ */ jsx(PageTitleCaption, { title: "Account Settings", caption: "Manage your account and organization memberships" }),
|
|
135
|
+
user && /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
136
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
137
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", children: /* @__PURE__ */ jsx(IconUser, { size: 18 }) }),
|
|
138
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: 1 }, children: [
|
|
139
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Name" }),
|
|
140
|
+
/* @__PURE__ */ jsxs(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: [
|
|
141
|
+
user.firstName,
|
|
142
|
+
" ",
|
|
143
|
+
user.lastName
|
|
144
|
+
] })
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
147
|
+
/* @__PURE__ */ jsx(Code, { children: user.id }),
|
|
148
|
+
/* @__PURE__ */ jsx(CopyButton, { value: user.id, timeout: 2e3, children: ({ copied, copy }) => /* @__PURE__ */ jsx(Tooltip, { label: copied ? "Copied!" : "Copy User ID", withArrow: true, position: "top", children: /* @__PURE__ */ jsx(
|
|
149
|
+
ActionIcon,
|
|
150
|
+
{
|
|
151
|
+
color: copied ? "teal" : "gray",
|
|
152
|
+
variant: copied ? "filled" : "subtle",
|
|
153
|
+
onClick: copy,
|
|
154
|
+
size: "sm",
|
|
155
|
+
children: copied ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : /* @__PURE__ */ jsx(IconCopy, { size: 14 })
|
|
156
|
+
}
|
|
157
|
+
) }) })
|
|
158
|
+
] })
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: "green", children: /* @__PURE__ */ jsx(IconMail, { size: 18 }) }),
|
|
162
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: 1 }, children: [
|
|
163
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Email" }),
|
|
164
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: user.email })
|
|
165
|
+
] })
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
|
|
168
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
169
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: "teal", children: /* @__PURE__ */ jsx(IconRefresh, { size: 18 }) }),
|
|
170
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
171
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Welcome Flow" }),
|
|
172
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: hasCompletedOnboarding ? "Re-run the onboarding flow to update your preferences" : "You have not completed the welcome flow yet" })
|
|
173
|
+
] })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
Button,
|
|
177
|
+
{
|
|
178
|
+
variant: "light",
|
|
179
|
+
leftSection: profileLoading ? void 0 : /* @__PURE__ */ jsx(IconRefresh, { size: 16 }),
|
|
180
|
+
onClick: () => resetWelcomeFlow.mutate(),
|
|
181
|
+
loading: profileLoading || resetWelcomeFlow.isPending,
|
|
182
|
+
disabled: profileLoading,
|
|
183
|
+
children: profileLoading ? "" : hasCompletedOnboarding ? "Reset & Redo" : "Start"
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] })
|
|
187
|
+
] }) }),
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
OrganizationMembershipsList,
|
|
190
|
+
{
|
|
191
|
+
memberships,
|
|
192
|
+
loading: isLoading,
|
|
193
|
+
error,
|
|
194
|
+
onEditRole: handleEditRole,
|
|
195
|
+
onLeaveOrganization: handleLeaveOrganization
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
error && /* @__PURE__ */ jsxs(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), title: "Error", color: "red", children: [
|
|
199
|
+
"Failed to load organization memberships: ",
|
|
200
|
+
error.message
|
|
201
|
+
] }),
|
|
202
|
+
!isLoading && !error && memberships.length === 0 && /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(
|
|
203
|
+
EmptyState,
|
|
204
|
+
{
|
|
205
|
+
icon: IconBuilding,
|
|
206
|
+
title: "No Organization Memberships",
|
|
207
|
+
description: "You are not currently a member of any organizations. Contact an administrator to be added to an organization."
|
|
208
|
+
}
|
|
209
|
+
) })
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
var useInternalThemeStore = create((set) => ({
|
|
213
|
+
preset: "default",
|
|
214
|
+
colorScheme: "auto",
|
|
215
|
+
setPreset: (preset) => set({ preset }),
|
|
216
|
+
setColorScheme: (colorScheme) => set({ colorScheme }),
|
|
217
|
+
setTheme: (theme) => set(theme)
|
|
218
|
+
}));
|
|
219
|
+
|
|
220
|
+
// src/hooks/operations/settings/useUpdateThemePreference.ts
|
|
221
|
+
var DEBOUNCE_MS = 500;
|
|
222
|
+
function useUpdateThemePreference() {
|
|
223
|
+
const { apiRequest } = useElevasisServices();
|
|
224
|
+
const setTheme = useInternalThemeStore((s) => s.setTheme);
|
|
225
|
+
const timerRef = useRef(null);
|
|
226
|
+
const updateTheme = useCallback(
|
|
227
|
+
(theme) => {
|
|
228
|
+
if (theme.preset !== void 0 && theme.colorScheme !== void 0) {
|
|
229
|
+
setTheme({ preset: theme.preset, colorScheme: theme.colorScheme });
|
|
230
|
+
} else {
|
|
231
|
+
const current = useInternalThemeStore.getState();
|
|
232
|
+
setTheme({
|
|
233
|
+
preset: theme.preset ?? current.preset,
|
|
234
|
+
colorScheme: theme.colorScheme ?? current.colorScheme
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
238
|
+
timerRef.current = setTimeout(async () => {
|
|
239
|
+
try {
|
|
240
|
+
await apiRequest("/users/me", {
|
|
241
|
+
method: "PATCH",
|
|
242
|
+
body: JSON.stringify({ config: { theme } })
|
|
243
|
+
});
|
|
244
|
+
} catch (error) {
|
|
245
|
+
showErrorNotification(error instanceof Error ? error : new Error("Failed to update appearance"));
|
|
246
|
+
}
|
|
247
|
+
}, DEBOUNCE_MS);
|
|
248
|
+
},
|
|
249
|
+
[apiRequest, setTheme]
|
|
250
|
+
);
|
|
251
|
+
return { updateTheme };
|
|
252
|
+
}
|
|
253
|
+
var COLOR_SCHEMES = [
|
|
254
|
+
{ value: "light", label: "Light", icon: /* @__PURE__ */ jsx(IconSun, { size: 16 }) },
|
|
255
|
+
{ value: "dark", label: "Dark", icon: /* @__PURE__ */ jsx(IconMoon, { size: 16 }) },
|
|
256
|
+
{ value: "auto", label: "System", icon: /* @__PURE__ */ jsx(IconDeviceDesktop, { size: 16 }) }
|
|
257
|
+
];
|
|
258
|
+
function AppearanceSettings({ initialTheme, onThemeChange }) {
|
|
259
|
+
const preset = useInternalThemeStore((s) => s.preset);
|
|
260
|
+
const colorScheme = useInternalThemeStore((s) => s.colorScheme);
|
|
261
|
+
const setInternalTheme = useInternalThemeStore((s) => s.setTheme);
|
|
262
|
+
const { updateTheme } = useUpdateThemePreference();
|
|
263
|
+
const { setColorScheme: setMantineColorScheme } = useMantineColorScheme();
|
|
264
|
+
const availablePresets = useAvailablePresets();
|
|
265
|
+
const hydratedRef = useRef(false);
|
|
266
|
+
if (!hydratedRef.current) {
|
|
267
|
+
setInternalTheme(initialTheme);
|
|
268
|
+
hydratedRef.current = true;
|
|
269
|
+
}
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
if (!hydratedRef.current) return;
|
|
272
|
+
onThemeChange?.({ preset, colorScheme });
|
|
273
|
+
}, [preset, colorScheme]);
|
|
274
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
275
|
+
/* @__PURE__ */ jsx(PageTitleCaption, { title: "Appearance", caption: "Customize how the command center looks" }),
|
|
276
|
+
/* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
|
|
277
|
+
/* @__PURE__ */ jsx(
|
|
278
|
+
CardHeader,
|
|
279
|
+
{
|
|
280
|
+
icon: /* @__PURE__ */ jsx(IconPalette, { size: 18 }),
|
|
281
|
+
title: "Theme",
|
|
282
|
+
subtitle: "Choose a color palette for the command center"
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ jsx(Stack, { gap: "md", children: /* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 2, sm: 3, md: 4 }, children: availablePresets.map((p) => {
|
|
286
|
+
const isActive = p.value === preset;
|
|
287
|
+
return /* @__PURE__ */ jsx(
|
|
288
|
+
UnstyledButton,
|
|
289
|
+
{
|
|
290
|
+
onClick: () => {
|
|
291
|
+
if (!isActive) {
|
|
292
|
+
updateTheme({ preset: p.value, colorScheme });
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
children: /* @__PURE__ */ jsx(
|
|
296
|
+
Card,
|
|
297
|
+
{
|
|
298
|
+
style: {
|
|
299
|
+
cursor: "pointer",
|
|
300
|
+
border: isActive ? "var(--active-border)" : "1px solid var(--color-border)",
|
|
301
|
+
backgroundColor: isActive ? "var(--active-background)" : "var(--color-surface)",
|
|
302
|
+
transition: `all var(--duration-fast) var(--easing)`
|
|
303
|
+
},
|
|
304
|
+
children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
305
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
|
|
306
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", children: p.label }),
|
|
307
|
+
/* @__PURE__ */ jsx(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
style: {
|
|
311
|
+
width: 14,
|
|
312
|
+
height: 14,
|
|
313
|
+
borderRadius: "50%",
|
|
314
|
+
backgroundColor: p.colors[0],
|
|
315
|
+
border: "1px solid var(--color-border)",
|
|
316
|
+
flexShrink: 0
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
] }),
|
|
321
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: p.description })
|
|
322
|
+
] })
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
},
|
|
326
|
+
p.value
|
|
327
|
+
);
|
|
328
|
+
}) }) })
|
|
329
|
+
] }),
|
|
330
|
+
/* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
|
|
331
|
+
/* @__PURE__ */ jsx(
|
|
332
|
+
CardHeader,
|
|
333
|
+
{
|
|
334
|
+
icon: /* @__PURE__ */ jsx(IconSun, { size: 18 }),
|
|
335
|
+
title: "Color Scheme",
|
|
336
|
+
subtitle: "Light, dark, or match your system preference"
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
/* @__PURE__ */ jsx(Stack, { gap: "md", children: /* @__PURE__ */ jsx(SimpleGrid, { cols: 3, children: COLOR_SCHEMES.map((s) => {
|
|
340
|
+
const isActive = s.value === colorScheme;
|
|
341
|
+
return /* @__PURE__ */ jsx(
|
|
342
|
+
UnstyledButton,
|
|
343
|
+
{
|
|
344
|
+
onClick: () => {
|
|
345
|
+
if (!isActive) {
|
|
346
|
+
setMantineColorScheme(s.value);
|
|
347
|
+
updateTheme({ preset, colorScheme: s.value });
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
style: { borderRadius: "var(--mantine-radius-md)" },
|
|
351
|
+
children: /* @__PURE__ */ jsx(
|
|
352
|
+
Card,
|
|
353
|
+
{
|
|
354
|
+
padding: "md",
|
|
355
|
+
style: {
|
|
356
|
+
cursor: "pointer",
|
|
357
|
+
border: isActive ? "var(--active-border)" : "1px solid var(--color-border)",
|
|
358
|
+
backgroundColor: isActive ? "var(--active-background)" : "var(--color-surface)",
|
|
359
|
+
transition: `all var(--duration-fast) var(--easing)`
|
|
360
|
+
},
|
|
361
|
+
children: /* @__PURE__ */ jsxs(Group, { gap: 6, justify: "center", wrap: "nowrap", children: [
|
|
362
|
+
s.icon,
|
|
363
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", children: s.label }),
|
|
364
|
+
isActive && /* @__PURE__ */ jsx(IconCheck, { size: 14, color: "var(--color-primary)", style: { flexShrink: 0 } })
|
|
365
|
+
] })
|
|
366
|
+
}
|
|
367
|
+
)
|
|
368
|
+
},
|
|
369
|
+
s.value
|
|
370
|
+
);
|
|
371
|
+
}) }) })
|
|
372
|
+
] }),
|
|
373
|
+
/* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
|
|
374
|
+
/* @__PURE__ */ jsx(
|
|
375
|
+
CardHeader,
|
|
376
|
+
{
|
|
377
|
+
icon: /* @__PURE__ */ jsx(IconEye, { size: 18 }),
|
|
378
|
+
title: "Preview",
|
|
379
|
+
subtitle: "See how common UI elements look with your current theme"
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ jsxs(Stack, { gap: "lg", children: [
|
|
383
|
+
/* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
384
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Page Layout" }),
|
|
385
|
+
/* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
386
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-start", wrap: "nowrap", children: [
|
|
387
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
388
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Operations Overview" }),
|
|
389
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Monitor recent activity across your workspace" })
|
|
390
|
+
] }),
|
|
391
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
392
|
+
/* @__PURE__ */ jsx(Button, { variant: "default", size: "xs", children: "Export" }),
|
|
393
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", leftSection: /* @__PURE__ */ jsx(IconSparkles, { size: 14 }), children: "New Workflow" })
|
|
394
|
+
] })
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 3 }, spacing: "sm", children: [
|
|
397
|
+
{ label: "Active Workflows", value: "24", trend: "+12%" },
|
|
398
|
+
{ label: "Executions Today", value: "1,284", trend: "+8.3%" },
|
|
399
|
+
{ label: "Success Rate", value: "98.2%", trend: "+0.4%" }
|
|
400
|
+
].map((stat) => /* @__PURE__ */ jsx(
|
|
401
|
+
Card,
|
|
402
|
+
{
|
|
403
|
+
padding: "sm",
|
|
404
|
+
withBorder: true,
|
|
405
|
+
style: {
|
|
406
|
+
transition: `all var(--duration-fast) var(--easing)`
|
|
407
|
+
},
|
|
408
|
+
children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
409
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: stat.label }),
|
|
410
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-end", wrap: "nowrap", children: [
|
|
411
|
+
/* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, children: stat.value }),
|
|
412
|
+
/* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "green", leftSection: /* @__PURE__ */ jsx(IconTrendingUp, { size: 10 }), children: stat.trend })
|
|
413
|
+
] })
|
|
414
|
+
] })
|
|
415
|
+
},
|
|
416
|
+
stat.label
|
|
417
|
+
)) })
|
|
418
|
+
] }) })
|
|
419
|
+
] }),
|
|
420
|
+
/* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, md: 2 }, spacing: "md", children: [
|
|
421
|
+
/* @__PURE__ */ jsx(Card, { padding: "md", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
422
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Buttons" }),
|
|
423
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
424
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", children: "Primary" }),
|
|
425
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "light", children: "Light" }),
|
|
426
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "outline", children: "Outline" }),
|
|
427
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "default", children: "Default" }),
|
|
428
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "subtle", children: "Subtle" })
|
|
429
|
+
] })
|
|
430
|
+
] }) }),
|
|
431
|
+
/* @__PURE__ */ jsx(Card, { padding: "md", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
432
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Status Badges" }),
|
|
433
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
434
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", children: "Active" }),
|
|
435
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", color: "green", children: "Success" }),
|
|
436
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", color: "yellow", children: "Pending" }),
|
|
437
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", color: "red", children: "Failed" }),
|
|
438
|
+
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: "Draft" })
|
|
439
|
+
] })
|
|
440
|
+
] }) }),
|
|
441
|
+
/* @__PURE__ */ jsx(Card, { padding: "md", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
442
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Inputs" }),
|
|
443
|
+
/* @__PURE__ */ jsx(TextInput, { placeholder: "Search workflows...", leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 14 }), size: "xs" }),
|
|
444
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
|
|
445
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: "Enable notifications" }),
|
|
446
|
+
/* @__PURE__ */ jsx(Switch, { defaultChecked: true, size: "sm" })
|
|
447
|
+
] })
|
|
448
|
+
] }) }),
|
|
449
|
+
/* @__PURE__ */ jsx(Card, { padding: "md", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
450
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Typography" }),
|
|
451
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
452
|
+
/* @__PURE__ */ jsx(Title, { order: 4, children: "Section Heading" }),
|
|
453
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: "The quick brown fox jumps over the lazy dog." }),
|
|
454
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Secondary text with dimmed color for less emphasis." }),
|
|
455
|
+
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
456
|
+
/* @__PURE__ */ jsx(Text, { span: true, c: "var(--color-primary)", fw: 600, inherit: true, children: "Link" }),
|
|
457
|
+
" ",
|
|
458
|
+
"styled with primary color token."
|
|
459
|
+
] })
|
|
460
|
+
] })
|
|
461
|
+
] }) })
|
|
462
|
+
] }),
|
|
463
|
+
/* @__PURE__ */ jsx(Card, { padding: "md", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
464
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Table" }),
|
|
465
|
+
/* @__PURE__ */ jsx(Table.ScrollContainer, { minWidth: 400, children: /* @__PURE__ */ jsxs(Table, { verticalSpacing: "xs", horizontalSpacing: "sm", children: [
|
|
466
|
+
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
467
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Workflow" }),
|
|
468
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
469
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Runs" }),
|
|
470
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Last Run" })
|
|
471
|
+
] }) }),
|
|
472
|
+
/* @__PURE__ */ jsx(Table.Tbody, { children: [
|
|
473
|
+
{ name: "deal-enrichment", status: "Active", color: "green", runs: "482", last: "2m ago" },
|
|
474
|
+
{ name: "ist-campaign-review", status: "Active", color: "green", runs: "156", last: "14m ago" },
|
|
475
|
+
{ name: "tomba-email-finder", status: "Paused", color: "yellow", runs: "89", last: "3h ago" }
|
|
476
|
+
].map((row) => /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
477
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", children: row.name }) }),
|
|
478
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { variant: "light", color: row.color, size: "xs", children: row.status }) }),
|
|
479
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", children: row.runs }) }),
|
|
480
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: row.last }) })
|
|
481
|
+
] }, row.name)) })
|
|
482
|
+
] }) })
|
|
483
|
+
] }) }),
|
|
484
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
485
|
+
/* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
486
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Alerts" }),
|
|
487
|
+
/* @__PURE__ */ jsx(Alert, { variant: "light", color: "blue", icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), title: "Informational", children: "This is how informational alerts look with your current theme." }),
|
|
488
|
+
/* @__PURE__ */ jsx(Alert, { variant: "light", color: "green", icon: /* @__PURE__ */ jsx(IconCheck, { size: 16 }), title: "Success", children: "Operation completed successfully." })
|
|
489
|
+
] })
|
|
490
|
+
] })
|
|
491
|
+
] })
|
|
492
|
+
] });
|
|
493
|
+
}
|
|
494
|
+
function EditWebhookEndpointModal({ opened, endpoint, onClose }) {
|
|
495
|
+
const updateEndpoint = useUpdateWebhookEndpoint();
|
|
496
|
+
const { data: resourcesData } = useResources();
|
|
497
|
+
const resourceOptions = useMemo(() => {
|
|
498
|
+
if (!resourcesData) return [];
|
|
499
|
+
const workflowOptions = (resourcesData.workflows || []).filter((w) => w?.resourceId).map((w) => ({
|
|
500
|
+
value: w.resourceId,
|
|
501
|
+
label: `Workflow: ${w.resourceId}`
|
|
502
|
+
}));
|
|
503
|
+
const agentOptions = (resourcesData.agents || []).filter((a) => a?.resourceId).map((a) => ({
|
|
504
|
+
value: a.resourceId,
|
|
505
|
+
label: `Agent: ${a.resourceId}`
|
|
506
|
+
}));
|
|
507
|
+
return [...workflowOptions, ...agentOptions];
|
|
508
|
+
}, [resourcesData]);
|
|
509
|
+
const form = useForm({
|
|
510
|
+
initialValues: {
|
|
511
|
+
name: "",
|
|
512
|
+
resourceId: ""
|
|
513
|
+
},
|
|
514
|
+
validate: {
|
|
515
|
+
name: (value) => {
|
|
516
|
+
if (!value.trim()) return "Name is required";
|
|
517
|
+
if (value.trim().length < 2) return "Name must be at least 2 characters";
|
|
518
|
+
if (value.trim().length > 100) return "Name must be less than 100 characters";
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
useEffect(() => {
|
|
524
|
+
if (endpoint && opened) {
|
|
525
|
+
form.setValues({
|
|
526
|
+
name: endpoint.name,
|
|
527
|
+
resourceId: endpoint.resourceId ?? ""
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}, [endpoint, opened]);
|
|
531
|
+
const handleSubmit = async (values) => {
|
|
532
|
+
if (!endpoint) return;
|
|
533
|
+
try {
|
|
534
|
+
await updateEndpoint.mutateAsync({
|
|
535
|
+
endpointId: endpoint.id,
|
|
536
|
+
data: {
|
|
537
|
+
name: values.name.trim(),
|
|
538
|
+
resourceId: values.resourceId || void 0
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
onClose();
|
|
542
|
+
} catch (error) {
|
|
543
|
+
console.error("Failed to update webhook endpoint:", error);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
const handleClose = () => {
|
|
547
|
+
if (!updateEndpoint.isPending) {
|
|
548
|
+
onClose();
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
return /* @__PURE__ */ jsx(CustomModal, { opened, onClose: handleClose, size: "md", loading: updateEndpoint.isPending, children: /* @__PURE__ */ jsx("form", { onSubmit: form.onSubmit(handleSubmit), children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
552
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Edit Webhook Endpoint" }),
|
|
553
|
+
/* @__PURE__ */ jsx(
|
|
554
|
+
TextInput,
|
|
555
|
+
{
|
|
556
|
+
label: "Name",
|
|
557
|
+
description: "A descriptive label for this endpoint",
|
|
558
|
+
leftSection: /* @__PURE__ */ jsx(IconWebhook, { size: 16 }),
|
|
559
|
+
required: true,
|
|
560
|
+
...form.getInputProps("name"),
|
|
561
|
+
disabled: updateEndpoint.isPending
|
|
562
|
+
}
|
|
563
|
+
),
|
|
564
|
+
/* @__PURE__ */ jsx(
|
|
565
|
+
Select,
|
|
566
|
+
{
|
|
567
|
+
label: "Target Resource",
|
|
568
|
+
description: "The workflow or agent to trigger on each inbound request",
|
|
569
|
+
placeholder: resourcesData ? "Select a workflow or agent" : "Loading resources...",
|
|
570
|
+
data: resourceOptions,
|
|
571
|
+
searchable: true,
|
|
572
|
+
clearable: true,
|
|
573
|
+
...form.getInputProps("resourceId"),
|
|
574
|
+
disabled: !resourcesData || updateEndpoint.isPending
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
updateEndpoint.error && /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconExclamationMark, { size: 16 }), color: "red", children: updateEndpoint.error instanceof Error ? updateEndpoint.error.message : "An error occurred while updating the webhook endpoint" }),
|
|
578
|
+
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "sm", children: [
|
|
579
|
+
/* @__PURE__ */ jsx(Button, { variant: "subtle", onClick: handleClose, disabled: updateEndpoint.isPending, children: "Cancel" }),
|
|
580
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", loading: updateEndpoint.isPending, leftSection: /* @__PURE__ */ jsx(IconPencil, { size: 16 }), children: "Save Changes" })
|
|
581
|
+
] })
|
|
582
|
+
] }) }) });
|
|
583
|
+
}
|
|
584
|
+
function getWebhookUrl(apiUrl, key) {
|
|
585
|
+
return `${apiUrl}/api/webhooks/inbound/${key}`;
|
|
586
|
+
}
|
|
587
|
+
function WebhookEndpointList({ endpoints, isLoading, apiUrl }) {
|
|
588
|
+
const [deleteTarget, setDeleteTarget] = useState(null);
|
|
589
|
+
const [editTarget, setEditTarget] = useState(null);
|
|
590
|
+
const deleteMutation = useDeleteWebhookEndpoint();
|
|
591
|
+
const updateMutation = useUpdateWebhookEndpoint();
|
|
592
|
+
const handleDelete = () => {
|
|
593
|
+
if (deleteTarget) {
|
|
594
|
+
deleteMutation.mutate(deleteTarget.id);
|
|
595
|
+
setDeleteTarget(null);
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
const handleCloseDelete = () => {
|
|
599
|
+
if (!deleteMutation.isPending) {
|
|
600
|
+
setDeleteTarget(null);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
const handleToggleStatus = (endpoint) => {
|
|
604
|
+
const newStatus = endpoint.status === "active" ? "paused" : "active";
|
|
605
|
+
updateMutation.mutate({ endpointId: endpoint.id, data: { status: newStatus } });
|
|
606
|
+
};
|
|
607
|
+
if (isLoading) {
|
|
608
|
+
return /* @__PURE__ */ jsx(ListSkeleton, { rows: 3, rowHeight: 50 });
|
|
609
|
+
}
|
|
610
|
+
if (endpoints.length === 0) {
|
|
611
|
+
return /* @__PURE__ */ jsx(
|
|
612
|
+
EmptyState,
|
|
613
|
+
{
|
|
614
|
+
icon: IconWebhook,
|
|
615
|
+
title: "No webhook endpoints yet",
|
|
616
|
+
description: "Create your first webhook endpoint to let third-party apps trigger your resources"
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
621
|
+
/* @__PURE__ */ jsxs(Table, { children: [
|
|
622
|
+
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
623
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
624
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
625
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Target Resource" }),
|
|
626
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "URL" }),
|
|
627
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Last Triggered" }),
|
|
628
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Requests" }),
|
|
629
|
+
/* @__PURE__ */ jsx(Table.Th, { w: 120 })
|
|
630
|
+
] }) }),
|
|
631
|
+
/* @__PURE__ */ jsx(Table.Tbody, { children: endpoints.map((endpoint) => {
|
|
632
|
+
const webhookUrl = getWebhookUrl(apiUrl, endpoint.key);
|
|
633
|
+
const truncatedUrl = webhookUrl.length > 50 ? `...${endpoint.key.slice(-16)}` : webhookUrl;
|
|
634
|
+
const isToggling = updateMutation.isPending;
|
|
635
|
+
return /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
636
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
637
|
+
/* @__PURE__ */ jsx(IconWebhook, { size: 16, style: { opacity: 0.6 } }),
|
|
638
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
639
|
+
/* @__PURE__ */ jsx(Text, { fw: 500, children: endpoint.name }),
|
|
640
|
+
endpoint.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: endpoint.description })
|
|
641
|
+
] })
|
|
642
|
+
] }) }),
|
|
643
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { color: endpoint.status === "active" ? "teal" : "gray", variant: "light", children: endpoint.status }) }),
|
|
644
|
+
/* @__PURE__ */ jsx(Table.Td, { children: endpoint.resourceId ? /* @__PURE__ */ jsx(Code, { children: endpoint.resourceId }) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Not configured" }) }),
|
|
645
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Paper, { withBorder: true, style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
|
|
646
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", style: { userSelect: "all" }, children: truncatedUrl }),
|
|
647
|
+
/* @__PURE__ */ jsx(CopyButton, { value: webhookUrl, timeout: 2e3, children: ({ copied, copy }) => /* @__PURE__ */ jsx(Tooltip, { label: copied ? "Copied!" : "Copy URL", position: "top", children: /* @__PURE__ */ jsx(
|
|
648
|
+
ActionIcon,
|
|
649
|
+
{
|
|
650
|
+
color: copied ? "teal" : "gray",
|
|
651
|
+
variant: copied ? "filled" : "subtle",
|
|
652
|
+
onClick: copy,
|
|
653
|
+
size: "sm",
|
|
654
|
+
children: copied ? /* @__PURE__ */ jsx(IconCheck, { size: 12 }) : /* @__PURE__ */ jsx(IconCopy, { size: 12 })
|
|
655
|
+
}
|
|
656
|
+
) }) })
|
|
657
|
+
] }) }),
|
|
658
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
|
|
659
|
+
/* @__PURE__ */ jsx(IconClock, { size: 14, style: { opacity: 0.5 } }),
|
|
660
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: formatDateTime(endpoint.lastTriggeredAt) })
|
|
661
|
+
] }) }),
|
|
662
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", children: endpoint.requestCount.toLocaleString() }) }),
|
|
663
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "flex-end", children: [
|
|
664
|
+
/* @__PURE__ */ jsx(Tooltip, { label: "Edit endpoint", position: "left", children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "blue", onClick: () => setEditTarget(endpoint), children: /* @__PURE__ */ jsx(IconPencil, { size: 16 }) }) }),
|
|
665
|
+
/* @__PURE__ */ jsx(
|
|
666
|
+
Tooltip,
|
|
667
|
+
{
|
|
668
|
+
label: endpoint.status === "active" ? "Pause endpoint" : "Resume endpoint",
|
|
669
|
+
position: "left",
|
|
670
|
+
children: /* @__PURE__ */ jsx(
|
|
671
|
+
ActionIcon,
|
|
672
|
+
{
|
|
673
|
+
variant: "subtle",
|
|
674
|
+
color: endpoint.status === "active" ? "yellow" : "teal",
|
|
675
|
+
onClick: () => handleToggleStatus(endpoint),
|
|
676
|
+
disabled: isToggling,
|
|
677
|
+
children: endpoint.status === "active" ? /* @__PURE__ */ jsx(IconPlayerPause, { size: 16 }) : /* @__PURE__ */ jsx(IconPlayerPlay, { size: 16 })
|
|
678
|
+
}
|
|
679
|
+
)
|
|
680
|
+
}
|
|
681
|
+
),
|
|
682
|
+
/* @__PURE__ */ jsx(Tooltip, { label: "Delete endpoint", position: "left", children: /* @__PURE__ */ jsx(
|
|
683
|
+
ActionIcon,
|
|
684
|
+
{
|
|
685
|
+
variant: "subtle",
|
|
686
|
+
color: "red",
|
|
687
|
+
onClick: () => setDeleteTarget(endpoint),
|
|
688
|
+
disabled: deleteMutation.isPending,
|
|
689
|
+
children: /* @__PURE__ */ jsx(IconTrash, { size: 16 })
|
|
690
|
+
}
|
|
691
|
+
) })
|
|
692
|
+
] }) })
|
|
693
|
+
] }, endpoint.id);
|
|
694
|
+
}) })
|
|
695
|
+
] }),
|
|
696
|
+
/* @__PURE__ */ jsx(EditWebhookEndpointModal, { opened: !!editTarget, endpoint: editTarget, onClose: () => setEditTarget(null) }),
|
|
697
|
+
/* @__PURE__ */ jsx(CustomModal, { opened: !!deleteTarget, onClose: handleCloseDelete, size: "md", loading: deleteMutation.isPending, children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
698
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
699
|
+
/* @__PURE__ */ jsx(IconAlertTriangle, { size: 24, color: "var(--color-error)" }),
|
|
700
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Delete Webhook Endpoint" })
|
|
701
|
+
] }),
|
|
702
|
+
/* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
703
|
+
"Are you sure you want to delete",
|
|
704
|
+
" ",
|
|
705
|
+
/* @__PURE__ */ jsxs(Text, { span: true, fw: 600, children: [
|
|
706
|
+
'"',
|
|
707
|
+
deleteTarget?.name,
|
|
708
|
+
'"'
|
|
709
|
+
] }),
|
|
710
|
+
"?"
|
|
711
|
+
] }),
|
|
712
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This action cannot be undone. Any third-party apps posting to this URL will receive a 404. The URL and its key will be permanently revoked." }),
|
|
713
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "sm", children: [
|
|
714
|
+
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleCloseDelete, disabled: deleteMutation.isPending, children: "Cancel" }),
|
|
715
|
+
/* @__PURE__ */ jsx(
|
|
716
|
+
Button,
|
|
717
|
+
{
|
|
718
|
+
color: "red",
|
|
719
|
+
onClick: handleDelete,
|
|
720
|
+
loading: deleteMutation.isPending,
|
|
721
|
+
leftSection: /* @__PURE__ */ jsx(IconTrash, { size: 16 }),
|
|
722
|
+
children: "Delete Endpoint"
|
|
723
|
+
}
|
|
724
|
+
)
|
|
725
|
+
] })
|
|
726
|
+
] }) })
|
|
727
|
+
] });
|
|
728
|
+
}
|
|
729
|
+
function CreateWebhookEndpointModal({ opened, onClose, onSuccess }) {
|
|
730
|
+
const createEndpoint = useCreateWebhookEndpoint();
|
|
731
|
+
const { data: resourcesData } = useResources();
|
|
732
|
+
const resourceOptions = useMemo(() => {
|
|
733
|
+
if (!resourcesData) return [];
|
|
734
|
+
const workflowOptions = (resourcesData.workflows || []).filter((w) => w?.resourceId).map((w) => ({
|
|
735
|
+
value: w.resourceId,
|
|
736
|
+
label: `Workflow: ${w.resourceId}`
|
|
737
|
+
}));
|
|
738
|
+
const agentOptions = (resourcesData.agents || []).filter((a) => a?.resourceId).map((a) => ({
|
|
739
|
+
value: a.resourceId,
|
|
740
|
+
label: `Agent: ${a.resourceId}`
|
|
741
|
+
}));
|
|
742
|
+
return [...workflowOptions, ...agentOptions];
|
|
743
|
+
}, [resourcesData]);
|
|
744
|
+
const form = useForm({
|
|
745
|
+
initialValues: {
|
|
746
|
+
name: "",
|
|
747
|
+
resourceId: "",
|
|
748
|
+
description: ""
|
|
749
|
+
},
|
|
750
|
+
validate: {
|
|
751
|
+
name: (value) => {
|
|
752
|
+
if (!value.trim()) return "Name is required";
|
|
753
|
+
if (value.trim().length < 2) return "Name must be at least 2 characters";
|
|
754
|
+
if (value.trim().length > 100) return "Name must be less than 100 characters";
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
const handleSubmit = async (values) => {
|
|
760
|
+
try {
|
|
761
|
+
const result = await createEndpoint.mutateAsync({
|
|
762
|
+
name: values.name.trim(),
|
|
763
|
+
...values.resourceId ? { resourceId: values.resourceId } : {},
|
|
764
|
+
...values.description.trim() ? { description: values.description.trim() } : {}
|
|
765
|
+
});
|
|
766
|
+
form.reset();
|
|
767
|
+
onSuccess(result);
|
|
768
|
+
} catch (error) {
|
|
769
|
+
console.error("Failed to create webhook endpoint:", error);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const handleClose = () => {
|
|
773
|
+
if (!createEndpoint.isPending) {
|
|
774
|
+
form.reset();
|
|
775
|
+
onClose();
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
return /* @__PURE__ */ jsx(CustomModal, { opened, onClose: handleClose, size: "md", loading: createEndpoint.isPending, children: /* @__PURE__ */ jsx("form", { onSubmit: form.onSubmit(handleSubmit), children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
779
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Create Webhook Endpoint" }),
|
|
780
|
+
/* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconExclamationMark, { size: 16 }), color: "blue", children: "A unique URL will be generated that any third-party app can POST to, triggering your target resource. The URL contains a secret key \u2014 treat it like a credential." }),
|
|
781
|
+
/* @__PURE__ */ jsx(
|
|
782
|
+
TextInput,
|
|
783
|
+
{
|
|
784
|
+
label: "Name",
|
|
785
|
+
description: "A descriptive label for this endpoint",
|
|
786
|
+
placeholder: "e.g., Zapier Lead Intake, Typeform Responses",
|
|
787
|
+
leftSection: /* @__PURE__ */ jsx(IconWebhook, { size: 16 }),
|
|
788
|
+
required: true,
|
|
789
|
+
...form.getInputProps("name"),
|
|
790
|
+
disabled: createEndpoint.isPending
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ jsx(
|
|
794
|
+
Select,
|
|
795
|
+
{
|
|
796
|
+
label: "Target Resource",
|
|
797
|
+
description: "The workflow or agent to trigger on each inbound request (can be set later)",
|
|
798
|
+
placeholder: resourcesData ? "Select a workflow or agent" : "Loading resources...",
|
|
799
|
+
data: resourceOptions,
|
|
800
|
+
searchable: true,
|
|
801
|
+
clearable: true,
|
|
802
|
+
...form.getInputProps("resourceId"),
|
|
803
|
+
disabled: !resourcesData || createEndpoint.isPending
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
/* @__PURE__ */ jsx(
|
|
807
|
+
Textarea,
|
|
808
|
+
{
|
|
809
|
+
label: "Description",
|
|
810
|
+
description: "Optional notes about what this endpoint is for",
|
|
811
|
+
placeholder: "e.g., Receives new lead submissions from Zapier",
|
|
812
|
+
rows: 3,
|
|
813
|
+
...form.getInputProps("description"),
|
|
814
|
+
disabled: createEndpoint.isPending
|
|
815
|
+
}
|
|
816
|
+
),
|
|
817
|
+
createEndpoint.error && /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconExclamationMark, { size: 16 }), color: "red", children: createEndpoint.error instanceof Error ? createEndpoint.error.message : "An error occurred while creating the webhook endpoint" }),
|
|
818
|
+
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "sm", children: [
|
|
819
|
+
/* @__PURE__ */ jsx(Button, { variant: "subtle", onClick: handleClose, disabled: createEndpoint.isPending, children: "Cancel" }),
|
|
820
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", loading: createEndpoint.isPending, leftSection: /* @__PURE__ */ jsx(IconWebhook, { size: 16 }), children: "Create Endpoint" })
|
|
821
|
+
] })
|
|
822
|
+
] }) }) });
|
|
823
|
+
}
|
|
824
|
+
function getWebhookUrl2(apiUrl, key) {
|
|
825
|
+
return `${apiUrl}/api/webhooks/inbound/${key}`;
|
|
826
|
+
}
|
|
827
|
+
function WebhookEndpointSettings({ apiUrl }) {
|
|
828
|
+
const { organizationReady } = useInitialization();
|
|
829
|
+
const [showCreateModal, setShowCreateModal] = useState(false);
|
|
830
|
+
const [newEndpoint, setNewEndpoint] = useState(null);
|
|
831
|
+
const { data: endpoints = [], isLoading } = useListWebhookEndpoints();
|
|
832
|
+
if (!organizationReady) return /* @__PURE__ */ jsx(AppShellLoader, {});
|
|
833
|
+
const handleEndpointCreated = (endpoint) => {
|
|
834
|
+
setNewEndpoint(endpoint);
|
|
835
|
+
setShowCreateModal(false);
|
|
836
|
+
};
|
|
837
|
+
const activeCount = endpoints.filter((e) => e.status === "active").length;
|
|
838
|
+
const totalRequests = endpoints.reduce((sum, e) => sum + e.requestCount, 0);
|
|
839
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
840
|
+
/* @__PURE__ */ jsx(
|
|
841
|
+
PageTitleCaption,
|
|
842
|
+
{
|
|
843
|
+
title: "Webhooks",
|
|
844
|
+
caption: "Create webhook URLs that third-party apps can send data to, triggering your resources.",
|
|
845
|
+
rightSection: /* @__PURE__ */ jsx(Button, { leftSection: /* @__PURE__ */ jsx(IconPlus, { size: 16 }), onClick: () => setShowCreateModal(true), variant: "light", children: "Create Endpoint" })
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ jsxs(SimpleGrid, { cols: 2, children: [
|
|
849
|
+
/* @__PURE__ */ jsx(
|
|
850
|
+
StatCard,
|
|
851
|
+
{
|
|
852
|
+
variant: "hero",
|
|
853
|
+
icon: IconWebhook,
|
|
854
|
+
value: activeCount,
|
|
855
|
+
label: "Active Endpoints",
|
|
856
|
+
isLoading
|
|
857
|
+
}
|
|
858
|
+
),
|
|
859
|
+
/* @__PURE__ */ jsx(
|
|
860
|
+
StatCard,
|
|
861
|
+
{
|
|
862
|
+
variant: "hero",
|
|
863
|
+
icon: IconActivity,
|
|
864
|
+
value: totalRequests,
|
|
865
|
+
label: "Total Requests",
|
|
866
|
+
isLoading
|
|
867
|
+
}
|
|
868
|
+
)
|
|
869
|
+
] }),
|
|
870
|
+
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(WebhookEndpointList, { endpoints, isLoading, apiUrl }) }),
|
|
871
|
+
/* @__PURE__ */ jsx(
|
|
872
|
+
CreateWebhookEndpointModal,
|
|
873
|
+
{
|
|
874
|
+
opened: showCreateModal,
|
|
875
|
+
onClose: () => setShowCreateModal(false),
|
|
876
|
+
onSuccess: handleEndpointCreated
|
|
877
|
+
}
|
|
878
|
+
),
|
|
879
|
+
newEndpoint && /* @__PURE__ */ jsx(
|
|
880
|
+
WebhookUrlDisplayModal,
|
|
881
|
+
{
|
|
882
|
+
opened: true,
|
|
883
|
+
endpoint: newEndpoint,
|
|
884
|
+
webhookUrl: getWebhookUrl2(apiUrl, newEndpoint.key),
|
|
885
|
+
onClose: () => setNewEndpoint(null)
|
|
886
|
+
}
|
|
887
|
+
)
|
|
888
|
+
] });
|
|
889
|
+
}
|
|
890
|
+
function MemberConfigModal({ opened, onClose, member }) {
|
|
891
|
+
const [localConfig, setLocalConfig] = useState(void 0);
|
|
892
|
+
const mutation = useUpdateMemberConfig();
|
|
893
|
+
useEffect(() => {
|
|
894
|
+
if (member) {
|
|
895
|
+
setLocalConfig(member.config);
|
|
896
|
+
}
|
|
897
|
+
}, [member]);
|
|
898
|
+
useEffect(() => {
|
|
899
|
+
if (!opened) {
|
|
900
|
+
setLocalConfig(void 0);
|
|
901
|
+
}
|
|
902
|
+
}, [opened]);
|
|
903
|
+
if (!member) return null;
|
|
904
|
+
const handleSave = async () => {
|
|
905
|
+
if (!localConfig) {
|
|
906
|
+
onClose();
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
try {
|
|
910
|
+
await mutation.mutateAsync({
|
|
911
|
+
membershipId: member.id,
|
|
912
|
+
config: localConfig
|
|
913
|
+
});
|
|
914
|
+
onClose();
|
|
915
|
+
} catch {
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
const handleClose = () => {
|
|
919
|
+
if (!mutation.isPending) {
|
|
920
|
+
onClose();
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
return /* @__PURE__ */ jsx(CustomModal, { opened, onClose: handleClose, size: "md", loading: mutation.isPending, children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
924
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Configure Member Access" }),
|
|
925
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
926
|
+
/* @__PURE__ */ jsx(Text, { fw: 500, children: member.name }),
|
|
927
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", size: "sm", children: member.role })
|
|
928
|
+
] }),
|
|
929
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: member.email }),
|
|
930
|
+
/* @__PURE__ */ jsx(
|
|
931
|
+
MembershipFeaturePanel,
|
|
932
|
+
{
|
|
933
|
+
currentConfig: localConfig ?? member.config,
|
|
934
|
+
onConfigChange: (newConfig) => setLocalConfig(newConfig),
|
|
935
|
+
disabled: mutation.isPending
|
|
936
|
+
}
|
|
937
|
+
),
|
|
938
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", mt: "md", children: [
|
|
939
|
+
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleClose, disabled: mutation.isPending, children: "Cancel" }),
|
|
940
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleSave, loading: mutation.isPending, children: "Save Changes" })
|
|
941
|
+
] })
|
|
942
|
+
] }) });
|
|
943
|
+
}
|
|
944
|
+
function transformMemberForModal(member) {
|
|
945
|
+
const firstName = member.user?.firstName || "";
|
|
946
|
+
const lastName = member.user?.lastName || "";
|
|
947
|
+
const name = firstName && lastName ? `${firstName} ${lastName}` : member.user?.email || "Unknown User";
|
|
948
|
+
return {
|
|
949
|
+
id: member.id,
|
|
950
|
+
name,
|
|
951
|
+
email: member.user?.email || "Unknown",
|
|
952
|
+
role: member.role.slug,
|
|
953
|
+
config: member.config
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function OrgMembersList({ orgId }) {
|
|
957
|
+
const { data: members, isLoading, error } = useOrganizationMembers(orgId);
|
|
958
|
+
const [selectedMember, setSelectedMember] = useState(null);
|
|
959
|
+
const [modalOpened, setModalOpened] = useState(false);
|
|
960
|
+
const handleConfigClick = (member) => {
|
|
961
|
+
setSelectedMember(member);
|
|
962
|
+
setModalOpened(true);
|
|
963
|
+
};
|
|
964
|
+
const handleModalClose = () => {
|
|
965
|
+
setModalOpened(false);
|
|
966
|
+
setSelectedMember(null);
|
|
967
|
+
};
|
|
968
|
+
if (isLoading) {
|
|
969
|
+
return /* @__PURE__ */ jsx(Center, { py: "xl", children: /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "sm", children: [
|
|
970
|
+
/* @__PURE__ */ jsx(Loader, { size: "md" }),
|
|
971
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Loading members..." })
|
|
972
|
+
] }) });
|
|
973
|
+
}
|
|
974
|
+
if (error) {
|
|
975
|
+
return /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), title: "Error loading members", color: "red", variant: "light", children: error.message || "Failed to load organization members. Please try again." });
|
|
976
|
+
}
|
|
977
|
+
if (!members || members.length === 0) {
|
|
978
|
+
return /* @__PURE__ */ jsx(EmptyState, { icon: IconUsers, title: "No members found" });
|
|
979
|
+
}
|
|
980
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
981
|
+
/* @__PURE__ */ jsx(Table.ScrollContainer, { minWidth: 500, children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
982
|
+
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
983
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
984
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Email" }),
|
|
985
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Role" }),
|
|
986
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
987
|
+
/* @__PURE__ */ jsx(Table.Th, { children: "Actions" })
|
|
988
|
+
] }) }),
|
|
989
|
+
/* @__PURE__ */ jsx(Table.Tbody, { children: members.map((member) => {
|
|
990
|
+
const firstName = member.user?.firstName || "";
|
|
991
|
+
const lastName = member.user?.lastName || "";
|
|
992
|
+
const displayName = firstName && lastName ? `${firstName} ${lastName}` : member.user?.email || "Unknown User";
|
|
993
|
+
return /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
994
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { fw: 500, size: "sm", children: displayName }) }),
|
|
995
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: member.user?.email || "Unknown" }) }),
|
|
996
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { variant: "light", color: "blue", size: "sm", children: member.role.slug }) }),
|
|
997
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(MembershipStatusBadge, { status: member.status }) }),
|
|
998
|
+
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Group, { gap: "xs", children: /* @__PURE__ */ jsx(
|
|
999
|
+
ActionIcon,
|
|
1000
|
+
{
|
|
1001
|
+
variant: "light",
|
|
1002
|
+
size: "sm",
|
|
1003
|
+
color: "gray",
|
|
1004
|
+
onClick: () => handleConfigClick(member),
|
|
1005
|
+
title: "Configure member access",
|
|
1006
|
+
children: /* @__PURE__ */ jsx(IconSettings, { size: 14 })
|
|
1007
|
+
}
|
|
1008
|
+
) }) })
|
|
1009
|
+
] }, member.id);
|
|
1010
|
+
}) })
|
|
1011
|
+
] }) }),
|
|
1012
|
+
/* @__PURE__ */ jsx(
|
|
1013
|
+
MemberConfigModal,
|
|
1014
|
+
{
|
|
1015
|
+
opened: modalOpened,
|
|
1016
|
+
onClose: handleModalClose,
|
|
1017
|
+
member: selectedMember ? transformMemberForModal(selectedMember) : null
|
|
1018
|
+
}
|
|
1019
|
+
)
|
|
1020
|
+
] });
|
|
1021
|
+
}
|
|
1022
|
+
function OrganizationSettings({ user, currentMembership, isOrgAdmin }) {
|
|
1023
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1024
|
+
/* @__PURE__ */ jsx(PageTitleCaption, { title: "Organization Settings", caption: "Manage your current organization" }),
|
|
1025
|
+
currentMembership?.organization && /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
1026
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1027
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: "green", children: /* @__PURE__ */ jsx(IconBuilding, { size: 18 }) }),
|
|
1028
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: 1 }, children: [
|
|
1029
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Current Organization" }),
|
|
1030
|
+
/* @__PURE__ */ jsx(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: currentMembership.organization.name })
|
|
1031
|
+
] }),
|
|
1032
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1033
|
+
/* @__PURE__ */ jsx(Code, { children: currentMembership.organization.id }),
|
|
1034
|
+
/* @__PURE__ */ jsx(CopyButton, { value: currentMembership.organization.id, timeout: 2e3, children: ({ copied, copy }) => /* @__PURE__ */ jsx(Tooltip, { label: copied ? "Copied!" : "Copy ID", withArrow: true, position: "top", children: /* @__PURE__ */ jsx(
|
|
1035
|
+
ActionIcon,
|
|
1036
|
+
{
|
|
1037
|
+
color: copied ? "teal" : "gray",
|
|
1038
|
+
variant: copied ? "filled" : "subtle",
|
|
1039
|
+
onClick: copy,
|
|
1040
|
+
size: "sm",
|
|
1041
|
+
children: copied ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : /* @__PURE__ */ jsx(IconCopy, { size: 14 })
|
|
1042
|
+
}
|
|
1043
|
+
) }) })
|
|
1044
|
+
] })
|
|
1045
|
+
] }),
|
|
1046
|
+
user && /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1047
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: "blue", children: /* @__PURE__ */ jsx(IconUsers, { size: 18 }) }),
|
|
1048
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: 1 }, children: [
|
|
1049
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Signed in as" }),
|
|
1050
|
+
/* @__PURE__ */ jsxs(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: [
|
|
1051
|
+
user.firstName,
|
|
1052
|
+
" ",
|
|
1053
|
+
user.lastName,
|
|
1054
|
+
" \u2022 ",
|
|
1055
|
+
user.email
|
|
1056
|
+
] })
|
|
1057
|
+
] }),
|
|
1058
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1059
|
+
/* @__PURE__ */ jsx(Code, { children: currentMembership.userId }),
|
|
1060
|
+
/* @__PURE__ */ jsx(CopyButton, { value: currentMembership.userId, timeout: 2e3, children: ({ copied, copy }) => /* @__PURE__ */ jsx(Tooltip, { label: copied ? "Copied!" : "Copy User ID", withArrow: true, position: "top", children: /* @__PURE__ */ jsx(
|
|
1061
|
+
ActionIcon,
|
|
1062
|
+
{
|
|
1063
|
+
color: copied ? "teal" : "gray",
|
|
1064
|
+
variant: copied ? "filled" : "subtle",
|
|
1065
|
+
onClick: copy,
|
|
1066
|
+
size: "sm",
|
|
1067
|
+
children: copied ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : /* @__PURE__ */ jsx(IconCopy, { size: 14 })
|
|
1068
|
+
}
|
|
1069
|
+
) }) })
|
|
1070
|
+
] })
|
|
1071
|
+
] })
|
|
1072
|
+
] }) }),
|
|
1073
|
+
isOrgAdmin && currentMembership?.organization && /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
1074
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "Manage Members" }),
|
|
1075
|
+
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: "Configure feature access for organization members." }),
|
|
1076
|
+
/* @__PURE__ */ jsx(OrgMembersList, { orgId: currentMembership.organization.id })
|
|
1077
|
+
] }) })
|
|
1078
|
+
] });
|
|
1079
|
+
}
|
|
1080
|
+
function useOAuthFlow({ apiUrl }) {
|
|
1081
|
+
const [isAuthorizing, setIsAuthorizing] = useState(false);
|
|
1082
|
+
const [error, setError] = useState(null);
|
|
1083
|
+
const { organizationId, isReady } = useElevasisServices();
|
|
1084
|
+
const authorize = useCallback(
|
|
1085
|
+
async (provider, credentialName) => {
|
|
1086
|
+
if (!isReady || !organizationId) {
|
|
1087
|
+
setError("Organization context not ready");
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
setIsAuthorizing(true);
|
|
1091
|
+
setError(null);
|
|
1092
|
+
try {
|
|
1093
|
+
const authorizeUrl = new URL(`${apiUrl}/api/oauth/authorize/${provider}`);
|
|
1094
|
+
authorizeUrl.searchParams.set("credentialName", credentialName);
|
|
1095
|
+
authorizeUrl.searchParams.set("organizationId", organizationId);
|
|
1096
|
+
const width = 600;
|
|
1097
|
+
const height = 700;
|
|
1098
|
+
const left = Math.round(window.screen.width / 2 - width / 2);
|
|
1099
|
+
const top = Math.round(window.screen.height / 2 - height / 2);
|
|
1100
|
+
const popup = window.open(
|
|
1101
|
+
authorizeUrl.toString(),
|
|
1102
|
+
`oauth-${provider}`,
|
|
1103
|
+
`width=${width},height=${height},left=${left},top=${top}`
|
|
1104
|
+
);
|
|
1105
|
+
if (!popup) {
|
|
1106
|
+
throw new Error("popup_blocked");
|
|
1107
|
+
}
|
|
1108
|
+
await waitForOAuthCallback(popup);
|
|
1109
|
+
} catch (err) {
|
|
1110
|
+
const rawError = err instanceof Error ? err.message : "unknown";
|
|
1111
|
+
if (rawError.includes("popup_blocked")) {
|
|
1112
|
+
setError("Please enable popups and try again");
|
|
1113
|
+
} else if (rawError.includes("cancelled")) {
|
|
1114
|
+
setError("Authorization cancelled");
|
|
1115
|
+
} else if (rawError.includes("timeout")) {
|
|
1116
|
+
setError("Authorization timed out. Please try again.");
|
|
1117
|
+
} else if (rawError.includes("token_exchange_failed")) {
|
|
1118
|
+
setError("Failed to obtain access token. Please try again.");
|
|
1119
|
+
} else if (rawError.includes("invalid_state")) {
|
|
1120
|
+
setError("Security validation failed. Please try again.");
|
|
1121
|
+
} else if (rawError.includes("state_expired")) {
|
|
1122
|
+
setError("Authorization expired. Please try again.");
|
|
1123
|
+
} else {
|
|
1124
|
+
setError(`Failed to connect: ${rawError}`);
|
|
1125
|
+
}
|
|
1126
|
+
throw err;
|
|
1127
|
+
} finally {
|
|
1128
|
+
setIsAuthorizing(false);
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
[isReady, organizationId, apiUrl]
|
|
1132
|
+
);
|
|
1133
|
+
const waitForOAuthCallback = (popup) => {
|
|
1134
|
+
return new Promise((resolve, reject) => {
|
|
1135
|
+
const messageHandler = (event) => {
|
|
1136
|
+
const expectedOrigin = window.location.origin;
|
|
1137
|
+
if (event.origin !== expectedOrigin) {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
if (event.data.type === "oauth-complete") {
|
|
1141
|
+
cleanup();
|
|
1142
|
+
if (event.data.status === "success") {
|
|
1143
|
+
resolve();
|
|
1144
|
+
} else {
|
|
1145
|
+
reject(new Error(event.data.error || "oauth_failed"));
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
window.addEventListener("message", messageHandler);
|
|
1150
|
+
const checkClosed = setInterval(() => {
|
|
1151
|
+
if (popup.closed) {
|
|
1152
|
+
cleanup();
|
|
1153
|
+
reject(new Error("cancelled"));
|
|
1154
|
+
}
|
|
1155
|
+
}, OAUTH_POPUP_CHECK_INTERVAL);
|
|
1156
|
+
const timeout = setTimeout(() => {
|
|
1157
|
+
cleanup();
|
|
1158
|
+
popup.close();
|
|
1159
|
+
reject(new Error("timeout"));
|
|
1160
|
+
}, OAUTH_FLOW_TIMEOUT);
|
|
1161
|
+
const cleanup = () => {
|
|
1162
|
+
clearInterval(checkClosed);
|
|
1163
|
+
clearTimeout(timeout);
|
|
1164
|
+
window.removeEventListener("message", messageHandler);
|
|
1165
|
+
};
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
return { authorize, isAuthorizing, error };
|
|
1169
|
+
}
|
|
1170
|
+
function EditCredentialModal({ apiUrl, credential, onClose }) {
|
|
1171
|
+
const [credentialName, setCredentialName] = useState("");
|
|
1172
|
+
const [nameError, setNameError] = useState(null);
|
|
1173
|
+
const [fieldValues, setFieldValues] = useState({});
|
|
1174
|
+
const { authorize, isAuthorizing, error: oauthError } = useOAuthFlow({ apiUrl });
|
|
1175
|
+
const updateMutation = useUpdateCredential();
|
|
1176
|
+
useEffect(() => {
|
|
1177
|
+
if (credential) {
|
|
1178
|
+
setCredentialName(credential.name);
|
|
1179
|
+
}
|
|
1180
|
+
}, [credential]);
|
|
1181
|
+
if (!credential) return null;
|
|
1182
|
+
const credentialType = credential.type || "api-key";
|
|
1183
|
+
const schema = getCredentialSchema(credentialType);
|
|
1184
|
+
const provider = credential.provider;
|
|
1185
|
+
const isOAuth = !!provider || schema.type === "oauth";
|
|
1186
|
+
const hasMetadataChanged = credentialName !== credential.name;
|
|
1187
|
+
const isPending = isAuthorizing || updateMutation.isPending;
|
|
1188
|
+
const handleClose = () => {
|
|
1189
|
+
if (!isPending) {
|
|
1190
|
+
onClose();
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
const handleOAuthReconnect = async () => {
|
|
1194
|
+
if (!provider) return;
|
|
1195
|
+
try {
|
|
1196
|
+
await authorize(provider, credential.name);
|
|
1197
|
+
onClose();
|
|
1198
|
+
} catch (err) {
|
|
1199
|
+
console.error("Reconnect failed:", err);
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
const handleSaveChanges = async () => {
|
|
1203
|
+
const nameValidation = CredentialSchemas.UpdateRequest.shape.name.safeParse(credentialName);
|
|
1204
|
+
if (!nameValidation.success) {
|
|
1205
|
+
setNameError(nameValidation.error.issues[0]?.message || "Invalid credential name");
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
setNameError(null);
|
|
1209
|
+
const updateData = { name: credentialName };
|
|
1210
|
+
const validationResult = CredentialSchemas.UpdateRequest.safeParse(updateData);
|
|
1211
|
+
if (!validationResult.success) {
|
|
1212
|
+
console.error("Validation failed:", validationResult.error);
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
try {
|
|
1216
|
+
await updateMutation.mutateAsync({
|
|
1217
|
+
credentialId: credential.id,
|
|
1218
|
+
updates: updateData
|
|
1219
|
+
});
|
|
1220
|
+
onClose();
|
|
1221
|
+
} catch (err) {
|
|
1222
|
+
console.error("Save changes failed:", err);
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
const handleCredentialUpdate = async () => {
|
|
1226
|
+
const hasValues = Object.values(fieldValues).some((v) => v.trim());
|
|
1227
|
+
if (!hasValues) return;
|
|
1228
|
+
try {
|
|
1229
|
+
const credentialValue = buildCredentialValue(credentialType, fieldValues);
|
|
1230
|
+
const updateData = { value: credentialValue };
|
|
1231
|
+
const validationResult = CredentialSchemas.UpdateRequest.safeParse(updateData);
|
|
1232
|
+
if (!validationResult.success) {
|
|
1233
|
+
console.error("Validation failed:", validationResult.error);
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
await updateMutation.mutateAsync({
|
|
1237
|
+
credentialId: credential.id,
|
|
1238
|
+
updates: updateData
|
|
1239
|
+
});
|
|
1240
|
+
onClose();
|
|
1241
|
+
} catch (err) {
|
|
1242
|
+
console.error("Update failed:", err);
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
const handleFieldChange = (key, value) => {
|
|
1246
|
+
setFieldValues((prev) => ({ ...prev, [key]: value }));
|
|
1247
|
+
};
|
|
1248
|
+
const handleNameChange = (value) => {
|
|
1249
|
+
setCredentialName(value);
|
|
1250
|
+
if (nameError) setNameError(null);
|
|
1251
|
+
};
|
|
1252
|
+
const hasFieldValues = Object.values(fieldValues).some((v) => v.trim());
|
|
1253
|
+
return /* @__PURE__ */ jsx(CustomModal, { opened: true, onClose: handleClose, loading: isPending, children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
1254
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1255
|
+
/* @__PURE__ */ jsx(IconSettings, { size: 24 }),
|
|
1256
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: isOAuth ? "Manage OAuth Credential" : "Edit API Key" })
|
|
1257
|
+
] }),
|
|
1258
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1259
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: "Type:" }),
|
|
1260
|
+
/* @__PURE__ */ jsx(Badge, { variant: "light", size: "sm", children: schema.label })
|
|
1261
|
+
] }),
|
|
1262
|
+
/* @__PURE__ */ jsx(
|
|
1263
|
+
TextInput,
|
|
1264
|
+
{
|
|
1265
|
+
label: "Name",
|
|
1266
|
+
value: credentialName,
|
|
1267
|
+
onChange: (e) => handleNameChange(e.target.value),
|
|
1268
|
+
disabled: isPending,
|
|
1269
|
+
maxLength: 100,
|
|
1270
|
+
description: "Lowercase letters, numbers, and hyphens only (e.g., gmail-dev, notion-prod)",
|
|
1271
|
+
error: nameError
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
isOAuth && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1275
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: 'OAuth credentials are managed by the provider. You can update the name above, or click "Reconnect" to refresh your connection and update access tokens.' }),
|
|
1276
|
+
oauthError && /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "red", title: "Connection Failed", children: oauthError }),
|
|
1277
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "sm", children: [
|
|
1278
|
+
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleClose, disabled: isPending, children: "Cancel" }),
|
|
1279
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx(
|
|
1281
|
+
Button,
|
|
1282
|
+
{
|
|
1283
|
+
variant: "light",
|
|
1284
|
+
onClick: handleSaveChanges,
|
|
1285
|
+
loading: updateMutation.isPending,
|
|
1286
|
+
disabled: !hasMetadataChanged || isAuthorizing,
|
|
1287
|
+
children: "Save Changes"
|
|
1288
|
+
}
|
|
1289
|
+
),
|
|
1290
|
+
/* @__PURE__ */ jsx(
|
|
1291
|
+
Button,
|
|
1292
|
+
{
|
|
1293
|
+
color: "blue",
|
|
1294
|
+
onClick: handleOAuthReconnect,
|
|
1295
|
+
loading: isAuthorizing,
|
|
1296
|
+
leftSection: /* @__PURE__ */ jsx(IconRefresh, { size: 16 }),
|
|
1297
|
+
disabled: updateMutation.isPending,
|
|
1298
|
+
children: "Reconnect OAuth"
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
] })
|
|
1302
|
+
] })
|
|
1303
|
+
] }),
|
|
1304
|
+
!isOAuth && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1305
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Current values are encrypted and cannot be displayed. Enter new values below to replace them." }),
|
|
1306
|
+
schema.fields?.map((field) => /* @__PURE__ */ jsx(
|
|
1307
|
+
PasswordInput,
|
|
1308
|
+
{
|
|
1309
|
+
label: `New ${field.label}`,
|
|
1310
|
+
placeholder: field.placeholder || `Enter new ${field.label.toLowerCase()}`,
|
|
1311
|
+
value: fieldValues[field.key] || "",
|
|
1312
|
+
onChange: (e) => handleFieldChange(field.key, e.target.value),
|
|
1313
|
+
description: field.description,
|
|
1314
|
+
disabled: isPending
|
|
1315
|
+
},
|
|
1316
|
+
field.key
|
|
1317
|
+
)),
|
|
1318
|
+
updateMutation.error && /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "red", title: "Update Failed", children: "Failed to update credential" }),
|
|
1319
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "sm", children: [
|
|
1320
|
+
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: handleClose, disabled: isPending, children: "Cancel" }),
|
|
1321
|
+
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1322
|
+
/* @__PURE__ */ jsx(
|
|
1323
|
+
Button,
|
|
1324
|
+
{
|
|
1325
|
+
variant: "light",
|
|
1326
|
+
onClick: handleSaveChanges,
|
|
1327
|
+
loading: updateMutation.isPending,
|
|
1328
|
+
disabled: !hasMetadataChanged,
|
|
1329
|
+
children: "Save Name"
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
/* @__PURE__ */ jsx(Button, { onClick: handleCredentialUpdate, loading: updateMutation.isPending, disabled: !hasFieldValues, children: "Save Credential" })
|
|
1333
|
+
] })
|
|
1334
|
+
] })
|
|
1335
|
+
] })
|
|
1336
|
+
] }) });
|
|
1337
|
+
}
|
|
1338
|
+
var PROVIDER_ICONS = {
|
|
1339
|
+
slack: IconBrandSlack,
|
|
1340
|
+
attio: IconPlug,
|
|
1341
|
+
// Attio doesn't have a brand icon
|
|
1342
|
+
"google-sheets": IconBrandGoogleDrive,
|
|
1343
|
+
gmail: IconBrandGmail,
|
|
1344
|
+
github: IconBrandGithub,
|
|
1345
|
+
linear: IconRocket,
|
|
1346
|
+
dropbox: IconBrandDropbox
|
|
1347
|
+
};
|
|
1348
|
+
var MOCK_PROVIDERS = [
|
|
1349
|
+
{ id: "google-sheets", name: "Google Sheets", available: false },
|
|
1350
|
+
{ id: "gmail", name: "Gmail", available: false },
|
|
1351
|
+
{ id: "github", name: "GitHub", available: false },
|
|
1352
|
+
{ id: "linear", name: "Linear", available: false }
|
|
1353
|
+
];
|
|
1354
|
+
function OAuthIntegrationsCard({ apiUrl }) {
|
|
1355
|
+
const [selectedProviderId, setSelectedProviderId] = useState(null);
|
|
1356
|
+
const [modalOpened, setModalOpened] = useState(false);
|
|
1357
|
+
const { authorize, isAuthorizing, error } = useOAuthFlow({ apiUrl });
|
|
1358
|
+
const queryClient = useQueryClient();
|
|
1359
|
+
const handleConnect = async (credentialName) => {
|
|
1360
|
+
if (!selectedProviderId) return;
|
|
1361
|
+
try {
|
|
1362
|
+
await authorize(selectedProviderId, credentialName);
|
|
1363
|
+
setModalOpened(false);
|
|
1364
|
+
setSelectedProviderId(null);
|
|
1365
|
+
queryClient.invalidateQueries({ queryKey: ["credentials"] });
|
|
1366
|
+
} catch (err) {
|
|
1367
|
+
console.error("OAuth flow failed:", err);
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
const handleOpenModal = (providerId) => {
|
|
1371
|
+
setSelectedProviderId(providerId);
|
|
1372
|
+
setModalOpened(true);
|
|
1373
|
+
};
|
|
1374
|
+
const realProviders = Object.values(OAUTH_PROVIDERS).map((p) => ({
|
|
1375
|
+
...p,
|
|
1376
|
+
available: true
|
|
1377
|
+
}));
|
|
1378
|
+
const allProviders = [...realProviders, ...MOCK_PROVIDERS];
|
|
1379
|
+
const selectedProvider = selectedProviderId ? OAUTH_PROVIDERS[selectedProviderId] : null;
|
|
1380
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1381
|
+
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
1382
|
+
/* @__PURE__ */ jsx(Group, { justify: "space-between", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
1383
|
+
/* @__PURE__ */ jsx(Title, { order: 3, children: "OAuth Integrations" }),
|
|
1384
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", mt: 4, children: "Connect third-party services using OAuth 2.0" })
|
|
1385
|
+
] }) }),
|
|
1386
|
+
/* @__PURE__ */ jsx(SimpleGrid, { cols: { base: 1, sm: 2, md: 3 }, children: allProviders.map((provider) => {
|
|
1387
|
+
const Icon = PROVIDER_ICONS[provider.id] || IconPlug;
|
|
1388
|
+
return /* @__PURE__ */ jsx(
|
|
1389
|
+
Card,
|
|
1390
|
+
{
|
|
1391
|
+
withBorder: true,
|
|
1392
|
+
style: {
|
|
1393
|
+
opacity: provider.available ? 1 : 0.6
|
|
1394
|
+
},
|
|
1395
|
+
children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
1396
|
+
/* @__PURE__ */ jsx(Group, { justify: "space-between", align: "flex-start", children: /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1397
|
+
/* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: provider.available ? "blue" : "gray", children: /* @__PURE__ */ jsx(Icon, { size: 20 }) }),
|
|
1398
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1399
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: provider.name }),
|
|
1400
|
+
!provider.available && /* @__PURE__ */ jsx(Badge, { color: "gray", variant: "light", size: "xs", mt: 4, children: "Coming Soon" })
|
|
1401
|
+
] })
|
|
1402
|
+
] }) }),
|
|
1403
|
+
/* @__PURE__ */ jsx(
|
|
1404
|
+
Button,
|
|
1405
|
+
{
|
|
1406
|
+
variant: "filled",
|
|
1407
|
+
size: "sm",
|
|
1408
|
+
onClick: () => handleOpenModal(provider.id),
|
|
1409
|
+
disabled: !provider.available,
|
|
1410
|
+
fullWidth: true,
|
|
1411
|
+
children: "Connect"
|
|
1412
|
+
}
|
|
1413
|
+
)
|
|
1414
|
+
] })
|
|
1415
|
+
},
|
|
1416
|
+
provider.id
|
|
1417
|
+
);
|
|
1418
|
+
}) })
|
|
1419
|
+
] }) }),
|
|
1420
|
+
/* @__PURE__ */ jsx(
|
|
1421
|
+
OAuthConnectModal,
|
|
1422
|
+
{
|
|
1423
|
+
opened: modalOpened,
|
|
1424
|
+
onClose: () => {
|
|
1425
|
+
setModalOpened(false);
|
|
1426
|
+
setSelectedProviderId(null);
|
|
1427
|
+
},
|
|
1428
|
+
provider: selectedProvider,
|
|
1429
|
+
onConnect: handleConnect,
|
|
1430
|
+
error,
|
|
1431
|
+
isLoading: isAuthorizing
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1434
|
+
] });
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
export { AccountSettings, AppearanceSettings, CreateWebhookEndpointModal, EditCredentialModal, EditWebhookEndpointModal, MemberConfigModal, OAuthIntegrationsCard, OrgMembersList, OrganizationSettings, WebhookEndpointList, WebhookEndpointSettings };
|