mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 10:33:57 +00:00
Replace toaster library (#1322)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { ToasterModule } from 'angular2-toaster';
|
||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
|
||||
|
||||
import { BitwardenToastModule } from 'jslib-angular/components/toastr.component';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { AppComponent } from './app.component';
|
||||
@@ -25,7 +25,11 @@ import { WildcardRoutingModule } from 'src/app/wildcard-routing.module';
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
ServicesModule,
|
||||
ToasterModule.forRoot(),
|
||||
BitwardenToastModule.forRoot({
|
||||
maxOpened: 5,
|
||||
autoDismiss: true,
|
||||
closeButton: true,
|
||||
}),
|
||||
InfiniteScrollModule,
|
||||
DragDropModule,
|
||||
AppRoutingModule,
|
||||
|
||||
@@ -5,9 +5,7 @@ import {
|
||||
OnInit,
|
||||
Output
|
||||
} from '@angular/core';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||
@@ -19,8 +17,6 @@ import { ProviderService } from '../services/provider.service';
|
||||
import { Organization } from 'jslib-common/models/domain/organization';
|
||||
import { Provider } from 'jslib-common/models/domain/provider';
|
||||
|
||||
import { PlanType } from 'jslib-common/enums/planType';
|
||||
|
||||
@Component({
|
||||
selector: 'provider-add-organization',
|
||||
templateUrl: 'add-organization.component.html',
|
||||
@@ -36,9 +32,8 @@ export class AddOrganizationComponent implements OnInit {
|
||||
loading = true;
|
||||
|
||||
constructor(private userService: UserService, private providerService: ProviderService,
|
||||
private toasterService: ToasterService, private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService, private validationService: ValidationService,
|
||||
private apiService: ApiService) { }
|
||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||
private validationService: ValidationService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
await this.load();
|
||||
@@ -77,7 +72,7 @@ export class AddOrganizationComponent implements OnInit {
|
||||
this.formPromise = null;
|
||||
}
|
||||
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('organizationJoinedProvider'));
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('organizationJoinedProvider'));
|
||||
this.onAddedOrganization.emit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ViewContainerRef
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
@@ -58,9 +57,8 @@ export class ClientsComponent implements OnInit {
|
||||
constructor(private route: ActivatedRoute, private userService: UserService,
|
||||
private apiService: ApiService, private searchService: SearchService,
|
||||
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
|
||||
private toasterService: ToasterService, private validationService: ValidationService,
|
||||
private providerService: ProviderService, private logService: LogService,
|
||||
private modalService: ModalService) { }
|
||||
private validationService: ValidationService, private providerService: ProviderService,
|
||||
private logService: LogService, private modalService: ModalService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.route.parent.params.subscribe(async params => {
|
||||
@@ -149,7 +147,8 @@ export class ClientsComponent implements OnInit {
|
||||
this.actionPromise = this.providerService.detachOrganizastion(this.providerId, organization.id);
|
||||
try {
|
||||
await this.actionPromise;
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('detachedOrganization', organization.organizationName));
|
||||
this.platformUtilsService.showToast('success', null,
|
||||
this.i18nService.t('detachedOrganization', organization.organizationName));
|
||||
await this.load();
|
||||
} catch (e) {
|
||||
this.validationService.showError(e);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Toast, ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { BaseAcceptComponent } from 'src/app/common/base.accept.component';
|
||||
|
||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||
import { StateService } from 'jslib-common/abstractions/state.service';
|
||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||
import { ProviderUserAcceptRequest } from 'jslib-common/models/request/provider/providerUserAcceptRequest';
|
||||
@@ -22,9 +22,10 @@ export class AcceptProviderComponent extends BaseAcceptComponent {
|
||||
|
||||
requiredParameters = ['providerId', 'providerUserId', 'token'];
|
||||
|
||||
constructor(router: Router, toasterService: ToasterService, i18nService: I18nService, route: ActivatedRoute,
|
||||
userService: UserService, stateService: StateService, private apiService: ApiService) {
|
||||
super(router, toasterService, i18nService, route, userService, stateService);
|
||||
constructor(router: Router, i18nService: I18nService, route: ActivatedRoute,
|
||||
userService: UserService, stateService: StateService, private apiService: ApiService,
|
||||
platformUtilService: PlatformUtilsService) {
|
||||
super(router, platformUtilService, i18nService, route, userService, stateService);
|
||||
}
|
||||
|
||||
async authedHandler(qParams: any) {
|
||||
@@ -32,13 +33,8 @@ export class AcceptProviderComponent extends BaseAcceptComponent {
|
||||
request.token = qParams.token;
|
||||
|
||||
await this.apiService.postProviderUserAccept(qParams.providerId, qParams.providerUserId, request);
|
||||
const toast: Toast = {
|
||||
type: 'success',
|
||||
title: this.i18nService.t('inviteAccepted'),
|
||||
body: this.i18nService.t('providerInviteAcceptedDesc'),
|
||||
timeout: 10000,
|
||||
};
|
||||
this.toasterService.popAsync(toast);
|
||||
this.platformUtilService.showToast('success', this.i18nService.t('inviteAccepted'),
|
||||
this.i18nService.t('providerInviteAcceptedDesc'), { timeout: 10000 });
|
||||
this.router.navigate(['/vault']);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||
import { ExportService } from 'jslib-common/abstractions/export.service';
|
||||
@@ -32,10 +31,10 @@ export class EventsComponent extends BaseEventsComponent implements OnInit {
|
||||
private providerUsersIdMap = new Map<string, any>();
|
||||
|
||||
constructor(private apiService: ApiService, private route: ActivatedRoute, eventService: EventService,
|
||||
i18nService: I18nService, toasterService: ToasterService, private userService: UserService,
|
||||
exportService: ExportService, platformUtilsService: PlatformUtilsService, private router: Router,
|
||||
logService: LogService, private userNamePipe: UserNamePipe) {
|
||||
super(eventService, i18nService, toasterService, exportService, platformUtilsService, logService);
|
||||
i18nService: I18nService, private userService: UserService, exportService: ExportService,
|
||||
platformUtilsService: PlatformUtilsService, private router: Router, logService: LogService,
|
||||
private userNamePipe: UserNamePipe) {
|
||||
super(eventService, i18nService, exportService, platformUtilsService, logService);
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ViewContainerRef
|
||||
} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
@@ -61,11 +60,11 @@ export class PeopleComponent extends BasePeopleComponent<ProviderUserUserDetails
|
||||
|
||||
constructor(apiService: ApiService, private route: ActivatedRoute,
|
||||
i18nService: I18nService, modalService: ModalService,
|
||||
platformUtilsService: PlatformUtilsService, toasterService: ToasterService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
cryptoService: CryptoService, private userService: UserService, private router: Router,
|
||||
storageService: StorageService, searchService: SearchService, validationService: ValidationService,
|
||||
logService: LogService, searchPipe: SearchPipe, userNamePipe: UserNamePipe) {
|
||||
super(apiService, searchService, i18nService, platformUtilsService, toasterService, cryptoService,
|
||||
super(apiService, searchService, i18nService, platformUtilsService, cryptoService,
|
||||
storageService, validationService, modalService, logService, searchPipe, userNamePipe);
|
||||
}
|
||||
|
||||
@@ -164,7 +163,7 @@ export class PeopleComponent extends BasePeopleComponent<ProviderUserUserDetails
|
||||
const filteredUsers = users.filter(u => u.status === ProviderUserStatusType.Invited);
|
||||
|
||||
if (filteredUsers.length <= 0) {
|
||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||
this.i18nService.t('noSelectedUsersApplicable'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
Output,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { LogService } from 'jslib-common/abstractions/log.service';
|
||||
@@ -44,8 +42,7 @@ export class UserAddEditComponent implements OnInit {
|
||||
userType = ProviderUserType;
|
||||
|
||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||
private toasterService: ToasterService, private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService) { }
|
||||
private platformUtilsService: PlatformUtilsService, private logService: LogService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.editMode = this.loading = this.providerUserId != null;
|
||||
@@ -79,7 +76,7 @@ export class UserAddEditComponent implements OnInit {
|
||||
this.formPromise = this.apiService.postProviderUserInvite(this.providerId, request);
|
||||
}
|
||||
await this.formPromise;
|
||||
this.toasterService.popAsync('success', null,
|
||||
this.platformUtilsService.showToast('success', null,
|
||||
this.i18nService.t(this.editMode ? 'editedUserId' : 'invitedUsers', this.name));
|
||||
this.onSavedUser.emit();
|
||||
} catch (e) {
|
||||
@@ -102,7 +99,7 @@ export class UserAddEditComponent implements OnInit {
|
||||
try {
|
||||
this.deletePromise = this.apiService.deleteProviderUser(this.providerId, this.providerUserId);
|
||||
await this.deletePromise;
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', this.name));
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('removedUserId', this.name));
|
||||
this.onDeletedUser.emit();
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
|
||||
@@ -5,15 +5,14 @@ import {
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||
import { UserService } from 'jslib-common/abstractions/user.service';
|
||||
|
||||
@Injectable()
|
||||
export class ProviderGuardService implements CanActivate {
|
||||
constructor(private userService: UserService, private router: Router,
|
||||
private toasterService: ToasterService, private i18nService: I18nService) { }
|
||||
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService) { }
|
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot) {
|
||||
const provider = await this.userService.getProvider(route.params.providerId);
|
||||
@@ -22,7 +21,7 @@ export class ProviderGuardService implements CanActivate {
|
||||
return false;
|
||||
}
|
||||
if (!provider.isProviderAdmin && !provider.enabled) {
|
||||
this.toasterService.popAsync('error', null, this.i18nService.t('providerIsDisabled'));
|
||||
this.platformUtilsService.showToast('error', null, this.i18nService.t('providerIsDisabled'));
|
||||
this.router.navigate(['/']);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { ApiService } from 'jslib-common/abstractions/api.service';
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
@@ -26,9 +25,8 @@ export class AccountComponent {
|
||||
private providerId: string;
|
||||
|
||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||
private toasterService: ToasterService, private route: ActivatedRoute,
|
||||
private syncService: SyncService, private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService) { }
|
||||
private route: ActivatedRoute, private syncService: SyncService,
|
||||
private platformUtilsService: PlatformUtilsService, private logService: LogService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.selfHosted = this.platformUtilsService.isSelfHost();
|
||||
@@ -54,7 +52,7 @@ export class AccountComponent {
|
||||
return this.syncService.fullSync(true);
|
||||
});
|
||||
await this.formPromise;
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('providerUpdated'));
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('providerUpdated'));
|
||||
} catch (e) {
|
||||
this.logService.error(`Handled exception: ${e}`);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ import {
|
||||
ActivatedRoute,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
import {
|
||||
Toast,
|
||||
ToasterService,
|
||||
} from 'angular2-toaster';
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
@@ -18,6 +14,7 @@ import { CryptoService } from 'jslib-common/abstractions/crypto.service';
|
||||
|
||||
import { ValidationService } from 'jslib-angular/services/validation.service';
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
||||
import { SyncService } from 'jslib-common/abstractions/sync.service';
|
||||
import { ProviderSetupRequest } from 'jslib-common/models/request/provider/providerSetupRequest';
|
||||
|
||||
@@ -36,7 +33,7 @@ export class SetupComponent implements OnInit {
|
||||
name: string;
|
||||
billingEmail: string;
|
||||
|
||||
constructor(private router: Router, private toasterService: ToasterService,
|
||||
constructor(private router: Router, private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService, private route: ActivatedRoute,
|
||||
private cryptoService: CryptoService, private apiService: ApiService,
|
||||
private syncService: SyncService, private validationService: ValidationService) { }
|
||||
@@ -47,13 +44,8 @@ export class SetupComponent implements OnInit {
|
||||
const error = qParams.providerId == null || qParams.email == null || qParams.token == null;
|
||||
|
||||
if (error) {
|
||||
const toast: Toast = {
|
||||
type: 'error',
|
||||
title: null,
|
||||
body: this.i18nService.t('emergencyInviteAcceptFailed'),
|
||||
timeout: 10000,
|
||||
};
|
||||
this.toasterService.popAsync(toast);
|
||||
this.platformUtilsService.showToast('error', null, this.i18nService.t('emergencyInviteAcceptFailed'),
|
||||
{ timeout: 10000 });
|
||||
this.router.navigate(['/']);
|
||||
return;
|
||||
}
|
||||
@@ -92,7 +84,7 @@ export class SetupComponent implements OnInit {
|
||||
request.key = key;
|
||||
|
||||
const provider = await this.apiService.postProviderSetup(this.providerId, request);
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t('providerSetup'));
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('providerSetup'));
|
||||
await this.syncService.fullSync(true);
|
||||
|
||||
this.router.navigate(['/providers', provider.id]);
|
||||
|
||||
Reference in New Issue
Block a user