Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: brought back workspace permission and made requested changes
=b4a2a477d341
diff --git a/backend/src/ee/services/permission/org-permission.ts b/backend/src/ee/services/permission/org-permission.tsindex 77eaacd3bb..c071079123 100644--- a/backend/src/ee/services/permission/org-permission.ts+++ b/backend/src/ee/services/permission/org-permission.ts@@ -9,6 +9,10 @@ export enum OrgPermissionActions {Delete = "delete"}+export enum OrgPermissionAdminConsoleAction {+ GrantAccessProjects = "grant-access-projects"+}+export enum OrgPermissionSubjects {Workspace = "workspace",Role = "role",@@ -22,7 +26,8 @@ export enum OrgPermissionSubjects {Billing = "billing",SecretScanning = "secret-scanning",Identity = "identity",- Kms = "kms"+ Kms = "kms",+ AdminConsole = "admin-console"}export type OrgPermissionSet =@@ -39,7 +44,8 @@ export type OrgPermissionSet =| [OrgPermissionActions, OrgPermissionSubjects.SecretScanning]| [OrgPermissionActions, OrgPermissionSubjects.Billing]| [OrgPermissionActions, OrgPermissionSubjects.Identity]- | [OrgPermissionActions, OrgPermissionSubjects.Kms];+ | [OrgPermissionActions, OrgPermissionSubjects.Kms]+ | [OrgPermissionAdminConsoleAction, OrgPermissionSubjects.AdminConsole];const buildAdminPermission = () => {const { can, build } = new AbilityBuilder<MongoAbility<OrgPermissionSet>>(createMongoAbility);@@ -107,6 +113,8 @@ const buildAdminPermission = () => {can(OrgPermissionActions.Edit, OrgPermissionSubjects.Kms);can(OrgPermissionActions.Delete, OrgPermissionSubjects.Kms);+ can(OrgPermissionAdminConsoleAction.GrantAccessProjects, OrgPermissionSubjects.AdminConsole);+return build({ conditionsMatcher });};diff --git a/backend/src/server/routes/v1/index.ts b/backend/src/server/routes/v1/index.tsindex bb6b9b57b6..6c988d9955 100644--- a/backend/src/server/routes/v1/index.ts+++ b/backend/src/server/routes/v1/index.ts@@ -51,7 +51,7 @@ export const registerV1Routes = async (server: FastifyZodProvider) => {await server.register(registerPasswordRouter, { prefix: "/password" });await server.register(registerOrgRouter, { prefix: "/organization" });await server.register(registerAdminRouter, { prefix: "/admin" });- await server.register(registerOrgAdminRouter, { prefix: "/org-admin" });+ await server.register(registerOrgAdminRouter, { prefix: "/organization-admin" });await server.register(registerUserRouter, { prefix: "/user" });await server.register(registerInviteOrgRouter, { prefix: "/invite-org" });await server.register(registerUserActionRouter, { prefix: "/user-action" });diff --git a/backend/src/server/routes/v1/org-admin-router.ts b/backend/src/server/routes/v1/org-admin-router.tsindex 5339d91b5f..2d28b09bdd 100644--- a/backend/src/server/routes/v1/org-admin-router.ts+++ b/backend/src/server/routes/v1/org-admin-router.ts@@ -45,7 +45,7 @@ export const registerOrgAdminRouter = async (server: FastifyZodProvider) => {server.route({method: "POST",- url: "/projects/:projectId/access",+ url: "/projects/:projectId/grant-admin-access",config: {rateLimit: readLimit},@@ -61,7 +61,7 @@ export const registerOrgAdminRouter = async (server: FastifyZodProvider) => {},onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {- const { membership } = await server.services.orgAdmin.accessProject({+ const { membership } = await server.services.orgAdmin.grantProjectAdminAccess({actorOrgId: req.permission.orgId,actorAuthMethod: req.permission.authMethod,actorId: req.permission.id,diff --git a/backend/src/services/org-admin/org-admin-service.ts b/backend/src/services/org-admin/org-admin-service.tsindex aef1342b42..cfdda663d4 100644--- a/backend/src/services/org-admin/org-admin-service.ts+++ b/backend/src/services/org-admin/org-admin-service.ts@@ -1,7 +1,10 @@-import { OrgMembershipRole, ProjectMembershipRole, ProjectVersion, SecretKeyEncoding } from "@app/db/schemas";+import { ForbiddenError } from "@casl/ability";++import { ProjectMembershipRole, ProjectVersion, SecretKeyEncoding } from "@app/db/schemas";+import { OrgPermissionAdminConsoleAction, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";import { infisicalSymmetricDecrypt } from "@app/lib/crypto/encryption";-import { BadRequestError, UnauthorizedError } from "@app/lib/errors";+import { BadRequestError } from "@app/lib/errors";import { TProjectDALFactory } from "../project/project-dal";import { assignWorkspaceKeysToMembers } from "../project/project-fns";@@ -42,15 +45,17 @@ export const orgAdminServiceFactory = ({actorOrgId,actorAuthMethod}: TListOrgProjectsDTO) => {- const { membership } = await permissionService.getOrgPermission(+ const { permission } = await permissionService.getOrgPermission(actor,actorId,actorOrgId,actorAuthMethod,actorOrgId);- const isAdmin = membership.role === OrgMembershipRole.Admin;- if (!isAdmin) throw new UnauthorizedError({ message: "Admin only operation" });+ ForbiddenError.from(permission).throwUnlessCan(+ OrgPermissionAdminConsoleAction.GrantAccessProjects,+ OrgPermissionSubjects.AdminConsole+ );const projects = await projectDAL.find({orgId: actorOrgId,@@ -65,16 +70,24 @@ export const orgAdminServiceFactory = ({return { projects, count };};- const accessProject = async ({ actor, actorId, actorOrgId, actorAuthMethod, projectId }: TAccessProjectDTO) => {- const { membership } = await permissionService.getOrgPermission(+ const grantProjectAdminAccess = async ({+ actor,+ actorId,+ actorOrgId,+ actorAuthMethod,+ projectId+ }: TAccessProjectDTO) => {+ const { permission, membership } = await permissionService.getOrgPermission(actor,actorId,actorOrgId,actorAuthMethod,actorOrgId);- const isAdmin = membership.role === OrgMembershipRole.Admin;- if (!isAdmin) throw new UnauthorizedError({ message: "Admin only operation" });+ ForbiddenError.from(permission).throwUnlessCan(+ OrgPermissionAdminConsoleAction.GrantAccessProjects,+ OrgPermissionSubjects.AdminConsole+ );const project = await projectDAL.findById(projectId);if (!project) throw new BadRequestError({ message: "Project not found" });@@ -174,5 +187,5 @@ export const orgAdminServiceFactory = ({return { isExistingMember: false, membership: updatedMembership };};- return { listOrgProjects, accessProject };+ return { listOrgProjects, grantProjectAdminAccess };};diff --git a/frontend/src/context/OrgPermissionContext/types.ts b/frontend/src/context/OrgPermissionContext/types.tsindex 36206873d3..a36aaac69e 100644--- a/frontend/src/context/OrgPermissionContext/types.ts+++ b/frontend/src/context/OrgPermissionContext/types.ts@@ -20,7 +20,12 @@ export enum OrgPermissionSubjects {Billing = "billing",SecretScanning = "secret-scanning",Identity = "identity",- Kms = "kms"+ Kms = "kms",+ AdminConsole = "admin-console"+}++export enum OrgPermissionAdminConsoleAction {+ GrantAccessProjects = "grant-access-projects"}export type OrgPermissionSet =@@ -37,6 +42,7 @@ export type OrgPermissionSet =| [OrgPermissionActions, OrgPermissionSubjects.SecretScanning]| [OrgPermissionActions, OrgPermissionSubjects.Billing]| [OrgPermissionActions, OrgPermissionSubjects.Identity]- | [OrgPermissionActions, OrgPermissionSubjects.Kms];+ | [OrgPermissionActions, OrgPermissionSubjects.Kms]+ | [OrgPermissionAdminConsoleAction, OrgPermissionSubjects.AdminConsole];export type TOrgPermission = MongoAbility<OrgPermissionSet>;diff --git a/frontend/src/hooks/api/orgAdmin/mutation.tsx b/frontend/src/hooks/api/orgAdmin/mutation.tsxindex 3b2c69efad..9fa93722ed 100644--- a/frontend/src/hooks/api/orgAdmin/mutation.tsx+++ b/frontend/src/hooks/api/orgAdmin/mutation.tsx@@ -7,7 +7,9 @@ import { TOrgAdminAccessProjectDTO } from "./types";export const useOrgAdminAccessProject = () =>useMutation({mutationFn: async ({ projectId }: TOrgAdminAccessProjectDTO) => {- const { data } = await apiRequest.post(`/api/v1/org-admin/projects/${projectId}/access`);+ const { data } = await apiRequest.post(+ `/api/v1/organization-admin/projects/${projectId}/grant-admin-access`+ );return data;}});diff --git a/frontend/src/hooks/api/orgAdmin/queries.tsx b/frontend/src/hooks/api/orgAdmin/queries.tsxindex 23826a9a41..2856de0a2e 100644--- a/frontend/src/hooks/api/orgAdmin/queries.tsx+++ b/frontend/src/hooks/api/orgAdmin/queries.tsx@@ -14,7 +14,7 @@ export const useOrgAdminGetProjects = ({ search, offset, limit = 50 }: TOrgAdminqueryKey: orgAdminQueryKeys.getProjects({ search, offset, limit }),queryFn: async () => {const { data } = await apiRequest.get<{ projects: Workspace[]; count: number }>(- "/api/v1/org-admin/projects",+ "/api/v1/organization-admin/projects",{params: {limit,diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsxindex 8a794f901b..0568a58212 100644--- a/frontend/src/layouts/AppLayout/AppLayout.tsx+++ b/frontend/src/layouts/AppLayout/AppLayout.tsx@@ -59,7 +59,6 @@ import {OrgPermissionActions,OrgPermissionSubjects,useOrganization,- useOrgPermission,useSubscription,useUser,useWorkspace@@ -132,8 +131,6 @@ export const AppLayout = ({ children }: LayoutProps) => {const { workspaces, currentWorkspace } = useWorkspace();const { orgs, currentOrg } = useOrganization();- const { membership } = useOrgPermission();- const isOrgAdmin = membership?.role === "admin";const { data: projectFavorites } = useGetUserProjectFavorites(currentOrg?.id!);const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();@@ -483,6 +480,11 @@ export const AppLayout = ({ children }: LayoutProps) => {</DropdownMenuItem></Link>)}+ <Link href={`/org/${currentOrg?.id}/admin`} legacyBehavior>+ <DropdownMenuItem className="mt-1 border-t border-mineshaft-600">+ Admin Panel+ </DropdownMenuItem>+ </Link><div className="mt-1 h-1 border-t border-mineshaft-600" /><button type="button" onClick={logOutUser} className="w-full"><DropdownMenuItem>Log Out</DropdownMenuItem>@@ -751,18 +753,6 @@ export const AppLayout = ({ children }: LayoutProps) => {</a></Link>)}- {isOrgAdmin && (- <Link href={`/org/${currentOrg?.id}/admin`} passHref>- <a>- <MenuItem- isSelected={router.asPath === `/org/${currentOrg?.id}/admin`}- icon="system-outline-109-slider-toggle-settings"- >- Admin Panel- </MenuItem>- </a>- </Link>- )}<Link href={`/org/${currentOrg?.id}/settings`} passHref><a><MenuItemdiff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsxindex a6256f5963..babf1a15f4 100644--- a/frontend/src/pages/org/[id]/overview/index.tsx+++ b/frontend/src/pages/org/[id]/overview/index.tsx@@ -60,7 +60,6 @@ import {useUser,useWorkspace} from "@app/context";-import { withPermission } from "@app/hoc";import {fetchOrgUsers,useAddUserToWsNonE2EE,@@ -488,673 +487,659 @@ const formSchema = yup.object({type TAddProjectFormData = yup.InferType<typeof formSchema>;// #TODO: Update all the workspaceIds-const OrganizationPage = withPermission(- () => {- const { t } = useTranslation();+const OrganizationPage = () => {+ const { t } = useTranslation();- const router = useRouter();+ const router = useRouter();- const { workspaces, isLoading: isWorkspaceLoading } = useWorkspace();- const { currentOrg } = useOrganization();- const routerOrgId = String(router.query.id);- const orgWorkspaces = workspaces?.filter((workspace) => workspace.orgId === routerOrgId) || [];- const { data: projectFavorites, isLoading: isProjectFavoritesLoading } =- useGetUserProjectFavorites(currentOrg?.id!);- const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();+ const { workspaces, isLoading: isWorkspaceLoading } = useWorkspace();+ const { currentOrg } = useOrganization();+ const routerOrgId = String(router.query.id);+ const orgWorkspaces = workspaces?.filter((workspace) => workspace.orgId === routerOrgId) || [];+ const { data: projectFavorites, isLoading: isProjectFavoritesLoading } =+ useGetUserProjectFavorites(currentOrg?.id!);+ const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();- const isProjectViewLoading = isWorkspaceLoading || isProjectFavoritesLoading;- const addUsersToProject = useAddUserToWsNonE2EE();+ const isProjectViewLoading = isWorkspaceLoading || isProjectFavoritesLoading;+ const addUsersToProject = useAddUserToWsNonE2EE();- const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([- "addNewWs",- "upgradePlan"- ] as const);- const {- control,- formState: { isSubmitting },- reset,- handleSubmit- } = useForm<TAddProjectFormData>({- resolver: yupResolver(formSchema),- defaultValues: {- kmsKeyId: INTERNAL_KMS_KEY_ID- }- });-- const [hasUserClickedSlack, setHasUserClickedSlack] = useState(false);- const [hasUserClickedIntro, setHasUserClickedIntro] = useState(false);- const [hasUserPushedSecrets, setHasUserPushedSecrets] = useState(false);- const [usersInOrg, setUsersInOrg] = useState(false);- const [searchFilter, setSearchFilter] = useState("");- const createWs = useCreateWorkspace();- const { user } = useUser();- const { data: serverDetails } = useFetchServerStatus();- const [projectsViewMode, setProjectsViewMode] = useState<ProjectsViewMode>(- (localStorage.getItem("projectsViewMode") as ProjectsViewMode) || ProjectsViewMode.GRID- );+ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([+ "addNewWs",+ "upgradePlan"+ ] as const);+ const {+ control,+ formState: { isSubmitting },+ reset,+ handleSubmit+ } = useForm<TAddProjectFormData>({+ resolver: yupResolver(formSchema),+ defaultValues: {+ kmsKeyId: INTERNAL_KMS_KEY_ID+ }+ });- const { data: externalKmsList } = useGetExternalKmsList(currentOrg?.id!);-- const onCreateProject = async ({ name, addMembers, kmsKeyId }: TAddProjectFormData) => {- // type check- if (!currentOrg) return;- if (!user) return;- try {- const {- data: {- project: { id: newProjectId }- }- } = await createWs.mutateAsync({- projectName: name,- kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined- });+ const [hasUserClickedSlack, setHasUserClickedSlack] = useState(false);+ const [hasUserClickedIntro, setHasUserClickedIntro] = useState(false);+ const [hasUserPushedSecrets, setHasUserPushedSecrets] = useState(false);+ const [usersInOrg, setUsersInOrg] = useState(false);+ const [searchFilter, setSearchFilter] = useState("");+ const createWs = useCreateWorkspace();+ const { user } = useUser();+ const { data: serverDetails } = useFetchServerStatus();+ const [projectsViewMode, setProjectsViewMode] = useState<ProjectsViewMode>(+ (localStorage.getItem("projectsViewMode") as ProjectsViewMode) || ProjectsViewMode.GRID+ );- if (addMembers) {- const orgUsers = await fetchOrgUsers(currentOrg.id);+ const { data: externalKmsList } = useGetExternalKmsList(currentOrg?.id!);- await addUsersToProject.mutateAsync({- usernames: orgUsers- .map((member) => member.user.username)- .filter((username) => username !== user.username),- projectId: newProjectId,- orgId: currentOrg.id- });+ const onCreateProject = async ({ name, addMembers, kmsKeyId }: TAddProjectFormData) => {+ // type check+ if (!currentOrg) return;+ if (!user) return;+ try {+ const {+ data: {+ project: { id: newProjectId }}+ } = await createWs.mutateAsync({+ projectName: name,+ kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined+ });- // eslint-disable-next-line no-promise-executor-return -- We do this because the function returns too fast, which sometimes causes an error when the user is redirected.- await new Promise((resolve) => setTimeout(resolve, 2_000));+ if (addMembers) {+ const orgUsers = await fetchOrgUsers(currentOrg.id);- handlePopUpClose("addNewWs");- createNotification({ text: "Project created", type: "success" });- router.push(`/project/${newProjectId}/secrets/overview`);- } catch (err) {- console.error(err);- createNotification({ text: "Failed to create project", type: "error" });+ await addUsersToProject.mutateAsync({+ usernames: orgUsers+ .map((member) => member.user.username)+ .filter((username) => username !== user.username),+ projectId: newProjectId,+ orgId: currentOrg.id+ });}- };- const { subscription } = useSubscription();+ // eslint-disable-next-line no-promise-executor-return -- We do this because the function returns too fast, which sometimes causes an error when the user is redirected.+ await new Promise((resolve) => setTimeout(resolve, 2_000));- const isAddingProjectsAllowed = subscription?.workspaceLimit- ? subscription.workspacesUsed < subscription.workspaceLimit- : true;+ handlePopUpClose("addNewWs");+ createNotification({ text: "Project created", type: "success" });+ router.push(`/project/${newProjectId}/secrets/overview`);+ } catch (err) {+ console.error(err);+ createNotification({ text: "Failed to create project", type: "error" });+ }+ };- useEffect(() => {- onboardingCheck({- orgId: routerOrgId,- setHasUserClickedIntro,- setHasUserClickedSlack,- setHasUserPushedSecrets,- setUsersInOrg- });- }, []);+ const { subscription } = useSubscription();- const isWorkspaceEmpty = !isWorkspaceLoading && orgWorkspaces?.length === 0;- const filteredWorkspaces = orgWorkspaces.filter((ws) =>- ws?.name?.toLowerCase().includes(searchFilter.toLowerCase())- );+ const isAddingProjectsAllowed = subscription?.workspaceLimit+ ? subscription.workspacesUsed < subscription.workspaceLimit+ : true;- const { workspacesWithFaveProp, favoriteWorkspaces, nonFavoriteWorkspaces } = useMemo(() => {- const workspacesWithFav = filteredWorkspaces- .map((w): Workspace & { isFavorite: boolean } => ({- ...w,- isFavorite: Boolean(projectFavorites?.includes(w.id))- }))- .sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite));+ useEffect(() => {+ onboardingCheck({+ orgId: routerOrgId,+ setHasUserClickedIntro,+ setHasUserClickedSlack,+ setHasUserPushedSecrets,+ setUsersInOrg+ });+ }, []);- const favWorkspaces = workspacesWithFav.filter((w) => w.isFavorite);- const nonFavWorkspaces = workspacesWithFav.filter((w) => !w.isFavorite);+ const isWorkspaceEmpty = !isWorkspaceLoading && orgWorkspaces?.length === 0;+ const filteredWorkspaces = orgWorkspaces.filter((ws) =>+ ws?.name?.toLowerCase().includes(searchFilter.toLowerCase())+ );- return {- workspacesWithFaveProp: workspacesWithFav,- favoriteWorkspaces: favWorkspaces,- nonFavoriteWorkspaces: nonFavWorkspaces- };- }, [filteredWorkspaces, projectFavorites]);+ const { workspacesWithFaveProp, favoriteWorkspaces, nonFavoriteWorkspaces } = useMemo(() => {+ const workspacesWithFav = filteredWorkspaces+ .map((w): Workspace & { isFavorite: boolean } => ({+ ...w,+ isFavorite: Boolean(projectFavorites?.includes(w.id))+ }))+ .sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite));- const addProjectToFavorites = async (projectId: string) => {- try {- if (currentOrg?.id) {- await updateUserProjectFavorites({- orgId: currentOrg?.id,- projectFavorites: [...(projectFavorites || []), projectId]- });- }- } catch (err) {- createNotification({- text: "Failed to add project to favorites.",- type: "error"+ const favWorkspaces = workspacesWithFav.filter((w) => w.isFavorite);+ const nonFavWorkspaces = workspacesWithFav.filter((w) => !w.isFavorite);++ return {+ workspacesWithFaveProp: workspacesWithFav,+ favoriteWorkspaces: favWorkspaces,+ nonFavoriteWorkspaces: nonFavWorkspaces+ };+ }, [filteredWorkspaces, projectFavorites]);++ const addProjectToFavorites = async (projectId: string) => {+ try {+ if (currentOrg?.id) {+ await updateUserProjectFavorites({+ orgId: currentOrg?.id,+ projectFavorites: [...(projectFavorites || []), projectId]});}- };+ } catch (err) {+ createNotification({+ text: "Failed to add project to favorites.",+ type: "error"+ });+ }+ };- const removeProjectFromFavorites = async (projectId: string) => {- try {- if (currentOrg?.id) {- await updateUserProjectFavorites({- orgId: currentOrg?.id,- projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]- });- }- } catch (err) {- createNotification({- text: "Failed to remove project from favorites.",- type: "error"+ const removeProjectFromFavorites = async (projectId: string) => {+ try {+ if (currentOrg?.id) {+ await updateUserProjectFavorites({+ orgId: currentOrg?.id,+ projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]});}- };+ } catch (err) {+ createNotification({+ text: "Failed to remove project from favorites.",+ type: "error"+ });+ }+ };- const renderProjectGridItem = (workspace: Workspace, isFavorite: boolean) => (- // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events- <div- onClick={() => {- router.push(`/project/${workspace.id}/secrets/overview`);- localStorage.setItem("projectData.id", workspace.id);- }}- key={workspace.id}- className="min-w-72 flex h-40 cursor-pointer flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"- >- <div className="flex flex-row justify-between">- <div className="mt-0 truncate text-lg text-mineshaft-100">{workspace.name}</div>- {isFavorite ? (- <FontAwesomeIcon- icon={faSolidStar}- className="text-sm text-mineshaft-300 hover:text-mineshaft-400"- onClick={(e) => {- e.stopPropagation();- removeProjectFromFavorites(workspace.id);- }}- />- ) : (- <FontAwesomeIcon- icon={faStar}- className="text-sm text-mineshaft-400 hover:text-mineshaft-300"- onClick={(e) => {- e.stopPropagation();- addProjectToFavorites(workspace.id);- }}- />- )}+ const renderProjectGridItem = (workspace: Workspace, isFavorite: boolean) => (+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events+ <div+ onClick={() => {+ router.push(`/project/${workspace.id}/secrets/overview`);+ localStorage.setItem("projectData.id", workspace.id);+ }}+ key={workspace.id}+ className="min-w-72 flex h-40 cursor-pointer flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"+ >+ <div className="flex flex-row justify-between">+ <div className="mt-0 truncate text-lg text-mineshaft-100">{workspace.name}</div>+ {isFavorite ? (+ <FontAwesomeIcon+ icon={faSolidStar}+ className="text-sm text-mineshaft-300 hover:text-mineshaft-400"+ onClick={(e) => {+ e.stopPropagation();+ removeProjectFromFavorites(workspace.id);+ }}+ />+ ) : (+ <FontAwesomeIcon+ icon={faStar}+ className="text-sm text-mineshaft-400 hover:text-mineshaft-300"+ onClick={(e) => {+ e.stopPropagation();+ addProjectToFavorites(workspace.id);+ }}+ />+ )}+ </div>+ <div className="mt-0 pb-6 text-sm text-mineshaft-300">+ {workspace.environments?.length || 0} environments+ </div>+ <button type="button">+ <div className="group ml-auto w-max cursor-pointer rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 transition-all hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200">+ Explore{" "}+ <FontAwesomeIcon+ icon={faArrowRight}+ className="pl-1.5 pr-0.5 duration-200 hover:pl-2 hover:pr-0"+ /></div>- <div className="mt-0 pb-6 text-sm text-mineshaft-300">+ </button>+ </div>+ );++ const renderProjectListItem = (workspace: Workspace, isFavorite: boolean, index: number) => (+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events+ <div+ onClick={() => {+ router.push(`/project/${workspace.id}/secrets/overview`);+ localStorage.setItem("projectData.id", workspace.id);+ }}+ key={workspace.id}+ className={`min-w-72 group grid h-14 cursor-pointer grid-cols-6 border-t border-l border-r border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${+ index === 0 && "rounded-t-md"+ } ${index === filteredWorkspaces.length - 1 && "rounded-b-md border-b"}`}+ >+ <div className="flex items-center sm:col-span-3 lg:col-span-4">+ <FontAwesomeIcon icon={faFileShield} className="text-sm text-primary/70" />+ <div className="ml-5 truncate text-sm text-mineshaft-100">{workspace.name}</div>+ </div>+ <div className="flex items-center justify-end sm:col-span-3 lg:col-span-2">+ <div className="text-center text-sm text-mineshaft-300">{workspace.environments?.length || 0} environments</div>- <button type="button">- <div className="group ml-auto w-max cursor-pointer rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 transition-all hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200">- Explore{" "}- <FontAwesomeIcon- icon={faArrowRight}- className="pl-1.5 pr-0.5 duration-200 hover:pl-2 hover:pr-0"- />- </div>- </button>+ {isFavorite ? (+ <FontAwesomeIcon+ icon={faSolidStar}+ className="ml-6 text-sm text-mineshaft-300 hover:text-mineshaft-400"+ onClick={(e) => {+ e.stopPropagation();+ removeProjectFromFavorites(workspace.id);+ }}+ />+ ) : (+ <FontAwesomeIcon+ icon={faStar}+ className="ml-6 text-sm text-mineshaft-400 hover:text-mineshaft-300"+ onClick={(e) => {+ e.stopPropagation();+ addProjectToFavorites(workspace.id);+ }}+ />+ )}</div>- );+ </div>+ );- const renderProjectListItem = (workspace: Workspace, isFavorite: boolean, index: number) => (- // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events- <div- onClick={() => {- router.push(`/project/${workspace.id}/secrets/overview`);- localStorage.setItem("projectData.id", workspace.id);- }}- key={workspace.id}- className={`min-w-72 group grid h-14 cursor-pointer grid-cols-6 border-t border-l border-r border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${- index === 0 && "rounded-t-md"- } ${index === filteredWorkspaces.length - 1 && "rounded-b-md border-b"}`}- >- <div className="flex items-center sm:col-span-3 lg:col-span-4">- <FontAwesomeIcon icon={faFileShield} className="text-sm text-primary/70" />- <div className="ml-5 truncate text-sm text-mineshaft-100">{workspace.name}</div>- </div>- <div className="flex items-center justify-end sm:col-span-3 lg:col-span-2">- <div className="text-center text-sm text-mineshaft-300">- {workspace.environments?.length || 0} environments+ const projectsGridView = (+ <>+ {favoriteWorkspaces.length > 0 && (+ <>+ <p className="mt-6 text-xl font-semibold text-white">Favorites</p>+ <div+ className={`b grid w-full grid-cols-1 gap-4 ${+ nonFavoriteWorkspaces.length > 0 && "border-b border-mineshaft-600"+ } py-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`}+ >+ {favoriteWorkspaces.map((workspace) => renderProjectGridItem(workspace, true))}</div>- {isFavorite ? (- <FontAwesomeIcon- icon={faSolidStar}- className="ml-6 text-sm text-mineshaft-300 hover:text-mineshaft-400"- onClick={(e) => {- e.stopPropagation();- removeProjectFromFavorites(workspace.id);- }}- />- ) : (- <FontAwesomeIcon- icon={faStar}- className="ml-6 text-sm text-mineshaft-400 hover:text-mineshaft-300"- onClick={(e) => {- e.stopPropagation();- addProjectToFavorites(workspace.id);- }}- />- )}- </div>- </div>- );-- const projectsGridView = (- <>- {favoriteWorkspaces.length > 0 && (- <>- <p className="mt-6 text-xl font-semibold text-white">Favorites</p>- <div- className={`b grid w-full grid-cols-1 gap-4 ${- nonFavoriteWorkspaces.length > 0 && "border-b border-mineshaft-600"- } py-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`}- >- {favoriteWorkspaces.map((workspace) => renderProjectGridItem(workspace, true))}- </div>- </>- )}- <div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">- {isProjectViewLoading &&- Array.apply(0, Array(3)).map((_x, i) => (- <div- key={`workspace-cards-loading-${i + 1}`}- className="min-w-72 flex h-40 flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"- >- <div className="mt-0 text-lg text-mineshaft-100">- <Skeleton className="w-3/4 bg-mineshaft-600" />- </div>- <div className="mt-0 pb-6 text-sm text-mineshaft-300">- <Skeleton className="w-1/2 bg-mineshaft-600" />- </div>- <div className="flex justify-end">- <Skeleton className="w-1/2 bg-mineshaft-600" />- </div>- </div>- ))}- {!isProjectViewLoading &&- nonFavoriteWorkspaces.map((workspace) => renderProjectGridItem(workspace, false))}- </div>- </>- );-- const projectsListView = (- <div className="mt-4 w-full rounded-md">+ </>+ )}+ <div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">{isProjectViewLoading &&Array.apply(0, Array(3)).map((_x, i) => (<divkey={`workspace-cards-loading-${i + 1}`}- className={`min-w-72 group flex h-12 cursor-pointer flex-row items-center justify-between border border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${- i === 0 && "rounded-t-md"- } ${i === 2 && "rounded-b-md border-b"}`}+ className="min-w-72 flex h-40 flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4">- <Skeleton className="w-full bg-mineshaft-600" />+ <div className="mt-0 text-lg text-mineshaft-100">+ <Skeleton className="w-3/4 bg-mineshaft-600" />+ </div>+ <div className="mt-0 pb-6 text-sm text-mineshaft-300">+ <Skeleton className="w-1/2 bg-mineshaft-600" />+ </div>+ <div className="flex justify-end">+ <Skeleton className="w-1/2 bg-mineshaft-600" />+ </div></div>))}{!isProjectViewLoading &&- workspacesWithFaveProp.map((workspace, ind) =>- renderProjectListItem(workspace, workspace.isFavorite, ind)- )}+ nonFavoriteWorkspaces.map((workspace) => renderProjectGridItem(workspace, false))}</div>- );+ </>+ );- return (- <div className="mx-auto flex max-w-7xl flex-col justify-start bg-bunker-800 md:h-screen">- <Head>- <title>{t("common.head-title", { title: t("settings.members.title") })}</title>- <link rel="icon" href="/infisical.ico" />- </Head>- {!serverDetails?.redisConfigured && (- <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">- <p className="mr-4 mb-4 font-semibold text-white">Announcements</p>- <div className="flex w-full items-center rounded-md border border-blue-400/70 bg-blue-900/70 p-2 text-base text-mineshaft-100">- <FontAwesomeIcon- icon={faExclamationCircle}- className="mr-4 p-4 text-2xl text-mineshaft-50"- />- Attention: Updated versions of Infisical now require Redis for full functionality.- Learn how to configure it- <Link- href="https://infisical.com/docs/self-hosting/configuration/redis"- target="_blank"- >- <span className="cursor-pointer pl-1 text-white underline underline-offset-2 duration-100 hover:text-blue-200 hover:decoration-blue-400">- here- </span>- </Link>- .- </div>+ const projectsListView = (+ <div className="mt-4 w-full rounded-md">+ {isProjectViewLoading &&+ Array.apply(0, Array(3)).map((_x, i) => (+ <div+ key={`workspace-cards-loading-${i + 1}`}+ className={`min-w-72 group flex h-12 cursor-pointer flex-row items-center justify-between border border-mineshaft-600 bg-mineshaft-800 px-6 hover:bg-mineshaft-700 ${+ i === 0 && "rounded-t-md"+ } ${i === 2 && "rounded-b-md border-b"}`}+ >+ <Skeleton className="w-full bg-mineshaft-600" /></div>+ ))}+ {!isProjectViewLoading &&+ workspacesWithFaveProp.map((workspace, ind) =>+ renderProjectListItem(workspace, workspace.isFavorite, ind))}+ </div>+ );++ return (+ <div className="mx-auto flex max-w-7xl flex-col justify-start bg-bunker-800 md:h-screen">+ <Head>+ <title>{t("common.head-title", { title: t("settings.members.title") })}</title>+ <link rel="icon" href="/infisical.ico" />+ </Head>+ {!serverDetails?.redisConfigured && (<div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">- <div className="flex w-full justify-between">- <p className="mr-4 font-semibold text-white">Projects</p>- </div>- <div className="mt-6 flex w-full flex-row">- <Input- className="h-[2.3rem] bg-mineshaft-800 text-sm placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"- placeholder="Search by project name..."- value={searchFilter}- onChange={(e) => setSearchFilter(e.target.value)}- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}+ <p className="mr-4 mb-4 font-semibold text-white">Announcements</p>+ <div className="flex w-full items-center rounded-md border border-blue-400/70 bg-blue-900/70 p-2 text-base text-mineshaft-100">+ <FontAwesomeIcon+ icon={faExclamationCircle}+ className="mr-4 p-4 text-2xl text-mineshaft-50"/>- <div className="ml-2 flex rounded-md border border-mineshaft-600 bg-mineshaft-800 p-1">- <IconButton- variant="outline_bg"- onClick={() => {- localStorage.setItem("projectsViewMode", ProjectsViewMode.GRID);- setProjectsViewMode(ProjectsViewMode.GRID);- }}- ariaLabel="grid"- size="xs"- className={`${- projectsViewMode === ProjectsViewMode.GRID ? "bg-mineshaft-500" : "bg-transparent"- } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}- >- <FontAwesomeIcon icon={faBorderAll} />- </IconButton>- <IconButton- variant="outline_bg"+ Attention: Updated versions of Infisical now require Redis for full functionality. Learn+ how to configure it+ <Link+ href="https://infisical.com/docs/self-hosting/configuration/redis"+ target="_blank"+ >+ <span className="cursor-pointer pl-1 text-white underline underline-offset-2 duration-100 hover:text-blue-200 hover:decoration-blue-400">+ here+ </span>+ </Link>+ .+ </div>+ </div>+ )}+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">+ <div className="flex w-full justify-between">+ <p className="mr-4 font-semibold text-white">Projects</p>+ </div>+ <div className="mt-6 flex w-full flex-row">+ <Input+ className="h-[2.3rem] bg-mineshaft-800 text-sm placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"+ placeholder="Search by project name..."+ value={searchFilter}+ onChange={(e) => setSearchFilter(e.target.value)}+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}+ />+ <div className="ml-2 flex rounded-md border border-mineshaft-600 bg-mineshaft-800 p-1">+ <IconButton+ variant="outline_bg"+ onClick={() => {+ localStorage.setItem("projectsViewMode", ProjectsViewMode.GRID);+ setProjectsViewMode(ProjectsViewMode.GRID);+ }}+ ariaLabel="grid"+ size="xs"+ className={`${+ projectsViewMode === ProjectsViewMode.GRID ? "bg-mineshaft-500" : "bg-transparent"+ } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}+ >+ <FontAwesomeIcon icon={faBorderAll} />+ </IconButton>+ <IconButton+ variant="outline_bg"+ onClick={() => {+ localStorage.setItem("projectsViewMode", ProjectsViewMode.LIST);+ setProjectsViewMode(ProjectsViewMode.LIST);+ }}+ ariaLabel="list"+ size="xs"+ className={`${+ projectsViewMode === ProjectsViewMode.LIST ? "bg-mineshaft-500" : "bg-transparent"+ } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}+ >+ <FontAwesomeIcon icon={faList} />+ </IconButton>+ </div>+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Workspace}>+ {(isAllowed) => (+ <Button+ isDisabled={!isAllowed}+ colorSchema="primary"+ leftIcon={<FontAwesomeIcon icon={faPlus} />}onClick={() => {- localStorage.setItem("projectsViewMode", ProjectsViewMode.LIST);- setProjectsViewMode(ProjectsViewMode.LIST);+ if (isAddingProjectsAllowed) {+ handlePopUpOpen("addNewWs");+ } else {+ handlePopUpOpen("upgradePlan");+ }}}- ariaLabel="list"- size="xs"- className={`${- projectsViewMode === ProjectsViewMode.LIST ? "bg-mineshaft-500" : "bg-transparent"- } min-w-[2.4rem] border-none hover:bg-mineshaft-600`}+ className="ml-2">- <FontAwesomeIcon icon={faList} />- </IconButton>+ Add New Project+ </Button>+ )}+ </OrgPermissionCan>+ </div>+ {projectsViewMode === ProjectsViewMode.LIST ? projectsListView : projectsGridView}+ {isWorkspaceEmpty && (+ <div className="w-full rounded-md border border-mineshaft-700 bg-mineshaft-800 px-4 py-6 text-base text-mineshaft-300">+ <FontAwesomeIcon+ icon={faFolderOpen}+ className="mb-4 mt-2 w-full text-center text-5xl text-mineshaft-400"+ />+ <div className="text-center font-light">+ You are not part of any projects in this organization yet. When you are, they will+ appear here.+ </div>+ <div className="mt-0.5 text-center font-light">+ Create a new project, or ask other organization members to give you necessary+ permissions.</div>- <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Workspace}>- {(isAllowed) => (- <Button- isDisabled={!isAllowed}- colorSchema="primary"- leftIcon={<FontAwesomeIcon icon={faPlus} />}- onClick={() => {- if (isAddingProjectsAllowed) {- handlePopUpOpen("addNewWs");- } else {- handlePopUpOpen("upgradePlan");- }- }}- className="ml-2"- >- Add New Project- </Button>- )}- </OrgPermissionCan></div>- {projectsViewMode === ProjectsViewMode.LIST ? projectsListView : projectsGridView}- {isWorkspaceEmpty && (- <div className="w-full rounded-md border border-mineshaft-700 bg-mineshaft-800 px-4 py-6 text-base text-mineshaft-300">- <FontAwesomeIcon- icon={faFolderOpen}- className="mb-4 mt-2 w-full text-center text-5xl text-mineshaft-400"- />- <div className="text-center font-light">- You are not part of any projects in this organization yet. When you are, they will- appear here.+ )}+ </div>+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-6 text-3xl">+ <p className="mr-4 font-semibold text-white">Explore Infisical</p>+ <div className="mt-4 grid w-full grid-cols-3 gap-4">+ {features.map((feature) => (+ <div+ key={feature.id}+ className="relative flex h-full w-full flex-col gap-2 overflow-auto rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"+ >+ <div className="mt-0 text-lg text-mineshaft-100">{feature.name}</div>+ <div className="line-clamp overflwo-auto mb-4 mt-2 h-full text-[15px] font-light text-mineshaft-300">+ {feature.description}</div>- <div className="mt-0.5 text-center font-light">- Create a new project, or ask other organization members to give you necessary- permissions.+ <div className="flex w-full flex-col items-start gap-2 xl:flex-row xl:items-center">+ <p className="left-0 text-[15px] font-light text-mineshaft-300">+ Setup time: 20 min+ </p>+ <a+ target="_blank"+ rel="noopener noreferrer"+ className="group ml-0 w-max cursor-default rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 transition-all hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200 xl:ml-auto"+ href={feature.link}+ >+ Learn more{" "}+ <FontAwesomeIcon+ icon={faArrowRight}+ className="s pl-1.5 pr-0.5 duration-200 group-hover:pl-2 group-hover:pr-0"+ />+ </a></div></div>- )}- </div>- <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-6 text-3xl">- <p className="mr-4 font-semibold text-white">Explore Infisical</p>- <div className="mt-4 grid w-full grid-cols-3 gap-4">- {features.map((feature) => (- <div- key={feature.id}- className="relative flex h-full w-full flex-col gap-2 overflow-auto rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"- >- <div className="mt-0 text-lg text-mineshaft-100">{feature.name}</div>- <div className="line-clamp overflwo-auto mb-4 mt-2 h-full text-[15px] font-light text-mineshaft-300">- {feature.description}- </div>- <div className="flex w-full flex-col items-start gap-2 xl:flex-row xl:items-center">- <p className="left-0 text-[15px] font-light text-mineshaft-300">- Setup time: 20 min- </p>- <a- target="_blank"- rel="noopener noreferrer"- className="group ml-0 w-max cursor-default rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 transition-all hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200 xl:ml-auto"- href={feature.link}- >- Learn more{" "}- <FontAwesomeIcon- icon={faArrowRight}- className="s pl-1.5 pr-0.5 duration-200 group-hover:pl-2 group-hover:pr-0"- />- </a>- </div>- </div>- ))}- </div>+ ))}</div>- {!(- new Date().getTime() - new Date(user?.createdAt).getTime() <- 30 * 24 * 60 * 60 * 1000- ) && (- <div className="mb-4 flex flex-col items-start justify-start px-6 pb-0 text-3xl">- <p className="mr-4 mb-4 font-semibold text-white">Onboarding Guide</p>- <div className="mb-3 grid w-full grid-cols-1 gap-3 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">- <LearningItemSquare- text="Watch Infisical demo"- subText="Set up Infisical in 3 min."- complete={hasUserClickedIntro}- icon={faHandPeace}- time="3 min"- userAction="intro_cta_clicked"- link="https://www.youtube.com/watch?v=PK23097-25I"- />- {orgWorkspaces.length !== 0 && (- <>- <LearningItemSquare- text="Add your secrets"- subText="Drop a .env file or type your secrets."- complete={hasUserPushedSecrets}- icon={faPlus}- time="1 min"- userAction="first_time_secrets_pushed"- link={`/project/${orgWorkspaces[0]?.id}/secrets/overview`}- />- <LearningItemSquare- text="Invite your teammates"- subText="Infisical is better used as a team."- complete={usersInOrg}- icon={faUserPlus}- time="2 min"- link={`/org/${router.query.id}/members?action=invite`}- />- </>- )}- <div className="block xl:hidden 2xl:block">+ </div>+ {!(new Date().getTime() - new Date(user?.createdAt).getTime() < 30 * 24 * 60 * 60 * 1000) && (+ <div className="mb-4 flex flex-col items-start justify-start px-6 pb-0 text-3xl">+ <p className="mr-4 mb-4 font-semibold text-white">Onboarding Guide</p>+ <div className="mb-3 grid w-full grid-cols-1 gap-3 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">+ <LearningItemSquare+ text="Watch Infisical demo"+ subText="Set up Infisical in 3 min."+ complete={hasUserClickedIntro}+ icon={faHandPeace}+ time="3 min"+ userAction="intro_cta_clicked"+ link="https://www.youtube.com/watch?v=PK23097-25I"+ />+ {orgWorkspaces.length !== 0 && (+ <><LearningItemSquare- text="Join Infisical Slack"- subText="Have any questions? Ask us!"- complete={hasUserClickedSlack}- icon={faSlack}+ text="Add your secrets"+ subText="Drop a .env file or type your secrets."+ complete={hasUserPushedSecrets}+ icon={faPlus}time="1 min"- userAction="slack_cta_clicked"- link="https://infisical.com/slack"+ userAction="first_time_secrets_pushed"+ link={`/project/${orgWorkspaces[0]?.id}/secrets/overview`}/>- </div>+ <LearningItemSquare+ text="Invite your teammates"+ subText="Infisical is better used as a team."+ complete={usersInOrg}+ icon={faUserPlus}+ time="2 min"+ link={`/org/${router.query.id}/members?action=invite`}+ />+ </>+ )}+ <div className="block xl:hidden 2xl:block">+ <LearningItemSquare+ text="Join Infisical Slack"+ subText="Have any questions? Ask us!"+ complete={hasUserClickedSlack}+ icon={faSlack}+ time="1 min"+ userAction="slack_cta_clicked"+ link="https://infisical.com/slack"+ /></div>- {orgWorkspaces.length !== 0 && (- <div className="group relative mb-3 flex h-full w-full cursor-default flex-col items-center justify-between overflow-hidden rounded-md border border-mineshaft-600 bg-mineshaft-800 pl-2 pr-2 pt-4 pb-2 text-mineshaft-100 shadow-xl duration-200">- <div className="mb-4 flex w-full flex-row items-center pr-4">- <div className="mr-4 flex w-full flex-row items-center">- <FontAwesomeIcon icon={faNetworkWired} className="mx-2 w-16 text-4xl" />- {false && (- <div className="absolute left-12 top-10 flex h-7 w-7 items-center justify-center rounded-full bg-bunker-500 p-2 group-hover:bg-mineshaft-700">- <FontAwesomeIcon- icon={faCheckCircle}- className="h-5 w-5 text-4xl text-green"- />- </div>- )}- <div className="flex flex-col items-start pl-0.5">- <div className="mt-0.5 text-xl font-semibold">Inject secrets locally</div>- <div className="text-sm font-normal">- Replace .env files with a more secure and efficient alternative.- </div>+ </div>+ {orgWorkspaces.length !== 0 && (+ <div className="group relative mb-3 flex h-full w-full cursor-default flex-col items-center justify-between overflow-hidden rounded-md border border-mineshaft-600 bg-mineshaft-800 pl-2 pr-2 pt-4 pb-2 text-mineshaft-100 shadow-xl duration-200">+ <div className="mb-4 flex w-full flex-row items-center pr-4">+ <div className="mr-4 flex w-full flex-row items-center">+ <FontAwesomeIcon icon={faNetworkWired} className="mx-2 w-16 text-4xl" />+ {false && (+ <div className="absolute left-12 top-10 flex h-7 w-7 items-center justify-center rounded-full bg-bunker-500 p-2 group-hover:bg-mineshaft-700">+ <FontAwesomeIcon+ icon={faCheckCircle}+ className="h-5 w-5 text-4xl text-green"+ />+ </div>+ )}+ <div className="flex flex-col items-start pl-0.5">+ <div className="mt-0.5 text-xl font-semibold">Inject secrets locally</div>+ <div className="text-sm font-normal">+ Replace .env files with a more secure and efficient alternative.</div></div>- <div- className={`w-28 pr-4 text-right text-sm font-semibold ${- false && "text-green"- }`}- >- About 2 min- </div></div>- <TabsObject />- {false && <div className="absolute bottom-0 left-0 h-1 w-full bg-green" />}+ <div+ className={`w-28 pr-4 text-right text-sm font-semibold ${false && "text-green"}`}+ >+ About 2 min+ </div></div>- )}- {orgWorkspaces.length !== 0 && (- <LearningItem- text="Integrate Infisical with your infrastructure"- subText="Connect Infisical to various 3rd party services and platforms."- complete={false}- icon={faPlug}- time="15 min"- link="https://infisical.com/docs/integrations/overview"- />- )}- </div>- )}- <Modal- isOpen={popUp.addNewWs.isOpen}- onOpenChange={(isModalOpen) => {- handlePopUpToggle("addNewWs", isModalOpen);- reset();- }}+ <TabsObject />+ {false && <div className="absolute bottom-0 left-0 h-1 w-full bg-green" />}+ </div>+ )}+ {orgWorkspaces.length !== 0 && (+ <LearningItem+ text="Integrate Infisical with your infrastructure"+ subText="Connect Infisical to various 3rd party services and platforms."+ complete={false}+ icon={faPlug}+ time="15 min"+ link="https://infisical.com/docs/integrations/overview"+ />+ )}+ </div>+ )}+ <Modal+ isOpen={popUp.addNewWs.isOpen}+ onOpenChange={(isModalOpen) => {+ handlePopUpToggle("addNewWs", isModalOpen);+ reset();+ }}+ >+ <ModalContent+ title="Create a new project"+ subTitle="This project will contain your secrets and configurations.">- <ModalContent- title="Create a new project"- subTitle="This project will contain your secrets and configurations."- >- <form onSubmit={handleSubmit(onCreateProject)}>+ <form onSubmit={handleSubmit(onCreateProject)}>+ <Controller+ control={control}+ name="name"+ defaultValue=""+ render={({ field, fieldState: { error } }) => (+ <FormControl+ label="Project Name"+ isError={Boolean(error)}+ errorText={error?.message}+ >+ <Input {...field} placeholder="Type your project name" />+ </FormControl>+ )}+ />+ <div className="mt-4 pl-1"><Controllercontrol={control}- name="name"- defaultValue=""- render={({ field, fieldState: { error } }) => (- <FormControl- label="Project Name"- isError={Boolean(error)}- errorText={error?.message}- >- <Input {...field} placeholder="Type your project name" />- </FormControl>+ 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 className="mt-4 pl-1">- <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">- <AccordionItem value="advance-settings" className="data-[state=open]:border-none">- <AccordionTrigger className="h-fit flex-none pl-1 text-sm">- <div className="order-1 ml-3">Advanced Settings</div>- </AccordionTrigger>- <AccordionContent>- <Controller- render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- errorText={error?.message}- isError={Boolean(error)}- label="KMS"+ </div>+ <div className="mt-14 flex">+ <Accordion type="single" collapsible className="w-full">+ <AccordionItem value="advance-settings" className="data-[state=open]:border-none">+ <AccordionTrigger className="h-fit flex-none pl-1 text-sm">+ <div className="order-1 ml-3">Advanced Settings</div>+ </AccordionTrigger>+ <AccordionContent>+ <Controller+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error)}+ label="KMS"+ >+ <Select+ {...field}+ onValueChange={(e) => {+ onChange(e);+ }}+ className="mb-12 w-full bg-mineshaft-600">- <Select- {...field}- onValueChange={(e) => {- onChange(e);- }}- className="mb-12 w-full bg-mineshaft-600"- >- <SelectItem value={INTERNAL_KMS_KEY_ID} key="kms-internal">- Default Infisical KMS+ <SelectItem value={INTERNAL_KMS_KEY_ID} key="kms-internal">+ Default Infisical KMS+ </SelectItem>+ {externalKmsList?.map((kms) => (+ <SelectItem value={kms.id} key={`kms-${kms.id}`}>+ {kms.slug}</SelectItem>- {externalKmsList?.map((kms) => (- <SelectItem value={kms.id} key={`kms-${kms.id}`}>- {kms.slug}- </SelectItem>- ))}- </Select>- </FormControl>- )}- control={control}- name="kmsKeyId"- />- </AccordionContent>- </AccordionItem>- </Accordion>- <div className="absolute right-0 bottom-0 mr-6 mb-6 flex items-start justify-end">- <Button- key="layout-cancel-create-project"- onClick={() => handlePopUpClose("addNewWs")}- colorSchema="secondary"- variant="plain"- className="py-2"- >- Cancel- </Button>- <Button- isDisabled={isSubmitting}- isLoading={isSubmitting}- key="layout-create-project-submit"- className="ml-4"- type="submit"- >- Create Project- </Button>- </div>+ ))}+ </Select>+ </FormControl>+ )}+ control={control}+ name="kmsKeyId"+ />+ </AccordionContent>+ </AccordionItem>+ </Accordion>+ <div className="absolute right-0 bottom-0 mr-6 mb-6 flex items-start justify-end">+ <Button+ key="layout-cancel-create-project"+ onClick={() => handlePopUpClose("addNewWs")}+ colorSchema="secondary"+ variant="plain"+ className="py-2"+ >+ Cancel+ </Button>+ <Button+ isDisabled={isSubmitting}+ isLoading={isSubmitting}+ key="layout-create-project-submit"+ className="ml-4"+ type="submit"+ >+ Create Project+ </Button></div>- </form>- </ModalContent>- </Modal>- <UpgradePlanModal- isOpen={popUp.upgradePlan.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}- text="You have exceeded the number of projects allowed on the free plan."- />- {/* <DeleteUserDialog isOpen={isDeleteOpen} closeModal={closeDeleteModal} submitModal={deleteMembership} userIdToBeDeleted={userIdToBeDeleted}/> */}- </div>- );- },- {- action: OrgPermissionActions.Read,- subject: OrgPermissionSubjects.Workspace- }-);+ </div>+ </form>+ </ModalContent>+ </Modal>+ <UpgradePlanModal+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text="You have exceeded the number of projects allowed on the free plan."+ />+ {/* <DeleteUserDialog isOpen={isDeleteOpen} closeModal={closeDeleteModal} submitModal={deleteMembership} userIdToBeDeleted={userIdToBeDeleted}/> */}+ </div>+ );+};Object.assign(OrganizationPage, { requireAuth: true });diff --git a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/WorkspacePermission.tsx b/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/WorkspacePermission.tsxdeleted file mode 100644index 465029f8ba..0000000000--- a/frontend/src/views/Org/MembersPage/components/OrgRoleTabSection/OrgRoleModifySection/WorkspacePermission.tsx+++ /dev/null@@ -1,133 +0,0 @@-import { useEffect, useMemo } from "react";-import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";-import { faMoneyBill } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { motion } from "framer-motion";-import { twMerge } from "tailwind-merge";--import { Checkbox, Select, SelectItem } from "@app/components/v2";-import { useToggle } from "@app/hooks";--import { TFormSchema } from "../../../../RolePage/components/OrgRoleModifySection.utils";--type Props = {- isNonEditable?: boolean;- setValue: UseFormSetValue<TFormSchema>;- control: Control<TFormSchema>;-};--enum Permission {- NoAccess = "no-access",- ReadOnly = "read-only",- FullAccess = "full-acess",- Custom = "custom"-}--const PERMISSIONS = [- { action: "read", label: "View projects" },- { action: "create", label: "Create new projects" }-] as const;--export const WorkspacePermission = ({ isNonEditable, setValue, control }: Props) => {- const rule = useWatch({- control,- name: "permissions.workspace"- });- const [isCustom, setIsCustom] = useToggle();-- const selectedPermissionCategory = useMemo(() => {- const actions = Object.keys(rule || {}) as Array<keyof typeof rule>;- const totalActions = PERMISSIONS.length;- const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number);-- if (isCustom) return Permission.Custom;- if (score === 0) return Permission.NoAccess;- if (score === totalActions) return Permission.FullAccess;- if (score === 1 && rule?.read) return Permission.ReadOnly;-- return Permission.Custom;- }, [rule, isCustom]);-- useEffect(() => {- if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();- else setIsCustom.off();- }, [selectedPermissionCategory]);-- const handlePermissionChange = (val: Permission) => {- if (val === Permission.Custom) setIsCustom.on();- else setIsCustom.off();-- switch (val) {- case Permission.NoAccess:- setValue("permissions.workspace", { read: false, create: false }, { shouldDirty: true });- break;- case Permission.FullAccess:- setValue("permissions.workspace", { read: true, create: true }, { shouldDirty: true });- break;- case Permission.ReadOnly:- setValue("permissions.workspace", { read: true, create: false }, { shouldDirty: true });- break;- default:- setValue("permissions.workspace", { read: false, create: false }, { shouldDirty: true });- break;- }- };-- return (- <div- className={twMerge(- "rounded-md bg-mineshaft-800 px-10 py-6",- selectedPermissionCategory !== Permission.NoAccess && "border-l-2 border-primary-600"- )}- >- <div className="flex items-center space-x-4">- <div>- <FontAwesomeIcon icon={faMoneyBill} className="text-4xl" />- </div>- <div className="flex flex-grow flex-col">- <div className="mb-1 text-lg font-medium">Project</div>- <div className="text-xs font-light">- View and create new projects in this organization- </div>- </div>- <div>- <Select- defaultValue={Permission.NoAccess}- isDisabled={isNonEditable}- value={selectedPermissionCategory}- onValueChange={handlePermissionChange}- >- <SelectItem value={Permission.NoAccess}>No Access</SelectItem>- <SelectItem value={Permission.ReadOnly}>Read Only</SelectItem>- <SelectItem value={Permission.FullAccess}>Full Access</SelectItem>- <SelectItem value={Permission.Custom}>Custom</SelectItem>- </Select>- </div>- </div>- <motion.div- initial={false}- animate={{ height: isCustom ? "2.5rem" : 0, paddingTop: isCustom ? "1rem" : 0 }}- className="grid auto-cols-min grid-flow-col gap-8 overflow-hidden"- >- {isCustom &&- PERMISSIONS.map(({ action, label }) => (- <Controller- name={`permissions.workspace.${action}`}- key={`permissions.workspace.${action}`}- control={control}- render={({ field }) => (- <Checkbox- isChecked={field.value}- onCheckedChange={field.onChange}- id={`permissions.workspace.${action}`}- isDisabled={isNonEditable}- >- {label}- </Checkbox>- )}- />- ))}- </motion.div>- </div>- );-};diff --git a/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts b/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.tsindex e85e62d0c7..ba5308cd9d 100644--- a/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts+++ b/frontend/src/views/Org/RolePage/components/OrgRoleModifySection.utils.ts@@ -12,6 +12,12 @@ const generalPermissionSchema = z}).optional();+const adminConsolePermissionSchmea = z+ .object({+ "grant-access-projects": z.boolean().optional()+ })+ .optional();+export const formSchema = z.object({name: z.string().trim(),description: z.string().trim().optional(),@@ -23,7 +29,6 @@ export const formSchema = z.object({.object({workspace: z.object({- read: z.boolean().optional(),create: z.boolean().optional()}).optional(),@@ -38,7 +43,8 @@ export const formSchema = z.object({scim: generalPermissionSchema,ldap: generalPermissionSchema,billing: generalPermissionSchema,- identity: generalPermissionSchema+ identity: generalPermissionSchema,+ "admin-console": adminConsolePermissionSchmea}).optional()});diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsxnew file mode 100644index 0000000000..21d58aabb1--- /dev/null+++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgPermissionAdminConsoleRow.tsx@@ -0,0 +1,135 @@+import { useEffect, useMemo } from "react";+import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";+import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++import { createNotification } from "@app/components/notifications";+import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2";+import { useToggle } from "@app/hooks";+import { TFormSchema } from "@app/views/Org/RolePage/components/OrgRoleModifySection.utils";++type Props = {+ isEditable: boolean;+ setValue: UseFormSetValue<TFormSchema>;+ control: Control<TFormSchema>;+};++enum Permission {+ NoAccess = "no-access",+ Custom = "custom"+}++const PERMISSION_ACTIONS = [+ { action: "grant-access-projects", label: "Grant access projects" }+] as const;++export const OrgPermissionAdminConsoleRow = ({ isEditable, control, setValue }: Props) => {+ const [isRowExpanded, setIsRowExpanded] = useToggle();+ const [isCustom, setIsCustom] = useToggle();++ const rule = useWatch({+ control,+ name: "permissions.admin-console"+ });++ const selectedPermissionCategory = useMemo(() => {+ if (rule?.["grant-access-projects"]) {+ return Permission.Custom;+ }+ return Permission.NoAccess;+ }, [rule, isCustom]);++ useEffect(() => {+ if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();+ else setIsCustom.off();+ }, [selectedPermissionCategory]);++ useEffect(() => {+ const isRowCustom = selectedPermissionCategory === Permission.Custom;+ if (isRowCustom) {+ setIsRowExpanded.on();+ }+ }, []);++ const handlePermissionChange = (val: Permission) => {+ if (!val) return;+ if (val === Permission.Custom) {+ setIsRowExpanded.on();+ setIsCustom.on();+ return;+ }+ setIsCustom.off();++ if (val === Permission.NoAccess) {+ setValue(+ "permissions.admin-console",+ { "grant-access-projects": false },+ { shouldDirty: true }+ );+ }+ };++ return (+ <>+ <Tr+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"+ onClick={() => setIsRowExpanded.toggle()}+ >+ <Td>+ <FontAwesomeIcon icon={isRowExpanded ? faChevronDown : faChevronRight} />+ </Td>+ <Td>Admin Console</Td>+ <Td>+ <Select+ value={selectedPermissionCategory}+ className="w-40 bg-mineshaft-600"+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"+ onValueChange={handlePermissionChange}+ isDisabled={!isEditable}+ >+ <SelectItem value={Permission.NoAccess}>No Access</SelectItem>+ <SelectItem value={Permission.Custom}>Custom</SelectItem>+ </Select>+ </Td>+ </Tr>+ {isRowExpanded && (+ <Tr>+ <Td+ colSpan={3}+ className={`bg-bunker-600 px-0 py-0 ${isRowExpanded && " border-mineshaft-500 p-8"}`}+ >+ <div className="grid grid-cols-3 gap-4">+ {PERMISSION_ACTIONS.map(({ action, label }) => {+ return (+ <Controller+ name={`permissions.admin-console.${action}`}+ key={`permissions.admin-console.${action}`}+ control={control}+ render={({ field }) => (+ <Checkbox+ isChecked={field.value}+ onCheckedChange={(e) => {+ if (!isEditable) {+ createNotification({+ type: "error",+ text: "Failed to update default role"+ });+ return;+ }+ field.onChange(e);+ }}+ id={`permissions.admin-console.${action}`}+ >+ {label}+ </Checkbox>+ )}+ />+ );+ })}+ </div>+ </Td>+ </Tr>+ )}+ </>+ );+};diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsxnew file mode 100644index 0000000000..ea7f368c55--- /dev/null+++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/OrgRoleWorkspaceRow.tsx@@ -0,0 +1,129 @@+import { useEffect, useMemo } from "react";+import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form";+import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++import { createNotification } from "@app/components/notifications";+import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2";+import { useToggle } from "@app/hooks";+import { TFormSchema } from "@app/views/Org/RolePage/components/OrgRoleModifySection.utils";++type Props = {+ isEditable: boolean;+ setValue: UseFormSetValue<TFormSchema>;+ control: Control<TFormSchema>;+};++enum Permission {+ NoAccess = "no-access",+ Custom = "custom"+}++const PERMISSION_ACTIONS = [{ action: "create", label: "Create projects" }] as const;++export const OrgRoleWorkspaceRow = ({ isEditable, control, setValue }: Props) => {+ const [isRowExpanded, setIsRowExpanded] = useToggle();+ const [isCustom, setIsCustom] = useToggle();++ const rule = useWatch({+ control,+ name: "permissions.workspace"+ });++ const selectedPermissionCategory = useMemo(() => {+ if (rule?.create) {+ return Permission.Custom;+ }+ return Permission.NoAccess;+ }, [rule, isCustom]);++ useEffect(() => {+ if (selectedPermissionCategory === Permission.Custom) setIsCustom.on();+ else setIsCustom.off();+ }, [selectedPermissionCategory]);++ useEffect(() => {+ const isRowCustom = selectedPermissionCategory === Permission.Custom;+ if (isRowCustom) {+ setIsRowExpanded.on();+ }+ }, []);++ const handlePermissionChange = (val: Permission) => {+ if (!val) return;+ if (val === Permission.Custom) {+ setIsRowExpanded.on();+ setIsCustom.on();+ return;+ }+ setIsCustom.off();++ if (val === Permission.NoAccess) {+ setValue("permissions.workspace", { create: false }, { shouldDirty: true });+ }+ };++ return (+ <>+ <Tr+ className="h-10 cursor-pointer transition-colors duration-100 hover:bg-mineshaft-700"+ onClick={() => setIsRowExpanded.toggle()}+ >+ <Td>+ <FontAwesomeIcon icon={isRowExpanded ? faChevronDown : faChevronRight} />+ </Td>+ <Td>Project</Td>+ <Td>+ <Select+ value={selectedPermissionCategory}+ className="w-40 bg-mineshaft-600"+ dropdownContainerClassName="border border-mineshaft-600 bg-mineshaft-800"+ onValueChange={handlePermissionChange}+ isDisabled={!isEditable}+ >+ <SelectItem value={Permission.NoAccess}>No Access</SelectItem>+ <SelectItem value={Permission.Custom}>Custom</SelectItem>+ </Select>+ </Td>+ </Tr>+ {isRowExpanded && (+ <Tr>+ <Td+ colSpan={3}+ className={`bg-bunker-600 px-0 py-0 ${isRowExpanded && " border-mineshaft-500 p-8"}`}+ >+ <div className="grid grid-cols-3 gap-4">+ {PERMISSION_ACTIONS.map(({ action, label }) => {+ return (+ <Controller+ name={`permissions.workspace.${action}`}+ key={`permissions.workspace.${action}`}+ control={control}+ render={({ field }) => (+ <Checkbox+ isChecked={field.value}+ onCheckedChange={(e) => {+ if (!isEditable) {+ createNotification({+ type: "error",+ text: "Failed to update default role"+ });+ return;+ }+ field.onChange(e);+ }}+ id={`permissions.admin-console.${action}`}+ >+ {label}+ </Checkbox>+ )}+ />+ );+ })}+ </div>+ </Td>+ </Tr>+ )}+ </>+ );+};diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsxindex 6f4cc7c880..7f6c3953e5 100644--- a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx+++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionRow.tsx@@ -61,7 +61,10 @@ const getPermissionList = (option: string) => {type Props = {isEditable: boolean;title: string;- formName: keyof Omit<Exclude<TFormSchema["permissions"], undefined>, "workspace">;+ formName: keyof Omit<+ Exclude<TFormSchema["permissions"], undefined>,+ "workspace" | "admin-console"+ >;setValue: UseFormSetValue<TFormSchema>;control: Control<TFormSchema>;};diff --git a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsxindex fe19620f5c..f4b237cfe5 100644--- a/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx+++ b/frontend/src/views/Org/RolePage/components/RolePermissionsSection/RolePermissionsSection.tsx@@ -12,6 +12,8 @@ import {TFormSchema} from "@app/views/Org/RolePage/components/OrgRoleModifySection.utils";+import { OrgPermissionAdminConsoleRow } from "./OrgPermissionAdminConsoleRow";+import { OrgRoleWorkspaceRow } from "./OrgRoleWorkspaceRow";import { RolePermissionRow } from "./RolePermissionRow";const SIMPLE_PERMISSION_OPTIONS = [@@ -153,6 +155,16 @@ export const RolePermissionsSection = ({ roleId }: Props) => {/>);})}+ <OrgRoleWorkspaceRow+ control={control}+ setValue={setValue}+ isEditable={isCustomRole}+ />+ <OrgPermissionAdminConsoleRow+ control={control}+ setValue={setValue}+ isEditable={isCustomRole}+ /></TBody></Table></TableContainer>diff --git a/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx b/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsxindex d2b66ad18b..8461cc8937 100644--- a/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx+++ b/frontend/src/views/OrgAdminPage/components/OrgAdminProjects/OrgAdminProjects.tsx@@ -23,133 +23,145 @@ import {Td,Th,THead,- Tr} from "@app/components/v2";+ Tr+} from "@app/components/v2";+import {+ OrgPermissionAdminConsoleAction,+ OrgPermissionSubjects+} from "@app/context/OrgPermissionContext/types";+import { withPermission } from "@app/hoc";import { useDebounce } from "@app/hooks";import { useOrgAdminAccessProject, useOrgAdminGetProjects } from "@app/hooks/api";-export const OrgAdminProjects = () => {- const [page, setPage] = useState(1);- const [search, setSearch] = useState("");- const debouncedSearch = useDebounce(search);- const [perPage, setPerPage] = useState(25);- const router = useRouter();- const orgAdminAccessProject = useOrgAdminAccessProject();+export const OrgAdminProjects = withPermission(+ () => {+ const [page, setPage] = useState(1);+ const [search, setSearch] = useState("");+ const debouncedSearch = useDebounce(search);+ const [perPage, setPerPage] = useState(25);+ const router = useRouter();+ const orgAdminAccessProject = useOrgAdminAccessProject();- const { data, isLoading: isProjectsLoading } = useOrgAdminGetProjects({- offset: (page - 1) * perPage,- limit: perPage,- search: debouncedSearch || undefined- });+ const { data, isLoading: isProjectsLoading } = useOrgAdminGetProjects({+ offset: (page - 1) * perPage,+ limit: perPage,+ search: debouncedSearch || undefined+ });- const projects = data?.projects || [];- const projectCount = data?.count || 0;- const isEmpty = !isProjectsLoading && projects.length === 0;+ const projects = data?.projects || [];+ const projectCount = data?.count || 0;+ const isEmpty = !isProjectsLoading && projects.length === 0;- const handleAccessProject = async (projectId: string) => {- try {- await orgAdminAccessProject.mutateAsync({- projectId- });- await router.push({- pathname: "/project/[projectId]/secrets/overview",- query: {+ const handleAccessProject = async (projectId: string) => {+ try {+ await orgAdminAccessProject.mutateAsync({projectId- }- });- } catch {- createNotification({- text: "Failed to access project",- type: "error"- });- }- };+ });+ await router.push({+ pathname: "/project/[projectId]/secrets/overview",+ query: {+ projectId+ }+ });+ } catch {+ createNotification({+ text: "Failed to access project",+ type: "error"+ });+ }+ };- return (- <motion.div- key="panel-projects"- transition={{ duration: 0.15 }}- initial={{ opacity: 0, translateX: 30 }}- animate={{ opacity: 1, translateX: 0 }}- exit={{ opacity: 0, translateX: 30 }}- >- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">- <div className="mb-4 flex justify-between">- <p className="text-xl font-semibold text-mineshaft-100">Projects</p>- </div>- <div>- <Input- value={search}- onChange={(e) => setSearch(e.target.value)}- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}- placeholder="Search by project name"- />- <TableContainer className="mt-4">- <Table>- <THead>- <Tr>- <Th>Name</Th>- <Th>Slug</Th>- <Th>Created At</Th>- <Th className="w-5" />- </Tr>- </THead>- <TBody>- {isProjectsLoading && <TableSkeleton columns={4} innerKey="projects" />}- {!isProjectsLoading &&- projects?.map(({ name, slug, createdAt, id }) => (- <Tr key={`project-${id}`} className="group w-full">- <Td>{name}</Td>- <Td>{slug}</Td>- <Td>{format(new Date(createdAt), "yyyy-MM-dd, hh:mm aaa")}</Td>- <Td>- <div>- <DropdownMenu>- <DropdownMenuTrigger asChild className="rounded-lg">- <Button- variant="link"- className="text-bunker-300 hover:text-primary-400 data-[state=open]:text-primary-400"- >- <FontAwesomeIcon size="sm" icon={faEllipsis} />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start" className="p-1">- <DropdownMenuItem- onClick={(e) => {- e.stopPropagation();- e.preventDefault();- handleAccessProject(id);- }}- icon={<FontAwesomeIcon icon={faSignIn} />}- disabled={- orgAdminAccessProject.variables?.projectId === id &&- orgAdminAccessProject.isLoading- }- >- Access{" "}- {orgAdminAccessProject.variables?.projectId === id &&- orgAdminAccessProject.isLoading && <Spinner size="xs" />}- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </div>- </Td>- </Tr>- ))}- </TBody>- </Table>- {!isProjectsLoading && (- <Pagination- count={projectCount}- page={page}- perPage={perPage}- onChangePage={(newPage) => setPage(newPage)}- onChangePerPage={(newPerPage) => setPerPage(newPerPage)}- />- )}- {isEmpty && <EmptyState title="No projects found" />}- </TableContainer>+ return (+ <motion.div+ key="panel-projects"+ transition={{ duration: 0.15 }}+ initial={{ opacity: 0, translateX: 30 }}+ animate={{ opacity: 1, translateX: 0 }}+ exit={{ opacity: 0, translateX: 30 }}+ >+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">+ <div className="mb-4 flex justify-between">+ <p className="text-xl font-semibold text-mineshaft-100">Projects</p>+ </div>+ <div>+ <Input+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}+ placeholder="Search by project name"+ />+ <TableContainer className="mt-4">+ <Table>+ <THead>+ <Tr>+ <Th>Name</Th>+ <Th>Slug</Th>+ <Th>Created At</Th>+ <Th className="w-5" />+ </Tr>+ </THead>+ <TBody>+ {isProjectsLoading && <TableSkeleton columns={4} innerKey="projects" />}+ {!isProjectsLoading &&+ projects?.map(({ name, slug, createdAt, id }) => (+ <Tr key={`project-${id}`} className="group w-full">+ <Td>{name}</Td>+ <Td>{slug}</Td>+ <Td>{format(new Date(createdAt), "yyyy-MM-dd, hh:mm aaa")}</Td>+ <Td>+ <div>+ <DropdownMenu>+ <DropdownMenuTrigger asChild className="rounded-lg">+ <Button+ variant="link"+ className="text-bunker-300 hover:text-primary-400 data-[state=open]:text-primary-400"+ >+ <FontAwesomeIcon size="sm" icon={faEllipsis} />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="p-1">+ <DropdownMenuItem+ onClick={(e) => {+ e.stopPropagation();+ e.preventDefault();+ handleAccessProject(id);+ }}+ icon={<FontAwesomeIcon icon={faSignIn} />}+ disabled={+ orgAdminAccessProject.variables?.projectId === id &&+ orgAdminAccessProject.isLoading+ }+ >+ Access{" "}+ {orgAdminAccessProject.variables?.projectId === id &&+ orgAdminAccessProject.isLoading && <Spinner size="xs" />}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ </Td>+ </Tr>+ ))}+ </TBody>+ </Table>+ {!isProjectsLoading && (+ <Pagination+ count={projectCount}+ page={page}+ perPage={perPage}+ onChangePage={(newPage) => setPage(newPage)}+ onChangePerPage={(newPerPage) => setPerPage(newPerPage)}+ />+ )}+ {isEmpty && <EmptyState title="No projects found" />}+ </TableContainer>+ </div></div>- </div>- </motion.div>- );-};+ </motion.div>+ );+ },+ {+ action: OrgPermissionAdminConsoleAction.GrantAccessProjects,+ subject: OrgPermissionSubjects.AdminConsole+ }+);