未验证 提交 c793baf9 编写于 作者: D Dmitry Kalinin 提交者: GitHub

Label form validator fix (#2879)

* Fixed label form validator

* Added CHANGELOG and increased package npm version

* Update Cypress test "Creating a label with existing label name" for PR 2879 (#2883)

* Fix case 43 for PR 2879

* Try restart CI
Co-authored-by: NDmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com>
上级 55b20e19
......@@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated the path to python for DL models inside automatic annotation documentation (<https://github.com/openvinotoolkit/cvat/pull/2847>)
- Fixed of receiving function variable (<https://github.com/openvinotoolkit/cvat/pull/2860>)
- Shortcuts with CAPSLOCK enabled and with non-US languages activated (<https://github.com/openvinotoolkit/cvat/pull/2872>)
- Fixed label editor name field validator (<https://github.com/openvinotoolkit/cvat/pull/2879>)
### Security
......
......@@ -390,10 +390,11 @@ export default class LabelForm extends React.Component<Props> {
message: patterns.validateAttributeName.message,
},
{
validator: async (_rule: any, labelName: string, callback: Function) => {
validator: (_rule: any, labelName: string) => {
if (labelNames && labelNames.includes(labelName)) {
callback('Label name must be unique for the task');
return Promise.reject(new Error('Label name must be unique for the task'));
}
return Promise.resolve();
},
},
]}
......@@ -522,7 +523,7 @@ export default class LabelForm extends React.Component<Props> {
public render(): JSX.Element {
return (
<Form onFinish={this.handleSubmit} layout='vertical' ref={this.formRef}>
<Row justify='start' align='middle'>
<Row justify='start' align='top'>
<Col span={10}>{this.renderLabelNameInput()}</Col>
<Col span={3} offset={1}>
{this.renderChangeColorButton()}
......@@ -531,7 +532,7 @@ export default class LabelForm extends React.Component<Props> {
{this.renderNewAttributeButton()}
</Col>
</Row>
<Row justify='start' align='middle'>
<Row justify='start' align='top'>
<Col span={24}>
<Form.List name='attributes'>{this.renderAttributes()}</Form.List>
</Col>
......
......@@ -24,11 +24,10 @@ context('Creating a label with existing label name.', () => {
// Try to create a label with existing label name
cy.get('.cvat-constructor-viewer-new-item').click();
cy.get('[placeholder="Label name"]').type(firstLabelName);
cy.contains('[type="submit"]', 'Done').click();
cy.contains('[role="alert"]', 'Label name must be unique for the task') // Checking alert visibility
.should('exist')
.and('be.visible');
});
cy.get('.cvat-notification-notice-update-task-failed')
.should('exist')
.and('contain.text', 'label names must be unique');
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册