/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import { type CollectionAdminConfig, type ColumnDefinition, defineAdmin } from '@byline/core' import { DateTimeFormatter } from '@byline/admin/react' import { NewsCategories } from './schema.js' // ---- Admin UI config (client-only, presentation concerns) ---- /** * Column definitions for the default table-based list view. * * These are passed to the built-in `ListView` component and control which * fields appear as columns, their labels, sort behaviour, and formatters. * * Note: when a custom `listView` component is registered on the * `CollectionAdminConfig`, it receives the raw paginated data directly and * is responsible for its own layout. These column definitions can still * be used in a custom list view, but they are not automatically applied * as they are with the default table-based `ListView`. You can import * them if needed - for example if you wanted to create a toggled grid/table * custom view. */ const listViewColumns: ColumnDefinition[] = [ { fieldName: 'name', label: 'Name', sortable: true, align: 'left', className: 'w-[25%]', }, { fieldName: 'status', label: 'Status', align: 'center', className: 'w-[15%]', }, { fieldName: 'updatedAt', label: 'Last Updated', sortable: true, align: 'right', className: 'w-[20%]', formatter: { component: DateTimeFormatter }, }, ] /** * Columns rendered per row when Media appears as the target of a relation * picker (e.g. News → `heroImage` → Media). Narrower than the list view — * just enough to identify the right media item at a glance. */ const itemViewColumns: ColumnDefinition[] = [ { fieldName: 'name', label: 'Name', align: 'left', className: 'flex-1', }, { fieldName: 'status', label: 'Status', align: 'right', className: 'w-[80px] shrink-0 text-xs text-gray-500', }, ] export const NewsCategoriesAdmin: CollectionAdminConfig = defineAdmin(NewsCategories, { columns: listViewColumns, itemView: itemViewColumns, })