// Copyright (c) 2025-2026, RTE (https://www.rte-france.com) // This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0. // If a copy of the Mozilla Public License, version 2.0 was not distributed with this file, // you can obtain one at http://mozilla.org/MPL/2.0/. // SPDX-License-Identifier: MPL-2.0 // This file is part of Co-Study4Grid a Power Grid Study tool Assistant Interface to help solve contigencies for a grid state under study. import { colors } from '../../styles/tokens'; import { useModalKeyboard } from '../../hooks/useModalKeyboard'; interface ReloadSessionModalProps { showReloadModal: boolean; setShowReloadModal: (v: boolean) => void; outputFolderPath: string; sessionListLoading: boolean; sessionList: string[]; sessionRestoring: boolean; onRestoreSession: (name: string) => void; } const ReloadSessionModal: React.FC = ({ showReloadModal, setShowReloadModal, outputFolderPath, sessionListLoading, sessionList, sessionRestoring, onRestoreSession, }) => { // Escape-to-close + focus trap/restore (QW20). Called before the early // return so hook order stays stable across open/closed renders. const { containerRef, dialogProps } = useModalKeyboard({ isOpen: showReloadModal, onClose: () => setShowReloadModal(false), }); if (!showReloadModal) return null; return (

Reload Session

From: {outputFolderPath}
{sessionListLoading ? (
Loading sessions...
) : sessionList.length === 0 ? (
No saved sessions found in this folder.
) : ( sessionList.map(name => (
!sessionRestoring && onRestoreSession(name)} style={{ padding: '10px 12px', margin: '4px 0', border: `1px solid ${colors.borderSubtle}`, borderRadius: '6px', cursor: sessionRestoring ? 'not-allowed' : 'pointer', fontSize: '0.85rem', fontFamily: 'monospace', transition: 'background 0.15s', opacity: sessionRestoring ? 0.5 : 1, }} onMouseOver={e => { if (!sessionRestoring) (e.currentTarget as HTMLElement).style.background = colors.brandSoft; }} onMouseOut={e => { (e.currentTarget as HTMLElement).style.background = 'transparent'; }} > {name}
)) )}
); }; export default ReloadSessionModal;