mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-13 19:29:54 +00:00
feat(infisical-pg): completed checklist run for dashboard
This commit is contained in:
@@ -35,7 +35,7 @@ export const useAddUserToWs = () => {
|
||||
workspaceEncryptedNonce: inviteeNonce
|
||||
};
|
||||
});
|
||||
const { data } = await apiRequest.post(`/api/v2/workspace/${workspaceId}/memberships`, {
|
||||
const { data } = await apiRequest.post(`/api/v1/workspace/${workspaceId}/memberships`, {
|
||||
members: newWsMembers
|
||||
});
|
||||
return data;
|
||||
|
||||
@@ -49,7 +49,7 @@ export type OrgUser = {
|
||||
role: "owner" | "admin" | "member" | "no-access" | "custom";
|
||||
status: "invited" | "accepted" | "verified" | "completed";
|
||||
deniedPermissions: any[];
|
||||
customRole: string;
|
||||
roleId: string;
|
||||
};
|
||||
|
||||
export type TWorkspaceUser = OrgUser;
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
DeleteWorkspaceDTO,
|
||||
NameWorkspaceSecretsDTO,
|
||||
RenameWorkspaceDTO,
|
||||
ReorderEnvironmentsDTO,
|
||||
ToggleAutoCapitalizationDTO,
|
||||
UpdateEnvironmentDTO,
|
||||
Workspace
|
||||
@@ -29,8 +28,9 @@ export const workspaceKeys = {
|
||||
getWorkspaceAuthorization: (workspaceId: string) => [{ workspaceId }, "workspace-authorizations"],
|
||||
getWorkspaceIntegrations: (workspaceId: string) => [{ workspaceId }, "workspace-integrations"],
|
||||
getAllUserWorkspace: ["workspaces"] as const,
|
||||
getWorkspaceAuditLogs: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }] as const,
|
||||
getWorkspaceAuditLogs: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-audit-logs"] as const,
|
||||
getWorkspaceUsers: (workspaceId: string) => [{ workspaceId }, "workspace-users"] as const,
|
||||
getWorkspaceIdentityMemberships: (workspaceId: string) =>
|
||||
[{ workspaceId }, "workspace-identity-memberships"] as const
|
||||
};
|
||||
@@ -234,38 +234,15 @@ export const useCreateWsEnvironment = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useReorderWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, ReorderEnvironmentsDTO>({
|
||||
mutationFn: ({
|
||||
workspaceId,
|
||||
environmentSlug,
|
||||
environmentName,
|
||||
otherEnvironmentSlug,
|
||||
otherEnvironmentName
|
||||
}) => {
|
||||
return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments`, {
|
||||
environmentSlug,
|
||||
environmentName,
|
||||
otherEnvironmentSlug,
|
||||
otherEnvironmentName
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useUpdateWsEnvironment = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, UpdateEnvironmentDTO>({
|
||||
mutationFn: ({ workspaceId, id, name, slug }) => {
|
||||
mutationFn: ({ workspaceId, id, name, slug, position }) => {
|
||||
return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments/${id}`, {
|
||||
name,
|
||||
slug
|
||||
slug,
|
||||
position
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -335,7 +312,7 @@ export const useDeleteUserFromWorkspace = () => {
|
||||
}) => {
|
||||
const {
|
||||
data: { deletedMembership }
|
||||
} = await apiRequest.delete(`/api/v1/${workspaceId}/membership/${membershipId}`);
|
||||
} = await apiRequest.delete(`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`);
|
||||
return deletedMembership;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
@@ -358,13 +335,16 @@ export const useUpdateUserWorkspaceRole = () => {
|
||||
}) => {
|
||||
const {
|
||||
data: { membership }
|
||||
} = await apiRequest.post(`/api/v1/${workspaceId}/membership/${membershipId}`, {
|
||||
role
|
||||
});
|
||||
} = await apiRequest.patch<{ membership: { projectId: string } }>(
|
||||
`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`,
|
||||
{
|
||||
role
|
||||
}
|
||||
);
|
||||
return membership;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(res.workspace));
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceUsers(res.projectId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -53,6 +53,7 @@ export type UpdateEnvironmentDTO = {
|
||||
id: string;
|
||||
name?: string;
|
||||
slug?: string;
|
||||
position?: number;
|
||||
};
|
||||
|
||||
export type DeleteEnvironmentDTO = { workspaceId: string; id: string };
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function SignupInvite() {
|
||||
const router = useRouter();
|
||||
const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
|
||||
const token = parsedUrl.token as string;
|
||||
const organizationId = parsedUrl.organizationid as string;
|
||||
const organizationId = parsedUrl.organization_id as string;
|
||||
const email = (parsedUrl.to as string)?.replace(" ", "+").trim();
|
||||
|
||||
// Verifies if the information that the users entered (name, workspace) is there, and if the password matched the criteria.
|
||||
|
||||
+2
-5
@@ -57,7 +57,6 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop
|
||||
const orgId = currentOrg?.id || "";
|
||||
|
||||
const { data: roles, isLoading: isRolesLoading } = useGetOrgRoles(orgId);
|
||||
console.log(roles);
|
||||
|
||||
const [searchMemberFilter, setSearchMemberFilter] = useState("");
|
||||
|
||||
@@ -172,7 +171,7 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop
|
||||
{isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
|
||||
{!isLoading &&
|
||||
filterdUser?.map(
|
||||
({ user: u, inviteEmail, role, customRole, id: orgMembershipId, status }) => {
|
||||
({ user: u, inviteEmail, role, roleId, id: orgMembershipId, status }) => {
|
||||
const name = u ? `${u.firstName} ${u.lastName}` : "-";
|
||||
const email = u?.email || inviteEmail;
|
||||
return (
|
||||
@@ -188,9 +187,7 @@ export const OrgMembersTable = ({ handlePopUpOpen, setCompleteInviteLink }: Prop
|
||||
<>
|
||||
{status === "accepted" && (
|
||||
<Select
|
||||
value={
|
||||
role === "custom" ? findRoleFromId(customRole)?.slug : role
|
||||
}
|
||||
value={role === "custom" ? findRoleFromId(roleId)?.slug : role}
|
||||
isDisabled={userId === u?.id || !isAllowed}
|
||||
className="w-40 bg-mineshaft-600"
|
||||
dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
|
||||
|
||||
@@ -349,8 +349,8 @@ export const OrgMembersTable = ({ roles = [], isRolesLoading }: Props) => {
|
||||
{isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
|
||||
{!isLoading &&
|
||||
filterdUser?.map(
|
||||
({ user: u, inviteEmail, role, customRole, id: orgMembershipId, status }) => {
|
||||
const name = u ? `${u.firstName} ${u.lastName}` : "-";
|
||||
({ user: u, inviteEmail, role, roleId, id: orgMembershipId, status }) => {
|
||||
const name = u ? `${u.firstName || "-"} ${u.lastName || ""}` : "-";
|
||||
const email = u?.email || inviteEmail;
|
||||
const userWs = workspaceMemberships?.[u?.id];
|
||||
|
||||
@@ -368,7 +368,7 @@ export const OrgMembersTable = ({ roles = [], isRolesLoading }: Props) => {
|
||||
{status === "accepted" && (
|
||||
<Select
|
||||
defaultValue={
|
||||
role === "custom" ? findRoleFromId(customRole)?.slug : role
|
||||
role === "custom" ? findRoleFromId(roleId)?.slug : role
|
||||
}
|
||||
isDisabled={userId === u?.id || !isAllowed}
|
||||
className="w-40 bg-mineshaft-600"
|
||||
|
||||
@@ -158,6 +158,7 @@ export const MemberListTab = () => {
|
||||
() => members?.find(({ user: u }) => userId === u?.id)?.role === "owner",
|
||||
[userId, members]
|
||||
);
|
||||
console.log(members);
|
||||
|
||||
const findRoleFromId = useCallback(
|
||||
(roleId: string) => {
|
||||
@@ -290,7 +291,7 @@ export const MemberListTab = () => {
|
||||
{isLoading && <TableSkeleton columns={4} innerKey="project-members" />}
|
||||
{!isLoading &&
|
||||
filterdUsers?.map(
|
||||
({ user: u, inviteEmail, id: membershipId, status, customRole, role }) => {
|
||||
({ user: u, inviteEmail, id: membershipId, status, roleId, role }) => {
|
||||
const name = u ? `${u.firstName} ${u.lastName}` : "-";
|
||||
const email = u?.email || inviteEmail;
|
||||
|
||||
@@ -306,9 +307,7 @@ export const MemberListTab = () => {
|
||||
{(isAllowed) => (
|
||||
<>
|
||||
<Select
|
||||
value={
|
||||
role === "custom" ? findRoleFromId(customRole)?.slug : role
|
||||
}
|
||||
value={role === "custom" ? findRoleFromId(roleId)?.slug : role}
|
||||
isDisabled={userId === u?.id || !isAllowed}
|
||||
className="w-40 bg-mineshaft-600"
|
||||
dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@ export const DeleteProjectSection = () => {
|
||||
try {
|
||||
if (!currentWorkspace?.id) return;
|
||||
|
||||
const orgId = currentOrg?.id;
|
||||
await deleteWorkspace.mutateAsync({
|
||||
workspaceID: currentWorkspace?.id
|
||||
});
|
||||
@@ -39,7 +40,7 @@ export const DeleteProjectSection = () => {
|
||||
type: "success"
|
||||
});
|
||||
|
||||
router.push(`/org/${currentOrg?.id}/overview`);
|
||||
router.push(`/org/${orgId}/overview`);
|
||||
handlePopUpClose("deleteWorkspace");
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
+13
-28
@@ -16,7 +16,7 @@ import {
|
||||
Tr
|
||||
} from "@app/components/v2";
|
||||
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
|
||||
import { useReorderWsEnvironment } from "@app/hooks/api";
|
||||
import { useUpdateWsEnvironment } from "@app/hooks/api";
|
||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||
|
||||
type Props = {
|
||||
@@ -37,32 +37,16 @@ type Props = {
|
||||
export const EnvironmentTable = ({ handlePopUpOpen }: Props) => {
|
||||
const { currentWorkspace, isLoading } = useWorkspace();
|
||||
const { createNotification } = useNotificationContext();
|
||||
const reorderWsEnvironment = useReorderWsEnvironment();
|
||||
const updateEnvironment = useUpdateWsEnvironment();
|
||||
|
||||
const handleReorderEnv = async (shouldMoveUp: boolean, name: string, slug: string) => {
|
||||
const handleReorderEnv = async (id: string, position: number) => {
|
||||
try {
|
||||
if (!currentWorkspace?.id) return;
|
||||
|
||||
const indexOfEnv = currentWorkspace.environments.findIndex(
|
||||
(env) => env.name === name && env.slug === slug
|
||||
);
|
||||
|
||||
// check that this reordering is possible
|
||||
if (
|
||||
(indexOfEnv === 0 && shouldMoveUp) ||
|
||||
(indexOfEnv === currentWorkspace.environments.length - 1 && !shouldMoveUp)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const indexToSwap = shouldMoveUp ? indexOfEnv - 1 : indexOfEnv + 1;
|
||||
|
||||
await reorderWsEnvironment.mutateAsync({
|
||||
await updateEnvironment.mutateAsync({
|
||||
workspaceId: currentWorkspace.id,
|
||||
environmentSlug: slug,
|
||||
environmentName: name,
|
||||
otherEnvironmentSlug: currentWorkspace.environments[indexToSwap].slug,
|
||||
otherEnvironmentName: currentWorkspace.environments[indexToSwap].name
|
||||
id,
|
||||
position
|
||||
});
|
||||
|
||||
createNotification({
|
||||
@@ -104,9 +88,12 @@ export const EnvironmentTable = ({ handlePopUpOpen }: Props) => {
|
||||
{(isAllowed) => (
|
||||
<IconButton
|
||||
className="mr-3 py-2"
|
||||
onClick={() => {
|
||||
handleReorderEnv(false, name, slug);
|
||||
}}
|
||||
onClick={() =>
|
||||
handleReorderEnv(
|
||||
id,
|
||||
Math.min(currentWorkspace.environments.length, pos + 2)
|
||||
)
|
||||
}
|
||||
colorSchema="primary"
|
||||
variant="plain"
|
||||
ariaLabel="update"
|
||||
@@ -123,9 +110,7 @@ export const EnvironmentTable = ({ handlePopUpOpen }: Props) => {
|
||||
{(isAllowed) => (
|
||||
<IconButton
|
||||
className="mr-3 py-2"
|
||||
onClick={() => {
|
||||
handleReorderEnv(true, name, slug);
|
||||
}}
|
||||
onClick={() => handleReorderEnv(id, Math.max(1, pos))}
|
||||
colorSchema="primary"
|
||||
variant="plain"
|
||||
ariaLabel="update"
|
||||
|
||||
Reference in New Issue
Block a user