Fix user ban modal grammar to account for multiple users (#4722)

* Fix user ban modal grammar to account for multiple users

* Address variable sugggestion

* Address property syntax suggestion

* Address localization suggestion

* More concise `isSingleUser` declaration
This commit is contained in:
The Cashew Trader 2022-01-14 19:40:27 +05:30 committed by GitHub
parent ff4d2c73fd
commit 884b17773d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -27,7 +27,7 @@
(click)="hide()" (key.enter)="hide()"
>
<input type="submit" i18n-value value="Ban this user" class="peertube-button orange-button" [disabled]="!form.valid" />
<input type="submit" i18n-value [value]="modalMessage" class="peertube-button orange-button" [disabled]="!form.valid" />
</div>
</form>
</div>

View File

@ -17,6 +17,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
private usersToBan: User | User[]
private openedModal: NgbModalRef
modalMessage = ''
constructor (
protected formValidatorService: FormValidatorService,
@ -36,6 +37,9 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
openModal (user: User | User[]) {
this.usersToBan = user
this.openedModal = this.modalService.open(this.modal, { centered: true })
const isSingleUser = !(Array.isArray(this.usersToBan) && this.usersToBan.length > 1)
this.modalMessage = isSingleUser ? $localize`Ban this user` : $localize`Ban these users`
}
hide () {