Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Rename whitelist to safelist #147

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/app/action-log/pages/action-log/action-log.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ <h3 class="card-title">{{"app.filter.title" | transloco}}</h3>
<option [value]="ActionLogReportActivity.Modified">{{"app.action_log.activity.modified" | transloco}}</option>
</select>
</div>
<div class="form-group" *ngIf="whitelistedDomains">
<div class="form-group" *ngIf="safelistedDomains">
<label for="inputSourceDomains">{{"app.source_domains" | transloco}}</label>
<select id="inputSourceDomains" formControlName="sourceDomains" multiple tom-select [maxItems]="null" [create]="true">
<option *ngFor="let option of whitelistedDomains" [value]="option">{{option}}</option>
<option *ngFor="let option of safelistedDomains" [value]="option">{{option}}</option>
</select>
</div>
<div class="form-group" *ngIf="whitelistedDomains && blacklistedDomains">
<div class="form-group" *ngIf="safelistedDomains && blacklistedDomains">
<label for="inputTargetDomains">{{"app.target_domains" | transloco}}</label>
<select id="inputTargetDomains" formControlName="targetDomains" multiple tom-select [maxItems]="null" [create]="true">
<option *ngFor="let option of blacklistedDomains" [value]="option">{{option}}</option>
<option *ngFor="let option of whitelistedDomains" [value]="option">{{option}}</option>
<option *ngFor="let option of safelistedDomains" [value]="option">{{option}}</option>
</select>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/action-log/pages/action-log/action-log.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ActionLogComponent implements OnInit {
public currentPage: int = 1;
public lastPageReached: boolean = false;

public whitelistedDomains: string[] | null = null;
public safelistedDomains: string[] | null = null;
public blacklistedDomains: string[] | null = null;

public form = new FormGroup({
Expand All @@ -58,7 +58,7 @@ export class ActionLogComponent implements OnInit {
this.titleService.title = this.translator.get('app.action_log');

Promise.all([
toPromise(this.cachedApi.getWhitelistedInstances().pipe(
toPromise(this.cachedApi.getSafelistedInstances().pipe(
map (response => {
if (this.apiResponseHelper.handleErrors([response])) {
return [];
Expand All @@ -77,7 +77,7 @@ export class ActionLogComponent implements OnInit {
}),
)),
]).then(responses => {
this.whitelistedDomains = responses[0];
this.safelistedDomains = responses[0];
this.blacklistedDomains = responses[1];

this.filtersLoading = false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</a>
</li>
<li class="nav-item">
<a routerLink="/instances/whitelisted" class="nav-link">
<a routerLink="/instances/safelisted" class="nav-link">
<i class="nav-icon fas fa-thumbs-up"></i>
<p>
{{ "app.sidebar.guaranteed_instances" | transloco }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class GuaranteeInstanceComponent implements OnInit {
this.loading = false;
this.router.navigateByUrl('/guarantees/my').then(() => {
this.messageService.createSuccess(`${this.form.controls.instance.value} was successfully guaranteed!`);
this.cachedApi.clearWhitelistCache();
this.cachedApi.clearSafelistCache();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class MyGuaranteesComponent implements OnInit {
this.instancesGuaranteedByMe = this.instancesGuaranteedByMe.filter(
guaranteedInstance => guaranteedInstance.domain !== instance,
);
this.cachedApi.clearWhitelistCache();
this.cachedApi.clearSafelistCache();
this.cachedApi.getGuaranteesByInstance(this.instance.name).subscribe();
});
}
Expand Down
12 changes: 9 additions & 3 deletions src/app/instances/instances.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule, Routes} from "@angular/router";
import {WhitelistedInstancesComponent} from './pages/whitelisted-instances/whitelisted-instances.component';
import {SafelistedInstancesComponent} from './pages/safelisted-instances/safelisted-instances.component';
import {InstanceDetailComponent} from './pages/instance-detail/instance-detail.component';
import {SuspiciousInstancesComponent} from './pages/suspicious-instances/suspicious-instances.component';
import {SharedModule} from "../shared/shared.module";
Expand All @@ -14,11 +14,16 @@ import {
SuspiciousInstanceDetailComponent
} from './pages/suspicious-instance-detail/suspicious-instance-detail.component';
import {ResetInstanceTokenComponent} from './pages/reset-instance-token/reset-instance-token.component';
import {RedirectWhitelistComponent} from './pages/redirect-whitelist/redirect-whitelist.component';

const routes: Routes = [
{
path: 'safelisted',
component: SafelistedInstancesComponent,
},
{
path: 'whitelisted',
component: WhitelistedInstancesComponent,
component: RedirectWhitelistComponent,
},
{
path: 'suspicious',
Expand Down Expand Up @@ -54,14 +59,15 @@ const routes: Routes = [

@NgModule({
declarations: [
WhitelistedInstancesComponent,
SafelistedInstancesComponent,
InstanceDetailComponent,
SuspiciousInstancesComponent,
CensuredInstancesComponent,
EditOwnInstanceComponent,
HesitatedInstancesComponent,
SuspiciousInstanceDetailComponent,
ResetInstanceTokenComponent,
RedirectWhitelistComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div class="form-group">
<label for="inputFilterInstances">Include instances censured by</label>
<select id="inputFilterInstances" tom-select [maxItems]="null" multiple formControlName="instances">
<option [value]="filterInstanceSpecialValueAll">All whitelisted instances</option>
<option *ngFor="let option of allWhitelistedInstances" [value]="option.domain">{{option.domain}}</option>
<option [value]="filterInstanceSpecialValueAll">All safelisted instances</option>
<option *ngFor="let option of allSafelistedInstances" [value]="option.domain">{{option.domain}}</option>
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CensuredInstancesComponent implements OnInit {
public currentPage = 1;
public pages: number[] = [];
public loading: boolean = true;
public allWhitelistedInstances: InstanceDetailResponse[] = [];
public allSafelistedInstances: InstanceDetailResponse[] = [];

public filterForm = new FormGroup({
instances: new FormControl<string[]>(environment.defaultCensuresListInstanceFilter),
Expand Down Expand Up @@ -72,12 +72,12 @@ export class CensuredInstancesComponent implements OnInit {
this.censuredByMe = response.successResponse!.instances.map(instance => instance.domain);
}

const allWhitelistedInstancesResponse = await toPromise(this.cachedApi.getWhitelistedInstances());
if (this.apiResponseHelper.handleErrors([allWhitelistedInstancesResponse])) {
const allSafelistedInstancesResponse = await toPromise(this.cachedApi.getSafelistedInstances());
if (this.apiResponseHelper.handleErrors([allSafelistedInstancesResponse])) {
this.loading = false;
return;
}
this.allWhitelistedInstances = allWhitelistedInstancesResponse.successResponse!.instances;
this.allSafelistedInstances = allSafelistedInstancesResponse.successResponse!.instances;

const storedFilters = this.database.censureListFilters;
if (!storedFilters.instances.length) {
Expand Down Expand Up @@ -161,9 +161,9 @@ export class CensuredInstancesComponent implements OnInit {
sourceInstances = environment.defaultCensuresListInstanceFilter;
}
if (sourceInstances.indexOf(this.filterInstanceSpecialValueAll) > -1) {
sourceInstances = this.allWhitelistedInstances.map(instance => instance.domain);
sourceInstances = this.allSafelistedInstances.map(instance => instance.domain);
} else {
const allInstancesString = this.allWhitelistedInstances.map(instance => instance.domain);
const allInstancesString = this.allSafelistedInstances.map(instance => instance.domain);
sourceInstances = sourceInstances.filter(instance => allInstancesString.indexOf(instance) > -1);
if (this.filterForm.controls.includeEndorsed.value) {
const endorsedResponse = await toPromise(this.cachedApi.getEndorsementsByInstances(sourceInstances));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class EditOwnInstanceComponent implements OnInit {
return;
}

this.cachedApi.clearWhitelistCache();
this.cachedApi.clearSafelistCache();
this.cachedApi.getAvailableTags({clear: true}).subscribe();
this.cachedApi.getCurrentInstanceInfo(null, {clear: true}).subscribe();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div class="form-group">
<label for="inputFilterInstances">Include instances hesitated on by</label>
<select id="inputFilterInstances" tom-select [maxItems]="null" multiple formControlName="instances">
<option [value]="filterInstanceSpecialValueAll">All whitelisted instances</option>
<option *ngFor="let option of allWhitelistedInstances" [value]="option.domain">{{option.domain}}</option>
<option [value]="filterInstanceSpecialValueAll">All safelisted instances</option>
<option *ngFor="let option of allSafelistedInstances" [value]="option.domain">{{option.domain}}</option>
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class HesitatedInstancesComponent {
public currentPage = 1;
public pages: number[] = [];
public loading: boolean = true;
public allWhitelistedInstances: InstanceDetailResponse[] = [];
public allSafelistedInstances: InstanceDetailResponse[] = [];

public filterForm = new FormGroup({
instances: new FormControl<string[]>(environment.defaultCensuresListInstanceFilter),
Expand Down Expand Up @@ -72,12 +72,12 @@ export class HesitatedInstancesComponent {
this.hesitatedByMe = response.successResponse!.instances.map(instance => instance.domain);
}

const allWhitelistedInstancesResponse = await toPromise(this.cachedApi.getWhitelistedInstances());
if (this.apiResponseHelper.handleErrors([allWhitelistedInstancesResponse])) {
const allSafelistedInstancesResponse = await toPromise(this.cachedApi.getSafelistedInstances());
if (this.apiResponseHelper.handleErrors([allSafelistedInstancesResponse])) {
this.loading = false;
return;
}
this.allWhitelistedInstances = allWhitelistedInstancesResponse.successResponse!.instances;
this.allSafelistedInstances = allSafelistedInstancesResponse.successResponse!.instances;

const storedFilters = this.database.censureListFilters;
if (!storedFilters.instances.length) {
Expand Down Expand Up @@ -157,9 +157,9 @@ export class HesitatedInstancesComponent {
sourceInstances = environment.defaultCensuresListInstanceFilter;
}
if (sourceInstances.indexOf(this.filterInstanceSpecialValueAll) > -1) {
sourceInstances = this.allWhitelistedInstances.map(instance => instance.domain);
sourceInstances = this.allSafelistedInstances.map(instance => instance.domain);
} else {
const allInstancesString = this.allWhitelistedInstances.map(instance => instance.domain);
const allInstancesString = this.allSafelistedInstances.map(instance => instance.domain);
sourceInstances = sourceInstances.filter(instance => allInstancesString.indexOf(instance) > -1);
if (this.filterForm.controls.includeEndorsed.value) {
const endorsedResponse = await toPromise(this.cachedApi.getEndorsementsByInstances(sourceInstances));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h3 class="card-title" id="instance-details">Instance details</h3>
<td>
<code *ngIf="!detail.tags.length">N/A</code>
<ng-container *ngIf="detail.tags.length">
<a routerLink="/instances/whitelisted" [queryParams]="{tags: tag}" class="btn btn-sm btn-outline-primary" *ngFor="let tag of detail.tags">
<a routerLink="/instances/safelisted" [queryParams]="{tags: tag}" class="btn btn-sm btn-outline-primary" *ngFor="let tag of detail.tags">
{{tag}}
</a>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>redirect-whitelist works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";

@Component({
selector: 'app-redirect-whitelist',
templateUrl: './redirect-whitelist.component.html',
styleUrls: ['./redirect-whitelist.component.scss']
})
export class RedirectWhitelistComponent implements OnInit {
constructor(
private readonly router: Router,
private readonly activatedRoute: ActivatedRoute,
) {
}

public ngOnInit(): void {
this.router.navigate(['/instances/safelisted'], {
queryParams: this.activatedRoute.snapshot.queryParams,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</form>
<!-- end filters -->
<p *ngIf="!currentInstance.anonymous">
If you're looking for managing of your own whitelist, go to <a routerLink="/endorsements/my">your endorsements</a>.
You might also be looking to manage <a routerLink="/endorsements/my">your endorsements</a>.
</p>
<table class="table table-bordered">
<thead>
Expand Down Expand Up @@ -87,7 +87,7 @@
<td>
<code *ngIf="!instance.tags.length">N/A</code>
<ng-container *ngIf="instance.tags.length">
<a routerLink="/instances/whitelisted" [queryParams]="{tags: tag}" class="btn btn-sm btn-outline-primary" *ngFor="let tag of instance.tags">
<a routerLink="/instances/safelisted" [queryParams]="{tags: tag}" class="btn btn-sm btn-outline-primary" *ngFor="let tag of instance.tags">
{{tag}}
</a>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import {Instance} from "../../../user/instance";
import {SuccessResponse} from "../../../response/success.response";
import {ApiResponseHelperService} from "../../../services/api-response-helper.service";
import {CachedFediseerApiService} from "../../../services/cached-fediseer-api.service";
import {WhitelistFilter} from "../../../types/whitelist-filter";
import {SafelistFilter} from "../../../types/safelist-filter";
import {FormControl, FormGroup, Validators} from "@angular/forms";
import {int} from "../../../types/number";

@Component({
selector: 'app-whitelisted-instances',
templateUrl: './whitelisted-instances.component.html',
styleUrls: ['./whitelisted-instances.component.scss']
selector: 'app-safelisted-instances',
templateUrl: './safelisted-instances.component.html',
styleUrls: ['./safelisted-instances.component.scss']
})
export class WhitelistedInstancesComponent implements OnInit {
export class SafelistedInstancesComponent implements OnInit {
private readonly perPage = 30;

private allInstances: InstanceDetailResponse[] = [];
Expand Down Expand Up @@ -54,14 +54,14 @@ export class WhitelistedInstancesComponent implements OnInit {
}

public async ngOnInit(): Promise<void> {
this.titleService.title = 'Whitelisted instances';
this.titleService.title = 'Safelisted instances';

this.activatedRoute.queryParams.subscribe(async queryParams => {
this.loading = true;
this.currentPage = queryParams['page'] ? Number(queryParams['page']) : 1;
this.pages = [];

const filters: WhitelistFilter = {};
const filters: SafelistFilter = {};
if (queryParams['tags'] !== undefined) {
filters.tags = queryParams['tags'].split(',');
}
Expand All @@ -72,7 +72,7 @@ export class WhitelistedInstancesComponent implements OnInit {
filters.minimumGuarantors = Number(queryParams['minimumGuarantors']);
}

const formPatch: WhitelistFilter = JSON.parse(JSON.stringify(filters));
const formPatch: SafelistFilter = JSON.parse(JSON.stringify(filters));
formPatch.tags ??= [];
formPatch.minimumGuarantors ??= 1;
formPatch.minimumEndorsements ??= 0;
Expand All @@ -87,7 +87,7 @@ export class WhitelistedInstancesComponent implements OnInit {
this.endorsedByMe = response.successResponse!.instances.map(instance => instance.domain);
}

const response = await toPromise(this.cachedApi.getWhitelistedInstances(filters));
const response = await toPromise(this.cachedApi.getSafelistedInstances(filters));
if (this.apiResponseHelper.handleErrors([response])) {
this.loading = false;
return;
Expand All @@ -99,7 +99,7 @@ export class WhitelistedInstancesComponent implements OnInit {

return a.endorsements > b.endorsements ? -1 : 1;
});
this.titleService.title = `Whitelisted instances (${this.allInstances.length})`;
this.titleService.title = `Safelisted instances (${this.allInstances.length})`;
this.maxPage = Math.ceil(this.allInstances.length / this.perPage);
for (let i = 1; i <= this.maxPage; ++i) {
this.pages.push(i);
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/home-page/home-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ <h3 class="card-title">Fediseer</h3>
</p>
<p *ngIf="currentInstance.anonymous">
<transloco [key]="'app.home.info_text.anonymous'" [params]="{
guaranteedLink: {route: ['instances/whitelisted']},
guaranteedLink: {route: ['instances/safelisted']},
censuredLink: {route: ['instances/censured']},
loginLink: {route: ['auth/login']},
claimLink: {route: ['/auth/claim-instance']}
}" />
</p>
<p *ngIf="!currentInstance.anonymous && currentInstanceDetail?.guarantor">
<transloco [key]="'app.home.info_text.logged_in.with_guarantor'" [params]="{
guaranteedLink: {route: ['instances/whitelisted']},
guaranteedLink: {route: ['instances/safelisted']},
censuredLink: {route: ['instances/censured']},
myEndorsements: {route: ['endorsements/my']},
myGuarantees: {route: ['guarantees/my']},
Expand Down
Loading