This commit is contained in:
Joshen Lim committed 2025-02-17 16:57:06 +08:00
1 parent 3b8a3a2d67
commit 0c5057814c
2 files changed
+28 -33

No files matched your search

@@ -105,12 +105,7 @@ const PolicyRow = ({
<Button type="default" className="px-1.5" icon={<MoreVertical />} />
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className="w-52">
<DropdownMenuItem
className="gap-x-2"
onClick={() => {
onSelectEditPolicy(policy)
}}
>
<DropdownMenuItem className="gap-x-2" onClick={() => onSelectEditPolicy(policy)}>
<Edit size={14} />
<p>Edit policy</p>
</DropdownMenuItem>
@@ -49,6 +49,13 @@ export const EditorPanel = ({ onChange }: EditorPanelProps) => {
const [savedCode, setSavedCode] = useState<string>('')
const [isPreviewingTemplate, setIsPreviewingTemplate] = useState(false)
const errorHeader = error?.formattedError?.split('\n')?.filter((x: string) => x.length > 0)?.[0]
const errorContent =
error?.formattedError
?.split('\n')
?.filter((x: string) => x.length > 0)
?.slice(1) ?? []
const { mutate: executeSql, isLoading: isExecuting } = useExecuteSqlMutation({
onSuccess: async (res) => {
setShowResults(true)
@@ -60,20 +67,6 @@ export const EditorPanel = ({ onChange }: EditorPanelProps) => {
},
})
useEffect(() => {
if (editorPanel.initialValue !== undefined && editorPanel.initialValue !== currentValue) {
setCurrentValue(editorPanel.initialValue)
}
}, [editorPanel.initialValue])
useEffect(() => {
if (editorPanel.initialValue !== currentValue) {
setEditorPanel({
initialValue: currentValue,
})
}
}, [currentValue, setEditorPanel])
const handleChat = () => {
setAiAssistantPanel({
open: true,
@@ -141,13 +134,6 @@ export const EditorPanel = ({ onChange }: EditorPanelProps) => {
[savedCode]
)
// Cleanup debounce on unmount
useEffect(() => {
return () => {
debouncedRevertCode.cancel()
}
}, [debouncedRevertCode])
const handleTemplateMouseEnter = (templateContent: string) => {
// Cancel any pending revert
debouncedRevertCode.cancel()
@@ -165,12 +151,26 @@ export const EditorPanel = ({ onChange }: EditorPanelProps) => {
}
}
const errorHeader = error?.formattedError?.split('\n')?.filter((x: string) => x.length > 0)?.[0]
const errorContent =
error?.formattedError
?.split('\n')
?.filter((x: string) => x.length > 0)
?.slice(1) ?? []
// Cleanup debounce on unmount
useEffect(() => {
return () => {
debouncedRevertCode.cancel()
}
}, [debouncedRevertCode])
useEffect(() => {
if (editorPanel.initialValue !== undefined && editorPanel.initialValue !== currentValue) {
setCurrentValue(editorPanel.initialValue)
}
}, [editorPanel.initialValue])
useEffect(() => {
if (editorPanel.initialValue !== currentValue) {
setEditorPanel({
initialValue: currentValue,
})
}
}, [currentValue, setEditorPanel])
return (
<div className="flex flex-col h-full bg-surface-100">