aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-27 11:05:32 +0200
committerChocobozzz <me@florianbigard.com>2022-07-27 13:52:13 +0200
commit073deef8862f462de5f159a57877ef415ebe4c69 (patch)
tree256d5ff4483ef68b07754f767626a72ac793bd5f /client
parent3267d381f4fdd128b2f948670b2e2ba765145276 (diff)
downloadPeerTube-073deef8862f462de5f159a57877ef415ebe4c69.tar.gz
PeerTube-073deef8862f462de5f159a57877ef415ebe4c69.tar.zst
PeerTube-073deef8862f462de5f159a57877ef415ebe4c69.zip
Handle rejected follows in client
Also add quick filters so it's easier to find pending follows
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.html19
-rw-r--r--client/src/app/+admin/follows/followers-list/followers-list.component.ts7
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.html13
-rw-r--r--client/src/app/+admin/follows/following-list/following-list.component.ts5
-rw-r--r--client/src/app/shared/shared-instance/instance-follow.service.ts41
5 files changed, 64 insertions, 21 deletions
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html
index 3081098c4..4f11f261d 100644
--- a/client/src/app/+admin/follows/followers-list/followers-list.component.html
+++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html
@@ -13,7 +13,7 @@
13 <ng-template pTemplate="caption"> 13 <ng-template pTemplate="caption">
14 <div class="caption"> 14 <div class="caption">
15 <div class="ms-auto"> 15 <div class="ms-auto">
16 <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter> 16 <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter>
17 </div> 17 </div>
18 </div> 18 </div>
19 </ng-template> 19 </ng-template>
@@ -31,12 +31,10 @@
31 <ng-template pTemplate="body" let-follow> 31 <ng-template pTemplate="body" let-follow>
32 <tr> 32 <tr>
33 <td class="action-cell"> 33 <td class="action-cell">
34 <ng-container *ngIf="follow.state === 'pending'"> 34 <my-button *ngIf="follow.state !== 'accepted'" i18n-title title="Accept" icon="tick" (click)="acceptFollower(follow)"></my-button>
35 <my-button i18n-title title="Accept" icon="tick" (click)="acceptFollower(follow)"></my-button> 35 <my-button *ngIf="follow.state !== 'rejected'" i18n-title title="Refuse" icon="cross" (click)="rejectFollower(follow)"></my-button>
36 <my-button i18n-title title="Refuse" icon="cross" (click)="rejectFollower(follow)"></my-button>
37 </ng-container>
38 36
39 <my-delete-button label *ngIf="follow.state === 'accepted'" (click)="deleteFollower(follow)"></my-delete-button> 37 <my-delete-button *ngIf="follow.state === 'rejected'" (click)="deleteFollower(follow)"></my-delete-button>
40 </td> 38 </td>
41 <td> 39 <td>
42 <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer"> 40 <a [href]="follow.follower.url" i18n-title title="Open actor page in a new tab" target="_blank" rel="noopener noreferrer">
@@ -45,11 +43,10 @@
45 </a> 43 </a>
46 </td> 44 </td>
47 45
48 <td *ngIf="follow.state === 'accepted'"> 46 <td>
49 <span class="pt-badge badge-green" i18n>Accepted</span> 47 <span *ngIf="follow.state === 'accepted'" class="pt-badge badge-green" i18n>Accepted</span>
50 </td> 48 <span *ngIf="follow.state === 'pending'" class="pt-badge badge-yellow" i18n>Pending</span>
51 <td *ngIf="follow.state === 'pending'"> 49 <span *ngIf="follow.state === 'rejected'" class="pt-badge badge-red" i18n>Rejected</span>
52 <span class="pt-badge badge-yellow" i18n>Pending</span>
53 </td> 50 </td>
54 51
55 <td>{{ follow.score }}</td> 52 <td>{{ follow.score }}</td>
diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts
index 329e3bcc7..d09e74fef 100644
--- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts
+++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts
@@ -1,6 +1,7 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' 3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4import { AdvancedInputFilter } from '@app/shared/shared-forms'
4import { InstanceFollowService } from '@app/shared/shared-instance' 5import { InstanceFollowService } from '@app/shared/shared-instance'
5import { ActorFollow } from '@shared/models' 6import { ActorFollow } from '@shared/models'
6 7
@@ -15,12 +16,16 @@ export class FollowersListComponent extends RestTable implements OnInit {
15 sort: SortMeta = { field: 'createdAt', order: -1 } 16 sort: SortMeta = { field: 'createdAt', order: -1 }
16 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
17 18
19 searchFilters: AdvancedInputFilter[]
20
18 constructor ( 21 constructor (
19 private confirmService: ConfirmService, 22 private confirmService: ConfirmService,
20 private notifier: Notifier, 23 private notifier: Notifier,
21 private followService: InstanceFollowService 24 private followService: InstanceFollowService
22 ) { 25 ) {
23 super() 26 super()
27
28 this.searchFilters = this.followService.buildFollowsListFilters()
24 } 29 }
25 30
26 ngOnInit () { 31 ngOnInit () {
@@ -70,7 +75,7 @@ export class FollowersListComponent extends RestTable implements OnInit {
70 } 75 }
71 76
72 async deleteFollower (follow: ActorFollow) { 77 async deleteFollower (follow: ActorFollow) {
73 const message = $localize`Do you really want to delete this follower?` 78 const message = $localize`Do you really want to delete this follower? It will be able to send again another follow request.`
74 const res = await this.confirmService.confirm(message, $localize`Delete`) 79 const res = await this.confirmService.confirm(message, $localize`Delete`)
75 if (res === false) return 80 if (res === false) return
76 81
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html
index 302dc9528..856c4a31f 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.html
+++ b/client/src/app/+admin/follows/following-list/following-list.component.html
@@ -20,7 +20,7 @@
20 </div> 20 </div>
21 21
22 <div class="ms-auto"> 22 <div class="ms-auto">
23 <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter> 23 <my-advanced-input-filter [filters]="searchFilters" (search)="onSearch($event)"></my-advanced-input-filter>
24 </div> 24 </div>
25 </div> 25 </div>
26 </ng-template> 26 </ng-template>
@@ -47,11 +47,10 @@
47 </a> 47 </a>
48 </td> 48 </td>
49 49
50 <td *ngIf="follow.state === 'accepted'"> 50 <td>
51 <span class="pt-badge badge-green" i18n>Accepted</span> 51 <span *ngIf="follow.state === 'accepted'" class="pt-badge badge-green" i18n>Accepted</span>
52 </td> 52 <span *ngIf="follow.state === 'pending'" class="pt-badge badge-yellow" i18n>Pending</span>
53 <td *ngIf="follow.state === 'pending'"> 53 <span *ngIf="follow.state === 'rejected'" class="pt-badge badge-red" i18n>Rejected</span>
54 <span class="pt-badge badge-yellow" i18n>Pending</span>
55 </td> 54 </td>
56 55
57 <td>{{ follow.createdAt | date: 'short' }}</td> 56 <td>{{ follow.createdAt | date: 'short' }}</td>
@@ -66,7 +65,7 @@
66 65
67 <ng-template pTemplate="emptymessage"> 66 <ng-template pTemplate="emptymessage">
68 <tr> 67 <tr>
69 <td colspan="6"> 68 <td colspan="5">
70 <div class="no-results"> 69 <div class="no-results">
71 <ng-container *ngIf="search" i18n>No host found matching current filters.</ng-container> 70 <ng-container *ngIf="search" i18n>No host found matching current filters.</ng-container>
72 <ng-container *ngIf="!search" i18n>Your instance is not following anyone.</ng-container> 71 <ng-container *ngIf="!search" i18n>Your instance is not following anyone.</ng-container>
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts
index 2c0f6db0c..7a854be81 100644
--- a/client/src/app/+admin/follows/following-list/following-list.component.ts
+++ b/client/src/app/+admin/follows/following-list/following-list.component.ts
@@ -1,6 +1,7 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { Component, OnInit, ViewChild } from '@angular/core' 2import { Component, OnInit, ViewChild } from '@angular/core'
3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' 3import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4import { AdvancedInputFilter } from '@app/shared/shared-forms'
4import { InstanceFollowService } from '@app/shared/shared-instance' 5import { InstanceFollowService } from '@app/shared/shared-instance'
5import { ActorFollow } from '@shared/models' 6import { ActorFollow } from '@shared/models'
6import { FollowModalComponent } from './follow-modal.component' 7import { FollowModalComponent } from './follow-modal.component'
@@ -17,12 +18,16 @@ export class FollowingListComponent extends RestTable implements OnInit {
17 sort: SortMeta = { field: 'createdAt', order: -1 } 18 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 } 19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
19 20
21 searchFilters: AdvancedInputFilter[]
22
20 constructor ( 23 constructor (
21 private notifier: Notifier, 24 private notifier: Notifier,
22 private confirmService: ConfirmService, 25 private confirmService: ConfirmService,
23 private followService: InstanceFollowService 26 private followService: InstanceFollowService
24 ) { 27 ) {
25 super() 28 super()
29
30 this.searchFilters = this.followService.buildFollowsListFilters()
26 } 31 }
27 32
28 ngOnInit () { 33 ngOnInit () {
diff --git a/client/src/app/shared/shared-instance/instance-follow.service.ts b/client/src/app/shared/shared-instance/instance-follow.service.ts
index a83f7c4ad..06484d938 100644
--- a/client/src/app/shared/shared-instance/instance-follow.service.ts
+++ b/client/src/app/shared/shared-instance/instance-follow.service.ts
@@ -6,6 +6,7 @@ import { Injectable } from '@angular/core'
6import { RestExtractor, RestPagination, RestService } from '@app/core' 6import { RestExtractor, RestPagination, RestService } from '@app/core'
7import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' 7import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models'
8import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
9import { AdvancedInputFilter } from '../shared-forms'
9 10
10@Injectable() 11@Injectable()
11export class InstanceFollowService { 12export class InstanceFollowService {
@@ -30,7 +31,10 @@ export class InstanceFollowService {
30 let params = new HttpParams() 31 let params = new HttpParams()
31 params = this.restService.addRestGetParams(params, pagination, sort) 32 params = this.restService.addRestGetParams(params, pagination, sort)
32 33
33 if (search) params = params.append('search', search) 34 if (search) {
35 params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search))
36 }
37
34 if (state) params = params.append('state', state) 38 if (state) params = params.append('state', state)
35 if (actorType) params = params.append('actorType', actorType) 39 if (actorType) params = params.append('actorType', actorType)
36 40
@@ -53,7 +57,10 @@ export class InstanceFollowService {
53 let params = new HttpParams() 57 let params = new HttpParams()
54 params = this.restService.addRestGetParams(params, pagination, sort) 58 params = this.restService.addRestGetParams(params, pagination, sort)
55 59
56 if (search) params = params.append('search', search) 60 if (search) {
61 params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search))
62 }
63
57 if (state) params = params.append('state', state) 64 if (state) params = params.append('state', state)
58 if (actorType) params = params.append('actorType', actorType) 65 if (actorType) params = params.append('actorType', actorType)
59 66
@@ -101,4 +108,34 @@ export class InstanceFollowService {
101 return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) 108 return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`)
102 .pipe(catchError(res => this.restExtractor.handleError(res))) 109 .pipe(catchError(res => this.restExtractor.handleError(res)))
103 } 110 }
111
112 buildFollowsListFilters (): AdvancedInputFilter[] {
113 return [
114 {
115 title: $localize`Advanced filters`,
116 children: [
117 {
118 value: 'state:accepted',
119 label: $localize`Accepted follows`
120 },
121 {
122 value: 'state:rejected',
123 label: $localize`Rejected follows`
124 },
125 {
126 value: 'state:pending',
127 label: $localize`Pending follows`
128 }
129 ]
130 }
131 ]
132 }
133
134 private parseFollowsListFilters (search: string) {
135 return this.restService.parseQueryStringFilter(search, {
136 state: {
137 prefix: 'state:'
138 }
139 })
140 }
104} 141}