import Paper from '@mui/material/Paper' import Stack from '@mui/material/Stack' import Typography from '@mui/material/Typography' import { CommandShape } from '@seleniumhq/side-model' import { CoreSessionData } from '@seleniumhq/side-api' import React, { FC } from 'react' import CommandSelector from './CommandFields/CommandSelector' import ArgField from './CommandFields/ArgField' import CommandTextField from './CommandFields/TextField' import { FormattedMessage, useIntl } from 'react-intl' import languageMap from 'browser/I18N/keys' export interface CommandEditorProps { command: CommandShape commands: CoreSessionData['state']['commands'] disabled?: boolean selectedCommandIndexes: number[] testID: string } export interface MiniCommandShape { id: string name: string } const CommandEditor: FC = ({ command, selectedCommandIndexes, ...props }) => { const intl = useIntl() if (typeof command.command != 'string') { command.command = '//unknown - could not process' } const { commands } = props const isDisabled = command.command.startsWith('//') const correctedCommand: CommandShape = { ...command, command: isDisabled ? command.command.slice(2) : command.command, } if (selectedCommandIndexes.length > 1) { return ( {selectedCommandIndexes.length} commands selected ) } if ( !(correctedCommand.command in commands) || selectedCommandIndexes.length === 0 ) { return ( {} ) } return ( {command.opensWindow && ( <> )} ) } export default CommandEditor