clean up tool view
This commit is contained in:
parent
21804ade01
commit
fdcd27c621
3 changed files with 28 additions and 75 deletions
|
|
@ -3,7 +3,6 @@ import { useMemo } from "react";
|
|||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import { toggleToolGroupSetting } from "../../../redux/slices/uiSlice";
|
||||
import ToggleSwitch from "../../gui/Switch";
|
||||
import InfoHover from "../../InfoHover";
|
||||
import ToolDropdownItem from "./ToolDropdownItem";
|
||||
|
||||
const ToolPermissionsDialog = () => {
|
||||
|
|
@ -40,60 +39,33 @@ const ToolPermissionsDialog = () => {
|
|||
}, [availableTools]);
|
||||
|
||||
return (
|
||||
<div className="px-1">
|
||||
<div className="text-vsc-foreground mb-1 flex items-center gap-2 px-2 py-2 text-xs">
|
||||
<h2 className="m-0 p-0 text-base">Tool policies</h2>
|
||||
<InfoHover
|
||||
id={"tool-policies"}
|
||||
size={"4"}
|
||||
msg={
|
||||
<div
|
||||
className="gap-0 *:m-1 *:text-left"
|
||||
style={{ fontSize: "10px" }}
|
||||
>
|
||||
<p>
|
||||
<span className="text-green-500">Automatic:</span> Can be used
|
||||
without asking
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-yellow-500">Allowed:</span> Will ask
|
||||
before using
|
||||
</p>
|
||||
<p>
|
||||
<span className="text-red-500">Disabled:</span> Cannot be used
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex max-h-72 flex-col gap-2 divide-y divide-zinc-700 overflow-y-auto pl-1 pr-2">
|
||||
{toolsByGroup.map(([groupName, tools]) => (
|
||||
<div key={groupName} className="mt-2 flex flex-col">
|
||||
<div className="mb-1 flex flex-row items-center justify-between px-1">
|
||||
<h3 className="m-0 p-0 text-xs font-bold">{groupName}</h3>
|
||||
<ToggleSwitch
|
||||
isToggled={toolGroupSettings[groupName] !== "exclude"}
|
||||
onToggle={() => dispatch(toggleToolGroupSetting(groupName))}
|
||||
text=""
|
||||
size={12}
|
||||
/>
|
||||
</div>
|
||||
<div className="relative flex flex-col p-1">
|
||||
{tools.map((tool) => (
|
||||
<ToolDropdownItem
|
||||
key={tool.uri + tool.function.name}
|
||||
tool={tool}
|
||||
duplicatesDetected={duplicateDetection[tool.function.name]}
|
||||
excluded={toolGroupSettings[groupName] === "exclude"}
|
||||
/>
|
||||
))}
|
||||
{toolGroupSettings[groupName] === "exclude" && (
|
||||
<div className="absolute right-0 top-0 h-full w-full cursor-not-allowed"></div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex max-h-72 flex-col gap-2 divide-y divide-zinc-700 overflow-y-auto pl-1 pr-2">
|
||||
{toolsByGroup.map(([groupName, tools]) => (
|
||||
<div key={groupName} className="mt-2 flex flex-col">
|
||||
<div className="mb-1 flex flex-row items-center justify-between px-1">
|
||||
<h3 className="m-0 p-0 text-xs font-bold">{groupName}</h3>
|
||||
<ToggleSwitch
|
||||
isToggled={toolGroupSettings[groupName] !== "exclude"}
|
||||
onToggle={() => dispatch(toggleToolGroupSetting(groupName))}
|
||||
text=""
|
||||
size={12}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="relative flex flex-col p-1">
|
||||
{tools.map((tool) => (
|
||||
<ToolDropdownItem
|
||||
key={tool.uri + tool.function.name}
|
||||
tool={tool}
|
||||
duplicatesDetected={duplicateDetection[tool.function.name]}
|
||||
excluded={toolGroupSettings[groupName] === "exclude"}
|
||||
/>
|
||||
))}
|
||||
{toolGroupSettings[groupName] === "exclude" && (
|
||||
<div className="absolute right-0 top-0 h-full w-full cursor-not-allowed"></div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,25 +1,7 @@
|
|||
import { useAppSelector } from "../../../../redux/hooks";
|
||||
import { getFontSize } from "../../../../util";
|
||||
import ToolDropdownItem from "../../InputToolbar/ToolDropdownItem";
|
||||
import ToolPermissionsDialog from "../../InputToolbar/ToolPermissionsDialog";
|
||||
|
||||
interface ToolsSectionProps {}
|
||||
|
||||
export function ToolsSection({}: ToolsSectionProps) {
|
||||
const availableTools = useAppSelector((state) => state.config.config.tools);
|
||||
|
||||
return (
|
||||
<div className="overflow-y-auto overflow-x-hidden pr-2">
|
||||
{availableTools.map((tool: any) => (
|
||||
<div
|
||||
key={tool.function.name}
|
||||
style={{
|
||||
fontSize: `${getFontSize() - 3}px`,
|
||||
}}
|
||||
className="text-vsc-foreground block w-full text-left brightness-75 hover:brightness-125"
|
||||
>
|
||||
<ToolDropdownItem tool={tool} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
return <ToolPermissionsDialog />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,7 +243,6 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
activeKey={activeKey}
|
||||
hidden={shouldHideToolbar && !props.isMainInput}
|
||||
onAddContextItem={() => insertCharacterWithWhitespace("@")}
|
||||
onAddSlashCommand={() => insertCharacterWithWhitespace("/")}
|
||||
lumpOpen={props.lumpOpen}
|
||||
setLumpOpen={props.setLumpOpen}
|
||||
onEnter={onEnterRef.current}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue