Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label form validator fix #2879

Merged
merged 3 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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

Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.15.0",
"version": "1.15.1",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions cvat-ui/src/components/labels-editor/label-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
},
]}
Expand Down Expand Up @@ -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()}
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});