Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
Signed-off-by: souissimai <[email protected]>
  • Loading branch information
souissimai committed Jan 7, 2025
1 parent aa0f905 commit 75f0e97
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const DynamicSimulationEventDialog = (props: DynamicSimulationEventDialog
const { snackError } = useSnackMessage();
const studyUuid = useSelector((state: AppState) => state.studyUuid);
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetwork);
const currentNodeId = currentNode?.id;
const [dataFetchStatus, setDataFetchStatus] = useState(FetchStatus.IDLE);
const [event, setEvent] = useState<Event>();
Expand Down Expand Up @@ -86,15 +87,15 @@ export const DynamicSimulationEventDialog = (props: DynamicSimulationEventDialog

// load event for equipment
useEffect(() => {
if (!studyUuid || !currentNodeId) {
if (!studyUuid || !currentNodeId || !currentRootNetworkUuid) {
return;
}
setDataFetchStatus(FetchStatus.RUNNING);
fetchDynamicSimulationEvent(studyUuid, currentNodeId, equipmentId).then((event) => {
fetchDynamicSimulationEvent(studyUuid, currentNodeId, currentRootNetworkUuid, equipmentId).then((event) => {
setDataFetchStatus(FetchStatus.SUCCEED);
setEvent(event);
});
}, [currentNodeId, equipmentId, studyUuid, reset]);
}, [currentNodeId, equipmentId, currentRootNetworkUuid, studyUuid, reset]);

// reset form data when event available after fetch
useEffect(() => {
Expand All @@ -117,7 +118,7 @@ export const DynamicSimulationEventDialog = (props: DynamicSimulationEventDialog
// submit form
const handleSubmit = useCallback(
(formObj: { [KEY in EventPropertyName]: any }) => {
if (!studyUuid || !currentNodeId) {
if (!studyUuid || !currentNodeId || !currentRootNetworkUuid) {
return;
}
// formObj to EventProperty[]
Expand Down Expand Up @@ -160,14 +161,24 @@ export const DynamicSimulationEventDialog = (props: DynamicSimulationEventDialog
properties,
};

saveDynamicSimulationEvent(studyUuid, currentNodeId, submitEvent).catch((error) => {
saveDynamicSimulationEvent(studyUuid, currentNodeId, currentRootNetworkUuid, submitEvent).catch((error) => {
snackError({
messageTxt: error.message,
headerId: 'DynamicSimulationEventSaveError',
});
});
},
[currentNodeId, equipmentId, equipmentType, snackError, studyUuid, eventType, event, eventDefinition]
[
currentNodeId,
equipmentId,
currentRootNetworkUuid,
equipmentType,
snackError,
studyUuid,
eventType,
event,
eventDefinition,
]
);

const waitingOpen = useOpenShortWaitFetching({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ export function LccCreationDialog({
}}
{...dialogProps}
>
<LccCreationForm studyUuid={studyUuid} currentNode={currentNode} tabIndex={tabIndex} />
<LccCreationForm
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
tabIndex={tabIndex}
/>
<EquipmentSearchDialog
open={searchCopy.isDialogSearchOpen}
onClose={searchCopy.handleCloseSearchDialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ interface LccCreationFormProps {
tabIndex: number;
studyUuid: UUID;
currentNode: CurrentTreeNode;
currentRootNetworkUuid: UUID;
}
export default function LccCreationForm({ tabIndex, studyUuid, currentNode }: Readonly<LccCreationFormProps>) {
export default function LccCreationForm({
tabIndex,
studyUuid,
currentRootNetworkUuid,
currentNode,
}: Readonly<LccCreationFormProps>) {
return (
<>
<Box hidden={tabIndex !== LccCreationDialogTab.HVDC_LINE_TAB} p={1}>
Expand All @@ -27,6 +33,7 @@ export default function LccCreationForm({ tabIndex, studyUuid, currentNode }: Re
<LccConverterStation
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_1}
stationLabel={'converterStation1'}
/>
Expand All @@ -35,6 +42,7 @@ export default function LccCreationForm({ tabIndex, studyUuid, currentNode }: Re
<LccConverterStation
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_2}
stationLabel={'converterStation2'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ import { Box } from '@mui/material';
interface VscCreationFormProps {
tabIndex: number;
studyUuid: UUID;
currentRootNetworkUuid: UUID;
currentNode: CurrentTreeNode;
}
const VscCreationForm: FunctionComponent<VscCreationFormProps> = ({ tabIndex, studyUuid, currentNode }) => {
const VscCreationForm: FunctionComponent<VscCreationFormProps> = ({
tabIndex,
studyUuid,
currentNode,
currentRootNetworkUuid,
}) => {
return (
<>
<Box hidden={tabIndex !== VSC_CREATION_TABS.HVDC_LINE_TAB} p={1}>
Expand All @@ -29,6 +35,7 @@ const VscCreationForm: FunctionComponent<VscCreationFormProps> = ({ tabIndex, st
<ConverterStationPane
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_1}
stationLabel={'converterStation1'}
/>
Expand All @@ -37,6 +44,7 @@ const VscCreationForm: FunctionComponent<VscCreationFormProps> = ({ tabIndex, st
<ConverterStationPane
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_2}
stationLabel={'converterStation2'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ const VscModificationDialog: React.FC<any> = ({
tabIndex={tabIndex}
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
equipmentId={equipmentId}
setTabIndex={setTabIndex}
vscToModify={vscToModify}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface VscModificationFormProps {
tabIndex: number;
studyUuid: UUID;
currentNode: CurrentTreeNode;
currentRootNetworkUuid: UUID;
equipmentId: string;
vscToModify: VscModificationInfo | null;
setTabIndex: React.Dispatch<React.SetStateAction<number>>;
Expand All @@ -40,6 +41,7 @@ export const VscModificationForm: FunctionComponent<VscModificationFormProps> =
setTabIndex,
studyUuid,
currentNode,
currentRootNetworkUuid,
equipmentId,
vscToModify,
tabIndexesWithError,
Expand Down Expand Up @@ -95,6 +97,7 @@ export const VscModificationForm: FunctionComponent<VscModificationFormProps> =
<ConverterStationPane
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_1}
stationLabel={'converterStation1'}
isModification
Expand All @@ -108,6 +111,7 @@ export const VscModificationForm: FunctionComponent<VscModificationFormProps> =
<ConverterStationPane
studyUuid={studyUuid}
currentNode={currentNode}
currentRootNetworkUuid={currentRootNetworkUuid}
id={CONVERTER_STATION_2}
stationLabel={'converterStation2'}
isModification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const ModelFilter = forwardRef<GetSelectedVariablesHandle, ModelFilterProps>(

// fetch all associated models and variables for current node and study
useEffect(() => {
if (!currentNode?.id) {
if (!currentNode?.id || !currentRootNetworkUuid) {
return;
}
fetchDynamicSimulationModels(studyUuid, currentNode.id, currentRootNetworkUuid).then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export const SensitivityAnalysisParameters: FunctionComponent<SensitivityAnalysi
(row: any, arrayFormName: SubTabsValues, index: number) => {
// TODO: not easy to fix any here since values[SubTabsValues] have each time different type which causes problems with "filter"
// "none of those signatures are compatible with each other
if (!currentNode) {
if (!currentNode || !currentRootNetworkUuid) {
return;
}
setLaunchLoader(true);
Expand Down
3 changes: 3 additions & 0 deletions src/components/dialogs/root-network-creation-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const RootNetworkCreationDialog: React.FC<RootNetworkCreationDialogProps> = ({

// Fetch default directory based on study UUID
const fetchDefaultDirectoryForStudy = useCallback(() => {
if (!studyUuid) {
return;
}
fetchDirectoryElementPath(studyUuid).then((res) => {
if (!res || res.length < 2) {
snackError({
Expand Down
4 changes: 2 additions & 2 deletions src/components/graph/menus/editable-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ interface EditableTitleProps {
name: string;
onClose: () => void;
onChange?: (value: string) => void;
isCloseIconVisible: boolean;
isCloseIconVisible?: boolean;
}

export const EditableTitle: FunctionComponent<EditableTitleProps> = ({
name,
isCloseIconVisible,
isCloseIconVisible = true,
onClose,
onChange,
}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/graph/menus/root-network-node-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ const RootNetworkNodeEditor = () => {
});
})
.finally(() => {
setSaveInProgress(false);
// setSaveInProgress(false);
});
};
const renderPaneSubtitle = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const useSecurityAnalysisColumnsDefs: UseSecurityAnalysisColumnsDefsProps
const { snackError } = useSnackMessage();
const studyUuid = useSelector((state: AppState) => state.studyUuid);
const currentNode = useSelector((state: AppState) => state.currentTreeNode);

const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetwork);
const nodeUuid = currentNode?.id;

const getEnumLabel = useCallback(
Expand All @@ -69,7 +69,7 @@ export const useSecurityAnalysisColumnsDefs: UseSecurityAnalysisColumnsDefsProps
// for nmk views, click handler on subjectId cell
const onClickNmKConstraint = useCallback(
(row: SecurityAnalysisNmkTableRow, column?: ColDef) => {
if (studyUuid && nodeUuid) {
if (studyUuid && nodeUuid && currentRootNetworkUuid) {
if (column?.field === 'subjectId') {
let vlId: string | undefined = '';
const { subjectId, side } = row || {};
Expand All @@ -86,6 +86,7 @@ export const useSecurityAnalysisColumnsDefs: UseSecurityAnalysisColumnsDefsProps
fetchVoltageLevelIdForLineOrTransformerBySide(
studyUuid,
nodeUuid,
currentRootNetworkUuid,
subjectId ?? '',
getBranchSide(side) ?? BranchSide.ONE
)
Expand Down Expand Up @@ -115,7 +116,7 @@ export const useSecurityAnalysisColumnsDefs: UseSecurityAnalysisColumnsDefsProps
}
}
},
[nodeUuid, openVoltageLevelDiagram, snackError, studyUuid, intl]
[nodeUuid, currentRootNetworkUuid, openVoltageLevelDiagram, snackError, studyUuid, intl]
);

// for nmk views, custom view for subjectId cell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export const ShortCircuitAnalysisResult: FunctionComponent<IShortCircuitAnalysis
if (analysisStatus !== RunningStatus.SUCCEED) {
return;
}

if (!currentRootNetworkUuid) {
return;
}
let active = true; // to manage race condition
setIsFetching(true);
updateResult(null);
Expand Down
2 changes: 2 additions & 0 deletions src/components/spreadsheet/utils/equipment-table-editors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const GeneratorRegulatingTerminalEditor = forwardRef(
open={openGeneratorPopup}
onClose={handleCancelRegulatingTerminalPopup}
currentNode={gridContext.currentNode}
currentRootNetworkUuid={gridContext.currentRootNetworkUuid}
studyUuid={gridContext.studyUuid}
onModifyRegulatingTerminalGenerator={(updatedRegulatedTerminal: any) => {
handleSaveRegulatingTerminalPopup(updatedRegulatedTerminal);
Expand Down Expand Up @@ -188,6 +189,7 @@ export const TWTRegulatingTerminalEditor = forwardRef(
open={openTWTRegulatingTerminalPopup}
onClose={handleCancelRegulatingTerminalPopup}
currentNode={gridContext.currentNode}
currentRootNetworkUuid={gridContext.currentRootNetworkUuid}
studyUuid={gridContext.studyUuid}
onModifyRegulatingTerminalGenerator={(updatedRegulatedTerminal: any) => {
handleSaveRegulatingTerminalPopup(updatedRegulatedTerminal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,35 @@ export const CustomSuffixRenderer: FunctionComponent<CustomSuffixRendererProps>
const dispatch = useDispatch<AppDispatch>();
const studyUuid = useSelector((state: AppState) => state.studyUuid);
const currentNode = useSelector((state: AppState) => state.currentTreeNode);
const currentRootNetworkUuid = useSelector((state: AppState) => state.currentRootNetwork);
const networkAreaDiagramNbVoltageLevels = useSelector((state: AppState) => state.networkAreaDiagramNbVoltageLevels);
const networkAreaDiagramDepth = useSelector((state: AppState) => state.networkAreaDiagramDepth);

const centerOnSubstationCB = useCallback(
(e: ReactMouseEvent<HTMLButtonElement, MouseEvent>) => {
e.stopPropagation();
if (!studyUuid || !currentNode) {
if (!studyUuid || !currentNode || !currentRootNetworkUuid) {
return;
}
let substationIdPromise;
// @ts-expect-error: conflicts between commons-ui's EquipmentType and gridstudy's EQUIPMENT_TYPE
if (element.type === EQUIPMENT_TYPES.SUBSTATION) {
substationIdPromise = Promise.resolve(element.id);
} else {
substationIdPromise = fetchSubstationIdForVoltageLevel(studyUuid, currentNode.id, element.id);
substationIdPromise = fetchSubstationIdForVoltageLevel(
studyUuid,
currentNode.id,
currentRootNetworkUuid,
element.id
);
}
substationIdPromise.then((substationId) => {
dispatch(centerOnSubstation(substationId));
onClose?.();
e.stopPropagation();
});
},
[studyUuid, currentNode, element.type, element.id, dispatch, onClose]
[studyUuid, currentNode, currentRootNetworkUuid, element.type, element.id, dispatch, onClose]
);

const openNetworkAreaDiagramCB = useCallback(
Expand Down

0 comments on commit 75f0e97

Please sign in to comment.