From 4e74e8032be8293ffe3cb3c30528d4ef7c11a798 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Dec 2018 14:36:05 +0100 Subject: Remove inferred type --- .../user-moderation-dropdown.component.ts | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'client/src/app/shared/moderation') diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts index d391246e0..e3c9db923 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts @@ -277,18 +277,18 @@ export class UserModerationDropdownComponent implements OnChanges { }, { label: this.i18n('Ban'), - handler: ({ user }: { user: User }) => this.openBanUserModal(user), - isDisplayed: ({ user }: { user: User }) => !user.blocked + handler: ({ user }) => this.openBanUserModal(user), + isDisplayed: ({ user }) => !user.blocked }, { label: this.i18n('Unban'), - handler: ({ user }: { user: User }) => this.unbanUser(user), - isDisplayed: ({ user }: { user: User }) => user.blocked + handler: ({ user }) => this.unbanUser(user), + isDisplayed: ({ user }) => user.blocked }, { label: this.i18n('Set Email as Verified'), - handler: ({ user }: { user: User }) => this.setEmailAsVerified(user), - isDisplayed: ({ user }: { user: User }) => this.requiresEmailVerification && !user.blocked && user.emailVerified === false + handler: ({ user }) => this.setEmailAsVerified(user), + isDisplayed: ({ user }) => this.requiresEmailVerification && !user.blocked && user.emailVerified === false } ]) } @@ -299,23 +299,23 @@ export class UserModerationDropdownComponent implements OnChanges { this.userActions.push([ { label: this.i18n('Mute this account'), - isDisplayed: ({ account }: { account: Account }) => account.mutedByUser === false, - handler: ({ account }: { account: Account }) => this.blockAccountByUser(account) + isDisplayed: ({ account }) => account.mutedByUser === false, + handler: ({ account }) => this.blockAccountByUser(account) }, { label: this.i18n('Unmute this account'), - isDisplayed: ({ account }: { account: Account }) => account.mutedByUser === true, - handler: ({ account }: { account: Account }) => this.unblockAccountByUser(account) + isDisplayed: ({ account }) => account.mutedByUser === true, + handler: ({ account }) => this.unblockAccountByUser(account) }, { label: this.i18n('Mute the instance'), - isDisplayed: ({ account }: { account: Account }) => !account.userId && account.mutedServerByInstance === false, - handler: ({ account }: { account: Account }) => this.blockServerByUser(account.host) + isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, + handler: ({ account }) => this.blockServerByUser(account.host) }, { label: this.i18n('Unmute the instance'), - isDisplayed: ({ account }: { account: Account }) => !account.userId && account.mutedServerByInstance === true, - handler: ({ account }: { account: Account }) => this.unblockServerByUser(account.host) + isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, + handler: ({ account }) => this.unblockServerByUser(account.host) } ]) @@ -326,13 +326,13 @@ export class UserModerationDropdownComponent implements OnChanges { instanceActions = instanceActions.concat([ { label: this.i18n('Mute this account by your instance'), - isDisplayed: ({ account }: { account: Account }) => account.mutedByInstance === false, - handler: ({ account }: { account: Account }) => this.blockAccountByInstance(account) + isDisplayed: ({ account }) => account.mutedByInstance === false, + handler: ({ account }) => this.blockAccountByInstance(account) }, { label: this.i18n('Unmute this account by your instance'), - isDisplayed: ({ account }: { account: Account }) => account.mutedByInstance === true, - handler: ({ account }: { account: Account }) => this.unblockAccountByInstance(account) + isDisplayed: ({ account }) => account.mutedByInstance === true, + handler: ({ account }) => this.unblockAccountByInstance(account) } ]) } @@ -342,13 +342,13 @@ export class UserModerationDropdownComponent implements OnChanges { instanceActions = instanceActions.concat([ { label: this.i18n('Mute the instance by your instance'), - isDisplayed: ({ account }: { account: Account }) => !account.userId && account.mutedServerByInstance === false, - handler: ({ account }: { account: Account }) => this.blockServerByInstance(account.host) + isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false, + handler: ({ account }) => this.blockServerByInstance(account.host) }, { label: this.i18n('Unmute the instance by your instance'), - isDisplayed: ({ account }: { account: Account }) => !account.userId && account.mutedServerByInstance === true, - handler: ({ account }: { account: Account }) => this.unblockServerByInstance(account.host) + isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, + handler: ({ account }) => this.unblockServerByInstance(account.host) } ]) } -- cgit v1.2.3 From f8b2c1b4f509c037b9650cca2c5befd21f056df3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Dec 2018 16:04:34 +0100 Subject: Refractor notification service Shorter name and use primeng component --- .../shared/moderation/user-ban-modal.component.ts | 8 +- .../user-moderation-dropdown.component.ts | 86 +++++++--------------- 2 files changed, 30 insertions(+), 64 deletions(-) (limited to 'client/src/app/shared/moderation') diff --git a/client/src/app/shared/moderation/user-ban-modal.component.ts b/client/src/app/shared/moderation/user-ban-modal.component.ts index 60bd442dd..f755ba0e8 100644 --- a/client/src/app/shared/moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/moderation/user-ban-modal.component.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' @@ -23,7 +23,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, private modalService: NgbModal, - private notificationsService: NotificationsService, + private notifier: Notifier, private userService: UserService, private userValidatorsService: UserValidatorsService, private i18n: I18n @@ -57,13 +57,13 @@ export class UserBanModalComponent extends FormReactive implements OnInit { ? this.i18n('{{num}} users banned.', { num: this.usersToBan.length }) : this.i18n('User {{username}} banned.', { username: this.usersToBan.username }) - this.notificationsService.success(this.i18n('Success'), message) + this.notifier.success(message) this.userBanned.emit(this.usersToBan) this.hideBanUserModal() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts index e3c9db923..9a2461ebf 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts @@ -1,10 +1,9 @@ import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' import { I18n } from '@ngx-translate/i18n-polyfill' import { DropdownAction } from '@app/shared/buttons/action-dropdown.component' import { UserBanModalComponent } from '@app/shared/moderation/user-ban-modal.component' import { UserService } from '@app/shared/users' -import { AuthService, ConfirmService, ServerService } from '@app/core' +import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' import { User, UserRight } from '../../../../../shared/models/users' import { Account } from '@app/shared/account/account.model' import { BlocklistService } from '@app/shared/blocklist' @@ -30,7 +29,7 @@ export class UserModerationDropdownComponent implements OnChanges { constructor ( private authService: AuthService, - private notificationsService: NotificationsService, + private notifier: Notifier, private confirmService: ConfirmService, private serverService: ServerService, private userService: UserService, @@ -48,7 +47,7 @@ export class UserModerationDropdownComponent implements OnChanges { openBanUserModal (user: User) { if (user.username === 'root') { - this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot ban root.')) + this.notifier.error(this.i18n('You cannot ban root.')) return } @@ -67,21 +66,18 @@ export class UserModerationDropdownComponent implements OnChanges { this.userService.unbanUsers(user) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('User {{username}} unbanned.', { username: user.username }) - ) + this.notifier.success(this.i18n('User {{username}} unbanned.', { username: user.username })) this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } async removeUser (user: User) { if (user.username === 'root') { - this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot delete root.')) + this.notifier.error(this.i18n('You cannot delete root.')) return } @@ -91,29 +87,23 @@ export class UserModerationDropdownComponent implements OnChanges { this.userService.removeUser(user).subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('User {{username}} deleted.', { username: user.username }) - ) + this.notifier.success(this.i18n('User {{username}} deleted.', { username: user.username })) this.userDeleted.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } setEmailAsVerified (user: User) { this.userService.updateUser(user.id, { emailVerified: true }).subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('User {{username}} email set as verified', { username: user.username }) - ) + this.notifier.success(this.i18n('User {{username}} email set as verified', { username: user.username })) this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -121,16 +111,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.blockAccountByUser(account) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Account {{nameWithHost}} muted.', { nameWithHost: account.nameWithHost }) - ) + this.notifier.success(this.i18n('Account {{nameWithHost}} muted.', { nameWithHost: account.nameWithHost })) this.account.mutedByUser = true this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -138,16 +125,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.unblockAccountByUser(account) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: account.nameWithHost }) - ) + this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: account.nameWithHost })) this.account.mutedByUser = false this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -155,16 +139,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.blockServerByUser(host) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Instance {{host}} muted.', { host }) - ) + this.notifier.success(this.i18n('Instance {{host}} muted.', { host })) this.account.mutedServerByUser = true this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -172,16 +153,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.unblockServerByUser(host) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Instance {{host}} unmuted.', { host }) - ) + this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host })) this.account.mutedServerByUser = false this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -189,16 +167,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.blockAccountByInstance(account) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Account {{nameWithHost}} muted by the instance.', { nameWithHost: account.nameWithHost }) - ) + this.notifier.success(this.i18n('Account {{nameWithHost}} muted by the instance.', { nameWithHost: account.nameWithHost })) this.account.mutedByInstance = true this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -206,16 +181,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.unblockAccountByInstance(account) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Account {{nameWithHost}} unmuted by the instance.', { nameWithHost: account.nameWithHost }) - ) + this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted by the instance.', { nameWithHost: account.nameWithHost })) this.account.mutedByInstance = false this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -223,16 +195,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.blockServerByInstance(host) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Instance {{host}} muted by the instance.', { host }) - ) + this.notifier.success(this.i18n('Instance {{host}} muted by the instance.', { host })) this.account.mutedServerByInstance = true this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -240,16 +209,13 @@ export class UserModerationDropdownComponent implements OnChanges { this.blocklistService.unblockServerByInstance(host) .subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Instance {{host}} unmuted by the instance.', { host }) - ) + this.notifier.success(this.i18n('Instance {{host}} unmuted by the instance.', { host })) this.account.mutedServerByInstance = false this.userChanged.emit() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } -- cgit v1.2.3 From 457bb213b273a9b206cc5654eb085cede4e916ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 16 Jan 2019 16:05:40 +0100 Subject: Refactor how we use icons Inject them in an angular component so we can easily change their color --- client/src/app/shared/moderation/user-ban-modal.component.html | 7 ++++--- client/src/app/shared/moderation/user-ban-modal.component.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'client/src/app/shared/moderation') diff --git a/client/src/app/shared/moderation/user-ban-modal.component.html b/client/src/app/shared/moderation/user-ban-modal.component.html index fa5cb7404..f38ea543d 100644 --- a/client/src/app/shared/moderation/user-ban-modal.component.html +++ b/client/src/app/shared/moderation/user-ban-modal.component.html @@ -1,7 +1,8 @@
- Cancel + Cancel
-
\ No newline at end of file + diff --git a/client/src/app/shared/moderation/user-ban-modal.component.ts b/client/src/app/shared/moderation/user-ban-modal.component.ts index f755ba0e8..942765301 100644 --- a/client/src/app/shared/moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/moderation/user-ban-modal.component.ts @@ -42,7 +42,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { this.openedModal = this.modalService.open(this.modal) } - hideBanUserModal () { + hide () { this.usersToBan = undefined this.openedModal.close() } @@ -60,7 +60,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { this.notifier.success(message) this.userBanned.emit(this.usersToBan) - this.hideBanUserModal() + this.hide() }, err => this.notifier.error(err.message) -- cgit v1.2.3