diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx
index 66428193a6c..70e2364f8b5 100644
--- a/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyTableRow/PolicyRow.tsx
@@ -105,12 +105,7 @@ const PolicyRow = ({
} />
- {
- onSelectEditPolicy(policy)
- }}
- >
+ onSelectEditPolicy(policy)}>
Edit policy
diff --git a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx b/apps/studio/components/ui/EditorPanel/EditorPanel.tsx
index 87fb03ec76c..9c0b063d46d 100644
--- a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx
+++ b/apps/studio/components/ui/EditorPanel/EditorPanel.tsx
@@ -49,6 +49,13 @@ export const EditorPanel = ({ onChange }: EditorPanelProps) => {
const [savedCode, setSavedCode] = useState('')
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 (