-
Notifications
You must be signed in to change notification settings - Fork 366
NAS-138855 / 25.10.2 / UI doesn't properly allow users to input directory services group names into audit watch list and ignore list forms if caching is disabled (by AlexKarpov98) #13009
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
Open
bugclerk
wants to merge
10
commits into
stable/goldeye
Choose a base branch
from
NAS-138855-25.10.2
base: stable/goldeye
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,199
−266
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
159d563
NAS-138855: UI doesnt properly allow users to input directory service…
AlexKarpov98 e331f50
NAS-138855: UI doesnt properly allow users to input directory services
AlexKarpov98 6784c9c
NAS-138855: PR Update
AlexKarpov98 f0d064e
NAS-138855: Fix async validator debounce timing and improve consistency
AlexKarpov98 12d8e73
NAS-138855: PR update
AlexKarpov98 ce30c80
NAS-138855: PR update
AlexKarpov98 8a0df59
NAS-138855: PR update
AlexKarpov98 ffa79f8
NAS-138855: PR update
AlexKarpov98 e540949
NAS-138855: PR update
AlexKarpov98 d49e26e
NAS-138855: PR update
AlexKarpov98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/app/modules/forms/ix-forms/components/ix-group-chips/ix-group-chips.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <ix-chips | ||
| [label]="label()" | ||
| [placeholder]="placeholder()" | ||
| [hint]="hint()" | ||
| [tooltip]="tooltip()" | ||
| [required]="required()" | ||
| [autocompleteProvider]="groupProvider" | ||
| ></ix-chips> |
52 changes: 52 additions & 0 deletions
52
src/app/modules/forms/ix-forms/components/ix-group-chips/ix-group-chips.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
| import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
| import { createComponentFactory, Spectator, mockProvider } from '@ngneat/spectator/jest'; | ||
| import { of } from 'rxjs'; | ||
| import { mockApi } from 'app/core/testing/utils/mock-api.utils'; | ||
| import { Group } from 'app/interfaces/group.interface'; | ||
| import { IxGroupChipsComponent } from 'app/modules/forms/ix-forms/components/ix-group-chips/ix-group-chips.component'; | ||
| import { TranslatedString } from 'app/modules/translate/translate.helper'; | ||
| import { UserService } from 'app/services/user.service'; | ||
|
|
||
| @Component({ | ||
| selector: 'ix-test-host', | ||
| template: '<ix-group-chips [formControl]="control" [label]="label" />', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| standalone: true, | ||
| imports: [IxGroupChipsComponent, ReactiveFormsModule], | ||
| }) | ||
| class TestHostComponent { | ||
| control = new FormControl<string[]>([]); | ||
| label = 'Test Groups' as TranslatedString; | ||
| } | ||
|
|
||
| describe('IxGroupChipsComponent', () => { | ||
| let spectator: Spectator<TestHostComponent>; | ||
|
|
||
| const createComponent = createComponentFactory({ | ||
| component: TestHostComponent, | ||
| providers: [ | ||
| mockApi([]), | ||
| mockProvider(UserService, { | ||
| groupQueryDsCache: jest.fn(() => of([ | ||
| { group: 'wheel' }, | ||
| { group: 'users' }, | ||
| ] as Group[])), | ||
| getGroupByName: jest.fn((groupName: string) => of({ group: groupName })), | ||
| }), | ||
| ], | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| spectator = createComponent(); | ||
| }); | ||
|
|
||
| it('shows label', () => { | ||
| expect(spectator.query('label')).toHaveText('Test Groups'); | ||
| }); | ||
|
|
||
| it('renders chip grid input', () => { | ||
| const input = spectator.query('input'); | ||
| expect(input).toExist(); | ||
| }); | ||
| }); |
93 changes: 93 additions & 0 deletions
93
src/app/modules/forms/ix-forms/components/ix-group-chips/ix-group-chips.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { | ||
| AfterViewInit, ChangeDetectionStrategy, Component, input, viewChild, inject, | ||
| } from '@angular/core'; | ||
| import { ControlValueAccessor, NgControl } from '@angular/forms'; | ||
| import { UntilDestroy } from '@ngneat/until-destroy'; | ||
| import { map } from 'rxjs/operators'; | ||
| import { ChipsProvider } from 'app/modules/forms/ix-forms/components/ix-chips/chips-provider'; | ||
| import { IxChipsComponent } from 'app/modules/forms/ix-forms/components/ix-chips/ix-chips.component'; | ||
| import { registeredDirectiveConfig } from 'app/modules/forms/ix-forms/directives/registered-control.directive'; | ||
| import { UserGroupExistenceValidationService } from 'app/modules/forms/ix-forms/validators/user-group-existence-validation.service'; | ||
| import { TranslatedString } from 'app/modules/translate/translate.helper'; | ||
| import { UserService } from 'app/services/user.service'; | ||
|
|
||
| /** | ||
| * Specialized chips component for group input with built-in validation. | ||
| * Automatically validates that entered groups exist in the system (local or directory services). | ||
| * Provides autocomplete suggestions from the group cache. | ||
| * | ||
| * @example | ||
| * ```html | ||
| * <ix-group-chips | ||
| * formControlName="groups" | ||
| * [label]="'Groups' | translate" | ||
| * [tooltip]="'Select groups' | translate" | ||
| * ></ix-group-chips> | ||
| * ``` | ||
| */ | ||
| @UntilDestroy() | ||
| @Component({ | ||
| selector: 'ix-group-chips', | ||
| templateUrl: './ix-group-chips.component.html', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| imports: [ | ||
| IxChipsComponent, | ||
| ], | ||
| hostDirectives: [ | ||
| { ...registeredDirectiveConfig }, | ||
| ], | ||
| }) | ||
| export class IxGroupChipsComponent implements AfterViewInit, ControlValueAccessor { | ||
| private controlDirective = inject(NgControl); | ||
| private userService = inject(UserService); | ||
| private existenceValidator = inject(UserGroupExistenceValidationService); | ||
|
|
||
| readonly label = input<TranslatedString>(); | ||
| readonly placeholder = input<TranslatedString>(''); | ||
| readonly hint = input<TranslatedString>(); | ||
| readonly tooltip = input<TranslatedString>(); | ||
| readonly required = input<boolean>(false); | ||
|
|
||
| private readonly ixChips = viewChild.required(IxChipsComponent); | ||
|
|
||
| protected readonly groupProvider: ChipsProvider = (query) => { | ||
| return this.userService.groupQueryDsCache(query).pipe( | ||
| map((groups) => groups.map((group) => group.group)), | ||
| ); | ||
| }; | ||
|
|
||
| constructor() { | ||
| this.controlDirective.valueAccessor = this; | ||
| } | ||
|
|
||
| ngAfterViewInit(): void { | ||
| // Add async validator to check group existence. | ||
| // The base ix-chips component allows new entries by default, | ||
| // so validation is always needed to ensure typed groups exist. | ||
| const control = this.controlDirective.control; | ||
| if (control) { | ||
| control.addAsyncValidators([ | ||
| this.existenceValidator.validateGroupsExist(), | ||
| ]); | ||
| // Don't call updateValueAndValidity() here to avoid showing validation errors | ||
| // immediately on form load. Validation will run automatically when the user | ||
| // interacts with the field or when the form is submitted. | ||
| } | ||
| } | ||
|
|
||
| writeValue(value: string[]): void { | ||
| this.ixChips().writeValue(value); | ||
| } | ||
|
|
||
| registerOnChange(onChange: (value: string[]) => void): void { | ||
| this.ixChips().registerOnChange(onChange); | ||
| } | ||
|
|
||
| registerOnTouched(onTouched: () => void): void { | ||
| this.ixChips().registerOnTouched(onTouched); | ||
| } | ||
|
|
||
| setDisabledState?(isDisabled: boolean): void { | ||
| this.ixChips().setDisabledState?.(isDisabled); | ||
| } | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
src/app/modules/forms/ix-forms/components/ix-group-combobox/ix-group-combobox.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <ix-combobox | ||
| [label]="label()" | ||
| [hint]="hint()" | ||
| [tooltip]="tooltip()" | ||
| [required]="required()" | ||
| [allowCustomValue]="allowCustomValue()" | ||
| [provider]="groupProvider" | ||
| ></ix-combobox> |
52 changes: 52 additions & 0 deletions
52
...p/modules/forms/ix-forms/components/ix-group-combobox/ix-group-combobox.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
| import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
| import { createComponentFactory, Spectator, mockProvider } from '@ngneat/spectator/jest'; | ||
| import { of } from 'rxjs'; | ||
| import { mockApi } from 'app/core/testing/utils/mock-api.utils'; | ||
| import { Group } from 'app/interfaces/group.interface'; | ||
| import { IxGroupComboboxComponent } from 'app/modules/forms/ix-forms/components/ix-group-combobox/ix-group-combobox.component'; | ||
| import { TranslatedString } from 'app/modules/translate/translate.helper'; | ||
| import { UserService } from 'app/services/user.service'; | ||
|
|
||
| @Component({ | ||
| selector: 'ix-test-host', | ||
| template: '<ix-group-combobox [formControl]="control" [label]="label" />', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| standalone: true, | ||
| imports: [IxGroupComboboxComponent, ReactiveFormsModule], | ||
| }) | ||
| class TestHostComponent { | ||
| control = new FormControl<string>(''); | ||
| label = 'Test Group' as TranslatedString; | ||
| } | ||
|
|
||
| describe('IxGroupComboboxComponent', () => { | ||
| let spectator: Spectator<TestHostComponent>; | ||
|
|
||
| const createComponent = createComponentFactory({ | ||
| component: TestHostComponent, | ||
| providers: [ | ||
| mockApi([]), | ||
| mockProvider(UserService, { | ||
| groupQueryDsCache: jest.fn(() => of([ | ||
| { group: 'wheel' }, | ||
| { group: 'users' }, | ||
| ] as Group[])), | ||
| getGroupByName: jest.fn((groupName: string) => of({ group: groupName })), | ||
| }), | ||
| ], | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| spectator = createComponent(); | ||
| }); | ||
|
|
||
| it('shows label', () => { | ||
| expect(spectator.query('label')).toHaveText('Test Group'); | ||
| }); | ||
|
|
||
| it('renders combobox input', () => { | ||
| const input = spectator.query('input'); | ||
| expect(input).toExist(); | ||
| }); | ||
| }); |
89 changes: 89 additions & 0 deletions
89
src/app/modules/forms/ix-forms/components/ix-group-combobox/ix-group-combobox.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { | ||
| AfterViewInit, ChangeDetectionStrategy, Component, input, viewChild, inject, | ||
| } from '@angular/core'; | ||
| import { ControlValueAccessor, NgControl } from '@angular/forms'; | ||
| import { UntilDestroy } from '@ngneat/until-destroy'; | ||
| import { GroupComboboxProvider } from 'app/modules/forms/ix-forms/classes/group-combobox-provider'; | ||
| import { IxComboboxComponent } from 'app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component'; | ||
| import { registeredDirectiveConfig } from 'app/modules/forms/ix-forms/directives/registered-control.directive'; | ||
| import { UserGroupExistenceValidationService } from 'app/modules/forms/ix-forms/validators/user-group-existence-validation.service'; | ||
| import { TranslatedString } from 'app/modules/translate/translate.helper'; | ||
| import { UserService } from 'app/services/user.service'; | ||
|
|
||
| /** | ||
| * Specialized combobox component for group input with built-in validation. | ||
| * Automatically validates that entered groups exist in the system (local or directory services). | ||
| * Provides autocomplete suggestions from the group cache. | ||
| * | ||
| * @example | ||
| * ```html | ||
| * <ix-group-combobox | ||
| * formControlName="ownerGroup" | ||
| * [label]="'Group' | translate" | ||
| * [tooltip]="'Select a group' | translate" | ||
| * [required]="true" | ||
| * ></ix-group-combobox> | ||
| * ``` | ||
| */ | ||
| @UntilDestroy() | ||
| @Component({ | ||
| selector: 'ix-group-combobox', | ||
| templateUrl: './ix-group-combobox.component.html', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| imports: [ | ||
| IxComboboxComponent, | ||
| ], | ||
| hostDirectives: [ | ||
| { ...registeredDirectiveConfig }, | ||
| ], | ||
| }) | ||
| export class IxGroupComboboxComponent implements AfterViewInit, ControlValueAccessor { | ||
| private controlDirective = inject(NgControl); | ||
| private userService = inject(UserService); | ||
| private existenceValidator = inject(UserGroupExistenceValidationService); | ||
|
|
||
| readonly label = input<TranslatedString>(); | ||
| readonly hint = input<TranslatedString>(); | ||
| readonly tooltip = input<TranslatedString>(); | ||
| readonly required = input<boolean>(false); | ||
| readonly allowCustomValue = input<boolean>(true); | ||
|
|
||
| private readonly ixCombobox = viewChild.required(IxComboboxComponent); | ||
|
|
||
| protected readonly groupProvider = new GroupComboboxProvider(this.userService); | ||
|
|
||
| constructor() { | ||
| this.controlDirective.valueAccessor = this; | ||
| } | ||
|
|
||
| ngAfterViewInit(): void { | ||
| // Add validation to check group existence when custom values are allowed (default). | ||
| // When allowCustomValue is false, users can only select from autocomplete | ||
| // suggestions which are guaranteed to exist, making validation redundant. | ||
| const control = this.controlDirective.control; | ||
| if (control && this.allowCustomValue()) { | ||
| control.addAsyncValidators([ | ||
| this.existenceValidator.validateGroupExists(), | ||
| ]); | ||
| // Don't call updateValueAndValidity() here to avoid showing validation errors | ||
| // immediately on form load. Validation will run automatically when the user | ||
| // interacts with the field or when the form is submitted. | ||
| } | ||
| } | ||
|
|
||
| writeValue(value: string | number): void { | ||
| this.ixCombobox().writeValue(value); | ||
| } | ||
|
|
||
| registerOnChange(onChange: (value: string | number | null) => void): void { | ||
| this.ixCombobox().registerOnChange(onChange); | ||
| } | ||
|
|
||
| registerOnTouched(onTouched: () => void): void { | ||
| this.ixCombobox().registerOnTouched(onTouched); | ||
| } | ||
|
|
||
| setDisabledState?(isDisabled: boolean): void { | ||
| this.ixCombobox().setDisabledState?.(isDisabled); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If think we are moving away from UntilDestroy