@mercurjs/admin 2.3.1 → 2.3.2-canary.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.
Files changed (62) hide show
  1. package/dist/{add-campaign-promotions-S4HKMFU7.js → add-campaign-promotions-NZ62V2LH.js} +3 -3
  2. package/dist/{adjust-inventory-CFQ6LD2U.js → adjust-inventory-BBAU3NMM.js} +1 -1
  3. package/dist/{campaign-detail-WPTZDDD5.js → campaign-detail-KZWQLIS5.js} +4 -4
  4. package/dist/{chunk-7PGZV6DQ.js → chunk-3W4T2KGY.js} +1 -1
  5. package/dist/{chunk-VKVK5D2F.js → chunk-4KULFU3V.js} +1 -1
  6. package/dist/{chunk-NKZLCOFU.js → chunk-ADI5XIXM.js} +1 -1
  7. package/dist/{chunk-6ZVRNI5K.js → chunk-AV6HBMRX.js} +1 -1
  8. package/dist/{chunk-7ZY7R6PG.js → chunk-GYHF5XBU.js} +1 -1
  9. package/dist/{chunk-H7HNJFQA.js → chunk-MIVPIACG.js} +1 -1
  10. package/dist/{chunk-NN6PSWE4.js → chunk-OQLWF43Y.js} +5 -1
  11. package/dist/{chunk-6XJUYY6G.js → chunk-PNLDVYCP.js} +1 -1
  12. package/dist/chunk-PVEB24HU.js +208 -0
  13. package/dist/{chunk-N5IUYCUZ.js → chunk-UYQY4B7J.js} +4 -2
  14. package/dist/{collection-edit-3ZZCDIUY.js → collection-edit-HMOZIS7Z.js} +1 -1
  15. package/dist/{collection-list-LM5SH67K.js → collection-list-GMAYML6Z.js} +1 -1
  16. package/dist/{customer-edit-RBPGTG32.js → customer-edit-5EH2AUGN.js} +1 -1
  17. package/dist/{customer-group-edit-A74OFHEH.js → customer-group-edit-ZQTBUZVR.js} +1 -1
  18. package/dist/{edit-inventory-item-JLTBJEVA.js → edit-inventory-item-ZSV4WF6G.js} +1 -1
  19. package/dist/{edit-inventory-item-attributes-BENAJP4P.js → edit-inventory-item-attributes-NWSAQMKX.js} +1 -1
  20. package/dist/{edit-reservation-FVJZ2NRW.js → edit-reservation-W3THLKKK.js} +1 -1
  21. package/dist/{edit-rules-BVZS6GBQ.js → edit-rules-RJC3AYJN.js} +1 -1
  22. package/dist/index.js +96 -68
  23. package/dist/{location-edit-TQFZN2RW.js → location-edit-XRGRJCVB.js} +1 -1
  24. package/dist/{location-service-zone-edit-36TATZI4.js → location-service-zone-edit-KFG52K4W.js} +1 -1
  25. package/dist/{location-service-zone-shipping-option-edit-HOEBC3D6.js → location-service-zone-shipping-option-edit-UUIR7B5S.js} +2 -2
  26. package/dist/{manage-locations-5CF36BYN.js → manage-locations-ZFIRHMNH.js} +1 -1
  27. package/dist/{marketplace-edit-GWOPSYXL.js → marketplace-edit-G7YNGABC.js} +1 -1
  28. package/dist/{order-create-refund-4MKAZL7C.js → order-create-refund-FJLL4CUD.js} +1 -1
  29. package/dist/{order-edit-billing-address-5OYY6SEI.js → order-edit-billing-address-QCVPGEL6.js} +2 -2
  30. package/dist/{order-edit-email-GM3HKYR6.js → order-edit-email-BREEW246.js} +1 -1
  31. package/dist/{order-edit-shipping-address-ZWGROPKU.js → order-edit-shipping-address-XUG74AFY.js} +1 -1
  32. package/dist/{order-list-GQ5IOA6I.js → order-list-WGQC2X2L.js} +1 -1
  33. package/dist/{order-request-transfer-OTGRHY6N.js → order-request-transfer-RYVK4WYW.js} +1 -1
  34. package/dist/pages/index.js +9 -9
  35. package/dist/{price-list-edit-ZZZDR62K.js → price-list-edit-ZVP6CCPE.js} +1 -1
  36. package/dist/{product-create-A7774JYE.js → product-create-QS5KIHET.js} +3 -3
  37. package/dist/{product-create-attribute-2PTO2UCX.js → product-create-attribute-FC26KQN4.js} +1 -1
  38. package/dist/{product-media-ROKDXANO.js → product-media-UHDJ6RSG.js} +2 -2
  39. package/dist/{product-organization-XS62HARL.js → product-organization-IX5XCZW4.js} +1 -1
  40. package/dist/{product-tag-detail-7P7MI52E.js → product-tag-detail-2YR6TXZI.js} +1 -1
  41. package/dist/{product-tag-list-43NFD36I.js → product-tag-list-3HOXFHMN.js} +1 -1
  42. package/dist/{product-type-edit-IEMK45NK.js → product-type-edit-X7VSBPUG.js} +1 -1
  43. package/dist/{promotion-add-campaign-TVTKI5EP.js → promotion-add-campaign-VAF3HTLK.js} +1 -1
  44. package/dist/{promotion-detail-4WNHEOG4.js → promotion-detail-ADTUSGD4.js} +3 -3
  45. package/dist/{promotion-edit-details-FFTEJ2CV.js → promotion-edit-details-7PHH756U.js} +1 -1
  46. package/dist/{promotion-list-AJ5NBDZ2.js → promotion-list-MRNS47TP.js} +4 -4
  47. package/dist/{refund-reason-list-R573DHM7.js → refund-reason-list-ODOF3ZLM.js} +1 -1
  48. package/dist/{region-edit-N6FXU7NY.js → region-edit-NUMG2V5L.js} +1 -1
  49. package/dist/{reset-password-7G75C4RO.js → reset-password-N4LXTU3G.js} +1 -1
  50. package/dist/{return-reason-list-A2RABTGP.js → return-reason-list-AVCC44CH.js} +1 -1
  51. package/dist/{sales-channel-edit-2SCFS7SA.js → sales-channel-edit-CO2V2VER.js} +1 -1
  52. package/dist/{shipping-option-type-edit-6PWBHHFP.js → shipping-option-type-edit-WXTEQM32.js} +1 -1
  53. package/dist/{store-details-GOVF3KFW.js → store-details-KI5D4VSI.js} +1 -1
  54. package/dist/{store-edit-IP6FR2NJ.js → store-edit-B54LFFLE.js} +3 -3
  55. package/dist/{store-list-OKKZA7VO.js → store-list-3KZCD7UB.js} +1 -1
  56. package/dist/{store-member-invite-RKP7K2S4.js → store-member-invite-5S64PDTE.js} +1 -1
  57. package/dist/{tax-region-create-P4IKQNTU.js → tax-region-create-DVBIX7IX.js} +1 -1
  58. package/dist/{tax-region-tax-override-create-7O3KDBUJ.js → tax-region-tax-override-create-XZ5BU2FP.js} +1 -1
  59. package/dist/{tax-region-tax-override-edit-SUL5VZ5D.js → tax-region-tax-override-edit-R4EGIUIZ.js} +1 -1
  60. package/dist/{user-edit-Z3ODTSMN.js → user-edit-O2M5II52.js} +1 -1
  61. package/dist/{user-invite-WG57KWD3.js → user-invite-WHBNPT4I.js} +127 -27
  62. package/package.json +6 -6
@@ -1,9 +1,20 @@
1
+ import {
2
+ useFeatureFlag,
3
+ usePermissions,
4
+ useRbacAssignableRoles
5
+ } from "./chunk-PVEB24HU.js";
1
6
  import {
2
7
  isFetchError
3
8
  } from "./chunk-C6SUTRP2.js";
9
+ import {
10
+ ListSummary
11
+ } from "./chunk-4F5GP7J7.js";
4
12
  import {
5
13
  useUserInviteTableQuery
6
- } from "./chunk-N5IUYCUZ.js";
14
+ } from "./chunk-UYQY4B7J.js";
15
+ import {
16
+ Combobox
17
+ } from "./chunk-SR3DYN52.js";
7
18
  import {
8
19
  KeyboundForm
9
20
  } from "./chunk-SITRHMZZ.js";
@@ -64,7 +75,8 @@ import { Trans, useTranslation } from "react-i18next";
64
75
  import * as zod from "zod";
65
76
  import { jsx, jsxs } from "react/jsx-runtime";
66
77
  var InviteUserSchema = zod.object({
67
- email: zod.string().email()
78
+ email: zod.string().email(),
79
+ roles: zod.array(zod.string()).optional()
68
80
  });
69
81
  var PAGE_SIZE = 10;
70
82
  var PREFIX = "usr_invite";
@@ -79,15 +91,47 @@ var getBaseUrl = () => {
79
91
  var INVITE_URL = `${window.location.origin}${getBaseUrl()}/invite?token=`;
80
92
  var InviteUserForm = () => {
81
93
  const { t } = useTranslation();
94
+ const isRbacEnabled = useFeatureFlag("rbac");
95
+ const { hasPermission } = usePermissions();
96
+ const canReadRbacRoles = hasPermission("rbac_role:read");
97
+ const showRbacRolesField = isRbacEnabled && canReadRbacRoles;
82
98
  const form = useForm({
83
99
  defaultValues: {
84
- email: ""
100
+ email: "",
101
+ roles: []
85
102
  },
86
103
  resolver: zodResolver(InviteUserSchema)
87
104
  });
105
+ const { data: assignableData, isPending: isRolesLoading } = useRbacAssignableRoles(
106
+ { limit: 200, order: "name" },
107
+ { enabled: showRbacRolesField }
108
+ );
109
+ const roleOptions = useMemo(() => {
110
+ return (assignableData?.roles ?? []).map((role) => ({
111
+ label: role.name,
112
+ value: role.id
113
+ }));
114
+ }, [assignableData?.roles]);
115
+ const inviteFields = useMemo(() => {
116
+ if (!showRbacRolesField) {
117
+ return void 0;
118
+ }
119
+ return [
120
+ "id",
121
+ "email",
122
+ "accepted",
123
+ "token",
124
+ "expires_at",
125
+ "created_at",
126
+ "updated_at",
127
+ "rbac_roles.id",
128
+ "rbac_roles.name"
129
+ ].join(",");
130
+ }, [showRbacRolesField]);
88
131
  const { raw, searchParams } = useUserInviteTableQuery({
89
132
  prefix: PREFIX,
90
- pageSize: PAGE_SIZE
133
+ pageSize: PAGE_SIZE,
134
+ fields: inviteFields
91
135
  });
92
136
  const {
93
137
  invites,
@@ -96,7 +140,7 @@ var InviteUserForm = () => {
96
140
  isError,
97
141
  error
98
142
  } = useInvites(searchParams);
99
- const columns = useColumns();
143
+ const columns = useColumns({ isRbacEnabled: showRbacRolesField });
100
144
  const { table } = useDataTable({
101
145
  data: invites ?? [],
102
146
  columns,
@@ -109,7 +153,13 @@ var InviteUserForm = () => {
109
153
  const { mutateAsync, isPending } = useCreateInvite();
110
154
  const handleSubmit = form.handleSubmit(async (values) => {
111
155
  try {
112
- await mutateAsync({ email: values.email });
156
+ const payload = {
157
+ email: values.email
158
+ };
159
+ if (showRbacRolesField && values.roles?.length) {
160
+ payload.roles = values.roles;
161
+ }
162
+ await mutateAsync(payload);
113
163
  form.reset();
114
164
  } catch (error2) {
115
165
  if (isFetchError(error2) && error2.status === 400) {
@@ -165,26 +215,63 @@ var InviteUserForm = () => {
165
215
  className: "flex flex-col gap-y-4",
166
216
  "data-testid": "user-invite-form-email-section",
167
217
  children: [
168
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4", children: /* @__PURE__ */ jsx(
169
- Form.Field,
170
- {
171
- control: form.control,
172
- name: "email",
173
- render: ({ field }) => {
174
- return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "user-invite-form-email-item", children: [
175
- /* @__PURE__ */ jsx(Form.Label, { "data-testid": "user-invite-form-email-label", children: t("fields.email") }),
176
- /* @__PURE__ */ jsx(Form.Control, { "data-testid": "user-invite-form-email-control", children: /* @__PURE__ */ jsx(
177
- Input,
178
- {
179
- ...field,
180
- "data-testid": "user-invite-form-email-input"
181
- }
182
- ) }),
183
- /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "user-invite-form-email-error" })
184
- ] });
218
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
219
+ /* @__PURE__ */ jsx(
220
+ Form.Field,
221
+ {
222
+ control: form.control,
223
+ name: "email",
224
+ render: ({ field }) => {
225
+ return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "user-invite-form-email-item", children: [
226
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "user-invite-form-email-label", children: t("fields.email") }),
227
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "user-invite-form-email-control", children: /* @__PURE__ */ jsx(
228
+ Input,
229
+ {
230
+ ...field,
231
+ "data-testid": "user-invite-form-email-input"
232
+ }
233
+ ) }),
234
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "user-invite-form-email-error" })
235
+ ] });
236
+ }
185
237
  }
186
- }
187
- ) }),
238
+ ),
239
+ showRbacRolesField && /* @__PURE__ */ jsx(
240
+ Form.Field,
241
+ {
242
+ control: form.control,
243
+ name: "roles",
244
+ render: ({ field }) => {
245
+ return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "user-invite-form-roles-item", children: [
246
+ /* @__PURE__ */ jsx(
247
+ Form.Label,
248
+ {
249
+ optional: true,
250
+ tooltip: t("users.inviteRolesTooltip"),
251
+ "data-testid": "user-invite-form-roles-label",
252
+ children: t("roles.domain")
253
+ }
254
+ ),
255
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "user-invite-form-roles-control", children: /* @__PURE__ */ jsx(
256
+ Combobox,
257
+ {
258
+ ...field,
259
+ value: field.value ?? [],
260
+ onChange: (value) => {
261
+ field.onChange(value ?? []);
262
+ },
263
+ options: roleOptions,
264
+ placeholder: t("labels.selectValues"),
265
+ disabled: isRolesLoading,
266
+ "data-testid": "user-invite-form-roles-input"
267
+ }
268
+ ) }),
269
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "user-invite-form-roles-error" })
270
+ ] });
271
+ }
272
+ }
273
+ )
274
+ ] }),
188
275
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx(
189
276
  Button,
190
277
  {
@@ -306,7 +393,7 @@ var InviteActions = ({ invite }) => {
306
393
  );
307
394
  };
308
395
  var columnHelper = createColumnHelper();
309
- var useColumns = () => {
396
+ var useColumns = ({ isRbacEnabled }) => {
310
397
  const { t } = useTranslation();
311
398
  return useMemo(
312
399
  () => [
@@ -316,6 +403,19 @@ var useColumns = () => {
316
403
  return getValue();
317
404
  }
318
405
  }),
406
+ ...isRbacEnabled ? [
407
+ columnHelper.display({
408
+ id: "roles",
409
+ header: t("roles.domain"),
410
+ cell: ({ row }) => {
411
+ const roleNames = row.original.rbac_roles?.map((role) => role.name) ?? [];
412
+ if (!roleNames.length) {
413
+ return /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "-" });
414
+ }
415
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(ListSummary, { inline: true, n: 1, list: roleNames }) });
416
+ }
417
+ })
418
+ ] : [],
319
419
  columnHelper.accessor("accepted", {
320
420
  header: t("fields.status"),
321
421
  cell: ({ getValue, row }) => {
@@ -382,7 +482,7 @@ var useColumns = () => {
382
482
  cell: ({ row }) => /* @__PURE__ */ jsx(InviteActions, { invite: row.original })
383
483
  })
384
484
  ],
385
- [t]
485
+ [t, isRbacEnabled]
386
486
  );
387
487
  };
388
488
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/admin",
3
- "version": "2.3.1",
3
+ "version": "2.3.2-canary.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",
@@ -34,8 +34,8 @@
34
34
  "lint": "oxlint --max-warnings 0"
35
35
  },
36
36
  "dependencies": {
37
- "@mercurjs/dashboard-shared": "2.3.1",
38
- "@mercurjs/client": "2.3.1",
37
+ "@mercurjs/dashboard-shared": "2.3.2-canary.1",
38
+ "@mercurjs/client": "2.3.2-canary.1",
39
39
  "@ariakit/react": "^0.4.15",
40
40
  "@babel/runtime": "^8.0.0",
41
41
  "@dnd-kit/core": "^6.1.0",
@@ -88,8 +88,8 @@
88
88
  "tsup": "^8.0.2",
89
89
  "typescript": "5.9.3",
90
90
  "@medusajs/types": "2.18.0",
91
- "@mercurjs/core": "2.3.1",
92
- "@mercurjs/dashboard-sdk": "2.3.1",
93
- "@mercurjs/types": "2.3.1"
91
+ "@mercurjs/core": "2.3.2-canary.1",
92
+ "@mercurjs/dashboard-sdk": "2.3.2-canary.1",
93
+ "@mercurjs/types": "2.3.2-canary.1"
94
94
  }
95
95
  }