diff --git a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.html b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.html index 6724b4a0e0..e30883515e 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.html +++ b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.html @@ -1,39 +1,21 @@ -

{{ "scimDescription" | i18n }}

+

{{ "scimDescription" | i18n }}

- {{ "loading" | i18n }} + {{ "loading" | i18n }}
-
-
-
- - -
- {{ "scimEnabledCheckboxDescHelpText" | i18n }} -
-
-
- + + + + {{ "scimEnabledCheckboxDesc" | i18n }} + {{ "scimEnabledCheckboxDescHelpText" | i18n }} + {{ "scimUrl" | i18n }} @@ -41,7 +23,7 @@ type="button" bitSuffix bitIconButton="bwi-clone" - (click)="copyScimUrl()" + [bitAction]="copyScimUrl" [appA11yTitle]="'copyScimUrl' | i18n" > @@ -54,44 +36,32 @@ formControlName="clientSecret" id="clientSecret" /> - - - - - - - + + {{ "scimApiKeyHelperText" | i18n }} -
diff --git a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.ts b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.ts index 8e8db457e5..55ae318e98 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/organizations/manage/scim.component.ts @@ -14,7 +14,6 @@ import { OrganizationApiKeyRequest } from "@bitwarden/common/admin-console/model import { OrganizationConnectionRequest } from "@bitwarden/common/admin-console/models/request/organization-connection.request"; import { ScimConfigRequest } from "@bitwarden/common/admin-console/models/request/scim-config.request"; import { OrganizationConnectionResponse } from "@bitwarden/common/admin-console/models/response/organization-connection.response"; -import { ApiKeyResponse } from "@bitwarden/common/auth/models/response/api-key.response"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; @@ -29,8 +28,6 @@ export class ScimComponent implements OnInit { loading = true; organizationId: string; existingConnectionId: string; - formPromise: Promise>; - rotatePromise: Promise; enabled = new FormControl(false); showScimSettings = false; showScimKey = false; @@ -82,11 +79,11 @@ export class ScimComponent implements OnInit { }); } - async copyScimUrl() { + copyScimUrl = async () => { this.platformUtilsService.copyToClipboard(await this.getScimEndpointUrl()); - } + }; - async rotateScimKey() { + rotateScimKey = async () => { const confirmed = await this.dialogService.openSimpleDialog({ title: { key: "rotateScimKey" }, content: { key: "rotateScimKeyWarning" }, @@ -102,62 +99,50 @@ export class ScimComponent implements OnInit { request.type = OrganizationApiKeyType.Scim; request.masterPasswordHash = "N/A"; - this.rotatePromise = this.organizationApiService.rotateApiKey(this.organizationId, request); + const response = await this.organizationApiService.rotateApiKey(this.organizationId, request); + this.formData.setValue({ + endpointUrl: await this.getScimEndpointUrl(), + clientSecret: response.apiKey, + }); + this.platformUtilsService.showToast("success", null, this.i18nService.t("scimApiKeyRotated")); + }; - try { - const response = await this.rotatePromise; - this.formData.setValue({ - endpointUrl: await this.getScimEndpointUrl(), - clientSecret: response.apiKey, - }); - this.platformUtilsService.showToast("success", null, this.i18nService.t("scimApiKeyRotated")); - } catch { - // Logged by appApiAction, do nothing - } - - this.rotatePromise = null; - } - - async copyScimKey() { + copyScimKey = async () => { this.platformUtilsService.copyToClipboard(this.formData.get("clientSecret").value); - } + }; - async submit() { - try { - const request = new OrganizationConnectionRequest( - this.organizationId, - OrganizationConnectionType.Scim, - true, - new ScimConfigRequest(this.enabled.value), + submit = async () => { + const request = new OrganizationConnectionRequest( + this.organizationId, + OrganizationConnectionType.Scim, + true, + new ScimConfigRequest(this.enabled.value), + ); + let response: OrganizationConnectionResponse; + + if (this.existingConnectionId == null) { + response = await this.apiService.createOrganizationConnection(request, ScimConfigApi); + } else { + response = await this.apiService.updateOrganizationConnection( + request, + ScimConfigApi, + this.existingConnectionId, ); - if (this.existingConnectionId == null) { - this.formPromise = this.apiService.createOrganizationConnection(request, ScimConfigApi); - } else { - this.formPromise = this.apiService.updateOrganizationConnection( - request, - ScimConfigApi, - this.existingConnectionId, - ); - } - const response = (await this.formPromise) as OrganizationConnectionResponse; - await this.setConnectionFormValues(response); - this.platformUtilsService.showToast("success", null, this.i18nService.t("scimSettingsSaved")); - } catch (e) { - // Logged by appApiAction, do nothing } - this.formPromise = null; - } + await this.setConnectionFormValues(response); + this.platformUtilsService.showToast("success", null, this.i18nService.t("scimSettingsSaved")); + }; async getScimEndpointUrl() { const env = await firstValueFrom(this.environmentService.environment$); return env.getScimUrl() + "/" + this.organizationId; } - toggleScimKey() { + toggleScimKey = () => { this.showScimKey = !this.showScimKey; document.getElementById("clientSecret").focus(); - } + }; private async setConnectionFormValues(connection: OrganizationConnectionResponse) { this.existingConnectionId = connection?.id;