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: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com>
main
Dmitry Kalinin 5 years ago committed by GitHub
parent 55b20e197d
commit c793baf910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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');
});
});
});

Loading…
Cancel
Save