Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 35 additions & 18 deletions src/custom/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export interface PermissionShieldProps {
permissionKey: PermissionKeySpec;
children: React.ReactNode;
variant?: 'inline' | 'badge';
boundaryPadding?: {
top?: number;
left?: number;
right?: number;
bottom?: number;
};
}

/** Distinct, defined values in first-seen order — used for the metadata chips. */
Expand All @@ -93,14 +99,18 @@ const uniqueDefined = (values: (string | undefined)[]): string[] =>
export const PermissionShield: React.FC<PermissionShieldProps> = ({
permissionKey,
children,
variant = 'inline'
variant = 'inline',
boundaryPadding
}) => {
const [open, setOpen] = React.useState(false);
const [copiedKeyId, setCopiedKeyId] = React.useState<string | null>(null);
const uniqueId = React.useId();
const userContext = usePermissionUserContext();
const unmetKeys = useUnmetPermissionKeys(permissionKey);

const defaultPadding = { top: 85, left: 270, right: 8, bottom: 8 };
const padding = boundaryPadding ? { ...defaultPadding, ...boundaryPadding } : defaultPadding;

const handleClose = () => {
setOpen(false);
};
Expand Down Expand Up @@ -419,31 +429,38 @@ export const PermissionShield: React.FC<PermissionShieldProps> = ({
disableTouchListener
slotProps={{
popper: {
modifiers: [
{
name: 'flip',
enabled: true,
options: {
fallbackPlacements: ['bottom', 'right', 'left']
}
},
{
name: 'preventOverflow',
enabled: true,
options: {
boundary: 'viewport',
altAxis: true,
padding: 8
popperOptions: {
modifiers: [
{
name: 'flip',
enabled: true,
options: {
boundary: 'viewport',
fallbackPlacements: ['right', 'bottom', 'left'],
padding
}
Comment thread
dhruveshmishra marked this conversation as resolved.
},
{
name: 'preventOverflow',
enabled: true,
options: {
boundary: 'viewport',
tether: false,
altAxis: true,
padding
}
}
}
]
]
}
},
tooltip: {
sx: {
background: '#1A1A1A',
color: '#FFFFFF',
maxWidth: 360,
minWidth: 300,
maxHeight: '320px',
overflowY: 'auto',
padding: '12px',
borderLeft: '4px solid #EBC024',
borderRadius: '8px',
Expand Down
Loading