From ff8f19aa2fdcc8bf24a18597c37b0c8663ddf185 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Mon, 6 Feb 2023 10:27:47 +0100 Subject: [PATCH] [EC-1003] Make External ID in group modal to read-only (#4492) * [EC-1003] chore: refactor form builder * [EC-1003] feat: disable externalId * [EC-1003] feat: disable `externalId` editing * [EC-1003] feat: remove `externalId` from request classes --- .../core/services/group/group.service.ts | 1 - .../core/services/group/requests/group.request.ts | 1 - .../manage/group-add-edit.component.ts | 13 ++++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/web/src/app/organizations/core/services/group/group.service.ts b/apps/web/src/app/organizations/core/services/group/group.service.ts index ba7c56a75a9..2a60da16f51 100644 --- a/apps/web/src/app/organizations/core/services/group/group.service.ts +++ b/apps/web/src/app/organizations/core/services/group/group.service.ts @@ -64,7 +64,6 @@ export class GroupService { async save(group: GroupView): Promise { const request = new GroupRequest(); request.name = group.name; - request.externalId = group.externalId; request.accessAll = group.accessAll; request.users = group.members; request.collections = group.collections.map( diff --git a/apps/web/src/app/organizations/core/services/group/requests/group.request.ts b/apps/web/src/app/organizations/core/services/group/requests/group.request.ts index e49c7978d33..26fa6f76dc0 100644 --- a/apps/web/src/app/organizations/core/services/group/requests/group.request.ts +++ b/apps/web/src/app/organizations/core/services/group/requests/group.request.ts @@ -3,7 +3,6 @@ import { SelectionReadOnlyRequest } from "@bitwarden/common/models/request/selec export class GroupRequest { name: string; accessAll: boolean; - externalId: string; collections: SelectionReadOnlyRequest[] = []; users: string[] = []; } diff --git a/apps/web/src/app/organizations/manage/group-add-edit.component.ts b/apps/web/src/app/organizations/manage/group-add-edit.component.ts index c1148a5bb44..9edeb8ddc4f 100644 --- a/apps/web/src/app/organizations/manage/group-add-edit.component.ts +++ b/apps/web/src/app/organizations/manage/group-add-edit.component.ts @@ -1,6 +1,6 @@ import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog"; import { ChangeDetectorRef, Component, Inject, OnDestroy, OnInit } from "@angular/core"; -import { FormBuilder, FormControl, Validators } from "@angular/forms"; +import { FormBuilder, Validators } from "@angular/forms"; import { catchError, combineLatest, from, map, of, Subject, switchMap, takeUntil } from "rxjs"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; @@ -90,11 +90,11 @@ export class GroupAddEditComponent implements OnInit, OnDestroy { group: GroupView; groupForm = this.formBuilder.group({ - accessAll: new FormControl(false), - name: new FormControl("", [Validators.required, Validators.maxLength(100)]), - externalId: new FormControl("", Validators.maxLength(300)), - members: new FormControl([]), - collections: new FormControl([]), + accessAll: [false], + name: ["", [Validators.required, Validators.maxLength(100)]], + externalId: this.formBuilder.control({ value: "", disabled: true }), + members: [[] as AccessItemValue[]], + collections: [[] as AccessItemValue[]], }); get groupId(): string | undefined { @@ -246,7 +246,6 @@ export class GroupAddEditComponent implements OnInit, OnDestroy { const formValue = this.groupForm.value; groupView.name = formValue.name; - groupView.externalId = formValue.externalId; groupView.accessAll = formValue.accessAll; groupView.members = formValue.members?.map((m) => m.id) ?? [];