mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 21:26:40 +00:00
Merge pull request #3206 from Infisical/fix/removeInviteAllOnProjectCreation
Remove addAllMembers option from project creation modal
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
|||||||
AccordionItem,
|
AccordionItem,
|
||||||
AccordionTrigger,
|
AccordionTrigger,
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
|
||||||
FormControl,
|
FormControl,
|
||||||
Input,
|
Input,
|
||||||
Modal,
|
Modal,
|
||||||
@@ -33,13 +32,7 @@ import {
|
|||||||
useUser
|
useUser
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import { getProjectHomePage } from "@app/helpers/project";
|
import { getProjectHomePage } from "@app/helpers/project";
|
||||||
import {
|
import { useCreateWorkspace, useGetExternalKmsList, useGetUserWorkspaces } from "@app/hooks/api";
|
||||||
fetchOrgUsers,
|
|
||||||
useAddUserToWsNonE2EE,
|
|
||||||
useCreateWorkspace,
|
|
||||||
useGetExternalKmsList,
|
|
||||||
useGetUserWorkspaces
|
|
||||||
} from "@app/hooks/api";
|
|
||||||
import { INTERNAL_KMS_KEY_ID } from "@app/hooks/api/kms/types";
|
import { INTERNAL_KMS_KEY_ID } from "@app/hooks/api/kms/types";
|
||||||
import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
|
import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
|
||||||
import { ProjectType } from "@app/hooks/api/workspace/types";
|
import { ProjectType } from "@app/hooks/api/workspace/types";
|
||||||
@@ -51,7 +44,6 @@ const formSchema = z.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.max(256, "Description too long, max length is 256 characters")
|
.max(256, "Description too long, max length is 256 characters")
|
||||||
.optional(),
|
.optional(),
|
||||||
addMembers: z.boolean(),
|
|
||||||
kmsKeyId: z.string(),
|
kmsKeyId: z.string(),
|
||||||
template: z.string()
|
template: z.string()
|
||||||
});
|
});
|
||||||
@@ -73,7 +65,6 @@ const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => {
|
|||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const createWs = useCreateWorkspace();
|
const createWs = useCreateWorkspace();
|
||||||
const { refetch: refetchWorkspaces } = useGetUserWorkspaces();
|
const { refetch: refetchWorkspaces } = useGetUserWorkspaces();
|
||||||
const addUsersToProject = useAddUserToWsNonE2EE();
|
|
||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
|
|
||||||
const canReadProjectTemplates = permission.can(
|
const canReadProjectTemplates = permission.can(
|
||||||
@@ -111,7 +102,6 @@ const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => {
|
|||||||
const onCreateProject = async ({
|
const onCreateProject = async ({
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
addMembers,
|
|
||||||
kmsKeyId,
|
kmsKeyId,
|
||||||
template
|
template
|
||||||
}: TAddProjectFormData) => {
|
}: TAddProjectFormData) => {
|
||||||
@@ -128,21 +118,6 @@ const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => {
|
|||||||
template,
|
template,
|
||||||
type: projectType
|
type: projectType
|
||||||
});
|
});
|
||||||
const { id: newProjectId } = project;
|
|
||||||
|
|
||||||
if (addMembers) {
|
|
||||||
const orgUsers = await fetchOrgUsers(currentOrg.id);
|
|
||||||
await addUsersToProject.mutateAsync({
|
|
||||||
usernames: orgUsers
|
|
||||||
.filter(
|
|
||||||
(member) => member.user.username !== user.username && member.status === "accepted"
|
|
||||||
)
|
|
||||||
.map((member) => member.user.username),
|
|
||||||
projectId: newProjectId,
|
|
||||||
orgId: currentOrg.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await refetchWorkspaces();
|
await refetchWorkspaces();
|
||||||
|
|
||||||
createNotification({ text: "Project created", type: "success" });
|
createNotification({ text: "Project created", type: "success" });
|
||||||
@@ -246,31 +221,7 @@ const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 pl-1">
|
<div className="mt-4 flex">
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
name="addMembers"
|
|
||||||
defaultValue={false}
|
|
||||||
render={({ field: { onBlur, value, onChange } }) => (
|
|
||||||
<OrgPermissionCan I={OrgPermissionActions.Read} a={OrgPermissionSubjects.Member}>
|
|
||||||
{(isAllowed) => (
|
|
||||||
<div>
|
|
||||||
<Checkbox
|
|
||||||
id="add-project-layout"
|
|
||||||
isChecked={value}
|
|
||||||
onCheckedChange={onChange}
|
|
||||||
isDisabled={!isAllowed}
|
|
||||||
onBlur={onBlur}
|
|
||||||
>
|
|
||||||
Add all members of my organization to this project
|
|
||||||
</Checkbox>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</OrgPermissionCan>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="mt-14 flex">
|
|
||||||
<Accordion type="single" collapsible className="w-full">
|
<Accordion type="single" collapsible className="w-full">
|
||||||
<AccordionItem value="advance-settings" className="data-[state=open]:border-none">
|
<AccordionItem value="advance-settings" className="data-[state=open]:border-none">
|
||||||
<AccordionTrigger className="h-fit flex-none pl-1 text-sm">
|
<AccordionTrigger className="h-fit flex-none pl-1 text-sm">
|
||||||
|
|||||||
Reference in New Issue
Block a user