Files
twenty/packages/twenty-front/src/modules/settings/roles/role-assignment/components/SettingsRoleAssignmentTableRow.tsx
T
Weiko 8e710004ba Role page various fixes 2 (#12416)
- Fix: AvatarURL signedPath for workspace members were not consistent
when queried multiple times and it was causing the frontend to wrongly
interpret this as a change in the deepEqual condition
- Use SaveAndCancel button to be consistent with data model page
- When applying all object permission changes, a "smarter" logic applies
and removes all permissions if read is unchecked for example
- Hide settings permissions when Settings All Access is toggled
2025-06-02 20:24:53 +02:00

71 lines
2.1 KiB
TypeScript

import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersStates';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow';
import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil';
import { Avatar, OverflowingTextWithTooltip } from 'twenty-ui/display';
import { WorkspaceMember } from '~/generated-metadata/graphql';
const StyledIconWrapper = styled.div`
align-items: center;
display: flex;
flex-shrink: 0;
margin-right: ${({ theme }) => theme.spacing(2)};
`;
const StyledNameCell = styled.div`
color: ${({ theme }) => theme.font.color.primary};
flex: 1;
min-width: 0;
`;
const StyledNameContainer = styled.div`
align-items: center;
display: flex;
overflow: hidden;
width: 100%;
`;
const StyledTableCell = styled(TableCell)`
overflow: hidden;
`;
type SettingsRoleAssignmentTableRowProps = {
workspaceMember: WorkspaceMember;
};
export const SettingsRoleAssignmentTableRow = ({
workspaceMember,
}: SettingsRoleAssignmentTableRowProps) => {
const currentWorkspaceMembers = useRecoilValue(currentWorkspaceMembersState);
const enrichedWorkspaceMember = currentWorkspaceMembers.find(
(member) => member.id === workspaceMember.id,
);
return (
<TableRow gridAutoColumns="2fr 4fr">
<StyledTableCell>
<StyledNameContainer>
<StyledIconWrapper>
<Avatar
avatarUrl={enrichedWorkspaceMember?.avatarUrl}
placeholderColorSeed={enrichedWorkspaceMember?.id}
placeholder={enrichedWorkspaceMember?.name.firstName ?? ''}
type="rounded"
size="md"
/>
</StyledIconWrapper>
<StyledNameCell>
<OverflowingTextWithTooltip
text={`${workspaceMember.name.firstName} ${workspaceMember.name.lastName}`}
/>
</StyledNameCell>
</StyledNameContainer>
</StyledTableCell>
<StyledTableCell>
<OverflowingTextWithTooltip text={workspaceMember.userEmail} />
</StyledTableCell>
</TableRow>
);
};