/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, Dropdown, Input, Option, OptionOnSelectData, SelectionEvents } from '@fluentui/react-components'; import { Edit16Regular } from '@fluentui/react-icons'; import * as mobxlite from 'mobx-react-lite'; import * as React from 'react'; import { SimulationRunsProvider } from '../stores/simulationBaseline'; import { useInternalToolbarPickerStyles } from './pickerStyle'; type Props = { simulationRunsProvider: SimulationRunsProvider; outputFolderName: string; onChange: (selected: string | undefined) => void; disabled?: boolean; }; export const CurrentRunPicker = mobxlite.observer(({ simulationRunsProvider, onChange, disabled, outputFolderName }: Props) => { const [isRenameDialogOpen, setIsRenameDialogOpen] = React.useState(false); const [newName, setNewName] = React.useState(''); const [runToRename, setRunToRename] = React.useState(''); const id = 'currentRunPicker'; const styles = useInternalToolbarPickerStyles(); const handleRenameClick = (runName: string) => { setRunToRename(runName); setNewName(runName); setIsRenameDialogOpen(true); }; const handleRenameConfirm = async () => { if (runToRename && newName) { const success = await simulationRunsProvider.renameRun(runToRename, newName); if (success) { onChange(newName); } } setIsRenameDialogOpen(false); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); handleRenameConfirm(); } }; return (
onChange(optionValue)} > {simulationRunsProvider.runs.map((run) => ( ))}
setIsRenameDialogOpen(open)}> Rename Run setNewName(e.target.value)} placeholder='Enter new name' onKeyDown={handleKeyDown} />
); });