@langwatch/server 3.1.0-beta.3 → 3.1.0-beta.5
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/langwatch/ee/admin/ImpersonationBanner.tsx +61 -0
- package/langwatch/ee/admin/ImpersonationSwitchBackMenuItem.tsx +30 -0
- package/langwatch/ee/admin/__tests__/ImpersonationBanner.integration.test.tsx +82 -0
- package/langwatch/ee/admin/__tests__/impersonation.service.unit.test.ts +231 -0
- package/langwatch/ee/admin/backoffice/BackofficeTable.tsx +200 -0
- package/langwatch/ee/admin/backoffice/__tests__/adminClient.unit.test.ts +147 -0
- package/langwatch/ee/admin/backoffice/__tests__/dateInputToISO.unit.test.ts +42 -0
- package/langwatch/ee/admin/backoffice/__tests__/userVisibility.unit.test.ts +174 -0
- package/langwatch/ee/admin/backoffice/adminClient.ts +114 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationFeaturesView.tsx +373 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationsView.tsx +677 -0
- package/langwatch/ee/admin/backoffice/resources/ProjectsView.tsx +647 -0
- package/langwatch/ee/admin/backoffice/resources/SubscriptionsView.tsx +628 -0
- package/langwatch/ee/admin/backoffice/resources/UsersView.tsx +556 -0
- package/langwatch/ee/admin/backoffice/useAdminResource.ts +104 -0
- package/langwatch/ee/admin/backoffice/userVisibility.ts +105 -0
- package/langwatch/ee/admin/impersonation.service.ts +170 -0
- package/langwatch/ee/admin/isAdmin.ts +9 -0
- package/langwatch/ee/admin/routes/admin.ts +531 -0
- package/langwatch/ee/admin/safeSelects.ts +64 -0
- package/langwatch/ee/billing/__tests__/customerService.unit.test.ts +183 -0
- package/langwatch/ee/billing/__tests__/growthSeatEvent.unit.test.ts +213 -0
- package/langwatch/ee/billing/__tests__/licensePurchaseHandler.unit.test.ts +250 -0
- package/langwatch/ee/billing/__tests__/notification.service.unit.test.ts +768 -0
- package/langwatch/ee/billing/__tests__/planLimits.unit.test.ts +19 -0
- package/langwatch/ee/billing/__tests__/planProvider.unit.test.ts +440 -0
- package/langwatch/ee/billing/__tests__/planTypes.unit.test.ts +32 -0
- package/langwatch/ee/billing/__tests__/pricing.unit.test.ts +54 -0
- package/langwatch/ee/billing/__tests__/seatEventSubscription.unit.test.ts +717 -0
- package/langwatch/ee/billing/__tests__/stripe.integration.test.ts +344 -0
- package/langwatch/ee/billing/__tests__/stripePrices.types.unit.test.ts +27 -0
- package/langwatch/ee/billing/__tests__/stripePricesLoader.unit.test.ts +72 -0
- package/langwatch/ee/billing/__tests__/subscription.service.unit.test.ts +730 -0
- package/langwatch/ee/billing/__tests__/subscriptionItemCalculator.unit.test.ts +176 -0
- package/langwatch/ee/billing/__tests__/usage-limit.service.unit.test.ts +706 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.integration.test.ts +421 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.unit.test.ts +515 -0
- package/langwatch/ee/billing/__tests__/webhookService.unit.test.ts +958 -0
- package/langwatch/ee/billing/currencyRouter.ts +18 -0
- package/langwatch/ee/billing/errors.ts +129 -0
- package/langwatch/ee/billing/index.ts +67 -0
- package/langwatch/ee/billing/middleware.ts +17 -0
- package/langwatch/ee/billing/notifications/notification.service.ts +651 -0
- package/langwatch/ee/billing/notifications/repositories/notification.repository.ts +51 -0
- package/langwatch/ee/billing/notifications/types.ts +9 -0
- package/langwatch/ee/billing/notifications/usage-limit.service.ts +622 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.ts +90 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.unit.test.ts +237 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.ts +120 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.unit.test.ts +324 -0
- package/langwatch/ee/billing/nurturing/hooks/index.ts +17 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.ts +68 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.unit.test.ts +138 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.integration.test.ts +288 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.ts +131 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.unit.test.ts +134 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.ts +101 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.unit.test.ts +317 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.ts +49 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.unit.test.ts +170 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.ts +143 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.unit.test.ts +307 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.ts +179 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.unit.test.ts +266 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.wiring.unit.test.ts +109 -0
- package/langwatch/ee/billing/nurturing/types.ts +125 -0
- package/langwatch/ee/billing/planLimits.ts +190 -0
- package/langwatch/ee/billing/planProvider.ts +119 -0
- package/langwatch/ee/billing/planTypes.ts +53 -0
- package/langwatch/ee/billing/pricing.ts +57 -0
- package/langwatch/ee/billing/services/billableEventsQuery.ts +248 -0
- package/langwatch/ee/billing/services/customerService.ts +90 -0
- package/langwatch/ee/billing/services/licensePurchaseHandler.ts +73 -0
- package/langwatch/ee/billing/services/seatEventSubscription.ts +351 -0
- package/langwatch/ee/billing/services/seatSyncService.ts +34 -0
- package/langwatch/ee/billing/services/subscription.repository.ts +203 -0
- package/langwatch/ee/billing/services/subscription.service.ts +549 -0
- package/langwatch/ee/billing/services/subscriptionItemCalculator.ts +249 -0
- package/langwatch/ee/billing/services/usageReportingService.ts +301 -0
- package/langwatch/ee/billing/services/webhookService.ts +858 -0
- package/langwatch/ee/billing/stripe/stripeCatalog.json +1781 -0
- package/langwatch/ee/billing/stripe/stripeClient.ts +13 -0
- package/langwatch/ee/billing/stripe/stripePriceCatalog.ts +70 -0
- package/langwatch/ee/billing/stripe/stripePrices.types.ts +118 -0
- package/langwatch/ee/billing/subscriptionRouter.ts +202 -0
- package/langwatch/ee/billing/types.ts +102 -0
- package/langwatch/ee/billing/utils/currency.ts +99 -0
- package/langwatch/ee/billing/utils/growthSeatEvent.ts +137 -0
- package/langwatch/ee/licensing/__tests__/constants.unit.test.ts +56 -0
- package/langwatch/ee/licensing/__tests__/defaults.unit.test.ts +192 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testKeys.ts +86 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testLicenses.ts +92 -0
- package/langwatch/ee/licensing/__tests__/licenseGenerationService.unit.test.ts +232 -0
- package/langwatch/ee/licensing/__tests__/licenseHandler.integration.test.ts +419 -0
- package/langwatch/ee/licensing/__tests__/planMapping.unit.test.ts +195 -0
- package/langwatch/ee/licensing/__tests__/planTemplates.unit.test.ts +193 -0
- package/langwatch/ee/licensing/__tests__/signing.unit.test.ts +164 -0
- package/langwatch/ee/licensing/__tests__/validation.unit.test.ts +281 -0
- package/langwatch/ee/licensing/client.ts +29 -0
- package/langwatch/ee/licensing/constants.ts +195 -0
- package/langwatch/ee/licensing/defaults.ts +55 -0
- package/langwatch/ee/licensing/errors.ts +11 -0
- package/langwatch/ee/licensing/index.ts +52 -0
- package/langwatch/ee/licensing/licenseGenerationService.ts +87 -0
- package/langwatch/ee/licensing/licenseHandler.ts +308 -0
- package/langwatch/ee/licensing/planInfo.ts +46 -0
- package/langwatch/ee/licensing/planMapping.ts +37 -0
- package/langwatch/ee/licensing/planTemplates.ts +109 -0
- package/langwatch/ee/licensing/server.ts +43 -0
- package/langwatch/ee/licensing/signing.ts +43 -0
- package/langwatch/ee/licensing/types.ts +156 -0
- package/langwatch/ee/licensing/validation.ts +107 -0
- package/langwatch/ee/managed-providers/ManagedModelProviderAlert.tsx +29 -0
- package/langwatch/ee/managed-providers/managedBedrockConfig.ts +226 -0
- package/langwatch/ee/saas/ExtraFooterComponents.tsx +169 -0
- package/langwatch/package.json +1 -1
- package/langwatch_nlp/uv.lock +179 -5
- package/package.json +1 -1
- package/packages/server/dist/cli.cjs +192 -142
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Button,
|
|
4
|
+
Field,
|
|
5
|
+
HStack,
|
|
6
|
+
Input,
|
|
7
|
+
NativeSelect,
|
|
8
|
+
Spacer,
|
|
9
|
+
Table,
|
|
10
|
+
Text,
|
|
11
|
+
VStack,
|
|
12
|
+
} from "@chakra-ui/react";
|
|
13
|
+
import { MoreVertical, Pencil } from "lucide-react";
|
|
14
|
+
import { useEffect, useMemo, useState } from "react";
|
|
15
|
+
import { useDebounce } from "use-debounce";
|
|
16
|
+
import { Drawer } from "~/components/ui/drawer";
|
|
17
|
+
import { Menu } from "~/components/ui/menu";
|
|
18
|
+
import { toaster } from "~/components/ui/toaster";
|
|
19
|
+
import {
|
|
20
|
+
BackofficeTable,
|
|
21
|
+
EmptyCell,
|
|
22
|
+
dateInputToISO,
|
|
23
|
+
formatDate,
|
|
24
|
+
} from "../BackofficeTable";
|
|
25
|
+
import {
|
|
26
|
+
useAdminCreate,
|
|
27
|
+
useAdminList,
|
|
28
|
+
useAdminUpdate,
|
|
29
|
+
} from "../useAdminResource";
|
|
30
|
+
|
|
31
|
+
interface AdminOrgFeature {
|
|
32
|
+
id: string;
|
|
33
|
+
feature: string;
|
|
34
|
+
organizationId: string;
|
|
35
|
+
trialEndDate: string | null;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
organization?: { id: string; name: string; slug: string };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface OrgOption {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const PAGE_SIZE = 25;
|
|
47
|
+
|
|
48
|
+
export default function OrganizationFeaturesView() {
|
|
49
|
+
const [page, setPage] = useState(1);
|
|
50
|
+
const [search, setSearch] = useState("");
|
|
51
|
+
const [debouncedSearch] = useDebounce(search, 300);
|
|
52
|
+
const [editing, setEditing] = useState<AdminOrgFeature | null>(null);
|
|
53
|
+
const [creating, setCreating] = useState(false);
|
|
54
|
+
|
|
55
|
+
const list = useAdminList<AdminOrgFeature>("organizationFeature", {
|
|
56
|
+
pagination: { page, perPage: PAGE_SIZE },
|
|
57
|
+
sort: { field: "createdAt", order: "DESC" },
|
|
58
|
+
filter: debouncedSearch ? { query: debouncedSearch } : {},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// The server's defaultHandler for organizationFeature getList doesn't
|
|
62
|
+
// include the organization relation, so rows arrive with a raw
|
|
63
|
+
// organizationId only. Resolve names client-side by fetching the org
|
|
64
|
+
// directory (first page of 200 is plenty for the small admin-facing
|
|
65
|
+
// tenant count) and mapping id → name. Rows whose org isn't in the
|
|
66
|
+
// map gracefully fall back to the raw ID.
|
|
67
|
+
const orgDirectory = useAdminList<OrgOption>("organization", {
|
|
68
|
+
pagination: { page: 1, perPage: 200 },
|
|
69
|
+
sort: { field: "name", order: "ASC" },
|
|
70
|
+
filter: {},
|
|
71
|
+
});
|
|
72
|
+
const orgNameById = useMemo(() => {
|
|
73
|
+
const map = new Map<string, string>();
|
|
74
|
+
for (const org of orgDirectory.data?.data ?? []) map.set(org.id, org.name);
|
|
75
|
+
return map;
|
|
76
|
+
}, [orgDirectory.data]);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<BackofficeTable
|
|
81
|
+
title="Organization Features"
|
|
82
|
+
searchValue={search}
|
|
83
|
+
onSearchChange={(v) => {
|
|
84
|
+
setSearch(v);
|
|
85
|
+
setPage(1);
|
|
86
|
+
}}
|
|
87
|
+
searchPlaceholder="Search by ID, feature, or organization"
|
|
88
|
+
isLoading={list.isLoading}
|
|
89
|
+
isFetching={list.isFetching}
|
|
90
|
+
error={list.error}
|
|
91
|
+
pagination={{
|
|
92
|
+
page,
|
|
93
|
+
perPage: PAGE_SIZE,
|
|
94
|
+
total: list.data?.total ?? 0,
|
|
95
|
+
onPageChange: setPage,
|
|
96
|
+
}}
|
|
97
|
+
onCreate={() => setCreating(true)}
|
|
98
|
+
createLabel="Grant feature"
|
|
99
|
+
>
|
|
100
|
+
<Table.Root variant="line" size="md" width="full">
|
|
101
|
+
<Table.Header>
|
|
102
|
+
<Table.Row>
|
|
103
|
+
<Table.ColumnHeader>Feature</Table.ColumnHeader>
|
|
104
|
+
<Table.ColumnHeader>Organization</Table.ColumnHeader>
|
|
105
|
+
<Table.ColumnHeader>Trial ends</Table.ColumnHeader>
|
|
106
|
+
<Table.ColumnHeader>Created</Table.ColumnHeader>
|
|
107
|
+
<Table.ColumnHeader width="60px" textAlign="right" />
|
|
108
|
+
</Table.Row>
|
|
109
|
+
</Table.Header>
|
|
110
|
+
<Table.Body>
|
|
111
|
+
{list.data?.data.length === 0 && (
|
|
112
|
+
<Table.Row>
|
|
113
|
+
<Table.Cell colSpan={5}>
|
|
114
|
+
<Text color="fg.muted" textAlign="center" paddingY={6}>
|
|
115
|
+
No organization features yet.
|
|
116
|
+
</Text>
|
|
117
|
+
</Table.Cell>
|
|
118
|
+
</Table.Row>
|
|
119
|
+
)}
|
|
120
|
+
{list.data?.data.map((item) => {
|
|
121
|
+
const orgName =
|
|
122
|
+
item.organization?.name ?? orgNameById.get(item.organizationId);
|
|
123
|
+
return (
|
|
124
|
+
<Table.Row key={item.id}>
|
|
125
|
+
<Table.Cell>{item.feature}</Table.Cell>
|
|
126
|
+
<Table.Cell>
|
|
127
|
+
{orgName ?? (
|
|
128
|
+
<Text fontSize="xs" color="fg.muted">
|
|
129
|
+
{item.organizationId}
|
|
130
|
+
</Text>
|
|
131
|
+
)}
|
|
132
|
+
</Table.Cell>
|
|
133
|
+
<Table.Cell>
|
|
134
|
+
{item.trialEndDate ? (
|
|
135
|
+
formatDate(item.trialEndDate)
|
|
136
|
+
) : (
|
|
137
|
+
<EmptyCell>Permanent</EmptyCell>
|
|
138
|
+
)}
|
|
139
|
+
</Table.Cell>
|
|
140
|
+
<Table.Cell>{formatDate(item.createdAt)}</Table.Cell>
|
|
141
|
+
<Table.Cell textAlign="right">
|
|
142
|
+
<Box
|
|
143
|
+
width="full"
|
|
144
|
+
height="full"
|
|
145
|
+
display="flex"
|
|
146
|
+
justifyContent="end"
|
|
147
|
+
>
|
|
148
|
+
<Menu.Root>
|
|
149
|
+
<Menu.Trigger>
|
|
150
|
+
<MoreVertical size={16} />
|
|
151
|
+
</Menu.Trigger>
|
|
152
|
+
<Menu.Content>
|
|
153
|
+
<Menu.Item
|
|
154
|
+
value="edit"
|
|
155
|
+
onClick={() => setEditing(item)}
|
|
156
|
+
>
|
|
157
|
+
<Pencil size={16} />
|
|
158
|
+
Edit
|
|
159
|
+
</Menu.Item>
|
|
160
|
+
</Menu.Content>
|
|
161
|
+
</Menu.Root>
|
|
162
|
+
</Box>
|
|
163
|
+
</Table.Cell>
|
|
164
|
+
</Table.Row>
|
|
165
|
+
);
|
|
166
|
+
})}
|
|
167
|
+
</Table.Body>
|
|
168
|
+
</Table.Root>
|
|
169
|
+
</BackofficeTable>
|
|
170
|
+
|
|
171
|
+
<OrgFeatureDrawer
|
|
172
|
+
mode="edit"
|
|
173
|
+
item={editing}
|
|
174
|
+
onClose={() => setEditing(null)}
|
|
175
|
+
/>
|
|
176
|
+
<OrgFeatureDrawer
|
|
177
|
+
mode="create"
|
|
178
|
+
item={creating ? null : undefined}
|
|
179
|
+
onClose={() => setCreating(false)}
|
|
180
|
+
/>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function toDateInputValue(value: string | null | undefined): string {
|
|
186
|
+
if (!value) return "";
|
|
187
|
+
const d = new Date(value);
|
|
188
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
189
|
+
return d.toISOString().slice(0, 10);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function OrgFeatureDrawer({
|
|
193
|
+
mode,
|
|
194
|
+
item,
|
|
195
|
+
onClose,
|
|
196
|
+
}: {
|
|
197
|
+
mode: "create" | "edit";
|
|
198
|
+
item: AdminOrgFeature | null | undefined;
|
|
199
|
+
onClose: () => void;
|
|
200
|
+
}) {
|
|
201
|
+
const update = useAdminUpdate<AdminOrgFeature>("organizationFeature");
|
|
202
|
+
const create = useAdminCreate<AdminOrgFeature>("organizationFeature");
|
|
203
|
+
const mutation = mode === "edit" ? update : create;
|
|
204
|
+
|
|
205
|
+
const [feature, setFeature] = useState("");
|
|
206
|
+
const [organizationId, setOrganizationId] = useState("");
|
|
207
|
+
const [trialEndDate, setTrialEndDate] = useState("");
|
|
208
|
+
const [orgQuery, setOrgQuery] = useState("");
|
|
209
|
+
const [debouncedOrgQuery] = useDebounce(orgQuery, 250);
|
|
210
|
+
|
|
211
|
+
const isOpen = mode === "edit" ? !!item : item !== undefined;
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (!isOpen) return;
|
|
215
|
+
if (mode === "edit" && item) {
|
|
216
|
+
setFeature(item.feature);
|
|
217
|
+
setOrganizationId(item.organizationId);
|
|
218
|
+
setTrialEndDate(toDateInputValue(item.trialEndDate));
|
|
219
|
+
} else if (mode === "create") {
|
|
220
|
+
setFeature("");
|
|
221
|
+
setOrganizationId("");
|
|
222
|
+
setTrialEndDate("");
|
|
223
|
+
setOrgQuery("");
|
|
224
|
+
}
|
|
225
|
+
}, [isOpen, mode, item]);
|
|
226
|
+
|
|
227
|
+
const orgList = useAdminList<OrgOption>(
|
|
228
|
+
"organization",
|
|
229
|
+
{
|
|
230
|
+
pagination: { page: 1, perPage: 50 },
|
|
231
|
+
sort: { field: "name", order: "ASC" },
|
|
232
|
+
filter: debouncedOrgQuery ? { query: debouncedOrgQuery } : {},
|
|
233
|
+
},
|
|
234
|
+
{ enabled: isOpen },
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const orgOptions = useMemo(() => orgList.data?.data ?? [], [orgList.data]);
|
|
238
|
+
|
|
239
|
+
const handleSave = () => {
|
|
240
|
+
if (!feature.trim()) {
|
|
241
|
+
toaster.create({
|
|
242
|
+
title: "Feature is required",
|
|
243
|
+
type: "error",
|
|
244
|
+
duration: 3000,
|
|
245
|
+
meta: { closable: true },
|
|
246
|
+
});
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (!organizationId) {
|
|
250
|
+
toaster.create({
|
|
251
|
+
title: "Organization is required",
|
|
252
|
+
type: "error",
|
|
253
|
+
duration: 3000,
|
|
254
|
+
meta: { closable: true },
|
|
255
|
+
});
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const payload: Record<string, unknown> = {
|
|
259
|
+
feature: feature.trim(),
|
|
260
|
+
organizationId,
|
|
261
|
+
trialEndDate: dateInputToISO(trialEndDate),
|
|
262
|
+
};
|
|
263
|
+
const onSuccess = () => {
|
|
264
|
+
toaster.create({
|
|
265
|
+
title:
|
|
266
|
+
mode === "edit"
|
|
267
|
+
? "Feature updated"
|
|
268
|
+
: "Feature granted",
|
|
269
|
+
type: "success",
|
|
270
|
+
duration: 3000,
|
|
271
|
+
meta: { closable: true },
|
|
272
|
+
});
|
|
273
|
+
onClose();
|
|
274
|
+
};
|
|
275
|
+
const onError = (err: Error) =>
|
|
276
|
+
toaster.create({
|
|
277
|
+
title: mode === "edit" ? "Update failed" : "Grant failed",
|
|
278
|
+
description: err.message,
|
|
279
|
+
type: "error",
|
|
280
|
+
duration: 5000,
|
|
281
|
+
meta: { closable: true },
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (mode === "edit" && item) {
|
|
285
|
+
update.mutate({ id: item.id, data: payload }, { onSuccess, onError });
|
|
286
|
+
} else {
|
|
287
|
+
create.mutate(payload, { onSuccess, onError });
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const title = mode === "edit" ? "Edit Organization Feature" : "Grant Feature";
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<Drawer.Root
|
|
295
|
+
open={isOpen}
|
|
296
|
+
onOpenChange={({ open }) => {
|
|
297
|
+
if (!open) onClose();
|
|
298
|
+
}}
|
|
299
|
+
size="md"
|
|
300
|
+
>
|
|
301
|
+
<Drawer.Content>
|
|
302
|
+
<Drawer.Header>
|
|
303
|
+
<Drawer.Title>{title}</Drawer.Title>
|
|
304
|
+
</Drawer.Header>
|
|
305
|
+
<Drawer.CloseTrigger />
|
|
306
|
+
<Drawer.Body>
|
|
307
|
+
<VStack gap={4} align="stretch">
|
|
308
|
+
<Field.Root required>
|
|
309
|
+
<Field.Label>Feature</Field.Label>
|
|
310
|
+
<Input
|
|
311
|
+
value={feature}
|
|
312
|
+
onChange={(e) => setFeature(e.target.value)}
|
|
313
|
+
placeholder="e.g. CUSTOM_EMBEDDINGS"
|
|
314
|
+
/>
|
|
315
|
+
<Field.HelperText>
|
|
316
|
+
Free-form feature key consumed by the entitlement checker.
|
|
317
|
+
</Field.HelperText>
|
|
318
|
+
</Field.Root>
|
|
319
|
+
<Field.Root required>
|
|
320
|
+
<Field.Label>Organization</Field.Label>
|
|
321
|
+
{mode === "edit" && item?.organization?.name && !orgQuery && (
|
|
322
|
+
<Text fontSize="xs" color="fg.muted">
|
|
323
|
+
Currently: {item.organization.name}
|
|
324
|
+
</Text>
|
|
325
|
+
)}
|
|
326
|
+
<Input
|
|
327
|
+
placeholder="Type to search organizations"
|
|
328
|
+
value={orgQuery}
|
|
329
|
+
onChange={(e) => setOrgQuery(e.target.value)}
|
|
330
|
+
/>
|
|
331
|
+
<NativeSelect.Root size="sm" width="full" mt={1}>
|
|
332
|
+
<NativeSelect.Field
|
|
333
|
+
value={organizationId}
|
|
334
|
+
onChange={(e) => setOrganizationId(e.target.value)}
|
|
335
|
+
>
|
|
336
|
+
<option value="">Select organization…</option>
|
|
337
|
+
{orgOptions.map((org) => (
|
|
338
|
+
<option key={org.id} value={org.id}>
|
|
339
|
+
{org.name} ({org.slug})
|
|
340
|
+
</option>
|
|
341
|
+
))}
|
|
342
|
+
</NativeSelect.Field>
|
|
343
|
+
<NativeSelect.Indicator />
|
|
344
|
+
</NativeSelect.Root>
|
|
345
|
+
</Field.Root>
|
|
346
|
+
<Field.Root>
|
|
347
|
+
<Field.Label>Trial end date</Field.Label>
|
|
348
|
+
<Input
|
|
349
|
+
type="date"
|
|
350
|
+
value={trialEndDate}
|
|
351
|
+
onChange={(e) => setTrialEndDate(e.target.value)}
|
|
352
|
+
/>
|
|
353
|
+
<Field.HelperText>
|
|
354
|
+
Leave empty to grant the feature permanently.
|
|
355
|
+
</Field.HelperText>
|
|
356
|
+
</Field.Root>
|
|
357
|
+
</VStack>
|
|
358
|
+
</Drawer.Body>
|
|
359
|
+
<Drawer.Footer>
|
|
360
|
+
<HStack width="full">
|
|
361
|
+
<Spacer />
|
|
362
|
+
<Button variant="ghost" onClick={onClose}>
|
|
363
|
+
Cancel
|
|
364
|
+
</Button>
|
|
365
|
+
<Button loading={mutation.isPending} onClick={handleSave}>
|
|
366
|
+
{mode === "edit" ? "Save" : "Grant"}
|
|
367
|
+
</Button>
|
|
368
|
+
</HStack>
|
|
369
|
+
</Drawer.Footer>
|
|
370
|
+
</Drawer.Content>
|
|
371
|
+
</Drawer.Root>
|
|
372
|
+
);
|
|
373
|
+
}
|