// 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 type { AnalysisResult } from '../types'; import { colors, radius, space } from '../styles/tokens'; import NoticesPanel, { type Notice } from './NoticesPanel'; import { useTheme } from '../hooks/useTheme'; type SettingsTab = 'paths' | 'recommender' | 'configurations'; interface HeaderProps { networkPath: string; setNetworkPath: (path: string) => void; /** * Called when the user "commits" a network path change — either by * blurring the path input after editing it, or by selecting a new * file via the picker. Goes through App's confirmation pipeline so * the user is warned before the currently-loaded study is dropped. */ onCommitNetworkPath: (path: string) => void; configLoading: boolean; result: AnalysisResult | null; /** Currently APPLIED contingency (list of element IDs). */ selectedContingency: string[]; sessionRestoring: boolean; onPickSettingsPath: (type: 'file' | 'dir', setter: (val: string) => void) => void; onLoadStudy: () => void; onSaveResults: () => void; onOpenReloadModal: () => void; onOpenSettings: (tab: SettingsTab) => void; /** Background notices — surfaced as a NoticesPanel pill tucked * directly under the app title. Self-hides when the list is empty. */ notices?: Notice[]; } const Header: React.FC = ({ networkPath, setNetworkPath, onCommitNetworkPath, configLoading, result, selectedContingency, sessionRestoring, onPickSettingsPath, onLoadStudy, onSaveResults, onOpenReloadModal, onOpenSettings, notices, }) => { const saveDisabled = !result && selectedContingency.length === 0; const { theme, toggleTheme } = useTheme(); return (

⚡ Co-Study4Grid

{/* Label and the Notices pill share one row — the pill is pushed to the right, just above the file-opener button, so the label line isn't a wasted standalone row. */}
{notices && }
setNetworkPath(e.target.value)} // Run the confirmation pipeline once the user finishes // editing so that switching networks while a study is // already loaded prompts before silently dropping the // in-flight work. onBlur={e => onCommitNetworkPath(e.target.value)} placeholder="load your grid xiidm file path" style={{ flex: 1, minWidth: 0, padding: `5px ${space[2]}`, border: '1px solid rgba(255,255,255,0.3)', borderRadius: radius.sm, background: 'rgba(255,255,255,0.1)', color: colors.textOnBrand, fontSize: '0.8rem' }} />
); }; export default Header;