Skip to content
Snippets Groups Projects

#3509089: Code component status is not reflected in the code editor

Merged #3509089: Code component status is not reflected in the code editor
1 unresolved thread
1 unresolved thread
2 files
+ 24
0
Compare changes
  • Side-by-side
  • Inline
Files
2
import { useEffect } from 'react';
import { useEffect } from 'react';
 
import { useNavigate } from 'react-router-dom';
import { useUpdateCodeComponentMutation } from '@/services/componentAndLayout';
import { useUpdateCodeComponentMutation } from '@/services/componentAndLayout';
import { useAppDispatch, useAppSelector } from '@/app/hooks';
import { useAppDispatch, useAppSelector } from '@/app/hooks';
import {
import {
@@ -6,12 +7,22 @@ import {
@@ -6,12 +7,22 @@ import {
selectDialogStates,
selectDialogStates,
selectSelectedCodeComponent,
selectSelectedCodeComponent,
} from '@/features/ui/codeComponentDialogSlice';
} from '@/features/ui/codeComponentDialogSlice';
 
import {
 
selectId as selectCodeEditorId,
 
setStatus,
 
} from '@/features/code-editor/codeEditorSlice';
 
import {
 
LayoutItemType,
 
setOpenLayoutItem,
 
} from '@/features/ui/primaryPanelSlice';
import Dialog from '@/components/Dialog';
import Dialog from '@/components/Dialog';
// This handles the dialog for removing a JS component from components. This changes
// This handles the dialog for removing a JS component from components. This changes
// the component from being "exposed" to "internal".
// the component from being "exposed" to "internal".
const RemoveFromComponentsDialog = () => {
const RemoveFromComponentsDialog = () => {
 
const navigate = useNavigate();
const selectedComponent = useAppSelector(selectSelectedCodeComponent);
const selectedComponent = useAppSelector(selectSelectedCodeComponent);
 
const isCodeEditorOpen = !!useAppSelector(selectCodeEditorId);
const [updateCodeComponent, { isLoading, isSuccess, isError, error, reset }] =
const [updateCodeComponent, { isLoading, isSuccess, isError, error, reset }] =
useUpdateCodeComponentMutation();
useUpdateCodeComponentMutation();
const dispatch = useAppDispatch();
const dispatch = useAppDispatch();
@@ -30,6 +41,18 @@ const RemoveFromComponentsDialog = () => {
@@ -30,6 +41,18 @@ const RemoveFromComponentsDialog = () => {
status: false,
status: false,
},
},
});
});
 
 
if (isCodeEditorOpen) {
 
// If the code editor is open when the component is being set to internal,
 
// also set the status in the codeEditorSlice to internal. While the
 
// `updateCodeComponent` mutation invalidates cache of the code component
 
// data, the code editor won't refetch while it's open.
 
dispatch(setStatus(false));
 
// Navigate to the code editor route that handles internal code components.
 
navigate(`/code-editor/code/${selectedComponent.machineName}`);
 
// Open the "Code" accordion in the primary panel.
 
dispatch(setOpenLayoutItem(LayoutItemType.CODE));
 
}
};
};
const handleOpenChange = (open: boolean) => {
const handleOpenChange = (open: boolean) => {
Loading