Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 5x 5x 5x 5x 5x 5x 5x 5x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 6x 1x 4x 4x | import { AuthService } from '../../../services/auth/auth.service';
import { VersionForModeration } from '../../models/version-for-moderation.model';
import { ArticleModerationPanelComponent } from '../article-moderation-panel/article-moderation-panel.component';
import { SidebarActionComponent } from '../sidebar-action/sidebar-action.component';
import { ChangeDetectionStrategy, Component, computed, inject, input, output, signal } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { APPROVAL_CLASS, APPROVAL_ICONS, ModerationResult, SidebarActionPriority } from '@drevo-web/shared';
import { SidePanelComponent } from '@drevo-web/ui';
@Component({
selector: 'app-moderation-sidebar-action',
imports: [ArticleModerationPanelComponent, SidebarActionComponent, SidePanelComponent],
templateUrl: './moderation-sidebar-action.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ModerationSidebarActionComponent {
readonly version = input.required<VersionForModeration>();
readonly disabled = input(false);
readonly priority = input<SidebarActionPriority>('secondary');
readonly moderated = output<ModerationResult>();
private readonly authService = inject(AuthService);
private readonly user = toSignal(this.authService.user$);
readonly canModerate = computed(() => this.user()?.permissions.canModerate ?? false);
private readonly approvalClass = computed(() => APPROVAL_CLASS[this.version().approved]);
readonly moderationIcon = computed(() => APPROVAL_ICONS[this.approvalClass()]);
private readonly _isPanelOpen = signal(false);
readonly isPanelOpen = this._isPanelOpen.asReadonly();
togglePanel(): void {
this._isPanelOpen.update(v => !v);
}
closePanel(): void {
this._isPanelOpen.set(false);
}
onModerated(result: ModerationResult): void {
this._isPanelOpen.set(false);
this.moderated.emit(result);
}
}
|