@forge-connect/react 1.0.7 → 1.0.9
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/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -369,6 +369,13 @@ function createApiClient(apiUrl) {
|
|
|
369
369
|
adminGetPermissions(token) {
|
|
370
370
|
return request("/admin/roles/permissions", { token });
|
|
371
371
|
},
|
|
372
|
+
/** Get the current user's own roles (no admin privileges needed). */
|
|
373
|
+
getMyRoles(token, tenantId) {
|
|
374
|
+
const query = new URLSearchParams();
|
|
375
|
+
if (tenantId) query.set("tenantId", tenantId);
|
|
376
|
+
const qs = query.toString();
|
|
377
|
+
return request(`/users/me/roles${qs ? `?${qs}` : ""}`, { token });
|
|
378
|
+
},
|
|
372
379
|
adminGetUserRoles(token, userId, tenantId) {
|
|
373
380
|
const query = new URLSearchParams();
|
|
374
381
|
if (tenantId) query.set("tenantId", tenantId);
|
|
@@ -4264,6 +4271,7 @@ function useRoles() {
|
|
|
4264
4271
|
const [userRoleAssignments, setUserRoleAssignments] = _react.useState.call(void 0, null);
|
|
4265
4272
|
const [roleUsers, setRoleUsers] = _react.useState.call(void 0, null);
|
|
4266
4273
|
const [permissionDomains, setPermissionDomains] = _react.useState.call(void 0, null);
|
|
4274
|
+
const [myPermissions, setMyPermissions] = _react.useState.call(void 0, []);
|
|
4267
4275
|
const [loading, setLoading] = _react.useState.call(void 0, false);
|
|
4268
4276
|
const listRoles = _react.useCallback.call(void 0,
|
|
4269
4277
|
async (tenantId) => {
|
|
@@ -4346,6 +4354,22 @@ function useRoles() {
|
|
|
4346
4354
|
},
|
|
4347
4355
|
[api, getAccessToken]
|
|
4348
4356
|
);
|
|
4357
|
+
const getMyRoles = _react.useCallback.call(void 0,
|
|
4358
|
+
async (tenantId) => {
|
|
4359
|
+
const token = getAccessToken();
|
|
4360
|
+
if (!token) throw new Error("Please sign in to continue.");
|
|
4361
|
+
setLoading(true);
|
|
4362
|
+
try {
|
|
4363
|
+
const data = await api.getMyRoles(token, tenantId);
|
|
4364
|
+
setUserRoleAssignments(data.data);
|
|
4365
|
+
setMyPermissions(_nullishCoalesce(data.permissions, () => ( [])));
|
|
4366
|
+
return data;
|
|
4367
|
+
} finally {
|
|
4368
|
+
setLoading(false);
|
|
4369
|
+
}
|
|
4370
|
+
},
|
|
4371
|
+
[api, getAccessToken]
|
|
4372
|
+
);
|
|
4349
4373
|
const getUserRoles = _react.useCallback.call(void 0,
|
|
4350
4374
|
async (userId, tenantId) => {
|
|
4351
4375
|
const token = getAccessToken();
|
|
@@ -4382,6 +4406,7 @@ function useRoles() {
|
|
|
4382
4406
|
selectedRole,
|
|
4383
4407
|
roleUsers,
|
|
4384
4408
|
userRoleAssignments,
|
|
4409
|
+
myPermissions,
|
|
4385
4410
|
permissionDomains,
|
|
4386
4411
|
loading,
|
|
4387
4412
|
listRoles,
|
|
@@ -4391,6 +4416,7 @@ function useRoles() {
|
|
|
4391
4416
|
updateRole,
|
|
4392
4417
|
deleteRole,
|
|
4393
4418
|
getPermissions,
|
|
4419
|
+
getMyRoles,
|
|
4394
4420
|
getUserRoles,
|
|
4395
4421
|
assignRole,
|
|
4396
4422
|
revokeRole
|