1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 07:13:32 +00:00

[PM-6565] migrate vault toasts to CL toastService (#10664)

* migrate vault toasts to CL toastService

* update component args

* add missing toastService deps

* add missing i18 key

* remove moved files

* remove duplicate args
This commit is contained in:
Jordan Aasen
2025-01-17 15:01:18 -08:00
committed by GitHub
parent 8674fb51db
commit a803e5b411
26 changed files with 317 additions and 202 deletions

View File

@@ -20,6 +20,7 @@ import {
DialogService, DialogService,
ItemModule, ItemModule,
SectionComponent, SectionComponent,
ToastService,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { PopOutComponent } from "../../../platform/popup/components/pop-out.component"; import { PopOutComponent } from "../../../platform/popup/components/pop-out.component";
@@ -57,6 +58,7 @@ export class PremiumV2Component extends BasePremiumComponent {
dialogService: DialogService, dialogService: DialogService,
environmentService: EnvironmentService, environmentService: EnvironmentService,
billingAccountProfileStateService: BillingAccountProfileStateService, billingAccountProfileStateService: BillingAccountProfileStateService,
toastService: ToastService,
accountService: AccountService, accountService: AccountService,
) { ) {
super( super(
@@ -68,6 +70,7 @@ export class PremiumV2Component extends BasePremiumComponent {
dialogService, dialogService,
environmentService, environmentService,
billingAccountProfileStateService, billingAccountProfileStateService,
toastService,
accountService, accountService,
); );

View File

@@ -9,7 +9,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
@Component({ @Component({
selector: "app-premium", selector: "app-premium",
@@ -25,6 +25,7 @@ export class PremiumComponent extends BasePremiumComponent {
dialogService: DialogService, dialogService: DialogService,
environmentService: EnvironmentService, environmentService: EnvironmentService,
billingAccountProfileStateService: BillingAccountProfileStateService, billingAccountProfileStateService: BillingAccountProfileStateService,
toastService: ToastService,
accountService: AccountService, accountService: AccountService,
) { ) {
super( super(
@@ -36,6 +37,7 @@ export class PremiumComponent extends BasePremiumComponent {
dialogService, dialogService,
environmentService, environmentService,
billingAccountProfileStateService, billingAccountProfileStateService,
toastService,
accountService, accountService,
); );
} }

View File

@@ -8,7 +8,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction"; import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management"; import { KeyService } from "@bitwarden/key-management";
@Component({ @Component({
@@ -26,6 +26,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
logService: LogService, logService: LogService,
dialogService: DialogService, dialogService: DialogService,
formBuilder: FormBuilder, formBuilder: FormBuilder,
toastService: ToastService,
) { ) {
super( super(
folderService, folderService,
@@ -37,6 +38,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
logService, logService,
dialogService, dialogService,
formBuilder, formBuilder,
toastService,
); );
} }
} }

View File

@@ -5,6 +5,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { ToastService } from "@bitwarden/components";
@Component({ @Component({
selector: "app-password-history", selector: "app-password-history",
@@ -16,7 +17,8 @@ export class PasswordHistoryComponent extends BasePasswordHistoryComponent {
platformUtilsService: PlatformUtilsService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, i18nService: I18nService,
accountService: AccountService, accountService: AccountService,
toastService: ToastService,
) { ) {
super(cipherService, platformUtilsService, i18nService, accountService, window); super(cipherService, platformUtilsService, i18nService, accountService, window, toastService);
} }
} }

View File

@@ -7,6 +7,7 @@ import { DisplayMode } from "@bitwarden/angular/vault/vault-filter/models/displa
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ToastService } from "@bitwarden/components";
@Component({ @Component({
selector: "app-organization-filter", selector: "app-organization-filter",
@@ -25,6 +26,7 @@ export class OrganizationFilterComponent extends BaseOrganizationFilterComponent
constructor( constructor(
private i18nService: I18nService, private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private toastService: ToastService,
) { ) {
super(); super();
} }
@@ -36,11 +38,11 @@ export class OrganizationFilterComponent extends BaseOrganizationFilterComponent
// eslint-disable-next-line @typescript-eslint/no-floating-promises // eslint-disable-next-line @typescript-eslint/no-floating-promises
super.applyOrganizationFilter(organization); super.applyOrganizationFilter(organization);
} else { } else {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
null, title: null,
this.i18nService.t("disabledOrganizationFilterError"), message: this.i18nService.t("disabledOrganizationFilterError"),
); });
} }
} }
} }

View File

@@ -35,7 +35,7 @@ import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { DecryptionFailureDialogComponent, PasswordRepromptService } from "@bitwarden/vault"; import { DecryptionFailureDialogComponent, PasswordRepromptService } from "@bitwarden/vault";
import { SearchBarService } from "../../../app/layout/search/search-bar.service"; import { SearchBarService } from "../../../app/layout/search/search-bar.service";
@@ -113,6 +113,7 @@ export class VaultComponent implements OnInit, OnDestroy {
private apiService: ApiService, private apiService: ApiService,
private dialogService: DialogService, private dialogService: DialogService,
private billingAccountProfileStateService: BillingAccountProfileStateService, private billingAccountProfileStateService: BillingAccountProfileStateService,
private toastService: ToastService,
private configService: ConfigService, private configService: ConfigService,
private accountService: AccountService, private accountService: AccountService,
private cipherService: CipherService, private cipherService: CipherService,
@@ -809,11 +810,11 @@ export class VaultComponent implements OnInit, OnDestroy {
} }
this.platformUtilsService.copyToClipboard(value); this.platformUtilsService.copyToClipboard(value);
this.platformUtilsService.showToast( this.toastService.showToast({
"info", variant: "info",
null, title: null,
this.i18nService.t("valueCopied", this.i18nService.t(labelI18nKey)), message: this.i18nService.t("valueCopied", this.i18nService.t(labelI18nKey)),
); });
if (this.action === "view") { if (this.action === "view") {
this.messagingService.send("minimizeOnCopy"); this.messagingService.send("minimizeOnCopy");
} }

View File

@@ -31,7 +31,7 @@ import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folde
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service"; import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management"; import { KeyService } from "@bitwarden/key-management";
import { DecryptionFailureDialogComponent, PasswordRepromptService } from "@bitwarden/vault"; import { DecryptionFailureDialogComponent, PasswordRepromptService } from "@bitwarden/vault";
@@ -68,6 +68,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
datePipe: DatePipe, datePipe: DatePipe,
billingAccountProfileStateService: BillingAccountProfileStateService, billingAccountProfileStateService: BillingAccountProfileStateService,
accountService: AccountService, accountService: AccountService,
toastService: ToastService,
cipherAuthorizationService: CipherAuthorizationService, cipherAuthorizationService: CipherAuthorizationService,
) { ) {
super( super(
@@ -94,6 +95,7 @@ export class ViewComponent extends BaseViewComponent implements OnInit, OnDestro
datePipe, datePipe,
accountService, accountService,
billingAccountProfileStateService, billingAccountProfileStateService,
toastService,
cipherAuthorizationService, cipherAuthorizationService,
); );
} }

View File

@@ -29,7 +29,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils"; import { Utils } from "@bitwarden/common/platform/misc/utils";
import { BitValidators, DialogService } from "@bitwarden/components"; import { BitValidators, DialogService, ToastService } from "@bitwarden/components";
import { GroupApiService, GroupView } from "../../../admin-console/organizations/core"; import { GroupApiService, GroupView } from "../../../admin-console/organizations/core";
import { PermissionMode } from "../../../admin-console/organizations/shared/components/access-selector/access-selector.component"; import { PermissionMode } from "../../../admin-console/organizations/shared/components/access-selector/access-selector.component";
@@ -110,6 +110,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
private organizationUserApiService: OrganizationUserApiService, private organizationUserApiService: OrganizationUserApiService,
private dialogService: DialogService, private dialogService: DialogService,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private toastService: ToastService,
) { ) {
this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info; this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info;
} }
@@ -274,17 +275,20 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
const accessTabError = this.formGroup.controls.access.hasError("managePermissionRequired"); const accessTabError = this.formGroup.controls.access.hasError("managePermissionRequired");
if (this.tabIndex === CollectionDialogTabType.Access && !accessTabError) { if (this.tabIndex === CollectionDialogTabType.Access && !accessTabError) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
null, title: null,
this.i18nService.t("fieldOnTabRequiresAttention", this.i18nService.t("collectionInfo")), message: this.i18nService.t(
); "fieldOnTabRequiresAttention",
this.i18nService.t("collectionInfo"),
),
});
} else if (this.tabIndex === CollectionDialogTabType.Info && accessTabError) { } else if (this.tabIndex === CollectionDialogTabType.Info && accessTabError) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
null, title: null,
this.i18nService.t("fieldOnTabRequiresAttention", this.i18nService.t("access")), message: this.i18nService.t("fieldOnTabRequiresAttention", this.i18nService.t("access")),
); });
} }
return; return;
} }
@@ -309,14 +313,14 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
const savedCollection = await this.collectionAdminService.save(collectionView); const savedCollection = await this.collectionAdminService.save(collectionView);
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t( message: this.i18nService.t(
this.editMode ? "editedCollectionId" : "createdCollectionId", this.editMode ? "editedCollectionId" : "createdCollectionId",
collectionView.name, collectionView.name,
), ),
); });
this.close(CollectionDialogAction.Saved, savedCollection); this.close(CollectionDialogAction.Saved, savedCollection);
}; };
@@ -339,11 +343,11 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
await this.collectionAdminService.delete(this.params.organizationId, this.params.collectionId); await this.collectionAdminService.delete(this.params.organizationId, this.params.collectionId);
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t("deletedCollectionId", this.collection?.name), message: this.i18nService.t("deletedCollectionId", this.collection?.name),
); });
this.close(CollectionDialogAction.Deleted, this.collection); this.close(CollectionDialogAction.Deleted, this.collection);
}; };

View File

@@ -194,11 +194,11 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit, On
} }
this.platformUtilsService.copyToClipboard(value, { window: window }); this.platformUtilsService.copyToClipboard(value, { window: window });
this.platformUtilsService.showToast( this.toastService.showToast({
"info", variant: "info",
null, title: null,
this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)), message: this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)),
); });
if (this.editMode) { if (this.editMode) {
if (typeI18nKey === "password") { if (typeI18nKey === "password") {

View File

@@ -10,7 +10,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherBulkDeleteRequest } from "@bitwarden/common/vault/models/request/cipher-bulk-delete.request"; import { CipherBulkDeleteRequest } from "@bitwarden/common/vault/models/request/cipher-bulk-delete.request";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
export interface BulkDeleteDialogParams { export interface BulkDeleteDialogParams {
cipherIds?: string[]; cipherIds?: string[];
@@ -60,6 +60,7 @@ export class BulkDeleteDialogComponent {
private i18nService: I18nService, private i18nService: I18nService,
private apiService: ApiService, private apiService: ApiService,
private collectionService: CollectionService, private collectionService: CollectionService,
private toastService: ToastService,
) { ) {
this.cipherIds = params.cipherIds ?? []; this.cipherIds = params.cipherIds ?? [];
this.permanent = params.permanent; this.permanent = params.permanent;
@@ -95,19 +96,19 @@ export class BulkDeleteDialogComponent {
await Promise.all(deletePromises); await Promise.all(deletePromises);
if (this.cipherIds.length || this.unassignedCiphers.length) { if (this.cipherIds.length || this.unassignedCiphers.length) {
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.permanent ? "permanentlyDeletedItems" : "deletedItems"), message: this.i18nService.t(this.permanent ? "permanentlyDeletedItems" : "deletedItems"),
); });
} }
if (this.collections.length) { if (this.collections.length) {
await this.collectionService.delete(this.collections.map((c) => c.id)); await this.collectionService.delete(this.collections.map((c) => c.id));
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t("deletedCollections"), message: this.i18nService.t("deletedCollections"),
); });
} }
this.close(BulkDeleteDialogResult.Deleted); this.close(BulkDeleteDialogResult.Deleted);
}; };
@@ -134,11 +135,11 @@ export class BulkDeleteDialogComponent {
// From org vault // From org vault
if (this.organization) { if (this.organization) {
if (this.collections.some((c) => !c.canDelete(this.organization))) { if (this.collections.some((c) => !c.canDelete(this.organization))) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("missingPermissions"), message: this.i18nService.t("missingPermissions"),
); });
return; return;
} }
return await this.apiService.deleteManyCollections( return await this.apiService.deleteManyCollections(
@@ -151,11 +152,11 @@ export class BulkDeleteDialogComponent {
for (const organization of this.organizations) { for (const organization of this.organizations) {
const orgCollections = this.collections.filter((o) => o.organizationId === organization.id); const orgCollections = this.collections.filter((o) => o.organizationId === organization.id);
if (orgCollections.some((c) => !c.canDelete(organization))) { if (orgCollections.some((c) => !c.canDelete(organization))) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("missingPermissions"), message: this.i18nService.t("missingPermissions"),
); });
return; return;
} }
const orgCollectionIds = orgCollections.map((c) => c.id); const orgCollectionIds = orgCollections.map((c) => c.id);

View File

@@ -11,7 +11,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
export interface BulkMoveDialogParams { export interface BulkMoveDialogParams {
cipherIds?: string[]; cipherIds?: string[];
@@ -58,6 +58,7 @@ export class BulkMoveDialogComponent implements OnInit {
private i18nService: I18nService, private i18nService: I18nService,
private folderService: FolderService, private folderService: FolderService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private toastService: ToastService,
private accountService: AccountService, private accountService: AccountService,
) { ) {
this.cipherIds = params.cipherIds ?? []; this.cipherIds = params.cipherIds ?? [];
@@ -81,7 +82,11 @@ export class BulkMoveDialogComponent implements OnInit {
} }
await this.cipherService.moveManyWithServer(this.cipherIds, this.formGroup.value.folderId); await this.cipherService.moveManyWithServer(this.cipherIds, this.formGroup.value.folderId);
this.platformUtilsService.showToast("success", null, this.i18nService.t("movedItems")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("movedItems"),
});
this.close(BulkMoveDialogResult.Moved); this.close(BulkMoveDialogResult.Moved);
}; };

View File

@@ -10,11 +10,10 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Checkable, isChecked } from "@bitwarden/common/types/checkable"; import { Checkable, isChecked } from "@bitwarden/common/types/checkable";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
export interface BulkShareDialogParams { export interface BulkShareDialogParams {
ciphers: CipherView[]; ciphers: CipherView[];
@@ -59,12 +58,12 @@ export class BulkShareDialogComponent implements OnInit, OnDestroy {
@Inject(DIALOG_DATA) params: BulkShareDialogParams, @Inject(DIALOG_DATA) params: BulkShareDialogParams,
private dialogRef: DialogRef<BulkShareDialogResult>, private dialogRef: DialogRef<BulkShareDialogResult>,
private cipherService: CipherService, private cipherService: CipherService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private i18nService: I18nService,
private collectionService: CollectionService, private collectionService: CollectionService,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private logService: LogService, private logService: LogService,
private accountService: AccountService, private accountService: AccountService,
private toastService: ToastService,
) { ) {
this.ciphers = params.ciphers ?? []; this.ciphers = params.ciphers ?? [];
this.organizationId = params.organizationId; this.organizationId = params.organizationId;
@@ -114,11 +113,11 @@ export class BulkShareDialogComponent implements OnInit, OnDestroy {
const orgName = const orgName =
this.organizations.find((o) => o.id === this.organizationId)?.name ?? this.organizations.find((o) => o.id === this.organizationId)?.name ??
this.i18nService.t("organization"); this.i18nService.t("organization");
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t("movedItemsToOrg", orgName), message: this.i18nService.t("movedItemsToOrg", orgName),
); });
this.close(BulkShareDialogResult.Shared); this.close(BulkShareDialogResult.Shared);
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);

View File

@@ -45,6 +45,7 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
logService, logService,
dialogService, dialogService,
formBuilder, formBuilder,
toastService,
); );
// FIXME: Remove when updating file. Eslint update // FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-expressions // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -89,11 +90,11 @@ export class FolderAddEditComponent extends BaseFolderAddEditComponent {
const folder = await this.folderService.encrypt(this.folder, userKey); const folder = await this.folderService.encrypt(this.folder, userKey);
this.formPromise = this.folderApiService.save(folder, activeAccountId); this.formPromise = this.folderApiService.save(folder, activeAccountId);
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.editMode ? "editedFolder" : "addedFolder"), message: this.i18nService.t(this.editMode ? "editedFolder" : "addedFolder"),
); });
this.onSavedFolder.emit(this.folder); this.onSavedFolder.emit(this.folder);
this.dialogRef.close(FolderAddEditDialogResult.Saved); this.dialogRef.close(FolderAddEditDialogResult.Saved);
} catch (e) { } catch (e) {

View File

@@ -146,7 +146,11 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy {
return this.syncService.fullSync(true); return this.syncService.fullSync(true);
}); });
await this.actionPromise; await this.actionPromise;
this.platformUtilsService.showToast("success", null, "Unlinked SSO"); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("unlinkedSso"),
});
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
} }
@@ -166,7 +170,11 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy {
try { try {
this.actionPromise = this.organizationApiService.leave(org.id); this.actionPromise = this.organizationApiService.leave(org.id);
await this.actionPromise; await this.actionPromise;
this.platformUtilsService.showToast("success", null, this.i18nService.t("leftOrganization")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("leftOrganization"),
});
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
} }
@@ -199,11 +207,11 @@ export class OrganizationOptionsComponent implements OnInit, OnDestroy {
); );
try { try {
await this.actionPromise; await this.actionPromise;
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t("withdrawPasswordResetSuccess"), message: this.i18nService.t("withdrawPasswordResetSuccess"),
); });
await this.syncService.fullSync(true); await this.syncService.fullSync(true);
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);

View File

@@ -13,7 +13,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node"; import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { TrialFlowService } from "../../../../billing/services/trial-flow.service"; import { TrialFlowService } from "../../../../billing/services/trial-flow.service";
import { VaultFilterService } from "../services/abstractions/vault-filter.service"; import { VaultFilterService } from "../services/abstractions/vault-filter.service";
@@ -98,6 +98,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
protected policyService: PolicyService, protected policyService: PolicyService,
protected i18nService: I18nService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected platformUtilsService: PlatformUtilsService,
protected toastService: ToastService,
protected billingApiService: BillingApiServiceAbstraction, protected billingApiService: BillingApiServiceAbstraction,
protected dialogService: DialogService, protected dialogService: DialogService,
protected configService: ConfigService, protected configService: ConfigService,
@@ -122,11 +123,11 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
applyOrganizationFilter = async (orgNode: TreeNode<OrganizationFilter>): Promise<void> => { applyOrganizationFilter = async (orgNode: TreeNode<OrganizationFilter>): Promise<void> => {
if (!orgNode?.node.enabled) { if (!orgNode?.node.enabled) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
null, title: null,
this.i18nService.t("disabledOrganizationFilterError"), message: this.i18nService.t("disabledOrganizationFilterError"),
); });
const metadata = await this.billingApiService.getOrganizationBillingMetadata(orgNode.node.id); const metadata = await this.billingApiService.getOrganizationBillingMetadata(orgNode.node.id);
await this.trialFlowService.handleUnpaidSubscriptionDialog(orgNode.node, metadata); await this.trialFlowService.handleUnpaidSubscriptionDialog(orgNode.node, metadata);
} }

View File

@@ -14,7 +14,7 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { GroupApiService, GroupView } from "../../../admin-console/organizations/core"; import { GroupApiService, GroupView } from "../../../admin-console/organizations/core";
import { import {
@@ -68,6 +68,7 @@ export class BulkCollectionsDialogComponent implements OnDestroy {
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService, private i18nService: I18nService,
private collectionAdminService: CollectionAdminService, private collectionAdminService: CollectionAdminService,
private toastService: ToastService,
) { ) {
this.numCollections = this.params.collections.length; this.numCollections = this.params.collections.length;
const organization$ = this.organizationService.get$(this.params.organizationId); const organization$ = this.organizationService.get$(this.params.organizationId);
@@ -119,7 +120,11 @@ export class BulkCollectionsDialogComponent implements OnDestroy {
groups, groups,
); );
this.platformUtilsService.showToast("success", null, this.i18nService.t("editedCollections")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("editedCollections"),
});
this.dialogRef.close(BulkCollectionsDialogResult.Saved); this.dialogRef.close(BulkCollectionsDialogResult.Saved);
}; };

View File

@@ -10,7 +10,7 @@ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/co
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node"; import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { VaultFilterComponent as BaseVaultFilterComponent } from "../../individual-vault/vault-filter/components/vault-filter.component"; //../../vault/vault-filter/components/vault-filter.component"; import { VaultFilterComponent as BaseVaultFilterComponent } from "../../individual-vault/vault-filter/components/vault-filter.component"; //../../vault/vault-filter/components/vault-filter.component";
import { VaultFilterService } from "../../individual-vault/vault-filter/services/abstractions/vault-filter.service"; import { VaultFilterService } from "../../individual-vault/vault-filter/services/abstractions/vault-filter.service";
@@ -43,6 +43,7 @@ export class VaultFilterComponent
protected policyService: PolicyService, protected policyService: PolicyService,
protected i18nService: I18nService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected platformUtilsService: PlatformUtilsService,
protected toastService: ToastService,
protected billingApiService: BillingApiServiceAbstraction, protected billingApiService: BillingApiServiceAbstraction,
protected dialogService: DialogService, protected dialogService: DialogService,
protected configService: ConfigService, protected configService: ConfigService,
@@ -52,6 +53,7 @@ export class VaultFilterComponent
policyService, policyService,
i18nService, i18nService,
platformUtilsService, platformUtilsService,
toastService,
billingApiService, billingApiService,
dialogService, dialogService,
configService, configService,

View File

@@ -11,7 +11,7 @@ import { Verification } from "@bitwarden/common/auth/types/verification";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SyncService } from "@bitwarden/common/platform/sync"; import { SyncService } from "@bitwarden/common/platform/sync";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
export interface PurgeVaultDialogData { export interface PurgeVaultDialogData {
organizationId: string; organizationId: string;
@@ -37,6 +37,7 @@ export class PurgeVaultComponent {
private userVerificationService: UserVerificationService, private userVerificationService: UserVerificationService,
private router: Router, private router: Router,
private syncService: SyncService, private syncService: SyncService,
private toastService: ToastService,
) { ) {
this.organizationId = data && data.organizationId ? data.organizationId : null; this.organizationId = data && data.organizationId ? data.organizationId : null;
} }
@@ -46,7 +47,11 @@ export class PurgeVaultComponent {
.buildRequest(this.formGroup.value.masterPassword) .buildRequest(this.formGroup.value.masterPassword)
.then((request) => this.apiService.postPurgeCiphers(request, this.organizationId)); .then((request) => this.apiService.postPurgeCiphers(request, this.organizationId));
await response; await response;
this.platformUtilsService.showToast("success", null, this.i18nService.t("vaultPurged")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("vaultPurged"),
});
await this.syncService.fullSync(true); await this.syncService.fullSync(true);
if (this.organizationId != null) { if (this.organizationId != null) {
await this.router.navigate(["organizations", this.organizationId, "vault"]); await this.router.navigate(["organizations", this.organizationId, "vault"]);

View File

@@ -3789,6 +3789,9 @@
} }
} }
}, },
"unlinkedSso": {
"message": "Unlinked SSO."
},
"unlinkedSsoUser": { "unlinkedSsoUser": {
"message": "Unlinked SSO for user $ID$.", "message": "Unlinked SSO for user $ID$.",
"placeholders": { "placeholders": {

View File

@@ -372,11 +372,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
} }
if (this.cipher.name == null || this.cipher.name === "") { if (this.cipher.name == null || this.cipher.name === "") {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("nameRequired"), message: this.i18nService.t("nameRequired"),
); });
return false; return false;
} }
@@ -385,11 +385,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
!this.allowPersonal && !this.allowPersonal &&
this.cipher.organizationId == null this.cipher.organizationId == null
) { ) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("personalOwnershipSubmitError"), message: this.i18nService.t("personalOwnershipSubmitError"),
); });
return false; return false;
} }
@@ -424,11 +424,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
this.formPromise = this.saveCipher(cipher); this.formPromise = this.saveCipher(cipher);
await this.formPromise; await this.formPromise;
this.cipher.id = cipher.id; this.cipher.id = cipher.id;
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.editMode && !this.cloneMode ? "editedItem" : "addedItem"), message: this.i18nService.t(this.editMode && !this.cloneMode ? "editedItem" : "addedItem"),
); });
this.onSavedCipher.emit(this.cipher); this.onSavedCipher.emit(this.cipher);
this.messagingService.send(this.editMode && !this.cloneMode ? "editedCipher" : "addedCipher"); this.messagingService.send(this.editMode && !this.cloneMode ? "editedCipher" : "addedCipher");
return true; return true;
@@ -514,11 +514,13 @@ export class AddEditComponent implements OnInit, OnDestroy {
try { try {
this.deletePromise = this.deleteCipher(); this.deletePromise = this.deleteCipher();
await this.deletePromise; await this.deletePromise;
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.cipher.isDeleted ? "permanentlyDeletedItem" : "deletedItem"), message: this.i18nService.t(
); this.cipher.isDeleted ? "permanentlyDeletedItem" : "deletedItem",
),
});
this.onDeletedCipher.emit(this.cipher); this.onDeletedCipher.emit(this.cipher);
this.messagingService.send( this.messagingService.send(
this.cipher.isDeleted ? "permanentlyDeletedCipher" : "deletedCipher", this.cipher.isDeleted ? "permanentlyDeletedCipher" : "deletedCipher",
@@ -538,7 +540,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
try { try {
this.restorePromise = this.restoreCipher(); this.restorePromise = this.restoreCipher();
await this.restorePromise; await this.restorePromise;
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("restoredItem"),
});
this.onRestoredCipher.emit(this.cipher); this.onRestoredCipher.emit(this.cipher);
this.messagingService.send("restoredCipher"); this.messagingService.send("restoredCipher");
} catch (e) { } catch (e) {
@@ -679,13 +685,17 @@ export class AddEditComponent implements OnInit, OnDestroy {
this.checkPasswordPromise = null; this.checkPasswordPromise = null;
if (matches > 0) { if (matches > 0) {
this.platformUtilsService.showToast( this.toastService.showToast({
"warning", variant: "warning",
null, title: null,
this.i18nService.t("passwordExposed", matches.toString()), message: this.i18nService.t("passwordExposed", matches.toString()),
); });
} else { } else {
this.platformUtilsService.showToast("success", null, this.i18nService.t("passwordSafe")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("passwordSafe"),
});
} }
} }
@@ -779,11 +789,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(value, copyOptions); this.platformUtilsService.copyToClipboard(value, copyOptions);
this.platformUtilsService.showToast( this.toastService.showToast({
"info", variant: "info",
null, title: null,
this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)), message: this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)),
); });
if (typeI18nKey === "password") { if (typeI18nKey === "password") {
void this.eventCollectionService.collectMany(EventType.Cipher_ClientCopiedPassword, [ void this.eventCollectionService.collectMany(EventType.Cipher_ClientCopiedPassword, [

View File

@@ -64,21 +64,21 @@ export class AttachmentsComponent implements OnInit {
const fileEl = document.getElementById("file") as HTMLInputElement; const fileEl = document.getElementById("file") as HTMLInputElement;
const files = fileEl.files; const files = fileEl.files;
if (files == null || files.length === 0) { if (files == null || files.length === 0) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("selectFile"), message: this.i18nService.t("selectFile"),
); });
return; return;
} }
if (files[0].size > 524288000) { if (files[0].size > 524288000) {
// 500 MB // 500 MB
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("maxFileSize"), message: this.i18nService.t("maxFileSize"),
); });
return; return;
} }
@@ -91,7 +91,11 @@ export class AttachmentsComponent implements OnInit {
this.cipher = await this.cipherDomain.decrypt( this.cipher = await this.cipherDomain.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(this.cipherDomain, activeUserId), await this.cipherService.getKeyForCipherKeyDecryption(this.cipherDomain, activeUserId),
); );
this.platformUtilsService.showToast("success", null, this.i18nService.t("attachmentSaved")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("attachmentSaved"),
});
this.onUploadedAttachment.emit(); this.onUploadedAttachment.emit();
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
@@ -122,7 +126,11 @@ export class AttachmentsComponent implements OnInit {
try { try {
this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id); this.deletePromises[attachment.id] = this.deleteCipherAttachment(attachment.id);
await this.deletePromises[attachment.id]; await this.deletePromises[attachment.id];
this.platformUtilsService.showToast("success", null, this.i18nService.t("deletedAttachment")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("deletedAttachment"),
});
const i = this.cipher.attachments.indexOf(attachment); const i = this.cipher.attachments.indexOf(attachment);
if (i > -1) { if (i > -1) {
this.cipher.attachments.splice(i, 1); this.cipher.attachments.splice(i, 1);
@@ -142,11 +150,11 @@ export class AttachmentsComponent implements OnInit {
} }
if (!this.canAccessAttachments) { if (!this.canAccessAttachments) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("premiumRequired"), title: this.i18nService.t("premiumRequired"),
this.i18nService.t("premiumRequiredDesc"), message: this.i18nService.t("premiumRequiredDesc"),
); });
return; return;
} }
@@ -171,7 +179,11 @@ export class AttachmentsComponent implements OnInit {
a.downloading = true; a.downloading = true;
const response = await fetch(new Request(url, { cache: "no-store" })); const response = await fetch(new Request(url, { cache: "no-store" }));
if (response.status !== 200) { if (response.status !== 200) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
a.downloading = false; a.downloading = false;
return; return;
} }
@@ -195,7 +207,11 @@ export class AttachmentsComponent implements OnInit {
// FIXME: Remove when updating file. Eslint update // FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) { } catch (e) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
} }
a.downloading = false; a.downloading = false;
@@ -243,7 +259,11 @@ export class AttachmentsComponent implements OnInit {
a.downloading = true; a.downloading = true;
const response = await fetch(new Request(attachment.url, { cache: "no-store" })); const response = await fetch(new Request(attachment.url, { cache: "no-store" }));
if (response.status !== 200) { if (response.status !== 200) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
a.downloading = false; a.downloading = false;
return; return;
} }
@@ -281,16 +301,20 @@ export class AttachmentsComponent implements OnInit {
} }
} }
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t("attachmentSaved"), message: this.i18nService.t("attachmentSaved"),
); });
this.onReuploadedAttachment.emit(); this.onReuploadedAttachment.emit();
// FIXME: Remove when updating file. Eslint update // FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) { } catch (e) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
} }
a.downloading = false; a.downloading = false;

View File

@@ -11,7 +11,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction"; import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management"; import { KeyService } from "@bitwarden/key-management";
@Directive() @Directive()
@@ -43,6 +43,7 @@ export class FolderAddEditComponent implements OnInit {
protected logService: LogService, protected logService: LogService,
protected dialogService: DialogService, protected dialogService: DialogService,
protected formBuilder: FormBuilder, protected formBuilder: FormBuilder,
protected toastService: ToastService,
) {} ) {}
async ngOnInit() { async ngOnInit() {
@@ -52,11 +53,11 @@ export class FolderAddEditComponent implements OnInit {
async submit(): Promise<boolean> { async submit(): Promise<boolean> {
this.folder.name = this.formGroup.controls.name.value; this.folder.name = this.formGroup.controls.name.value;
if (this.folder.name == null || this.folder.name === "") { if (this.folder.name == null || this.folder.name === "") {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("nameRequired"), message: this.i18nService.t("nameRequired"),
); });
return false; return false;
} }
@@ -66,11 +67,11 @@ export class FolderAddEditComponent implements OnInit {
const folder = await this.folderService.encrypt(this.folder, userKey); const folder = await this.folderService.encrypt(this.folder, userKey);
this.formPromise = this.folderApiService.save(folder, activeUserId); this.formPromise = this.folderApiService.save(folder, activeUserId);
await this.formPromise; await this.formPromise;
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.editMode ? "editedFolder" : "addedFolder"), message: this.i18nService.t(this.editMode ? "editedFolder" : "addedFolder"),
); });
this.onSavedFolder.emit(this.folder); this.onSavedFolder.emit(this.folder);
return true; return true;
} catch (e) { } catch (e) {
@@ -95,7 +96,11 @@ export class FolderAddEditComponent implements OnInit {
const activeUserId = await firstValueFrom(this.activeUserId$); const activeUserId = await firstValueFrom(this.activeUserId$);
this.deletePromise = this.folderApiService.delete(this.folder.id, activeUserId); this.deletePromise = this.folderApiService.delete(this.folder.id, activeUserId);
await this.deletePromise; await this.deletePromise;
this.platformUtilsService.showToast("success", null, this.i18nService.t("deletedFolder")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("deletedFolder"),
});
this.onDeletedFolder.emit(this.folder); this.onDeletedFolder.emit(this.folder);
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);

View File

@@ -8,6 +8,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { PasswordHistoryView } from "@bitwarden/common/vault/models/view/password-history.view"; import { PasswordHistoryView } from "@bitwarden/common/vault/models/view/password-history.view";
import { ToastService } from "@bitwarden/components";
@Directive() @Directive()
export class PasswordHistoryComponent implements OnInit { export class PasswordHistoryComponent implements OnInit {
@@ -20,6 +21,7 @@ export class PasswordHistoryComponent implements OnInit {
protected i18nService: I18nService, protected i18nService: I18nService,
protected accountService: AccountService, protected accountService: AccountService,
private win: Window, private win: Window,
private toastService: ToastService,
) {} ) {}
async ngOnInit() { async ngOnInit() {
@@ -29,11 +31,11 @@ export class PasswordHistoryComponent implements OnInit {
copy(password: string) { copy(password: string) {
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions); this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast( this.toastService.showToast({
"info", variant: "info",
null, title: null,
this.i18nService.t("valueCopied", this.i18nService.t("password")), message: this.i18nService.t("valueCopied", this.i18nService.t("password")),
); });
} }
protected async init() { protected async init() {

View File

@@ -12,7 +12,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService, SimpleDialogOptions } from "@bitwarden/components"; import { DialogService, SimpleDialogOptions, ToastService } from "@bitwarden/components";
@Directive() @Directive()
export class PremiumComponent implements OnInit { export class PremiumComponent implements OnInit {
@@ -31,6 +31,7 @@ export class PremiumComponent implements OnInit {
protected dialogService: DialogService, protected dialogService: DialogService,
private environmentService: EnvironmentService, private environmentService: EnvironmentService,
billingAccountProfileStateService: BillingAccountProfileStateService, billingAccountProfileStateService: BillingAccountProfileStateService,
private toastService: ToastService,
accountService: AccountService, accountService: AccountService,
) { ) {
this.isPremium$ = accountService.activeAccount$.pipe( this.isPremium$ = accountService.activeAccount$.pipe(
@@ -51,7 +52,11 @@ export class PremiumComponent implements OnInit {
try { try {
this.refreshPromise = this.apiService.refreshIdentityToken(); this.refreshPromise = this.apiService.refreshIdentityToken();
await this.refreshPromise; await this.refreshPromise;
this.platformUtilsService.showToast("success", null, this.i18nService.t("refreshComplete")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("refreshComplete"),
});
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
} }

View File

@@ -40,7 +40,7 @@ import { AttachmentView } from "@bitwarden/common/vault/models/view/attachment.v
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view"; import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service"; import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
import { DialogService } from "@bitwarden/components"; import { DialogService, ToastService } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management"; import { KeyService } from "@bitwarden/key-management";
import { PasswordRepromptService } from "@bitwarden/vault"; import { PasswordRepromptService } from "@bitwarden/vault";
@@ -115,6 +115,7 @@ export class ViewComponent implements OnDestroy, OnInit {
protected datePipe: DatePipe, protected datePipe: DatePipe,
protected accountService: AccountService, protected accountService: AccountService,
private billingAccountProfileStateService: BillingAccountProfileStateService, private billingAccountProfileStateService: BillingAccountProfileStateService,
protected toastService: ToastService,
private cipherAuthorizationService: CipherAuthorizationService, private cipherAuthorizationService: CipherAuthorizationService,
) {} ) {}
@@ -246,11 +247,13 @@ export class ViewComponent implements OnDestroy, OnInit {
try { try {
await this.deleteCipher(); await this.deleteCipher();
this.platformUtilsService.showToast( this.toastService.showToast({
"success", variant: "success",
null, title: null,
this.i18nService.t(this.cipher.isDeleted ? "permanentlyDeletedItem" : "deletedItem"), message: this.i18nService.t(
); this.cipher.isDeleted ? "permanentlyDeletedItem" : "deletedItem",
),
});
this.onDeletedCipher.emit(this.cipher); this.onDeletedCipher.emit(this.cipher);
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
@@ -266,7 +269,11 @@ export class ViewComponent implements OnDestroy, OnInit {
try { try {
await this.restoreCipher(); await this.restoreCipher();
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("restoredItem"),
});
this.onRestoredCipher.emit(this.cipher); this.onRestoredCipher.emit(this.cipher);
} catch (e) { } catch (e) {
this.logService.error(e); this.logService.error(e);
@@ -349,13 +356,17 @@ export class ViewComponent implements OnDestroy, OnInit {
const matches = await this.checkPasswordPromise; const matches = await this.checkPasswordPromise;
if (matches > 0) { if (matches > 0) {
this.platformUtilsService.showToast( this.toastService.showToast({
"warning", variant: "warning",
null, title: null,
this.i18nService.t("passwordExposed", matches.toString()), message: this.i18nService.t("passwordExposed", matches.toString()),
); });
} else { } else {
this.platformUtilsService.showToast("success", null, this.i18nService.t("passwordSafe")); this.toastService.showToast({
variant: "success",
title: null,
message: this.i18nService.t("passwordSafe"),
});
} }
} }
@@ -385,11 +396,11 @@ export class ViewComponent implements OnDestroy, OnInit {
const copyOptions = this.win != null ? { window: this.win } : null; const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(value, copyOptions); this.platformUtilsService.copyToClipboard(value, copyOptions);
this.platformUtilsService.showToast( this.toastService.showToast({
"info", variant: "info",
null, title: null,
this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)), message: this.i18nService.t("valueCopied", this.i18nService.t(typeI18nKey)),
); });
if (typeI18nKey === "password") { if (typeI18nKey === "password") {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
@@ -422,11 +433,11 @@ export class ViewComponent implements OnDestroy, OnInit {
} }
if (this.cipher.organizationId == null && !this.canAccessPremium) { if (this.cipher.organizationId == null && !this.canAccessPremium) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("premiumRequired"), title: this.i18nService.t("premiumRequired"),
this.i18nService.t("premiumRequiredDesc"), message: this.i18nService.t("premiumRequiredDesc"),
); });
return; return;
} }
@@ -450,7 +461,11 @@ export class ViewComponent implements OnDestroy, OnInit {
a.downloading = true; a.downloading = true;
const response = await fetch(new Request(url, { cache: "no-store" })); const response = await fetch(new Request(url, { cache: "no-store" }));
if (response.status !== 200) { if (response.status !== 200) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
a.downloading = false; a.downloading = false;
return; return;
} }
@@ -469,7 +484,11 @@ export class ViewComponent implements OnDestroy, OnInit {
// FIXME: Remove when updating file. Eslint update // FIXME: Remove when updating file. Eslint update
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) { } catch (e) {
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred")); this.toastService.showToast({
variant: "error",
title: null,
message: this.i18nService.t("errorOccurred"),
});
} }
a.downloading = false; a.downloading = false;

View File

@@ -13,6 +13,7 @@ import {
DialogModule, DialogModule,
FormFieldModule, FormFieldModule,
IconButtonModule, IconButtonModule,
ToastService,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { KeyService } from "@bitwarden/key-management"; import { KeyService } from "@bitwarden/key-management";
@@ -45,6 +46,7 @@ export class PasswordRepromptComponent {
protected i18nService: I18nService, protected i18nService: I18nService,
protected formBuilder: FormBuilder, protected formBuilder: FormBuilder,
protected dialogRef: DialogRef, protected dialogRef: DialogRef,
private toastService: ToastService,
protected accountService: AccountService, protected accountService: AccountService,
) {} ) {}
@@ -72,11 +74,11 @@ export class PasswordRepromptComponent {
userId, userId,
)) ))
) { ) {
this.platformUtilsService.showToast( this.toastService.showToast({
"error", variant: "error",
this.i18nService.t("errorOccurred"), title: this.i18nService.t("errorOccurred"),
this.i18nService.t("invalidMasterPassword"), message: this.i18nService.t("invalidMasterPassword"),
); });
return; return;
} }