Skip to content
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
3 changes: 1 addition & 2 deletions ui/src/app/user/user-update.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ <h1 id="jhi-ms-user-heading" class="mt-5" i18n="@@gatewayApp.msUserServiceMSUser
for="field_salesforceId.string"
>Organization</label
>
<fieldset [disabled]="disableSalesForceIdDD()">
<fieldset [disabled]="isExistentMember">
<select
*ngIf="memberList.length > 0"
class="custom-select"
name="salesforceId"
id="field_salesforceId"
formControlName="salesforceId"
(change)="validateOrgOwners()"
>
<option *ngFor="let member of memberList" [ngValue]="member.salesforceId">{{ member.clientName }}</option>
</select>
Expand Down
10 changes: 5 additions & 5 deletions ui/src/app/user/user-update.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ describe('UserUpdateComponent', () => {
expect(router.navigate).toHaveBeenCalledWith(['/users'])
})

it('should disable salesforceId dropdown on init for non-admin users', () => {
it('should disable salesforceId dropdown on init for existing users', () => {
activatedRoute.data = of({ user: { salesforceId: 'test', id: 'id' } as IUser })
accountService.hasAnyAuthority.and.returnValue(false)
fixture.detectChanges()

expect(component.disableSalesForceIdDD()).toBe(true)
expect(component.isExistentMember).toBe(true)
})

it('should display disable 2fa checkbox for admins when editing an existing user', () => {
Expand Down Expand Up @@ -191,17 +191,18 @@ describe('UserUpdateComponent', () => {
accountService.hasAnyAuthority.and.returnValue(true)
fixture.detectChanges()

expect(component.disableSalesForceIdDD()).toBe(false)
expect(component.isExistentMember).toBe(false)
})

it('should validate non-owners', () => {
activatedRoute.data = of({ user: { salesforceId: 'test', id: 'id' } as IUser })
userService.hasOwner.and.returnValue(of(true))
fixture.detectChanges()

component.editForm.patchValue({ salesforceId: '123', mainContact: false })
component.validateOrgOwners()
expect(component.hasOwner).toBe(false)
expect(component.editForm.get('salesforceId')?.disabled).toBe(false)
expect(component.isExistentMember).toBe(true)
})

it('should validate org owners', () => {
Expand All @@ -211,7 +212,6 @@ describe('UserUpdateComponent', () => {
component.editForm.patchValue({ salesforceId: '123', mainContact: true })
component.validateOrgOwners()
expect(component.hasOwner).toBe(true)
expect(component.editForm.get('salesforceId')?.disabled).toBe(true)
})

it('should create new user', () => {
Expand Down
18 changes: 0 additions & 18 deletions ui/src/app/user/user-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,6 @@ export class UserUpdateComponent {
this.router.navigate(['/'])
}

disableSalesForceIdDD() {
if (this.hasRoleAdmin()) {
return false
} else if (this.hasRoleOrgOwner() || this.hasRoleConsortiumLead()) {
this.editForm.patchValue({
salesforceId: this.getSalesForceId(),
})
return true
}
return this.isExistentMember
}

getSalesForceId() {
return this.accountService.getSalesforceId()
}
Expand Down Expand Up @@ -234,12 +222,6 @@ export class UserUpdateComponent {
this.hasOwner = value
}
})

if (this.editForm.get('mainContact')?.value) {
this.editForm.get('salesforceId')?.disable()
} else {
this.editForm.get('salesforceId')?.enable()
}
}
}

Expand Down
Loading