From 073deef8862f462de5f159a57877ef415ebe4c69 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Jul 2022 11:05:32 +0200 Subject: Handle rejected follows in client Also add quick filters so it's easier to find pending follows --- .../followers-list/followers-list.component.html | 19 +++++----- .../followers-list/followers-list.component.ts | 7 +++- .../following-list/following-list.component.html | 13 ++++--- .../following-list/following-list.component.ts | 5 +++ .../shared-instance/instance-follow.service.ts | 41 ++++++++++++++++++++-- 5 files changed, 64 insertions(+), 21 deletions(-) (limited to 'client/src') 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 @@
- +
@@ -31,12 +31,10 @@ - - - - + + - + @@ -45,11 +43,10 @@ - - Accepted - - - Pending + + Accepted + Pending + Rejected {{ follow.score }} 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 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' +import { AdvancedInputFilter } from '@app/shared/shared-forms' import { InstanceFollowService } from '@app/shared/shared-instance' import { ActorFollow } from '@shared/models' @@ -15,12 +16,16 @@ export class FollowersListComponent extends RestTable implements OnInit { sort: SortMeta = { field: 'createdAt', order: -1 } pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + searchFilters: AdvancedInputFilter[] + constructor ( private confirmService: ConfirmService, private notifier: Notifier, private followService: InstanceFollowService ) { super() + + this.searchFilters = this.followService.buildFollowsListFilters() } ngOnInit () { @@ -70,7 +75,7 @@ export class FollowersListComponent extends RestTable implements OnInit { } async deleteFollower (follow: ActorFollow) { - const message = $localize`Do you really want to delete this follower?` + const message = $localize`Do you really want to delete this follower? It will be able to send again another follow request.` const res = await this.confirmService.confirm(message, $localize`Delete`) if (res === false) return 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 @@
- +
@@ -47,11 +47,10 @@ - - Accepted - - - Pending + + Accepted + Pending + Rejected {{ follow.createdAt | date: 'short' }} @@ -66,7 +65,7 @@ - +
No host found matching current filters. Your instance is not following anyone. 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 @@ import { SortMeta } from 'primeng/api' import { Component, OnInit, ViewChild } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' +import { AdvancedInputFilter } from '@app/shared/shared-forms' import { InstanceFollowService } from '@app/shared/shared-instance' import { ActorFollow } from '@shared/models' import { FollowModalComponent } from './follow-modal.component' @@ -17,12 +18,16 @@ export class FollowingListComponent extends RestTable implements OnInit { sort: SortMeta = { field: 'createdAt', order: -1 } pagination: RestPagination = { count: this.rowsPerPage, start: 0 } + searchFilters: AdvancedInputFilter[] + constructor ( private notifier: Notifier, private confirmService: ConfirmService, private followService: InstanceFollowService ) { super() + + this.searchFilters = this.followService.buildFollowsListFilters() } 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' import { RestExtractor, RestPagination, RestService } from '@app/core' import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' import { environment } from '../../../environments/environment' +import { AdvancedInputFilter } from '../shared-forms' @Injectable() export class InstanceFollowService { @@ -30,7 +31,10 @@ export class InstanceFollowService { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - if (search) params = params.append('search', search) + if (search) { + params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search)) + } + if (state) params = params.append('state', state) if (actorType) params = params.append('actorType', actorType) @@ -53,7 +57,10 @@ export class InstanceFollowService { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - if (search) params = params.append('search', search) + if (search) { + params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search)) + } + if (state) params = params.append('state', state) if (actorType) params = params.append('actorType', actorType) @@ -101,4 +108,34 @@ export class InstanceFollowService { return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) .pipe(catchError(res => this.restExtractor.handleError(res))) } + + buildFollowsListFilters (): AdvancedInputFilter[] { + return [ + { + title: $localize`Advanced filters`, + children: [ + { + value: 'state:accepted', + label: $localize`Accepted follows` + }, + { + value: 'state:rejected', + label: $localize`Rejected follows` + }, + { + value: 'state:pending', + label: $localize`Pending follows` + } + ] + } + ] + } + + private parseFollowsListFilters (search: string) { + return this.restService.parseQueryStringFilter(search, { + state: { + prefix: 'state:' + } + }) + } } -- cgit v1.2.3