// Copyright (C) 2020-2022 Intel Corporation // Copyright (C) 2022 CVAT.ai Corporation // // SPDX-License-Identifier: MIT import React, { RefObject } from 'react'; import Input from 'antd/lib/input'; import Text from 'antd/lib/typography/Text'; import Tooltip from 'antd/lib/tooltip'; import Form, { FormInstance } from 'antd/lib/form'; import { QuestionCircleOutlined } from '@ant-design/icons'; export interface BaseConfiguration { name: string; } interface Props { onChange(values: BaseConfiguration): void; many: boolean; exampleMultiTaskName?: string; } export default class BasicConfigurationForm extends React.PureComponent { private formRef: RefObject; private inputRef: RefObject; private initialName: string; public constructor(props: Props) { super(props); this.formRef = React.createRef(); this.inputRef = React.createRef(); const { many } = this.props; this.initialName = many ? '{{file_name}}' : ''; } componentDidMount(): void { const { onChange } = this.props; onChange({ name: this.initialName, }); } private handleChangeName(e: React.ChangeEvent): void { const { onChange } = this.props; onChange({ name: e.target.value, }); } public submit(): Promise { if (this.formRef.current) { return this.formRef.current.validateFields(); } return Promise.reject(new Error('Form ref is empty')); } public resetFields(): void { if (this.formRef.current) { this.formRef.current.resetFields(); } } public focus(): void { if (this.inputRef.current) { this.inputRef.current.focus(); } } public render(): JSX.Element { const { many, exampleMultiTaskName } = this.props; return (
Name} rules={[ { required: true, message: 'Task name cannot be empty', }, ]} initialValue={this.initialName} > this.handleChangeName(e)} /> {many ? ( ( <> You can substitute in the template:
  • some_text - any text
  • {'{{'} index {'}}'}  - index file in set
  • {'{{'} file_name {'}}'}  - name of file
Example:  {exampleMultiTaskName || 'Task name 1 - video_1.mp4'} )} > When forming the name, a template is used. {' '}
) : null}
); } }