Skip to content

Commit bc231d6

Browse files
authored
Merge pull request #1280 from ORCID/disable-org-change-when-editing-users
disable org change when editing users
2 parents 7f3ba51 + ec5feca commit bc231d6

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

ui/src/app/user/user-update.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,13 @@ <h1 id="jhi-ms-user-heading" class="mt-5" i18n="@@gatewayApp.msUserServiceMSUser
7575
for="field_salesforceId.string"
7676
>Organization</label
7777
>
78-
<fieldset [disabled]="disableSalesForceIdDD()">
78+
<fieldset [disabled]="isExistentMember">
7979
<select
8080
*ngIf="memberList.length > 0"
8181
class="custom-select"
8282
name="salesforceId"
8383
id="field_salesforceId"
8484
formControlName="salesforceId"
85-
(change)="validateOrgOwners()"
8685
>
8786
<option *ngFor="let member of memberList" [ngValue]="member.salesforceId">{{ member.clientName }}</option>
8887
</select>

ui/src/app/user/user-update.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ describe('UserUpdateComponent', () => {
102102
expect(router.navigate).toHaveBeenCalledWith(['/users'])
103103
})
104104

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

110-
expect(component.disableSalesForceIdDD()).toBe(true)
110+
expect(component.isExistentMember).toBe(true)
111111
})
112112

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

194-
expect(component.disableSalesForceIdDD()).toBe(false)
194+
expect(component.isExistentMember).toBe(false)
195195
})
196196

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

201202
component.editForm.patchValue({ salesforceId: '123', mainContact: false })
202203
component.validateOrgOwners()
203204
expect(component.hasOwner).toBe(false)
204-
expect(component.editForm.get('salesforceId')?.disabled).toBe(false)
205+
expect(component.isExistentMember).toBe(true)
205206
})
206207

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

217217
it('should create new user', () => {

ui/src/app/user/user-update.component.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,6 @@ export class UserUpdateComponent {
194194
this.router.navigate(['/'])
195195
}
196196

197-
disableSalesForceIdDD() {
198-
if (this.hasRoleAdmin()) {
199-
return false
200-
} else if (this.hasRoleOrgOwner() || this.hasRoleConsortiumLead()) {
201-
this.editForm.patchValue({
202-
salesforceId: this.getSalesForceId(),
203-
})
204-
return true
205-
}
206-
return this.isExistentMember
207-
}
208-
209197
getSalesForceId() {
210198
return this.accountService.getSalesforceId()
211199
}
@@ -234,12 +222,6 @@ export class UserUpdateComponent {
234222
this.hasOwner = value
235223
}
236224
})
237-
238-
if (this.editForm.get('mainContact')?.value) {
239-
this.editForm.get('salesforceId')?.disable()
240-
} else {
241-
this.editForm.get('salesforceId')?.enable()
242-
}
243225
}
244226
}
245227

0 commit comments

Comments
 (0)