mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 15:41:27 +00:00
Merge remote-tracking branch 'origin' into stv3-update
This commit is contained in:
@@ -8,6 +8,7 @@ import { apiRequest } from "@app/config/request";
|
||||
import { OrgPermissionSet } from "@app/context/OrgPermissionContext/types";
|
||||
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext/types";
|
||||
|
||||
import { OrgUser } from "../users/types";
|
||||
import {
|
||||
TGetRolesDTO,
|
||||
TGetUserOrgPermissionsDTO,
|
||||
@@ -63,13 +64,16 @@ export const useGetRoles = ({ orgId, workspaceId }: TGetRolesDTO) =>
|
||||
});
|
||||
|
||||
const getUserOrgPermissions = async ({ orgId }: TGetUserOrgPermissionsDTO) => {
|
||||
if (orgId === "") return [];
|
||||
if (orgId === "") return { permissions: [], membership: null };
|
||||
|
||||
const { data } = await apiRequest.get<{
|
||||
data: { permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[] };
|
||||
}>(`/api/v1/roles/organization/${orgId}/permissions`, {});
|
||||
|
||||
return data.data.permissions;
|
||||
data: {
|
||||
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
|
||||
membership: OrgUser;
|
||||
};
|
||||
}>(`/api/v1/roles/organization/${orgId}/permissions`);
|
||||
|
||||
return data.data;
|
||||
};
|
||||
|
||||
export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =>
|
||||
@@ -78,9 +82,9 @@ export const useGetUserOrgPermissions = ({ orgId }: TGetUserOrgPermissionsDTO) =
|
||||
queryFn: () => getUserOrgPermissions({ orgId }),
|
||||
// enabled: Boolean(orgId),
|
||||
select: (data) => {
|
||||
const rule = unpackRules<RawRuleOf<MongoAbility<OrgPermissionSet>>>(data);
|
||||
const rule = unpackRules<RawRuleOf<MongoAbility<OrgPermissionSet>>>(data.permissions);
|
||||
const ability = createMongoAbility<OrgPermissionSet>(rule, { conditionsMatcher });
|
||||
return ability;
|
||||
return { permission: ability, membership: data.membership };
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ export const workspaceKeys = {
|
||||
getUserWsEnvironments: (workspaceId: string) => ["workspace-env", { workspaceId }] as const,
|
||||
getWorkspaceAuditLogs: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceServiceTokenDataV3: (workspaceId: string) => [{ workspaceId }, "workspace-service-token-data-v3"] as const
|
||||
getWorkspaceServiceTokenDataV3: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-service-token-data-v3"] as const
|
||||
};
|
||||
|
||||
const fetchWorkspaceById = async (workspaceId: string) => {
|
||||
@@ -53,7 +54,7 @@ const fetchWorkspaceIndexStatus = async (workspaceId: string) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
const fetchWorkspaceSecrets = async (workspaceId: string) => {
|
||||
export const fetchWorkspaceSecrets = async (workspaceId: string) => {
|
||||
const {
|
||||
data: { secrets }
|
||||
} = await apiRequest.get<{ secrets: EncryptedSecret[] }>(
|
||||
@@ -253,9 +254,18 @@ export const useReorderWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, ReorderEnvironmentsDTO>({
|
||||
mutationFn: ({ workspaceID, environmentSlug, environmentName, otherEnvironmentSlug, otherEnvironmentName}) => {
|
||||
mutationFn: ({
|
||||
workspaceID,
|
||||
environmentSlug,
|
||||
environmentName,
|
||||
otherEnvironmentSlug,
|
||||
otherEnvironmentName
|
||||
}) => {
|
||||
return apiRequest.patch(`/api/v2/workspace/${workspaceID}/environments`, {
|
||||
environmentSlug, environmentName, otherEnvironmentSlug, otherEnvironmentName
|
||||
environmentSlug,
|
||||
environmentName,
|
||||
otherEnvironmentSlug,
|
||||
otherEnvironmentName
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -378,4 +388,4 @@ export const useGetWorkspaceServiceTokenDataV3 = (workspaceId: string) => {
|
||||
},
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user