Repository: cvat-ai/cvat
Pull request: Fixed removing job assignee
<!-- Raise an issue to propose your change (https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent contributors.
Discuss your ideas with maintainers to be sure that changes will be approved and merged.
Read the [Contribution guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it fixes an open
issue, please link to the issue here. Describe your changes in detail, add
screenshots. -->
Resolves #6700 
Fix + tests

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes that apply.
If an item isn't applicable for some reason, then ~~explicitly strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the pull request.
If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have added a description of my changes into the [CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md) file
- ~~[ ] I have updated the documentation accordingly~~
- [x] I have added tests to cover my changes
- [x] I have linked related issues (see [GitHub docs](
  https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [x] I have increased versions of npm packages if it is necessary
  ([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),
  [cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),
  [cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning) and
  [cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
  https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the project.
  Feel free to contact the maintainers if that's a concern.


Problem statement:
Remove assignee from job
Hi!
How do I remove a user from a job via the UI? I can only reassign to another user, but I can't completely delete it. It turns out to be deleted only through the admin panel.

Hints from issue discussion:
@klakhov Could you please take a look at the issue?
@vaneuss1 Thank you for report, as a temporary workaround you can assign yourself.

Commit message: updated changelog and verisions

Patch to review:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27692a58d4af..15ffb8035f17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,7 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
-- TBD
+- Removing job assignee (<https://github.com/opencv/cvat/pull/6712>)
 
 ### Security
 
diff --git a/cvat-core/package.json b/cvat-core/package.json
index b832b1da0673..67efac501ab0 100644
--- a/cvat-core/package.json
+++ b/cvat-core/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cvat-core",
-  "version": "11.0.1",
+  "version": "11.0.2",
   "description": "Part of Computer Vision Tool which presents an interface for client-side integration",
   "main": "src/api.ts",
   "scripts": {
diff --git a/cvat-core/src/session.ts b/cvat-core/src/session.ts
index 8f07ba7d070c..923687195d05 100644
--- a/cvat-core/src/session.ts
+++ b/cvat-core/src/session.ts
@@ -317,7 +317,7 @@ function buildDuplicatedAPI(prototype) {
 export class Session {}
 
 export class Job extends Session {
-    public assignee: User;
+    public assignee: User | null;
     public stage: JobStage;
     public state: JobState;
     public readonly id: number;
diff --git a/cvat-ui/package.json b/cvat-ui/package.json
index 6085aa3fb28b..94ed848f40f9 100644
--- a/cvat-ui/package.json
+++ b/cvat-ui/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cvat-ui",
-  "version": "1.55.1",
+  "version": "1.55.2",
   "description": "CVAT single-page application",
   "main": "src/index.tsx",
   "scripts": {
diff --git a/cvat-ui/src/components/job-item/job-item.tsx b/cvat-ui/src/components/job-item/job-item.tsx
index d9a80e5cff1f..614d058d3426 100644
--- a/cvat-ui/src/components/job-item/job-item.tsx
+++ b/cvat-ui/src/components/job-item/job-item.tsx
@@ -156,10 +156,8 @@ function JobItem(props: Props): JSX.Element {
                                             value={job.assignee}
                                             onSelect={(user: User | null): void => {
                                                 if (job?.assignee?.id === user?.id) return;
-                                                if (user) {
-                                                    job.assignee = user;
-                                                    onJobUpdate(job);
-                                                }
+                                                job.assignee = user;
+                                                onJobUpdate(job);
                                             }}
                                         />
                                     </Col>
diff --git a/tests/cypress/e2e/actions_users/registration_involved/case_4_assign_task_job_users.js b/tests/cypress/e2e/actions_users/registration_involved/case_4_assign_task_job_users.js
index 7859cc3f70ca..8e4d9e75ed82 100644
--- a/tests/cypress/e2e/actions_users/registration_involved/case_4_assign_task_job_users.js
+++ b/tests/cypress/e2e/actions_users/registration_involved/case_4_assign_task_job_users.js
@@ -115,6 +115,7 @@ context('Multiple users. Assign task, job. Deactivating users.', () => {
             cy.goToTaskList();
             cy.openTask(taskName);
             cy.assignTaskToUser(secondUserName);
+            cy.assignJobToUser(0, secondUserName);
             cy.openJob();
             // Getting the task and job id
             cy.url().then((url) => {
@@ -140,6 +141,7 @@ context('Multiple users. Assign task, job. Deactivating users.', () => {
         it('First user login and assign the job to the third user. Logout', () => {
             cy.login();
             cy.openTask(taskName);
+            cy.assignJobToUser(0, '');
             cy.assignJobToUser(0, thirdUserName);
             cy.logout();
         });
diff --git a/tests/cypress/support/commands_review_pipeline.js b/tests/cypress/support/commands_review_pipeline.js
index 93ed4a15a561..4196dad1ad59 100644
--- a/tests/cypress/support/commands_review_pipeline.js
+++ b/tests/cypress/support/commands_review_pipeline.js
@@ -21,16 +21,21 @@ Cypress.Commands.add('assignJobToUser', (jobID, user) => {
         cy.get('.cvat-jobs-list')
             .contains('a', `Job #${$job}`)
             .parents('.cvat-job-item')
-            .find('.cvat-job-assignee-selector')
-            .click();
+            .find('.cvat-job-assignee-selector input')
+            .click()
+            .clear();
     });
 
     cy.intercept('PATCH', '/api/jobs/**').as('patchJobAssignee');
-    cy.get('.ant-select-dropdown')
-        .should('be.visible')
-        .not('.ant-select-dropdown-hidden')
-        .contains(new RegExp(`^${user}$`, 'g'))
-        .click();
+    if (user) {
+        cy.get('.ant-select-dropdown')
+            .should('be.visible')
+            .not('.ant-select-dropdown-hidden')
+            .contains(new RegExp(`^${user}$`, 'g'))
+            .click();
+    } else {
+        cy.get('body').type('{Enter}');
+    }
 
     cy.wait('@patchJobAssignee').its('response.statusCode').should('equal', 200);
     cy.get('.cvat-spinner').should('not.exist');


Code review comments:
diff_hunk: @@ -140,6 +141,7 @@ context('Multiple users. Assign task, job. Deactivating users.', () => {
         it('First user login and assign the job to the third user. Logout', () => {
             cy.login();
             cy.openTask(taskName);
+            cy.assignJobToUser(0, '');
path: tests/cypress/e2e/actions_users/registration_involved/case_4_assign_task_job_users.js
text: @user1:
Maybe better to pass null?