Skip to content

Commit

Permalink
disable hide email when in policy in send options (#11161)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaasen-livefront authored Sep 19, 2024
1 parent 01f668e commit 992964f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2 class="tw-mt-4" bitTypography="h5">{{ "additionalOptions" | i18n }}</h2>
<button type="button" bitIconButton="bwi-refresh" bitSuffix></button>
<bit-hint>{{ "sendPasswordDescV2" | i18n }}</bit-hint>
</bit-form-field>
<bit-form-control>
<bit-form-control *ngIf="!disableHideEmail">
<input bitCheckbox type="checkbox" formControlName="hideEmail" />
<bit-label>{{ "hideYourEmail" | i18n }}</bit-label>
</bit-form-control>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { CommonModule } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
import { map } from "rxjs";

import { JslibModule } from "@bitwarden/angular/jslib.module";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import {
CardComponent,
Expand Down Expand Up @@ -40,13 +43,15 @@ export class SendOptionsComponent implements OnInit {
config: SendFormConfig;
@Input()
originalSendView: SendView;
disableHideEmail = false;
sendOptionsForm = this.formBuilder.group({
maxAccessCount: [null as number],
accessCount: [null as number],
notes: [null as string],
password: [null as string],
hideEmail: [false as boolean],
});

get hasPassword(): boolean {
return (
this.sendOptionsForm.value.password !== null && this.sendOptionsForm.value.password !== ""
Expand All @@ -66,8 +71,19 @@ export class SendOptionsComponent implements OnInit {
constructor(
private sendFormContainer: SendFormContainer,
private formBuilder: FormBuilder,
private policyService: PolicyService,
) {
this.sendFormContainer.registerChildForm("sendOptionsForm", this.sendOptionsForm);
this.policyService
.getAll$(PolicyType.SendOptions)
.pipe(
map((policies) => policies?.some((p) => p.data.disableHideEmail)),
takeUntilDestroyed(),
)
.subscribe((disableHideEmail) => {
this.disableHideEmail = disableHideEmail;
});

this.sendOptionsForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
this.sendFormContainer.patchSend((send) => {
Object.assign(send, {
Expand Down

0 comments on commit 992964f

Please sign in to comment.