The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Show the Admin role in the roles list again (#28946)
Paul Rastoin6bfb99afaade
diff --git a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsxindex 679dc3257ff..d31713231f7 100644--- a/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx+++ b/packages/twenty-front/src/modules/settings/roles/components/SettingsRolesList.tsx@@ -2,6 +2,7 @@ import { useInstalledApplications } from '@/applications/hooks/useInstalledAppliimport { SettingsRolesTableHeader } from '@/settings/roles/components/SettingsRolesTableHeader';import { SettingsRolesTableRow } from '@/settings/roles/components/SettingsRolesTableRow';import { useSettingsAllRoles } from '@/settings/roles/hooks/useSettingsAllRoles';+import { type RoleWithPartialMembers } from '@/settings/roles/types/RoleWithPartialMembers';import { SettingsTextInput } from '@/ui/input/components/SettingsTextInput';import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';@@ -61,22 +62,24 @@ export const SettingsRolesList = () => {.map((application) => [application.defaultRoleId, application]),);- const sortedSettingsAllRoles = [...settingsAllRoles].sort((a, b) => {- const applicationNameA =- installedApplicationByDefaultRoleId.get(a.id)?.name ?? '';- const applicationNameB =- installedApplicationByDefaultRoleId.get(b.id)?.name ?? '';+ // Admin is the standard application's default role but stays a member role+ const isApplicationRole = (role: RoleWithPartialMembers) =>+ !role.canBeAssignedToUsers &&+ installedApplicationByDefaultRoleId.has(role.id);- return (- sortByAscString(applicationNameA, applicationNameB) ||- sortByAscString(a.label, b.label)- );- });+ const getApplicationName = (role: RoleWithPartialMembers) =>+ isApplicationRole(role)+ ? (installedApplicationByDefaultRoleId.get(role.id)?.name ?? '')+ : '';- const filteredRoles = sortedSettingsAllRoles.filter((role) => {- const isApplicationRole = installedApplicationByDefaultRoleId.has(role.id);+ const sortedSettingsAllRoles = [...settingsAllRoles].sort(+ (a, b) =>+ sortByAscString(getApplicationName(a), getApplicationName(b)) ||+ sortByAscString(a.label, b.label),+ );- const matchesType = isApplicationRole+ const filteredRoles = sortedSettingsAllRoles.filter((role) => {+ const matchesType = isApplicationRole(role)? showApplicationRoles: role.canBeAssignedToUsers ||(showAgentRoles && role.canBeAssignedToAgents) ||