mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
Implement disable send policy (#259)
* Implement disable send policy * Linter fixes * Add toast on submit if sends are disabled
This commit is contained in:
@@ -3,6 +3,8 @@ import {
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { OrganizationUserStatusType } from '../../../enums/organizationUserStatusType';
|
||||
import { PolicyType } from '../../../enums/policyType';
|
||||
import { SendType } from '../../../enums/sendType';
|
||||
|
||||
import { SendView } from '../../../models/view/sendView';
|
||||
@@ -10,8 +12,10 @@ import { SendView } from '../../../models/view/sendView';
|
||||
import { EnvironmentService } from '../../../abstractions/environment.service';
|
||||
import { I18nService } from '../../../abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from '../../../abstractions/platformUtils.service';
|
||||
import { PolicyService } from '../../../abstractions/policy.service';
|
||||
import { SearchService } from '../../../abstractions/search.service';
|
||||
import { SendService } from '../../../abstractions/send.service';
|
||||
import { UserService } from '../../../abstractions/user.service';
|
||||
|
||||
import { BroadcasterService } from '../../../angular/services/broadcaster.service';
|
||||
|
||||
@@ -19,6 +23,7 @@ const BroadcasterSubscriptionId = 'SendComponent';
|
||||
|
||||
export class SendComponent implements OnInit {
|
||||
|
||||
disableSend = false;
|
||||
sendType = SendType;
|
||||
loaded = false;
|
||||
loading = true;
|
||||
@@ -43,9 +48,20 @@ export class SendComponent implements OnInit {
|
||||
constructor(protected sendService: SendService, protected i18nService: I18nService,
|
||||
protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
|
||||
protected broadcasterService: BroadcasterService, protected ngZone: NgZone,
|
||||
protected searchService: SearchService) { }
|
||||
protected searchService: SearchService, protected policyService: PolicyService,
|
||||
protected userService: UserService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
||||
const organizations = await this.userService.getAllOrganizations();
|
||||
this.disableSend = organizations.some(o => {
|
||||
return o.enabled &&
|
||||
o.status === OrganizationUserStatusType.Confirmed &&
|
||||
o.usePolicies &&
|
||||
!o.canManagePolicies &&
|
||||
policies.some(p => p.organizationId === o.id && p.enabled);
|
||||
});
|
||||
|
||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
||||
this.ngZone.run(async () => {
|
||||
switch (message.command) {
|
||||
@@ -199,7 +215,7 @@ export class SendComponent implements OnInit {
|
||||
|
||||
private applyTextSearch() {
|
||||
if (this.searchText != null) {
|
||||
this.filteredSends = this.searchService.searchSends(this.filteredSends, this.searchText);
|
||||
this.filteredSends = this.searchService.searchSends(this.filteredSends, this.searchText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user