feat(console): show user/project on new auth input (#5116)

Prefills user and project searchfields with results for authorization creation
This commit is contained in:
Miguel Cabrerizo 2023-02-02 10:29:36 +01:00 committed by GitHub
parent 5704c44117
commit 1fa50c8074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, ElementRef, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core';
import { Component, ElementRef, EventEmitter, Input, OnInit, OnDestroy, Output, ViewChild } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';
import {
MatLegacyAutocomplete as MatAutocomplete,
@ -25,7 +25,7 @@ export enum ProjectAutocompleteType {
templateUrl: './search-project-autocomplete.component.html',
styleUrls: ['./search-project-autocomplete.component.scss'],
})
export class SearchProjectAutocompleteComponent implements OnDestroy {
export class SearchProjectAutocompleteComponent implements OnInit, OnDestroy {
public selectable: boolean = true;
public removable: boolean = true;
public addOnBlur: boolean = true;
@ -91,6 +91,35 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
});
}
public ngOnInit(): void {
// feat-3916 show projects as soon as I am in the input field of the project
const query = new ProjectQuery();
const nameQuery = new ProjectNameQuery();
nameQuery.setMethod(TextQueryMethod.TEXT_QUERY_METHOD_CONTAINS_IGNORE_CASE);
query.setNameQuery(nameQuery);
switch (this.autocompleteType) {
case ProjectAutocompleteType.PROJECT_GRANTED:
this.mgmtService.listGrantedProjects(10, 0, [query]).then((projects) => {
this.filteredProjects = projects.resultList;
});
break;
case ProjectAutocompleteType.PROJECT_OWNED:
this.mgmtService.listProjects(10, 0, [query]).then((projects) => {
this.filteredProjects = projects.resultList;
});
break;
default:
Promise.all([
this.mgmtService.listGrantedProjects(10, 0, [query]),
this.mgmtService.listProjects(10, 0, [query]),
]).then((values) => {
this.filteredProjects = values[0].resultList;
this.filteredProjects = this.filteredProjects.concat(values[1].resultList);
});
}
}
public ngOnDestroy(): void {
this.unsubscribed$.next();
}

View File

@ -64,6 +64,15 @@ export class SearchUserAutocompleteComponent implements OnInit, AfterContentChec
this.filteredUsers = [];
this.unsubscribed$.next(); // clear old subscription
} else if (this.target === UserTarget.SELF) {
// feat-3916 show users as soon as I am in the input field of the user
const query = new SearchQuery();
const lnQuery = new LoginNameQuery();
lnQuery.setMethod(TextQueryMethod.TEXT_QUERY_METHOD_CONTAINS_IGNORE_CASE);
query.setLoginNameQuery(lnQuery);
this.userService.listUsers(10, 0, [query]).then((users) => {
this.filteredUsers = users.resultList;
});
this.getFilteredResults(); // new subscription
}
}

View File

@ -36,7 +36,7 @@ describe('permissions', () => {
it('should add a manager', () => {
cy.get('[data-e2e="add-member-button"]').click();
cy.get('[data-e2e="add-member-input"]').type(testManagerLoginname);
cy.get('[data-e2e="user-option"]').click();
cy.get('[data-e2e="user-option"]').first().click();
cy.contains('[data-e2e="role-checkbox"]', roles[0]).click();
cy.get('[data-e2e="confirm-add-member-button"]').click();
cy.shouldConfirmSuccess();