-
-
Notifications
You must be signed in to change notification settings - Fork 5
SF-3768 Add assignee and resolution to draft request detail page #3780
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
Nateowami
wants to merge
1
commit into
master
Choose a base branch
from
feature/SF-3768-update-draft-request-detail-ui
base: master
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.
Open
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions
12
...tion/onboarding-request-assignee-select/onboarding-request-assignee-select.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,12 @@ | ||
| <mat-form-field class="assignee-field" subscriptSizing="dynamic"> | ||
| <mat-select [value]="value" (selectionChange)="onSelectionChange($event.value)"> | ||
| <mat-option value=""> | ||
| <span class="unassigned-option">Unassigned</span> | ||
| </mat-option> | ||
| @for (userId of getOptions(); track userId) { | ||
| <mat-option [value]="userId"> | ||
| <app-owner [ownerRef]="userId" [includeAvatar]="true"></app-owner> | ||
| </mat-option> | ||
| } | ||
| </mat-select> | ||
| </mat-form-field> |
14 changes: 14 additions & 0 deletions
14
...tion/onboarding-request-assignee-select/onboarding-request-assignee-select.component.scss
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,14 @@ | ||
| :host { | ||
| --mat-form-field-container-vertical-padding: 8px; | ||
| --mat-form-field-container-height: 40px; | ||
| } | ||
|
|
||
| .assignee-field { | ||
| width: 200px; | ||
| font-size: 14px; | ||
|
|
||
| .unassigned-option { | ||
| font-style: italic; | ||
| color: var(--color-text-secondary); | ||
| } | ||
| } |
146 changes: 146 additions & 0 deletions
146
...n/onboarding-request-assignee-select/onboarding-request-assignee-select.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,146 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; | ||
| import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; | ||
| import { provideHttpClientTesting } from '@angular/common/http/testing'; | ||
| import { mock, when } from 'ts-mockito'; | ||
| import { OnlineStatusService } from 'xforge-common/online-status.service'; | ||
| import { provideTestOnlineStatus } from 'xforge-common/test-online-status-providers'; | ||
| import { TestOnlineStatusService } from 'xforge-common/test-online-status.service'; | ||
| import { configureTestingModule, getTestTranslocoModule } from 'xforge-common/test-utils'; | ||
| import { UserService } from 'xforge-common/user.service'; | ||
| import { OnboardingRequestAssigneeSelectComponent } from './onboarding-request-assignee-select.component'; | ||
|
|
||
| const mockedUserService = mock(UserService); | ||
|
|
||
| const CURRENT_USER_ID = 'user01'; | ||
| const ASSIGNEE_USER_ID = 'user02'; | ||
| const OTHER_USER_ID = 'user03'; | ||
|
|
||
| /** Host component used to drive the OnboardingRequestAssigneeSelectComponent under test. */ | ||
| @Component({ | ||
| template: `<app-onboarding-request-assignee-select | ||
| [value]="value" | ||
| [knownAssigneeIds]="knownAssigneeIds" | ||
| [currentUserId]="currentUserId" | ||
| (selectionChange)="lastEmitted = $event" | ||
| ></app-onboarding-request-assignee-select>`, | ||
| imports: [OnboardingRequestAssigneeSelectComponent] | ||
| }) | ||
| class TestHostComponent { | ||
| value: string = ''; | ||
| knownAssigneeIds: string[] = []; | ||
| currentUserId?: string; | ||
| lastEmitted?: string; | ||
| } | ||
|
|
||
| describe('OnboardingRequestAssigneeSelectComponent', () => { | ||
| configureTestingModule(() => ({ | ||
| imports: [TestHostComponent, getTestTranslocoModule()], | ||
| providers: [ | ||
| provideTestOnlineStatus(), | ||
| provideHttpClient(withInterceptorsFromDi()), | ||
| provideHttpClientTesting(), | ||
| { provide: OnlineStatusService, useClass: TestOnlineStatusService }, | ||
| { provide: UserService, useMock: mockedUserService } | ||
| ] | ||
| })); | ||
|
|
||
| describe('getOptions()', () => { | ||
| it('should include the current user in options', fakeAsync(() => { | ||
| const env = new TestEnvironment({ currentUserId: CURRENT_USER_ID }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options).toContain(CURRENT_USER_ID); | ||
| })); | ||
|
|
||
| it('should include a known assignee who is not the current user', fakeAsync(() => { | ||
| const env = new TestEnvironment({ currentUserId: CURRENT_USER_ID, knownAssigneeIds: [ASSIGNEE_USER_ID] }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options).toContain(CURRENT_USER_ID); | ||
| expect(options).toContain(ASSIGNEE_USER_ID); | ||
| })); | ||
|
|
||
| it('should list the current user first', fakeAsync(() => { | ||
| const env = new TestEnvironment({ currentUserId: CURRENT_USER_ID, knownAssigneeIds: [ASSIGNEE_USER_ID] }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options[0]).toBe(CURRENT_USER_ID); | ||
| })); | ||
|
|
||
| it('should not duplicate the current user if they are also in knownAssigneeIds', fakeAsync(() => { | ||
| const env = new TestEnvironment({ | ||
| currentUserId: CURRENT_USER_ID, | ||
| knownAssigneeIds: [CURRENT_USER_ID, ASSIGNEE_USER_ID] | ||
| }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options.filter(id => id === CURRENT_USER_ID).length).toBe(1); | ||
| })); | ||
|
|
||
| it('should return only the current user when there are no known assignees', fakeAsync(() => { | ||
| const env = new TestEnvironment({ currentUserId: CURRENT_USER_ID, knownAssigneeIds: [] }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options).toEqual([CURRENT_USER_ID]); | ||
| })); | ||
|
|
||
| it('should return multiple known assignees after the current user', fakeAsync(() => { | ||
| const env = new TestEnvironment({ | ||
| currentUserId: CURRENT_USER_ID, | ||
| knownAssigneeIds: [ASSIGNEE_USER_ID, OTHER_USER_ID] | ||
| }); | ||
| env.wait(); | ||
|
|
||
| const options = env.component.getOptions(); | ||
|
|
||
| expect(options).toEqual([CURRENT_USER_ID, ASSIGNEE_USER_ID, OTHER_USER_ID]); | ||
| })); | ||
| }); | ||
|
|
||
| /** | ||
| * Test environment for OnboardingRequestAssigneeSelectComponent tests. | ||
| * Uses a TestHostComponent to drive inputs and capture output. | ||
| */ | ||
| class TestEnvironment { | ||
| readonly host: TestHostComponent; | ||
| readonly fixture: ComponentFixture<TestHostComponent>; | ||
| readonly component: OnboardingRequestAssigneeSelectComponent; | ||
|
|
||
| constructor({ | ||
| value = '', | ||
| knownAssigneeIds = [], | ||
| currentUserId | ||
| }: { | ||
| value?: string; | ||
| knownAssigneeIds?: string[]; | ||
| currentUserId?: string; | ||
| } = {}) { | ||
| when(mockedUserService.currentUserId).thenReturn(CURRENT_USER_ID); | ||
|
|
||
| this.fixture = TestBed.createComponent(TestHostComponent); | ||
| this.host = this.fixture.componentInstance; | ||
| this.host.value = value; | ||
| this.host.knownAssigneeIds = knownAssigneeIds; | ||
| this.host.currentUserId = currentUserId; | ||
| this.component = this.fixture.debugElement.children[0] | ||
| .componentInstance as OnboardingRequestAssigneeSelectComponent; | ||
| this.fixture.detectChanges(); | ||
| } | ||
|
|
||
| wait(): void { | ||
| tick(); | ||
| this.fixture.detectChanges(); | ||
| } | ||
| } | ||
| }); |
45 changes: 45 additions & 0 deletions
45
...ration/onboarding-request-assignee-select/onboarding-request-assignee-select.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,45 @@ | ||
| import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { MatFormFieldModule } from '@angular/material/form-field'; | ||
| import { MatSelectModule } from '@angular/material/select'; | ||
| import { OwnerComponent } from 'xforge-common/owner/owner.component'; | ||
|
|
||
| /** | ||
| * A dropdown component for selecting an assignee on an onboarding request. | ||
| * Always shows the current user first. Used in the onboarding requests list and detail views. | ||
| */ | ||
| @Component({ | ||
| selector: 'app-onboarding-request-assignee-select', | ||
| templateUrl: './onboarding-request-assignee-select.component.html', | ||
| styleUrls: ['./onboarding-request-assignee-select.component.scss'], | ||
| imports: [FormsModule, MatFormFieldModule, MatSelectModule, OwnerComponent] | ||
| }) | ||
| export class OnboardingRequestAssigneeSelectComponent { | ||
| /** The ID of the currently selected assignee. An empty string means unassigned. */ | ||
| @Input() value: string = ''; | ||
| /** IDs of users who are already known assignees and should appear in the dropdown. */ | ||
| @Input() knownAssigneeIds: string[] = []; | ||
| /** The current user's ID. Always shown first in the dropdown. */ | ||
| @Input() currentUserId?: string; | ||
| /** Emitted when the user selects a new assignee. */ | ||
| @Output() selectionChange = new EventEmitter<string>(); | ||
|
|
||
| protected onSelectionChange(newValue: string): void { | ||
| this.selectionChange.emit(newValue); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the ordered list of user IDs to show in the dropdown. | ||
| * The current user is shown first, followed by any other known assignees. | ||
| */ | ||
| getOptions(): string[] { | ||
| const options: string[] = []; | ||
| if (this.currentUserId != null) { | ||
| options.push(this.currentUserId); | ||
| } | ||
| for (const id of this.knownAssigneeIds) { | ||
| if (!options.includes(id)) options.push(id); | ||
| } | ||
| return options; | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.