このコミットが含まれているのは:
@@ -1,7 +1,9 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
|
||||
import { translateUIMessage } from '@/lib/i18n'
|
||||
import { apiGet } from '@/lib/api'
|
||||
|
||||
import type { LocaleCode } from '@/lib/locales'
|
||||
import type { CountField, CountsResource } from '@/lib/counts'
|
||||
|
||||
export type CountsAxis = { field: string; grain?: string }
|
||||
@@ -51,6 +53,23 @@ export const countsFieldLabel = (key: string): string => {
|
||||
}
|
||||
|
||||
|
||||
export const countsEventTypes = ['create', 'update', 'discard', 'restore'] as const
|
||||
|
||||
|
||||
export const countsAxisLabel = (
|
||||
axis: CountsAxis,
|
||||
definition: CountsDefinition,
|
||||
locale: LocaleCode,
|
||||
): { text: string; language: string } => {
|
||||
const field = translateUIMessage (countsFieldLabel (axis.field), 'counts', locale)
|
||||
if (axis.grain == null || definition.fields.find (item => item.key === axis.field)
|
||||
?.type !== 'datetime') return field
|
||||
return translateUIMessage ('axisWithGrain', 'counts', locale, {
|
||||
field: field.text,
|
||||
grain: translateUIMessage (`grains.${axis.grain}`, 'counts', locale).text })
|
||||
}
|
||||
|
||||
|
||||
export const countsAxisFields = (
|
||||
definition: CountsDefinition,
|
||||
history: boolean,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fieldsForCounts, orderedCountFields, selectedCountChildren,
|
||||
sortedCountChildren } from '@/lib/counts'
|
||||
import { countsEventTypes } from '@/lib/countsDefinitions'
|
||||
import { translateUIMessage } from '@/lib/i18n'
|
||||
import { localisedDateString, msToTime, originalCreatedAtString } from '@/lib/utils'
|
||||
|
||||
@@ -51,9 +52,10 @@ export const countsCellText = (
|
||||
return row.deprecated == null ? '' : date (row.deprecated)
|
||||
case 'user':
|
||||
if (row.createdByUser == null)
|
||||
return translateUIMessage ('history:bot', 'counts', locale).text
|
||||
return translateUIMessage ('bot', 'counts', locale).text
|
||||
return row.createdByUser.name
|
||||
? `${row.createdByUser.name} (#${row.createdByUser.id})`
|
||||
? translateUIMessage ('actorWithId', 'counts', locale, {
|
||||
name: row.createdByUser.name, id: row.createdByUser.id }).text
|
||||
: translateUIMessage ('history:anonymous', 'counts', locale, {
|
||||
id: row.createdByUser.id }).text
|
||||
case 'created_at': return date (row.createdAt)
|
||||
@@ -274,8 +276,11 @@ export const countsExportLabels = (
|
||||
`history:languageNames.${key}`, 'counts', locale).text
|
||||
labels.id = translateUIMessage ('columns.resourceId', 'counts', locale).text
|
||||
labels.name = translateUIMessage ('history:name', 'counts', locale).text
|
||||
for (const event of ['create', 'update', 'discard', 'restore'])
|
||||
for (const event of countsEventTypes)
|
||||
labels[`event_type:${event}`] = translateUIMessage (`events.${event}`, 'counts', locale).text
|
||||
labels.bot = translateUIMessage ('bot', 'counts', locale).text
|
||||
labels.actorFormat = translateUIMessage ('actorWithId', 'counts', locale, {
|
||||
name: '{{name}}', id: '{{id}}' }).text
|
||||
labels.latest = translateUIMessage ('latestValue', 'counts', locale).text
|
||||
labels.notRegistered = translateUIMessage ('notRegistered', 'counts', locale).text
|
||||
return labels
|
||||
|
||||
@@ -49,7 +49,7 @@ export const countsSummaryCell = (
|
||||
switch (key)
|
||||
{
|
||||
case 'group': return row.key == null
|
||||
? translateUIMessage ('history:bot', 'counts', locale)
|
||||
? translateUIMessage ('bot', 'counts', locale)
|
||||
: { text: row.name ?? String (row.key) }
|
||||
case 'count': return { text: row.count == null ? '—' : String (row.count) }
|
||||
case 'tag_id': return { text: String (row.tagId) }
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする