mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-25 20:58:50 +01:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import React, { memo } from 'react';
|
|
import { CheckboxButton, VectorIcon } from '@librechat/client';
|
|
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
|
import { useLocalize, useHasAccess } from '~/hooks';
|
|
import { useBadgeRowContext } from '~/Providers';
|
|
|
|
function FileSearch() {
|
|
const localize = useLocalize();
|
|
const { fileSearch } = useBadgeRowContext();
|
|
const { toggleState: fileSearchEnabled, debouncedChange, isPinned } = fileSearch;
|
|
|
|
const canUseFileSearch = useHasAccess({
|
|
permissionType: PermissionTypes.FILE_SEARCH,
|
|
permission: Permissions.USE,
|
|
});
|
|
|
|
if (!canUseFileSearch) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{(fileSearchEnabled || isPinned) && (
|
|
<CheckboxButton
|
|
className="max-w-fit"
|
|
checked={fileSearchEnabled}
|
|
setValue={debouncedChange}
|
|
label={localize('com_assistants_file_search')}
|
|
isCheckedClassName="border-green-600/40 bg-green-500/10 hover:bg-green-700/10"
|
|
icon={<VectorIcon className="icon-md" />}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default memo(FileSearch);
|