Skip to content

Commit

Permalink
Feat: Add link to edit hestiation/censure from instance detail (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage authored Feb 20, 2024
1 parent 4128655 commit 839622a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ <h3 class="card-title" id="censures-received">Censures received ({{censuresRecei
<th>Reasons</th>
<th>Evidence</th>
<th>{{'app.rebuttal' | transloco}}</th>
<th *ngIf="myInstanceHasGivenCensure">{{'app.actions' | transloco}}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -315,6 +316,11 @@ <h3 class="card-title" id="censures-received">Censures received ({{censuresRecei
</ng-container>
</ng-container>
</td>
<td *ngIf="myInstanceHasGivenCensure">
<ng-container *ngIf="instance.domain === myInstanceName">
<a routerLink="/censures/my/edit/{{detail!.domain}}">{{'app.censure.edit' | transloco}}</a>
</ng-container>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -377,6 +383,7 @@ <h3 class="card-title" id="hesitations-received">Hesitations received ({{hesitat
<th>Reasons</th>
<th>Evidence</th>
<th>{{'app.rebuttal' | transloco}}</th>
<th *ngIf="myInstanceHasGivenHesitation">{{'app.actions' | transloco}}</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -415,6 +422,11 @@ <h3 class="card-title" id="hesitations-received">Hesitations received ({{hesitat
</ng-container>
</ng-container>
</td>
<td *ngIf="myInstanceHasGivenHesitation">
<ng-container *ngIf="instance.domain === myInstanceName">
<a routerLink="/hesitations/my/edit/{{detail!.domain}}">{{'app.hesitation.edit' | transloco}}</a>
</ng-container>
</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class InstanceDetailComponent implements OnInit {

public loading: boolean = true;
public myInstance: boolean = false;
public myInstanceName: string | null = null;
public myInstanceHasGivenCensure = false;
public myInstanceHasGivenHesitation = false;
public loggedIn = !this.authManager.currentInstanceSnapshot.anonymous;

constructor(
Expand Down Expand Up @@ -105,13 +108,21 @@ export class InstanceDetailComponent implements OnInit {
this.guaranteesGiven = responses[4].successResponse?.instances ?? null;
this.detail = responses[5].successResponse ?? null;
this.myInstance = !this.authManager.currentInstanceSnapshot.anonymous && this.detail?.domain === this.authManager.currentInstanceSnapshot.name;
this.myInstanceName = this.authManager.currentInstanceSnapshot.anonymous ? null : this.authManager.currentInstanceSnapshot.name;
this.hesitationsReceived = responses[6].successResponse!.instances.map(
instance => NormalizedInstanceDetailResponse.fromInstanceDetail(instance),
);
this.hesitationsGiven = responses[7].successResponse?.instances.map(
instance => NormalizedInstanceDetailResponse.fromInstanceDetail(instance),
) ?? null;

if (this.myInstanceName) {
this.myInstanceHasGivenCensure = this.censuresReceived !== null
&& this.censuresReceived.filter(detail => detail.domain === this.myInstanceName).length > 0;
this.myInstanceHasGivenHesitation = this.hesitationsReceived !== null
&& this.hesitationsReceived.filter(detail => detail.domain === this.myInstanceName).length > 0;
}

this.loading = false;
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,7 @@
"app.warning.empty_rebuttal": "Cannot create an empty rebuttal",
"app.rebuttal.created": "Rebuttal has been successfully created",
"app.rebuttal.deleted": "Rebuttal has been successfully deleted",
"app.rebuttal.updated": "Rebuttal has been successfully updated"
"app.rebuttal.updated": "Rebuttal has been successfully updated",
"app.censure.edit": "Edit censure",
"app.hesitation.edit": "Edit hesitation"
}

0 comments on commit 839622a

Please sign in to comment.