From 228393302d98136d4dc35c5f197edc8cebd5d64f Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 15 Jun 2020 13:18:22 +0200 Subject: factorize account/server blocklists for users and instance (#2875) --- .../my-account-blocklist.component.html | 27 ---------- .../my-account-blocklist.component.scss | 7 --- .../my-account-blocklist.component.ts | 56 +++------------------ .../my-account-server-blocklist.component.html | 27 ---------- .../my-account-server-blocklist.component.scss | 7 --- .../my-account-server-blocklist.component.ts | 57 +++------------------- .../app/+my-account/my-account-routing.module.ts | 2 +- client/src/app/+my-account/my-account.component.ts | 2 +- 8 files changed, 14 insertions(+), 171 deletions(-) delete mode 100644 client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html delete mode 100644 client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss delete mode 100644 client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html delete mode 100644 client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss (limited to 'client/src/app/+my-account') diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html deleted file mode 100644 index 90f657521..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.html +++ /dev/null @@ -1,27 +0,0 @@ -
-

Muted accounts

-
- - - - - - Account - Muted at - - - - - - - {{ accountBlock.blockedAccount.nameWithHost }} - {{ accountBlock.createdAt }} - - - - - - diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss deleted file mode 100644 index 6028b75ea..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.unblock-button { - @include peertube-button; - @include grey-button; -} \ No newline at end of file diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts index fd1fabcdb..e48c39cdf 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts @@ -1,59 +1,15 @@ -import { Component, OnInit } from '@angular/core' -import { Notifier } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { RestPagination, RestTable } from '@app/shared' -import { SortMeta } from 'primeng/api' -import { AccountBlock, BlocklistService } from '@app/shared/blocklist' +import { Component } from '@angular/core' +import { GenericAccountBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist' @Component({ selector: 'my-account-blocklist', - styleUrls: [ './my-account-blocklist.component.scss' ], - templateUrl: './my-account-blocklist.component.html' + styleUrls: [ '../../shared/blocklist/account-blocklist.component.scss' ], + templateUrl: '../../shared/blocklist/account-blocklist.component.html' }) -export class MyAccountBlocklistComponent extends RestTable implements OnInit { - blockedAccounts: AccountBlock[] = [] - totalRecords = 0 - sort: SortMeta = { field: 'createdAt', order: -1 } - pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - - constructor ( - private notifier: Notifier, - private blocklistService: BlocklistService, - private i18n: I18n - ) { - super() - } - - ngOnInit () { - this.initialize() - } +export class MyAccountBlocklistComponent extends GenericAccountBlocklistComponent { + mode = BlocklistComponentType.Account getIdentifier () { return 'MyAccountBlocklistComponent' } - - unblockAccount (accountBlock: AccountBlock) { - const blockedAccount = accountBlock.blockedAccount - - this.blocklistService.unblockAccountByUser(blockedAccount) - .subscribe( - () => { - this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })) - - this.loadData() - } - ) - } - - protected loadData () { - return this.blocklistService.getUserAccountBlocklist(this.pagination, this.sort) - .subscribe( - resultList => { - this.blockedAccounts = resultList.data - this.totalRecords = resultList.total - }, - - err => this.notifier.error(err.message) - ) - } } diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html deleted file mode 100644 index c31cff16f..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.html +++ /dev/null @@ -1,27 +0,0 @@ -
-

Muted instances

-
- - - - - - Instance - Muted at - - - - - - - {{ serverBlock.blockedServer.host }} - {{ serverBlock.createdAt }} - - - - - - diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss deleted file mode 100644 index 6028b75ea..000000000 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.unblock-button { - @include peertube-button; - @include grey-button; -} \ No newline at end of file diff --git a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts index 483c11804..cfaba1c7b 100644 --- a/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts +++ b/client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts @@ -1,60 +1,15 @@ -import { Component, OnInit } from '@angular/core' -import { Notifier } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { RestPagination, RestTable } from '@app/shared' -import { SortMeta } from 'primeng/api' -import { ServerBlock } from '../../../../../shared' -import { BlocklistService } from '@app/shared/blocklist' +import { Component } from '@angular/core' +import { GenericServerBlocklistComponent, BlocklistComponentType } from '@app/shared/blocklist' @Component({ selector: 'my-account-server-blocklist', - styleUrls: [ './my-account-server-blocklist.component.scss' ], - templateUrl: './my-account-server-blocklist.component.html' + styleUrls: [ '../../+admin/moderation/moderation.component.scss', '../../shared/blocklist/server-blocklist.component.scss' ], + templateUrl: '../../shared/blocklist/server-blocklist.component.html' }) -export class MyAccountServerBlocklistComponent extends RestTable implements OnInit { - blockedServers: ServerBlock[] = [] - totalRecords = 0 - sort: SortMeta = { field: 'createdAt', order: -1 } - pagination: RestPagination = { count: this.rowsPerPage, start: 0 } - - constructor ( - private notifier: Notifier, - private blocklistService: BlocklistService, - private i18n: I18n - ) { - super() - } - - ngOnInit () { - this.initialize() - } +export class MyAccountServerBlocklistComponent extends GenericServerBlocklistComponent { + mode = BlocklistComponentType.Account getIdentifier () { return 'MyAccountServerBlocklistComponent' } - - unblockServer (serverBlock: ServerBlock) { - const host = serverBlock.blockedServer.host - - this.blocklistService.unblockServerByUser(host) - .subscribe( - () => { - this.notifier.success(this.i18n('Instance {{host}} unmuted.', { host })) - - this.loadData() - } - ) - } - - protected loadData () { - return this.blocklistService.getUserServerBlocklist(this.pagination, this.sort) - .subscribe( - resultList => { - this.blockedServers = resultList.data - this.totalRecords = resultList.total - }, - - err => this.notifier.error(err.message) - ) - } } diff --git a/client/src/app/+my-account/my-account-routing.module.ts b/client/src/app/+my-account/my-account-routing.module.ts index f44b60ec9..f6b711e09 100644 --- a/client/src/app/+my-account/my-account-routing.module.ts +++ b/client/src/app/+my-account/my-account-routing.module.ts @@ -140,7 +140,7 @@ const myAccountRoutes: Routes = [ component: MyAccountServerBlocklistComponent, data: { meta: { - title: 'Muted instances' + title: 'Muted servers' } } }, diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts index 05dcf522d..ca447c054 100644 --- a/client/src/app/+my-account/my-account.component.ts +++ b/client/src/app/+my-account/my-account.component.ts @@ -72,7 +72,7 @@ export class MyAccountComponent implements OnInit { iconName: 'user' }, { - label: this.i18n('Muted instances'), + label: this.i18n('Muted servers'), routerLink: '/my-account/blocklist/servers', iconName: 'server' }, -- cgit v1.2.3