AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(web): rename the roles tab and rebuild the roles card (#15697)
lina-alomari8006c490cf9f
diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex a6d9e07c205..ba015defbce 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -738,6 +738,24 @@"Security": "Security","Single Sign On": "Single Sign On","Project Roles": "Project Roles",+ "Roles & Access": "Roles & Access",+ "Full access": "Full access",+ "Build, publish, and manage flows": "Build, publish, and manage flows",+ "View only": "View only",+ "Access to the team projects they're invited to": "Access to the team projects they're invited to",+ "What new members get, and what each role can do.": "What new members get, and what each role can do.",+ "Two kinds. A platform role is one per person and decides console access and which projects they see. A project role is chosen per project and decides what they can do inside it.": "Two kinds. A platform role is one per person and decides console access and which projects they see. A project role is chosen per project and decides what they can do inside it.",+ "Platform roles": "Platform roles",+ "New role": "New role",+ "Built in": "Built in",+ "Press a row to open the role. Press the people count to see who has it. Edit and delete live inside the role, so the list stays quiet.": "Press a row to open the role. Press the people count to see who has it. Edit and delete live inside the role, so the list stays quiet.",+ "Everyone has exactly one. To change someone's, open": "Everyone has exactly one. To change someone's, open",+ "Every project as Admin, plus this console": "Every project as Admin, plus this console",+ "Every project as Editor, no console": "Every project as Editor, no console",+ "Own project, plus the projects they're added to": "Own project, plus the projects they're added to",+ "Default for new people": "Default for new people",+ "rolePeopleCount": "{count, plural, =1 {1 person} other {# people}}",+ "roles": "roles","API Keys": "API Keys","Secret Managers": "Secret Managers","Observability": "Observability",@@ -1354,9 +1372,7 @@"Deleting this signing key will invalidate any tokens signed with it.": "Deleting this signing key will invalidate any tokens signed with it.","New Role": "New Role","Contact sales to unlock custom roles": "Contact sales to unlock custom roles",- "Project Role Management": "Project Role Management","Define custom roles and permissions to control what your team members can access and modify": "Define custom roles and permissions to control what your team members can access and modify",- "Define custom roles and permissions that can be assigned to your team members": "Define custom roles and permissions that can be assigned to your team members","Create Role": "Create Role","View Role: {name}": "View Role: {name}","Edit Role: {name}": "Edit Role: {name}",@@ -1369,7 +1385,6 @@"Start by assigning users to this role": "Start by assigning users to this role","No project roles yet. Create one to get started.": "No project roles yet. Create one to get started.","Custom": "Custom",- "1 user": "1 user","Delete Role": "Delete Role","Deleting this role will remove {count} project member(s) and all associated invitations.": "Deleting this role will remove {count} project member(s) and all associated invitations.","Project Role": "Project Role",@@ -1398,6 +1413,7 @@"Email authentication updated": "Email authentication updated","Google authentication updated": "Google authentication updated","Enable Single Sign On": "Enable Single Sign On",+ "Enable Custom Roles": "Enable Custom Roles","Let your users sign in with your current SSO provider or give them self serve sign up access": "Let your users sign in with your current SSO provider or give them self serve sign up access","Manage single sign on providers": "Manage single sign on providers","Allowed Domains": "Allowed Domains",@@ -2429,9 +2445,6 @@"Full access to all projects and platform settings": "Full access to all projects and platform settings","Access and edit flows in all projects, no platform settings": "Access and edit flows in all projects, no platform settings","Access to personal project and any team projects they're invited to": "Access to personal project and any team projects they're invited to",- "Manage project settings, members, connections, and git sync": "Manage project settings, members, connections, and git sync",- "Build, publish, and manage flows": "Build, publish, and manage flows",- "View flows and monitor run history": "View flows and monitor run history","Platform Roles": "Platform Roles","Select Role": "Select Role","Roles": "Roles",diff --git a/packages/web/src/app/components/global-search/static-pages.ts b/packages/web/src/app/components/global-search/static-pages.tsindex 2e13806d6f7..a0ff86883c7 100644--- a/packages/web/src/app/components/global-search/static-pages.ts+++ b/packages/web/src/app/components/global-search/static-pages.ts@@ -171,7 +171,7 @@ export const STATIC_PAGES: StaticPage[] = [},{id: 'page-platform-project-roles',- label: 'Platform Admin — Project Roles',+ label: 'Platform Admin — Roles & Access',href: '/platform/users/roles',icon: Settings2Icon,requiresPlatformAdmin: true,diff --git a/packages/web/src/app/components/sidebar/platform/index.tsx b/packages/web/src/app/components/sidebar/platform/index.tsxindex aad9d3f02a3..a2280729b3a 100644--- a/packages/web/src/app/components/sidebar/platform/index.tsx+++ b/packages/web/src/app/components/sidebar/platform/index.tsx@@ -74,7 +74,7 @@ export function PlatformSidebar() {{ to: '/platform/users', label: t('Members'), end: true },{to: '/platform/users/roles',- label: t('Project Roles'),+ label: t('Roles & Access'),locked: !platform.plan.projectRolesEnabled,tier: PLATFORM_FEATURES.projectRoles.tier,},diff --git a/packages/web/src/app/routes/platform-routes.tsx b/packages/web/src/app/routes/platform-routes.tsxindex 4e5a64ca219..0f385fb036a 100644--- a/packages/web/src/app/routes/platform-routes.tsx+++ b/packages/web/src/app/routes/platform-routes.tsx@@ -416,7 +416,7 @@ export const platformRoutes = [path: '/platform/users/roles',element: (<PlatformLayout>- <PageTitle title="Project Roles">+ <PageTitle title="Roles & Access"><PlanFeatureSample feature="projectRoles"><SuspenseWrapper><ProjectRolePage />diff --git a/packages/web/src/app/routes/platform/plan-feature-sample.tsx b/packages/web/src/app/routes/platform/plan-feature-sample.tsxindex ee99ba12cee..b8be4a317d5 100644--- a/packages/web/src/app/routes/platform/plan-feature-sample.tsx+++ b/packages/web/src/app/routes/platform/plan-feature-sample.tsx@@ -42,7 +42,7 @@ const PLAN_FEATURE_SAMPLES: Record<PlanFeature, PlanFeatureSampleSpec> = {isLocked: (plan) => !plan.projectRolesEnabled,teaser: {featureKey: 'CUSTOM_ROLES',- title: 'Project Role Management',+ title: 'Enable Custom Roles',description:'Define custom roles and permissions to control what your team members can access and modify',tier: 'team',diff --git a/packages/web/src/app/routes/platform/security/project-role/index.tsx b/packages/web/src/app/routes/platform/security/project-role/index.tsxindex a860409d141..784e0fa9f15 100644--- a/packages/web/src/app/routes/platform/security/project-role/index.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/index.tsx@@ -1,64 +1,31 @@import { t } from 'i18next';import { CenteredPage } from '@/app/components/centered-page';-import { AnimatedIconButton } from '@/components/custom/animated-icon-button';-import { PlusIcon } from '@/components/icons/plus';-import {- Tooltip,- TooltipContent,- TooltipTrigger,-} from '@/components/ui/tooltip';import { projectRoleQueries } from '@/features/platform-admin';import { platformHooks } from '@/hooks/platform-hooks';import { sampleData } from '../../sample-data';-import { ProjectRoleDialog } from './project-role-dialog';-import { ProjectRolesTable } from './project-roles-table';+import { RolesCard } from './roles-card';const ProjectRolePage = () => {const { platform } = platformHooks.useCurrentPlatform();- const { data, isLoading, refetch } = projectRoleQueries.useProjectRoles(- platform.plan.projectRolesEnabled,- );+ const { data, isLoading, isError, refetch } =+ projectRoleQueries.useProjectRoles(platform.plan.projectRolesEnabled);const isSample = !platform.plan.projectRolesEnabled;const roles = isSample ? sampleData.projectRolesPage() : data;- const newRoleButton = !platform.plan.customRolesEnabled ? (- <Tooltip>- <TooltipTrigger>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm" disabled>- {t('New Role')}- </AnimatedIconButton>- </TooltipTrigger>- <TooltipContent side="bottom">- {t('Contact sales to unlock custom roles')}- </TooltipContent>- </Tooltip>- ) : (- <ProjectRoleDialog- mode="create"- onSave={() => refetch()}- platformId={platform.id}- >- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">- {t('New Role')}- </AnimatedIconButton>- </ProjectRoleDialog>- );-return (<CenteredPage- title={t('Project Role Management')}- description={t(- 'Define custom roles and permissions that can be assigned to your team members',- )}- actions={newRoleButton}+ title={t('Roles & Access')}+ description={t('What new members get, and what each role can do.')}+ widthClassName="max-w-4xl">- <ProjectRolesTable+ <RolesCardprojectRoles={roles}isLoading={isSample ? false : isLoading}+ isError={isSample ? false : isError}refetch={refetch}/></CenteredPage>diff --git a/packages/web/src/app/routes/platform/security/project-role/platform-roles-list.tsx b/packages/web/src/app/routes/platform/security/project-role/platform-roles-list.tsxnew file mode 100644index 00000000000..a5921bdbcd5--- /dev/null+++ b/packages/web/src/app/routes/platform/security/project-role/platform-roles-list.tsx@@ -0,0 +1,64 @@+import { t } from 'i18next';+import { Link } from 'react-router-dom';++import { Badge } from '@/components/ui/badge';+import {+ Item,+ ItemContent,+ ItemDescription,+ ItemGroup,+ ItemTitle,+} from '@/components/ui/item';+import { roleCopy } from '@/features/members/lib/role-copy';+import { platformHooks } from '@/hooks/platform-hooks';++import { RoleAvatar } from './role-avatar';++export function PlatformRolesList() {+ const { platform } = platformHooks.useCurrentPlatform();++ return (+ <div className="flex flex-col gap-3">+ <ItemGroup className="gap-2">+ {roleCopy+ .platformRoles({+ personalProjectsEnabled: platform.autoCreatePersonalProjects,+ })+ .map((platformRole) => (+ <Item key={platformRole.role} variant="outline" size="sm">+ <RoleAvatar name={platformRole.label} />+ <ItemContent>+ <ItemTitle>+ {platformRole.label}+ <Badge+ variant="accent"+ className="text-xss uppercase tracking-wider"+ >+ {t('Built in')}+ </Badge>+ {platformRole.isDefaultForNewMembers && (+ <Badge+ variant="inverted"+ className="text-xss uppercase tracking-wider"+ >+ {t('Default for new people')}+ </Badge>+ )}+ </ItemTitle>+ <ItemDescription>{platformRole.description}</ItemDescription>+ </ItemContent>+ </Item>+ ))}+ </ItemGroup>+ <p className="text-xs text-muted-foreground">+ {t("Everyone has exactly one. To change someone's, open")}{' '}+ <Link+ to="/platform/users"+ className="text-primary underline underline-offset-4"+ >+ {t('Users')} →+ </Link>+ </p>+ </div>+ );+}diff --git a/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx b/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsxindex 98a76b9d6bf..7373b22f950 100644--- a/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx@@ -1,7 +1,9 @@import { Permission, ProjectRole, RoleType } from '@activepieces/core-utils';import { t } from 'i18next';+import { Trash } from 'lucide-react';import { useState, ReactNode } from 'react';+import { ConfirmationDeleteDialog } from '@/components/custom/delete-dialog';import { Button } from '@/components/ui/button';import {Dialog,@@ -115,8 +117,10 @@ interface ProjectRoleDialogProps {projectRole?: ProjectRole;platformId: string;onSave: () => void;- children: ReactNode;+ children?: ReactNode;disabled?: boolean;+ open?: boolean;+ onOpenChange?: (open: boolean) => void;}export const ProjectRoleDialog = ({@@ -125,8 +129,17 @@ export const ProjectRoleDialog = ({onSave,children,disabled = false,+ open,+ onOpenChange,}: ProjectRoleDialogProps) => {- const [isOpen, setIsOpen] = useState(false);+ const [uncontrolledOpen, setUncontrolledOpen] = useState(false);+ const isOpen = open ?? uncontrolledOpen;+ const setIsOpen = (nextOpen: boolean) => {+ if (open === undefined) {+ setUncontrolledOpen(nextOpen);+ }+ onOpenChange?.(nextOpen);+ };const [roleName, setRoleName] = useState(projectRole?.name || '');const [permissions, setPermissions] = useState<string[]>(() => {if (!projectRole?.permissions) {@@ -147,6 +160,13 @@ export const ProjectRoleDialog = ({onSave();},});+ const { mutate: deleteProjectRole } =+ projectRoleMutations.useDeleteProjectRole({+ onSuccess: () => {+ setIsOpen(false);+ onSave();+ },+ });const handlePermissionChange = (permission: string, level: string) => {const currentPermission = initialPermissions.find(@@ -221,7 +241,7 @@ export const ProjectRoleDialog = ({return (<Dialog open={isOpen} onOpenChange={setIsOpen}>- <DialogTrigger asChild>{children}</DialogTrigger>+ {children && <DialogTrigger asChild>{children}</DialogTrigger>}<DialogContent className="w-full max-w-3xl"><DialogHeader><DialogTitle>@@ -324,9 +344,29 @@ export const ProjectRoleDialog = ({</div></div>{!disabled && (- <Button onClick={handleSubmit}>- {mode === 'create' ? t('Create') : t('Save')}- </Button>+ <div className="flex items-center justify-between gap-2">+ {mode === 'edit' && projectRole && (+ <ConfirmationDeleteDialog+ isDanger={true}+ title={t('Delete Role')}+ message={t(+ 'Deleting this role will remove {count} project member(s) and all associated invitations.',+ { count: projectRole.userCount },+ )}+ entityName={`${t('Project Role')} ${projectRole.name}`}+ buttonText={t('Delete Role')}+ mutationFn={async () => deleteProjectRole(projectRole.name)}+ >+ <Button variant="ghost" className="text-destructive">+ <Trash className="size-4" />+ {t('Delete Role')}+ </Button>+ </ConfirmationDeleteDialog>+ )}+ <Button onClick={handleSubmit} className="ml-auto">+ {mode === 'create' ? t('Create') : t('Save')}+ </Button>+ </div>)}</div></DialogContent>diff --git a/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsx b/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsxnew file mode 100644index 00000000000..70a2ce64ef5--- /dev/null+++ b/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsx@@ -0,0 +1,149 @@+import { ProjectRole, RoleType, SeekPage } from '@activepieces/core-utils';+import { isNil } from '@activepieces/shared';+import { t } from 'i18next';+import { ChevronRight, Shield } from 'lucide-react';+import { useState } from 'react';++import { DataFetchErrorState } from '@/components/custom/data-fetch-error-state';+import { Badge } from '@/components/ui/badge';+import {+ Item,+ ItemContent,+ ItemDescription,+ ItemGroup,+ ItemTitle,+} from '@/components/ui/item';+import { SkeletonList } from '@/components/ui/skeleton';+import { roleCopy } from '@/features/members/lib/role-copy';+import { platformHooks } from '@/hooks/platform-hooks';++import { ProjectRoleDialog } from './project-role-dialog';+import { ProjectRoleUsersSheet } from './project-role-users-table';+import { RoleAvatar } from './role-avatar';++export function ProjectRolesList({+ projectRoles,+ isLoading,+ isError,+ refetch,+}: ProjectRolesListProps) {+ const { platform } = platformHooks.useCurrentPlatform();+ const [openedRole, setOpenedRole] = useState<ProjectRole | null>(null);+ const [peopleRole, setPeopleRole] = useState<ProjectRole | null>(null);++ if (isLoading) {+ return <SkeletonList numberOfItems={3} className="w-full h-[60px]" />;+ }++ if (isError) {+ return <DataFetchErrorState entity={t('roles')} onRetry={refetch} />;+ }++ const roles = projectRoles?.data ?? [];++ if (roles.length === 0) {+ return (+ <div className="flex flex-col items-center gap-3 py-12 text-muted-foreground">+ <Shield className="size-10" />+ <p className="text-sm">+ {t('No project roles yet. Create one to get started.')}+ </p>+ </div>+ );+ }++ return (+ <div className="flex flex-col gap-3">+ <ItemGroup className="gap-2">+ {roles.map((role) => {+ const description = roleCopy.projectRoleDescription(role.name);+ return (+ <Item+ key={role.id}+ variant="outline"+ size="sm"+ className="relative cursor-pointer hover:bg-accent/50 focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50"+ >+ <RoleAvatar name={role.name} />+ <ItemContent>+ <ItemTitle>+ <button+ type="button"+ className="text-left after:absolute after:inset-0 after:content-[''] focus-visible:outline-none"+ onClick={() => setOpenedRole(role)}+ >+ {role.name}+ </button>+ <Badge+ variant={+ role.type === RoleType.DEFAULT ? 'accent' : 'inverted'+ }+ className="text-xss uppercase tracking-wider"+ >+ {role.type === RoleType.DEFAULT+ ? t('Built in')+ : t('Custom')}+ </Badge>+ </ItemTitle>+ <ItemDescription>+ {description}+ {description && !isNil(role.userCount) && ' · '}+ {!isNil(role.userCount) && (+ <button+ type="button"+ className="relative z-10 text-primary underline-offset-4 hover:underline"+ onClick={() => setPeopleRole(role)}+ >+ {t('rolePeopleCount', { count: role.userCount })}+ </button>+ )}+ </ItemDescription>+ </ItemContent>+ <ChevronRight className="size-4 shrink-0 text-muted-foreground" />+ </Item>+ );+ })}+ </ItemGroup>+ <p className="text-xs text-muted-foreground">+ {t(+ 'Press a row to open the role. Press the people count to see who has it. Edit and delete live inside the role, so the list stays quiet.',+ )}+ </p>+ {openedRole && (+ <ProjectRoleDialog+ key={openedRole.id}+ mode="edit"+ projectRole={openedRole}+ platformId={platform.id}+ open={true}+ onOpenChange={(open) => {+ if (!open) {+ setOpenedRole(null);+ }+ }}+ onSave={() => {+ setOpenedRole(null);+ refetch();+ }}+ disabled={openedRole.type === RoleType.DEFAULT}+ />+ )}+ <ProjectRoleUsersSheet+ projectRole={peopleRole}+ isOpen={peopleRole !== null}+ onOpenChange={(open) => {+ if (!open) {+ setPeopleRole(null);+ }+ }}+ />+ </div>+ );+}++type ProjectRolesListProps = {+ projectRoles: SeekPage<ProjectRole> | undefined;+ isLoading: boolean;+ isError: boolean;+ refetch: () => void;+};diff --git a/packages/web/src/app/routes/platform/security/project-role/project-roles-table.tsx b/packages/web/src/app/routes/platform/security/project-role/project-roles-table.tsxdeleted file mode 100644index 5169ce914c8..00000000000--- a/packages/web/src/app/routes/platform/security/project-role/project-roles-table.tsx+++ /dev/null@@ -1,161 +0,0 @@-import { ProjectRole, RoleType, SeekPage } from '@activepieces/core-utils';-import { t } from 'i18next';-import {- Eye,- PenLine,- Pencil,- Shield,- ShieldCheck,- Trash,- Users,-} from 'lucide-react';-import { useState } from 'react';--import { ConfirmationDeleteDialog } from '@/components/custom/delete-dialog';-import { Badge } from '@/components/ui/badge';-import { Button } from '@/components/ui/button';-import {- Item,- ItemActions,- ItemContent,- ItemDescription,- ItemGroup,- ItemMedia,- ItemTitle,-} from '@/components/ui/item';-import { SkeletonList } from '@/components/ui/skeleton';-import { projectRoleMutations } from '@/features/platform-admin';-import { platformHooks } from '@/hooks/platform-hooks';--import { ProjectRoleDialog } from './project-role-dialog';-import { ProjectRoleUsersSheet } from './project-role-users-table';--interface ProjectRolesListProps {- projectRoles: SeekPage<ProjectRole> | undefined;- isLoading: boolean;- refetch: () => void;-}--function getRoleIcon(roleName: string) {- switch (roleName) {- case 'Admin':- return <ShieldCheck />;- case 'Editor':- return <PenLine />;- case 'Viewer':- return <Eye />;- default:- return <Shield />;- }-}--export const ProjectRolesTable = ({- projectRoles,- isLoading,- refetch,-}: ProjectRolesListProps) => {- const { platform } = platformHooks.useCurrentPlatform();- const [selectedRole, setSelectedRole] = useState<ProjectRole | null>(null);- const [isUsersSheetOpen, setIsUsersSheetOpen] = useState(false);-- const { mutate: deleteProjectRole } =- projectRoleMutations.useDeleteProjectRole({- onSuccess: () => refetch(),- });-- if (isLoading) {- return <SkeletonList numberOfItems={3} className="w-full h-[60px]" />;- }-- const roles = projectRoles?.data ?? [];-- if (roles.length === 0) {- return (- <div className="flex flex-col items-center gap-3 py-12 text-muted-foreground">- <Shield className="size-10" />- <p className="text-sm">- {t('No project roles yet. Create one to get started.')}- </p>- </div>- );- }-- return (- <>- <ItemGroup className="gap-2">- {roles.map((role) => (- <Item key={role.id} variant="outline" size="sm">- <ItemMedia variant="icon">{getRoleIcon(role.name)}</ItemMedia>- <ItemContent>- <ItemTitle>{role.name}</ItemTitle>- <ItemDescription>- <Badge- variant={- role.type === RoleType.DEFAULT ? 'accent' : 'secondary'- }- >- {role.type === RoleType.DEFAULT ? t('Default') : t('Custom')}- </Badge>- </ItemDescription>- </ItemContent>- <ItemActions>- <Button- variant="ghost"- size="sm"- className="flex items-center gap-1.5 px-2 h-8 text-muted-foreground"- onClick={() => {- setSelectedRole(role);- setIsUsersSheetOpen(true);- }}- >- <Users className="size-4" />- <span className="text-xs">- {role.userCount === 1- ? t('1 user')- : t(`${role.userCount} users`)}- </span>- </Button>- <ProjectRoleDialog- mode="edit"- projectRole={role}- platformId={platform.id}- onSave={() => refetch()}- disabled={role.type === RoleType.DEFAULT}- >- <Button variant="ghost" size="sm" className="size-8 p-0">- {role.type === RoleType.DEFAULT ? (- <Eye className="size-4" />- ) : (- <Pencil className="size-4" />- )}- </Button>- </ProjectRoleDialog>- {role.type !== RoleType.DEFAULT && (- <ConfirmationDeleteDialog- isDanger={true}- title={t('Delete Role')}- message={t(- 'Deleting this role will remove {count} project member(s) and all associated invitations.',- { count: role.userCount },- )}- entityName={`${t('Project Role')} ${role.name}`}- buttonText={t('Delete Role')}- mutationFn={async () => deleteProjectRole(role.name)}- >- <Button variant="ghost" size="sm" className="size-8 p-0">- <Trash className="size-4 text-destructive" />- </Button>- </ConfirmationDeleteDialog>- )}- </ItemActions>- </Item>- ))}- </ItemGroup>- <ProjectRoleUsersSheet- projectRole={selectedRole}- isOpen={isUsersSheetOpen}- onOpenChange={setIsUsersSheetOpen}- />- </>- );-};diff --git a/packages/web/src/app/routes/platform/security/project-role/role-avatar.tsx b/packages/web/src/app/routes/platform/security/project-role/role-avatar.tsxnew file mode 100644index 00000000000..64f56522be7--- /dev/null+++ b/packages/web/src/app/routes/platform/security/project-role/role-avatar.tsx@@ -0,0 +1,19 @@+import { ItemMedia } from '@/components/ui/item';+import { cn } from '@/lib/utils';++export function RoleAvatar({ name, className }: RoleAvatarProps) {+ return (+ <ItemMedia+ variant="icon"+ className={cn('text-sm font-medium text-muted-foreground', className)}+ aria-hidden+ >+ {name.trim().charAt(0).toUpperCase()}+ </ItemMedia>+ );+}++type RoleAvatarProps = {+ name: string;+ className?: string;+};diff --git a/packages/web/src/app/routes/platform/security/project-role/roles-card.tsx b/packages/web/src/app/routes/platform/security/project-role/roles-card.tsxnew file mode 100644index 00000000000..2d8b35bae59--- /dev/null+++ b/packages/web/src/app/routes/platform/security/project-role/roles-card.tsx@@ -0,0 +1,118 @@+import { ProjectRole, SeekPage } from '@activepieces/core-utils';+import { isNil } from '@activepieces/shared';+import { t } from 'i18next';+import { useState } from 'react';++import { AnimatedIconButton } from '@/components/custom/animated-icon-button';+import { PlusIcon } from '@/components/icons/plus';+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';+import {+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@/components/ui/tooltip';+import { platformHooks } from '@/hooks/platform-hooks';++import { PlatformRolesList } from './platform-roles-list';+import { ProjectRoleDialog } from './project-role-dialog';+import { ProjectRolesList } from './project-roles-list';++const PLATFORM_ROLE_COUNT = 3;++export function RolesCard({+ projectRoles,+ isLoading,+ isError,+ refetch,+}: RolesCardProps) {+ const { platform } = platformHooks.useCurrentPlatform();+ const [activeTab, setActiveTab] = useState<RolesTab>('project');++ const projectRolesCount =+ isLoading || isError ? null : projectRoles?.data.length ?? 0;+ const platformRolesCount = PLATFORM_ROLE_COUNT;++ const newRoleButton = !platform.plan.customRolesEnabled ? (+ <Tooltip>+ <TooltipTrigger>+ <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm" disabled>+ {t('New role')}+ </AnimatedIconButton>+ </TooltipTrigger>+ <TooltipContent side="bottom">+ {t('Contact sales to unlock custom roles')}+ </TooltipContent>+ </Tooltip>+ ) : (+ <ProjectRoleDialog+ mode="create"+ onSave={() => refetch()}+ platformId={platform.id}+ >+ <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ {t('New role')}+ </AnimatedIconButton>+ </ProjectRoleDialog>+ );++ return (+ <section className="flex flex-col gap-4">+ <div className="flex flex-col gap-1">+ <h2 className="text-base font-medium">{t('Roles')}</h2>+ <p className="text-sm text-muted-foreground">+ {t(+ 'Two kinds. A platform role is one per person and decides console access and which projects they see. A project role is chosen per project and decides what they can do inside it.',+ )}+ </p>+ </div>+ <Tabs+ value={activeTab}+ onValueChange={(value) => setActiveTab(toRolesTab(value))}+ >+ <div className="flex items-center justify-between gap-4">+ <TabsList>+ <TabsTrigger value="project" className="gap-2">+ {t('Project roles')}+ {!isNil(projectRolesCount) && (+ <span className="text-muted-foreground">+ {projectRolesCount}+ </span>+ )}+ </TabsTrigger>+ <TabsTrigger value="platform" className="gap-2">+ {t('Platform roles')}+ <span className="text-muted-foreground">+ {platformRolesCount}+ </span>+ </TabsTrigger>+ </TabsList>+ {activeTab === 'project' && newRoleButton}+ </div>+ <TabsContent value="project">+ <ProjectRolesList+ projectRoles={projectRoles}+ isLoading={isLoading}+ isError={isError}+ refetch={refetch}+ />+ </TabsContent>+ <TabsContent value="platform">+ <PlatformRolesList />+ </TabsContent>+ </Tabs>+ </section>+ );+}++function toRolesTab(value: string): RolesTab {+ return value === 'platform' ? 'platform' : 'project';+}++type RolesTab = 'project' | 'platform';++type RolesCardProps = {+ projectRoles: SeekPage<ProjectRole> | undefined;+ isLoading: boolean;+ isError: boolean;+ refetch: () => void;+};diff --git a/packages/web/src/features/members/components/role-selector.tsx b/packages/web/src/features/members/components/role-selector.tsxindex f81c8eb51cb..387d426a2aa 100644--- a/packages/web/src/features/members/components/role-selector.tsx+++ b/packages/web/src/features/members/components/role-selector.tsx@@ -1,4 +1,3 @@-import { PlatformRole } from '@activepieces/shared';import { t } from 'i18next';import { Loader2 } from 'lucide-react';@@ -11,43 +10,11 @@ import {SelectTrigger,SelectValue,} from '@/components/ui/select';--type RoleConfig<T = string> = {- value: T;- label: string;- description: string;-};--const PLATFORM_ROLES: RoleConfig<PlatformRole>[] = [- {- value: PlatformRole.ADMIN,- label: t('Admin'),- description: t('Full access to all projects and platform settings'),- },- {- value: PlatformRole.OPERATOR,- label: t('Operator'),- description: t(- 'Access and edit flows in all projects, no platform settings',- ),- },- {- value: PlatformRole.MEMBER,- label: t('Member'),- description: t(- "Access to personal project and any team projects they're invited to",- ),- },-];--const PROJECT_ROLE_DESCRIPTIONS: Record<string, string> = {- Admin: t('Manage project settings, members, connections, and git sync'),- Editor: t('Build, publish, and manage flows'),- Viewer: t('View flows and monitor run history'),-};+import { roleCopy } from '@/features/members/lib/role-copy';+import { platformHooks } from '@/hooks/platform-hooks';export const getProjectRoleDescription = (roleName: string): string => {- return PROJECT_ROLE_DESCRIPTIONS[roleName] || '';+ return roleCopy.projectRoleDescription(roleName) ?? '';};interface RoleSelectorProps {@@ -71,6 +38,7 @@ export const RoleSelector = ({isLoading = false,isAssigningRole = false,}: RoleSelectorProps) => {+ const { platform } = platformHooks.useCurrentPlatform();const isPlatform = type === 'platform';const projectRolesLoading = !isPlatform && isLoading;const projectRoleAssigning = !isPlatform && isAssigningRole;@@ -80,11 +48,15 @@ export const RoleSelector = ({const label = isPlatform ? t('Platform Roles') : t('Project Roles');const options = isPlatform- ? PLATFORM_ROLES.map((role) => ({- value: role.value,- label: role.label,- description: role.description,- }))+ ? roleCopy+ .platformRoles({+ personalProjectsEnabled: platform.autoCreatePersonalProjects,+ })+ .map((role) => ({+ value: role.role,+ label: role.label,+ description: role.description,+ })): roles.map((role) => ({value: role.name,label: role.name,diff --git a/packages/web/src/features/members/lib/role-copy.ts b/packages/web/src/features/members/lib/role-copy.tsnew file mode 100644index 00000000000..4e68285bc46--- /dev/null+++ b/packages/web/src/features/members/lib/role-copy.ts@@ -0,0 +1,109 @@+import { ProjectRole, RoleType } from '@activepieces/core-utils';+import { DefaultProjectRole, PlatformRole } from '@activepieces/shared';+import { t } from 'i18next';++const BUILT_IN_ORDER: string[] = [+ DefaultProjectRole.ADMIN,+ DefaultProjectRole.EDITOR,+ DefaultProjectRole.VIEWER,+];++function projectRoleDescription(roleName: string): string | null {+ switch (roleName) {+ case DefaultProjectRole.ADMIN:+ return t('Full access');+ case DefaultProjectRole.EDITOR:+ return t('Build, publish, and manage flows');+ case DefaultProjectRole.VIEWER:+ return t('View only');+ default:+ return null;+ }+}++function projectRoleTone(roleName: string): RoleTone {+ switch (roleName) {+ case DefaultProjectRole.ADMIN:+ return 'brand';+ case DefaultProjectRole.EDITOR:+ return 'info';+ case DefaultProjectRole.VIEWER:+ return 'neutral';+ default:+ return 'custom';+ }+}++function platformRoles({+ personalProjectsEnabled,+}: PlatformRolesParams): PlatformRoleSummary[] {+ return [+ {+ role: PlatformRole.ADMIN,+ tone: 'brand',+ label: t('Admin'),+ description: t('Full access to all projects and platform settings'),+ isDefaultForNewMembers: false,+ },+ {+ role: PlatformRole.OPERATOR,+ tone: 'info',+ label: t('Operator'),+ description: t(+ 'Access and edit flows in all projects, no platform settings',+ ),+ isDefaultForNewMembers: false,+ },+ {+ role: PlatformRole.MEMBER,+ tone: 'neutral',+ label: t('Member'),+ description: personalProjectsEnabled+ ? t(+ "Access to personal project and any team projects they're invited to",+ )+ : t("Access to the team projects they're invited to"),+ isDefaultForNewMembers: true,+ },+ ];+}++function sortProjectRoles({ roles }: { roles: ProjectRole[] }): ProjectRole[] {+ return [...roles].sort((left, right) => {+ const leftRank = builtInRank(left);+ const rightRank = builtInRank(right);+ if (leftRank !== rightRank) {+ return leftRank - rightRank;+ }+ return left.name.localeCompare(right.name);+ });+}++function builtInRank(role: ProjectRole): number {+ if (role.type !== RoleType.DEFAULT) {+ return BUILT_IN_ORDER.length;+ }+ const index = BUILT_IN_ORDER.indexOf(role.name);+ return index === -1 ? BUILT_IN_ORDER.length - 1 : index;+}++export const roleCopy = {+ projectRoleDescription,+ projectRoleTone,+ platformRoles,+ sortProjectRoles,+};++export type RoleTone = 'brand' | 'info' | 'neutral' | 'custom';++export type PlatformRoleSummary = {+ role: PlatformRole;+ tone: RoleTone;+ label: string;+ description: string;+ isDefaultForNewMembers: boolean;+};++type PlatformRolesParams = {+ personalProjectsEnabled: boolean;+};