Unify labels

This commit is contained in:
shamoon
2025-11-05 08:47:52 -08:00
parent 08f71a7ed7
commit b4972d2bca
3 changed files with 22 additions and 26 deletions

View File

@@ -4,7 +4,10 @@ import { Component, Input, inject } from '@angular/core'
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms' import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { import {
SHARE_BUNDLE_FILE_VERSION_LABELS,
SHARE_BUNDLE_STATUS_LABELS,
ShareBundleCreatePayload, ShareBundleCreatePayload,
ShareBundleStatus,
ShareBundleSummary, ShareBundleSummary,
} from 'src/app/data/share-bundle' } from 'src/app/data/share-bundle'
import { import {
@@ -47,16 +50,7 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
createdBundle: ShareBundleSummary | null = null createdBundle: ShareBundleSummary | null = null
copied = false copied = false
onOpenManage?: () => void onOpenManage?: () => void
readonly statusLabels: Record<ShareBundleSummary['status'], string> = { readonly statuses = ShareBundleStatus
pending: $localize`Pending`,
processing: $localize`Processing`,
ready: $localize`Ready`,
failed: $localize`Failed`,
}
readonly fileVersionLabels: Record<FileVersion, string> = {
[FileVersion.Archive]: $localize`Archive`,
[FileVersion.Original]: $localize`Original`,
}
constructor() { constructor() {
super() super()
@@ -116,10 +110,10 @@ export class ShareBundleDialogComponent extends ConfirmDialogComponent {
} }
statusLabel(status: ShareBundleSummary['status']): string { statusLabel(status: ShareBundleSummary['status']): string {
return this.statusLabels[status] ?? status return SHARE_BUNDLE_STATUS_LABELS[status] ?? status
} }
fileVersionLabel(version: FileVersion): string { fileVersionLabel(version: FileVersion): string {
return this.fileVersionLabels[version] ?? version return SHARE_BUNDLE_FILE_VERSION_LABELS[version] ?? version
} }
} }

View File

@@ -5,6 +5,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { Subject, catchError, of, switchMap, takeUntil, timer } from 'rxjs' import { Subject, catchError, of, switchMap, takeUntil, timer } from 'rxjs'
import { import {
SHARE_BUNDLE_FILE_VERSION_LABELS,
SHARE_BUNDLE_STATUS_LABELS,
ShareBundleStatus, ShareBundleStatus,
ShareBundleSummary, ShareBundleSummary,
} from 'src/app/data/share-bundle' } from 'src/app/data/share-bundle'
@@ -41,18 +43,6 @@ export class ShareBundleManageDialogComponent
private readonly refresh$ = new Subject<boolean>() private readonly refresh$ = new Subject<boolean>()
private readonly statusLabels: Record<ShareBundleStatus, string> = {
[ShareBundleStatus.Pending]: $localize`Pending`,
[ShareBundleStatus.Processing]: $localize`Processing`,
[ShareBundleStatus.Ready]: $localize`Ready`,
[ShareBundleStatus.Failed]: $localize`Failed`,
}
private readonly fileVersionLabels: Record<FileVersion, string> = {
[FileVersion.Archive]: $localize`Archive`,
[FileVersion.Original]: $localize`Original`,
}
ngOnInit(): void { ngOnInit(): void {
this.refresh$ this.refresh$
.pipe( .pipe(
@@ -154,11 +144,11 @@ export class ShareBundleManageDialogComponent
} }
statusLabel(status: ShareBundleStatus): string { statusLabel(status: ShareBundleStatus): string {
return this.statusLabels[status] ?? status return SHARE_BUNDLE_STATUS_LABELS[status] ?? status
} }
fileVersionLabel(version: FileVersion): string { fileVersionLabel(version: FileVersion): string {
return this.fileVersionLabels[version] ?? version return SHARE_BUNDLE_FILE_VERSION_LABELS[version] ?? version
} }
close(): void { close(): void {

View File

@@ -26,3 +26,15 @@ export interface ShareBundleCreatePayload {
file_version: FileVersion file_version: FileVersion
expiration_days: number | null expiration_days: number | null
} }
export const SHARE_BUNDLE_STATUS_LABELS: Record<ShareBundleStatus, string> = {
[ShareBundleStatus.Pending]: $localize`Pending`,
[ShareBundleStatus.Processing]: $localize`Processing`,
[ShareBundleStatus.Ready]: $localize`Ready`,
[ShareBundleStatus.Failed]: $localize`Failed`,
}
export const SHARE_BUNDLE_FILE_VERSION_LABELS: Record<FileVersion, string> = {
[FileVersion.Archive]: $localize`Archive`,
[FileVersion.Original]: $localize`Original`,
}