From cd579e00d008145fa8e845924f7d6199a2c027b5 Mon Sep 17 00:00:00 2001 From: FTCHD Date: Fri, 31 Jan 2025 16:24:16 +0200 Subject: [PATCH] lock toggle for JSON OptionsSection --- src/components/OptionsSection.tsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/OptionsSection.tsx b/src/components/OptionsSection.tsx index b0ba1cd..6559b37 100644 --- a/src/components/OptionsSection.tsx +++ b/src/components/OptionsSection.tsx @@ -1,5 +1,5 @@ import { Chip, Textarea, Tooltip } from '@nextui-org/react' -import { XIcon } from 'lucide-react' +import { LockKeyholeIcon, LockOpenIcon, XIcon } from 'lucide-react' import { useCallback, useEffect, useState } from 'react' import { replaceSmartQuotes } from '../../lib/format' @@ -9,12 +9,16 @@ export default function OptionsSection({ globalOptions, optionsFetcher, rows = 14, + isLocked, + setIsLocked, }: { optionsJson: string setOptionsJson: (value: string) => void globalOptions: any[] optionsFetcher: () => Promise rows?: number + isLocked?: boolean + setIsLocked?: (value: boolean) => void }) { const [copyAvailableOptions, setCopyAvailableOptions] = useState([]) @@ -87,6 +91,24 @@ export default function OptionsSection({ onClear={() => { setOptionsJson('{}') }} + endContent={ + setIsLocked && ( + + {isLocked ? ( + setIsLocked(false)} + /> + ) : ( + setIsLocked(true)} + /> + )} + + ) + } + data-focus-visible="false" />