mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 05:39:11 +00:00
Ease bulk (de-)selecting of files to add/remove to agent knowledge base
Add select all, deselect all buttons to select all (filtered) files to add, remove from an agent's knowledge base.
This commit is contained in:
@@ -533,6 +533,7 @@ export function AgentModificationForm(props: AgentModificationFormProps) {
|
|||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
const [allFileOptions, setAllFileOptions] = useState<string[]>([]);
|
const [allFileOptions, setAllFileOptions] = useState<string[]>([]);
|
||||||
const [currentStep, setCurrentStep] = useState(0);
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
|
const [fileSearchValue, setFileSearchValue] = useState("");
|
||||||
|
|
||||||
const [showSubscribeDialog, setShowSubscribeDialog] = useState(false);
|
const [showSubscribeDialog, setShowSubscribeDialog] = useState(false);
|
||||||
|
|
||||||
@@ -1044,10 +1045,50 @@ export function AgentModificationForm(props: AgentModificationFormProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<CommandInput placeholder="Select files..." />
|
<CommandInput
|
||||||
|
placeholder="Select files..."
|
||||||
|
value={fileSearchValue}
|
||||||
|
onValueChange={setFileSearchValue}
|
||||||
|
/>
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>No files found.</CommandEmpty>
|
<CommandEmpty>No files found.</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
|
<div className="flex gap-2 px-2 py-1 border-b">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="h-6 px-2 text-xs"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const filteredFiles = allFileOptions.filter(file =>
|
||||||
|
file.toLowerCase().includes(fileSearchValue.toLowerCase())
|
||||||
|
);
|
||||||
|
const currentFiles = props.form.getValues("files") || [];
|
||||||
|
const newFiles = [...new Set([...currentFiles, ...filteredFiles])];
|
||||||
|
props.form.setValue("files", newFiles);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Select All
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="h-6 px-2 text-xs"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const filteredFiles = allFileOptions.filter(file =>
|
||||||
|
file.toLowerCase().includes(fileSearchValue.toLowerCase())
|
||||||
|
);
|
||||||
|
const currentFiles = props.form.getValues("files") || [];
|
||||||
|
const newFiles = currentFiles.filter(file => !filteredFiles.includes(file));
|
||||||
|
props.form.setValue("files", newFiles);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Deselect All
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
{allFileOptions.map((file) => (
|
{allFileOptions.map((file) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
value={file}
|
value={file}
|
||||||
|
|||||||
Reference in New Issue
Block a user