🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)

WIP: pre-granular-permissions commit

feat: Add category and support contact fields to Agent schema and UI components

Revert "feat: Add category and support contact fields to Agent schema and UI components"

This reverts commit c43a52b4c9.

Fix: Update import for renderHook in useAgentCategories.spec.tsx

fix: Update icon rendering in AgentCategoryDisplay tests to use empty spans

refactor: Improve category synchronization logic and clean up AgentConfig component

refactor: Remove unused UI flow translations from translation.json

feat: agent marketplace features

🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
This commit is contained in:
Danny Avila 2025-06-23 10:22:27 -04:00
parent aec1777a90
commit 28d9deed0a
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
143 changed files with 17590 additions and 629 deletions

View file

@ -97,7 +97,13 @@ const Dropdown: React.FC<DropdownProps> = ({
<Select.SelectPopover
portal={portal}
store={selectProps}
className={cn('popover-ui', sizeClasses, className, 'max-h-[80vh] overflow-y-auto')}
className={cn(
'popover-ui',
sizeClasses,
className,
'max-h-[80vh] overflow-y-auto',
'[pointer-events:auto]', // Override body's pointer-events:none when in modal
)}
>
{options.map((item, index) => {
if (isDivider(item)) {

View file

@ -0,0 +1,192 @@
'use client';
import * as React from 'react';
import * as Ariakit from '@ariakit/react';
import { Search, X } from 'lucide-react';
import { cn } from '~/utils';
import { Spinner } from '~/components/svg';
import { Skeleton } from '~/components/ui';
import { useLocalize } from '~/hooks';
type SearchPickerProps<TOption extends { key: string }> = {
options: TOption[];
renderOptions: (option: TOption) => React.ReactElement;
query: string;
onQueryChange: (query: string) => void;
onPick: (pickedOption: TOption) => void;
placeholder?: string;
inputClassName?: string;
label: string;
resetValueOnHide?: boolean;
isSmallScreen?: boolean;
isLoading?: boolean;
minQueryLengthForNoResults?: number;
};
export function SearchPicker<TOption extends { key: string; value: string }>({
options,
renderOptions,
onPick,
onQueryChange,
query,
label,
isSmallScreen = false,
placeholder,
resetValueOnHide = false,
isLoading = false,
minQueryLengthForNoResults = 2,
}: SearchPickerProps<TOption>) {
const localize = useLocalize();
const [_open, setOpen] = React.useState(false);
const inputRef = React.useRef<HTMLInputElement>(null);
const combobox = Ariakit.useComboboxStore({
resetValueOnHide,
});
const onPickHandler = (option: TOption) => {
onQueryChange('');
onPick(option);
setOpen(false);
if (inputRef.current) {
inputRef.current.focus();
}
};
const showClearIcon = query.trim().length > 0;
const clearText = () => {
onQueryChange('');
if (inputRef.current) {
inputRef.current.focus();
}
};
return (
<Ariakit.ComboboxProvider store={combobox}>
<Ariakit.ComboboxLabel className="text-token-text-primary mb-2 block font-medium">
{label}
</Ariakit.ComboboxLabel>
<div className="py-1.5">
<div
className={cn(
'group relative mt-1 flex h-10 cursor-pointer items-center gap-3 rounded-lg border-border-medium px-3 py-2 text-text-primary transition-colors duration-200 focus-within:bg-surface-hover hover:bg-surface-hover',
isSmallScreen === true ? 'mb-2 h-14 rounded-2xl' : '',
)}
>
{isLoading ? (
<Spinner className="absolute left-3 h-4 w-4 text-text-primary" />
) : (
<Search className="absolute left-3 h-4 w-4 text-text-secondary group-focus-within:text-text-primary group-hover:text-text-primary" />
)}
<Ariakit.Combobox
ref={inputRef}
onKeyDown={(e) => {
if (e.key === 'Escape' && combobox.getState().open) {
e.preventDefault();
e.stopPropagation();
onQueryChange('');
setOpen(false);
}
}}
store={combobox}
setValueOnClick={false}
setValueOnChange={false}
onChange={(e) => {
onQueryChange(e.target.value);
}}
value={query}
// autoSelect
placeholder={placeholder || localize('com_ui_select_options')}
className="m-0 mr-0 w-full rounded-md border-none bg-transparent p-0 py-2 pl-9 pr-3 text-sm leading-tight text-text-primary placeholder-text-secondary placeholder-opacity-100 focus:outline-none focus-visible:outline-none group-focus-within:placeholder-text-primary group-hover:placeholder-text-primary"
/>
<button
type="button"
aria-label={`${localize('com_ui_clear')} ${localize('com_ui_search')}`}
className={cn(
'absolute right-[7px] flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 transition-opacity duration-200',
showClearIcon ? 'opacity-100' : 'opacity-0',
isSmallScreen === true ? 'right-[16px]' : '',
)}
onClick={clearText}
tabIndex={showClearIcon ? 0 : -1}
disabled={!showClearIcon}
>
<X className="h-5 w-5 cursor-pointer" />
</button>
</div>
</div>
<Ariakit.ComboboxPopover
portal={false} //todo fix focus when set to true
gutter={10}
// sameWidth
open={
isLoading ||
options.length > 0 ||
(query.trim().length >= minQueryLengthForNoResults && !isLoading)
}
store={combobox}
unmountOnHide
autoFocusOnShow={false}
modal={false}
className={cn(
'animate-popover z-[9999] min-w-64 overflow-hidden rounded-xl border border-border-light bg-surface-secondary shadow-lg',
'[pointer-events:auto]', // Override body's pointer-events:none when in modal
)}
>
{(() => {
if (isLoading) {
return (
<div className="space-y-2 p-2">
{Array.from({ length: 3 }).map((_, index) => (
<div key={index} className="flex items-center gap-3 px-3 py-2">
<Skeleton className="h-8 w-8 rounded-full" />
<div className="flex-1 space-y-1">
<Skeleton className="h-4 w-3/4" />
<Skeleton className="h-3 w-1/2" />
</div>
</div>
))}
</div>
);
}
if (options.length > 0) {
return options.map((o) => (
<Ariakit.ComboboxItem
key={o.key}
focusOnHover
// hideOnClick
value={o.value}
selectValueOnClick={false}
onClick={() => onPickHandler(o)}
className={cn(
'flex w-full cursor-pointer items-center px-3 text-sm',
'text-text-primary hover:bg-surface-tertiary',
'data-[active-item]:bg-surface-tertiary',
)}
render={renderOptions(o)}
></Ariakit.ComboboxItem>
));
}
if (query.trim().length >= minQueryLengthForNoResults) {
return (
<div
className={cn(
'flex items-center justify-center px-4 py-8 text-center',
'text-sm text-text-secondary',
)}
>
<div className="flex flex-col items-center gap-2">
<Search className="h-8 w-8 text-text-tertiary opacity-50" />
<div className="font-medium">{localize('com_ui_no_results_found')}</div>
<div className="text-xs text-text-tertiary">
{localize('com_ui_try_adjusting_search')}
</div>
</div>
</div>
);
}
return null;
})()}
</Ariakit.ComboboxPopover>
</Ariakit.ComboboxProvider>
);
}

View file

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { Root, Trigger, Content, Portal } from '@radix-ui/react-popover';
import MenuItem from '~/components/Chat/Menus/UI/MenuItem';
import type { Option } from '~/common';
@ -32,6 +32,7 @@ function SelectDropDownPop({
footer,
}: SelectDropDownProps) {
const localize = useLocalize();
const [open, setOpen] = useState(false);
const transitionProps = { className: 'top-full mt-3' };
if (showAbove) {
transitionProps.className = 'bottom-full mb-3';
@ -54,8 +55,13 @@ function SelectDropDownPop({
const hasSearchRender = Boolean(searchRender);
const options = hasSearchRender ? filteredValues : availableValues;
const handleSelect = (selectedValue: string) => {
setValue(selectedValue);
setOpen(false);
};
return (
<Root>
<Root open={open} onOpenChange={setOpen}>
<div className={'flex items-center justify-center gap-2'}>
<div className={'relative w-full'}>
<Trigger asChild>
@ -108,19 +114,32 @@ function SelectDropDownPop({
side="bottom"
align="start"
className={cn(
'mr-3 mt-2 max-h-[52vh] w-full max-w-[85vw] overflow-hidden overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-700 dark:text-white sm:max-w-full lg:max-h-[52vh]',
'z-50 mr-3 mt-2 max-h-[52vh] w-full max-w-[85vw] overflow-hidden overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-700 dark:text-white sm:max-w-full lg:max-h-[52vh]',
hasSearchRender && 'relative',
)}
>
{searchRender}
{options.map((option) => {
if (typeof option === 'string') {
return (
<MenuItem
key={option}
title={option}
value={option}
selected={!!(value && value === option)}
onClick={() => handleSelect(option)}
/>
);
}
return (
<MenuItem
key={option}
title={option}
value={option}
selected={!!(value && value === option)}
onClick={() => setValue(option)}
key={option.value}
title={option.label}
description={option.description}
value={option.value}
icon={option.icon}
selected={!!(value && value === option.value)}
onClick={() => handleSelect(option.value)}
/>
);
})}