mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
chore: address ESLint errors
This commit is contained in:
parent
5512c55d71
commit
f8c8b89f4d
6 changed files with 86 additions and 60 deletions
|
|
@ -188,7 +188,10 @@ const getUserOwnedEntraGroups = async (accessToken, sub) => {
|
||||||
try {
|
try {
|
||||||
const graphClient = await createGraphClient(accessToken, sub);
|
const graphClient = await createGraphClient(accessToken, sub);
|
||||||
|
|
||||||
const groupsResponse = await graphClient.api('/me/ownedObjects/microsoft.graph.group').select('id').get();
|
const groupsResponse = await graphClient
|
||||||
|
.api('/me/ownedObjects/microsoft.graph.group')
|
||||||
|
.select('id')
|
||||||
|
.get();
|
||||||
|
|
||||||
return (groupsResponse.value || []).map((group) => group.id);
|
return (groupsResponse.value || []).map((group) => group.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,7 @@ const hasPublicPermission = async ({ resourceType, resourceId, requiredPermissio
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if any entry has the required permission bits
|
// Check if any entry has the required permission bits
|
||||||
return entries.some(entry => (entry.permBits & requiredPermissions) === requiredPermissions);
|
return entries.some((entry) => (entry.permBits & requiredPermissions) === requiredPermissions);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`[PermissionService.hasPublicPermission] Error: ${error.message}`);
|
logger.error(`[PermissionService.hasPublicPermission] Error: ${error.message}`);
|
||||||
// Re-throw validation errors
|
// Re-throw validation errors
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ export default function GrantAccessDialog({
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: permissionsData,
|
data: permissionsData,
|
||||||
isLoading: isLoadingPermissions,
|
// isLoading: isLoadingPermissions,
|
||||||
error: permissionsError,
|
// error: permissionsError,
|
||||||
} = useGetResourcePermissionsQuery(resourceType, agentDbId!, {
|
} = useGetResourcePermissionsQuery(resourceType, agentDbId!, {
|
||||||
enabled: !!agentDbId,
|
enabled: !!agentDbId,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import {
|
||||||
OGDialogClose,
|
OGDialogClose,
|
||||||
OGDialogContent,
|
OGDialogContent,
|
||||||
OGDialogTrigger,
|
OGDialogTrigger,
|
||||||
Badge,
|
|
||||||
} from '~/components/ui';
|
} from '~/components/ui';
|
||||||
import { cn, removeFocusOutlines } from '~/utils';
|
import { cn, removeFocusOutlines } from '~/utils';
|
||||||
import { useToastContext } from '~/Providers';
|
import { useToastContext } from '~/Providers';
|
||||||
|
|
@ -43,7 +42,10 @@ export default function ManagePermissionsDialog({
|
||||||
} = useGetResourcePermissionsQuery(resourceType, agentDbId, {
|
} = useGetResourcePermissionsQuery(resourceType, agentDbId, {
|
||||||
enabled: !!agentDbId,
|
enabled: !!agentDbId,
|
||||||
});
|
});
|
||||||
const { data: accessRoles, isLoading: rolesLoading } = useGetAccessRolesQuery(resourceType);
|
const {
|
||||||
|
data: accessRoles,
|
||||||
|
// isLoading,
|
||||||
|
} = useGetAccessRolesQuery(resourceType);
|
||||||
|
|
||||||
const updatePermissionsMutation = useUpdateResourcePermissionsMutation();
|
const updatePermissionsMutation = useUpdateResourcePermissionsMutation();
|
||||||
|
|
||||||
|
|
@ -165,11 +167,31 @@ export default function ManagePermissionsDialog({
|
||||||
const totalShares = managedShares.length + (managedIsPublic ? 1 : 0);
|
const totalShares = managedShares.length + (managedIsPublic ? 1 : 0);
|
||||||
const originalTotalShares = currentShares.length + (isPublic ? 1 : 0);
|
const originalTotalShares = currentShares.length + (isPublic ? 1 : 0);
|
||||||
|
|
||||||
// Check if there's at least one owner (user, group, or public with owner role)
|
/** Check if there's at least one owner (user, group, or public with owner role) */
|
||||||
const hasAtLeastOneOwner =
|
const hasAtLeastOneOwner =
|
||||||
managedShares.some((share) => share.accessRoleId === ACCESS_ROLE_IDS.AGENT_OWNER) ||
|
managedShares.some((share) => share.accessRoleId === ACCESS_ROLE_IDS.AGENT_OWNER) ||
|
||||||
(managedIsPublic && managedPublicRole === ACCESS_ROLE_IDS.AGENT_OWNER);
|
(managedIsPublic && managedPublicRole === ACCESS_ROLE_IDS.AGENT_OWNER);
|
||||||
|
|
||||||
|
let peopleLabel = localize('com_ui_people');
|
||||||
|
if (managedShares.length === 1) {
|
||||||
|
peopleLabel = localize('com_ui_person');
|
||||||
|
}
|
||||||
|
|
||||||
|
let buttonAriaLabel = localize('com_ui_manage_permissions_for') + ' agent';
|
||||||
|
if (agentName != null && agentName !== '') {
|
||||||
|
buttonAriaLabel = localize('com_ui_manage_permissions_for') + ` "${agentName}"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dialogTitle = localize('com_ui_manage_permissions_for') + ' Agent';
|
||||||
|
if (agentName != null && agentName !== '') {
|
||||||
|
dialogTitle = localize('com_ui_manage_permissions_for') + ` "${agentName}"`;
|
||||||
|
}
|
||||||
|
|
||||||
|
let publicSuffix = '';
|
||||||
|
if (managedIsPublic) {
|
||||||
|
publicSuffix = localize('com_ui_and_public');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OGDialog open={isModalOpen} onOpenChange={setIsModalOpen}>
|
<OGDialog open={isModalOpen} onOpenChange={setIsModalOpen}>
|
||||||
<OGDialogTrigger asChild>
|
<OGDialogTrigger asChild>
|
||||||
|
|
@ -178,11 +200,7 @@ export default function ManagePermissionsDialog({
|
||||||
'btn btn-neutral border-token-border-light relative h-9 rounded-lg font-medium',
|
'btn btn-neutral border-token-border-light relative h-9 rounded-lg font-medium',
|
||||||
removeFocusOutlines,
|
removeFocusOutlines,
|
||||||
)}
|
)}
|
||||||
aria-label={
|
aria-label={buttonAriaLabel}
|
||||||
agentName != null && agentName !== ''
|
|
||||||
? localize('com_ui_manage_permissions_for') + ` "${agentName}"`
|
|
||||||
: localize('com_ui_manage_permissions_for') + ' agent'
|
|
||||||
}
|
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-center gap-2 text-blue-500">
|
<div className="flex items-center justify-center gap-2 text-blue-500">
|
||||||
|
|
@ -197,9 +215,7 @@ export default function ManagePermissionsDialog({
|
||||||
<OGDialogTitle>
|
<OGDialogTitle>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Shield className="h-5 w-5 text-blue-500" />
|
<Shield className="h-5 w-5 text-blue-500" />
|
||||||
{agentName != null && agentName !== ''
|
{dialogTitle}
|
||||||
? localize('com_ui_manage_permissions_for') + ` "${agentName}"`
|
|
||||||
: localize('com_ui_manage_permissions_for') + ' Agent'}
|
|
||||||
</div>
|
</div>
|
||||||
</OGDialogTitle>
|
</OGDialogTitle>
|
||||||
|
|
||||||
|
|
@ -211,16 +227,16 @@ export default function ManagePermissionsDialog({
|
||||||
{localize('com_ui_current_access')}
|
{localize('com_ui_current_access')}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-text-secondary">
|
<p className="text-xs text-text-secondary">
|
||||||
{totalShares === 0
|
{(() => {
|
||||||
? localize('com_ui_no_users_groups_access')
|
if (totalShares === 0) {
|
||||||
: localize('com_ui_shared_with_count', {
|
return localize('com_ui_no_users_groups_access');
|
||||||
|
}
|
||||||
|
return localize('com_ui_shared_with_count', {
|
||||||
0: managedShares.length,
|
0: managedShares.length,
|
||||||
1:
|
1: peopleLabel,
|
||||||
managedShares.length === 1
|
2: publicSuffix,
|
||||||
? localize('com_ui_person')
|
});
|
||||||
: localize('com_ui_people'),
|
})()}
|
||||||
2: managedIsPublic ? localize('com_ui_and_public') : '',
|
|
||||||
})}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{(managedShares.length > 0 || managedIsPublic) && (
|
{(managedShares.length > 0 || managedIsPublic) && (
|
||||||
|
|
@ -237,14 +253,20 @@ export default function ManagePermissionsDialog({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isLoadingPermissions ? (
|
{(() => {
|
||||||
|
if (isLoadingPermissions) {
|
||||||
|
return (
|
||||||
<div className="flex items-center justify-center p-8">
|
<div className="flex items-center justify-center p-8">
|
||||||
<Loader className="h-6 w-6 animate-spin" />
|
<Loader className="h-6 w-6 animate-spin" />
|
||||||
<span className="ml-2 text-sm text-text-secondary">
|
<span className="ml-2 text-sm text-text-secondary">
|
||||||
{localize('com_ui_loading_permissions')}
|
{localize('com_ui_loading_permissions')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : managedShares.length > 0 ? (
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (managedShares.length > 0) {
|
||||||
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3 className="mb-3 flex items-center gap-2 text-sm font-medium text-text-primary">
|
<h3 className="mb-3 flex items-center gap-2 text-sm font-medium text-text-primary">
|
||||||
<UserCheck className="h-4 w-4" />
|
<UserCheck className="h-4 w-4" />
|
||||||
|
|
@ -257,14 +279,18 @@ export default function ManagePermissionsDialog({
|
||||||
onRoleChange={(id, newRole) => handleRoleChange(id, newRole)}
|
onRoleChange={(id, newRole) => handleRoleChange(id, newRole)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<div className="rounded-lg border-2 border-dashed border-border-light p-8 text-center">
|
<div className="rounded-lg border-2 border-dashed border-border-light p-8 text-center">
|
||||||
<Users className="mx-auto h-8 w-8 text-text-secondary" />
|
<Users className="mx-auto h-8 w-8 text-text-secondary" />
|
||||||
<p className="mt-2 text-sm text-text-secondary">
|
<p className="mt-2 text-sm text-text-secondary">
|
||||||
{localize('com_ui_no_individual_access')}
|
{localize('com_ui_no_individual_access')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
);
|
||||||
|
})()}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="mb-3 text-sm font-medium text-text-primary">
|
<h3 className="mb-3 text-sm font-medium text-text-primary">
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { Search, X } from 'lucide-react';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
import { Spinner } from '~/components/svg';
|
import { Spinner } from '~/components/svg';
|
||||||
import { Skeleton } from '~/components/ui';
|
import { Skeleton } from '~/components/ui';
|
||||||
import { useLocation } from 'react-router-dom';
|
|
||||||
import { useLocalize } from '~/hooks';
|
import { useLocalize } from '~/hooks';
|
||||||
|
|
||||||
type SearchPickerProps<TOption extends { key: string }> = {
|
type SearchPickerProps<TOption extends { key: string }> = {
|
||||||
|
|
@ -31,7 +30,6 @@ export function SearchPicker<TOption extends { key: string; value: string }>({
|
||||||
onQueryChange,
|
onQueryChange,
|
||||||
query,
|
query,
|
||||||
label,
|
label,
|
||||||
inputClassName,
|
|
||||||
isSmallScreen = false,
|
isSmallScreen = false,
|
||||||
placeholder,
|
placeholder,
|
||||||
resetValueOnHide = false,
|
resetValueOnHide = false,
|
||||||
|
|
@ -39,8 +37,7 @@ export function SearchPicker<TOption extends { key: string; value: string }>({
|
||||||
minQueryLengthForNoResults = 2,
|
minQueryLengthForNoResults = 2,
|
||||||
}: SearchPickerProps<TOption>) {
|
}: SearchPickerProps<TOption>) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const location = useLocation();
|
const [_open, setOpen] = React.useState(false);
|
||||||
const [open, setOpen] = React.useState(false);
|
|
||||||
const inputRef = React.useRef<HTMLInputElement>(null);
|
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||||
const combobox = Ariakit.useComboboxStore({
|
const combobox = Ariakit.useComboboxStore({
|
||||||
resetValueOnHide,
|
resetValueOnHide,
|
||||||
|
|
@ -96,7 +93,7 @@ export function SearchPicker<TOption extends { key: string; value: string }>({
|
||||||
value={query}
|
value={query}
|
||||||
// autoSelect
|
// autoSelect
|
||||||
placeholder={placeholder || localize('com_ui_select_options')}
|
placeholder={placeholder || localize('com_ui_select_options')}
|
||||||
className="m-0 mr-0 w-full rounded-md border-none bg-surface-secondary bg-transparent p-0 py-2 pl-7 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"
|
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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue