このコミットが含まれているのは:
@@ -0,0 +1,52 @@
|
||||
import { translateUIMessage } from '@/lib/i18n'
|
||||
|
||||
import type { CountField, CountsStateRow } from '@/lib/counts'
|
||||
import type { LocaleCode } from '@/lib/locales'
|
||||
|
||||
|
||||
export const countsStateFields = (trend: boolean): CountField[] => trend
|
||||
? [{ key: 'period', label: 'counts:state.period' },
|
||||
{ key: 'count', label: 'counts:state.postCount' }]
|
||||
: [{ key: 'kind', label: 'counts:columns.kind' },
|
||||
{ key: 'tag_id', label: 'counts:columns.resourceId' },
|
||||
{ key: 'name', label: 'history:tagName' },
|
||||
{ key: 'deprecated', label: 'counts:columns.deprecated' },
|
||||
{ key: 'count', label: 'counts:state.postCount' }]
|
||||
|
||||
|
||||
export const countsStateCell = (
|
||||
row: CountsStateRow,
|
||||
key: string,
|
||||
locale: LocaleCode,
|
||||
): string => {
|
||||
switch (key)
|
||||
{
|
||||
case 'period': return row.period ?? ''
|
||||
case 'count': return row.count == null ? '—' : String (row.count)
|
||||
case 'tag_id': return String (row.tagId)
|
||||
case 'kind': return translateUIMessage (`kinds.${row.kind}`, 'counts', locale).text
|
||||
case 'name': return row.name ?? translateUIMessage ('notRegistered', 'counts', locale).text
|
||||
case 'deprecated': return row.deprecated
|
||||
? translateUIMessage ('common:states.deprecated', 'counts', locale).text : ''
|
||||
default: return ''
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const countsStateDrill = (
|
||||
params: URLSearchParams,
|
||||
at: string,
|
||||
resource = 'posts',
|
||||
row?: CountsStateRow,
|
||||
): string => {
|
||||
const next = new URLSearchParams (params)
|
||||
for (const key of ['sort', 'page', 'tag', 'from', 'before']) next.delete (key)
|
||||
next.set ('mode', 'snapshot')
|
||||
next.set ('at', at)
|
||||
if (row != null)
|
||||
{
|
||||
next.set ('kind', row.kind)
|
||||
next.set ('tag', String (row.tagId))
|
||||
}
|
||||
return `/counts/${resource}?${next}`
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする