make list column more type safe

This commit is contained in:
Nate Kelley 2025-08-02 23:08:28 -06:00
parent fd377cbfa2
commit 962b4edd8d
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
27 changed files with 43 additions and 41 deletions

View File

@ -31,7 +31,7 @@ export const PermissionListDatasetGroupContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<ListDatasetGroupsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -19,7 +19,7 @@ export const PermissionListUserContainer: React.FC<{
}> = React.memo(({ className = '', filteredUsers }) => { }> = React.memo(({ className = '', filteredUsers }) => {
const numberOfUsers = filteredUsers.length; const numberOfUsers = filteredUsers.length;
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<DatasetPermissionOverviewUser>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -31,7 +31,7 @@ export const PermissionListPermissionGroupContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<ListPermissionGroupsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -13,7 +13,7 @@ export const ListDatasetGroupsComponent: React.FC<{
datasetGroups: DatasetGroup[]; datasetGroups: DatasetGroup[];
isFetched: boolean; isFetched: boolean;
}> = React.memo(({ datasetGroups, isFetched }) => { }> = React.memo(({ datasetGroups, isFetched }) => {
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<DatasetGroup>[] = useMemo(
() => [ () => [
{ {
title: 'Title', title: 'Title',

View File

@ -32,7 +32,7 @@ export const DatasetGroupDatasetsListContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetDatasetGroupDatasetsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -32,7 +32,7 @@ export const DatasetGroupPermissionGroupsListContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetPermissionGroupDatasetGroupsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -33,7 +33,7 @@ export const DatasetGroupUsersListContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetPermissionGroupUsersResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -13,7 +13,7 @@ export const ListPermissionGroupsComponent: React.FC<{
permissionGroups: ListPermissionGroupsResponse[]; permissionGroups: ListPermissionGroupsResponse[];
isFetched: boolean; isFetched: boolean;
}> = React.memo(({ permissionGroups, isFetched }) => { }> = React.memo(({ permissionGroups, isFetched }) => {
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<ListPermissionGroupsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Title', title: 'Title',

View File

@ -27,7 +27,7 @@ export const PermissionGroupDatasetGroupsListContainer: React.FC<{
await updatePermissionGroupDatasetGroups([params]); await updatePermissionGroupDatasetGroups([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetPermissionGroupDatasetGroupsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -32,7 +32,7 @@ export const PermissionGroupDatasetsListContainer: React.FC<{
}); });
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetPermissionGroupDatasetsResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',
@ -42,11 +42,11 @@ export const PermissionGroupDatasetsListContainer: React.FC<{
title: 'Assigned', title: 'Assigned',
dataIndex: 'assigned', dataIndex: 'assigned',
width: 130 + 85, width: 130 + 85,
render: (assigned: boolean, permissionGroup: GetPermissionGroupUsersResponse) => { render: (assigned, dataset: GetPermissionGroupDatasetsResponse) => {
return ( return (
<div className="flex justify-end"> <div className="flex justify-end">
<PermissionAssignedCell <PermissionAssignedCell
id={permissionGroup.id} id={dataset.id}
assigned={assigned} assigned={assigned}
text="assigned" text="assigned"
onSelect={onSelectAssigned} onSelect={onSelectAssigned}

View File

@ -28,7 +28,7 @@ export const PermissionGroupUsersListContainer: React.FC<{
await updatePermissionGroupUsers([params]); await updatePermissionGroupUsers([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<GetPermissionGroupUsersResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -18,7 +18,7 @@ export const ListUsersComponent: React.FC<{
users: OrganizationUser[]; users: OrganizationUser[];
isFetched: boolean; isFetched: boolean;
}> = React.memo(({ users, isFetched }) => { }> = React.memo(({ users, isFetched }) => {
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<OrganizationUser>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -12,7 +12,7 @@ import { Text } from '@/components/ui/typography';
export const UserDatasetListContainer = React.memo( export const UserDatasetListContainer = React.memo(
({ filteredDatasets }: { filteredDatasets: OrganizationUserDataset[] }) => { ({ filteredDatasets }: { filteredDatasets: OrganizationUserDataset[] }) => {
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<OrganizationUserDataset>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -12,7 +12,7 @@ export const UserAttributesListContainer: React.FC<{
filteredAttributes: BusterUserAttribute[]; filteredAttributes: BusterUserAttribute[];
userId: string; userId: string;
}> = React.memo(({ filteredAttributes, userId }) => { }> = React.memo(({ filteredAttributes, userId }) => {
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterUserAttribute>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -31,7 +31,7 @@ export const UserDatasetGroupListContainer: React.FC<{
await updateUserDatasetGroups([params]); await updateUserDatasetGroups([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterUserDatasetGroup>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -28,7 +28,7 @@ export const UserDatasetsListContainer: React.FC<{
await updateUserDatasets([params]); await updateUserDatasets([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterUserPermissionGroup>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',
@ -38,7 +38,7 @@ export const UserDatasetsListContainer: React.FC<{
title: 'Assigned', title: 'Assigned',
dataIndex: 'assigned', dataIndex: 'assigned',
width: 130, width: 130,
render: (assigned: boolean, permissionGroup: BusterUserPermissionGroup) => { render: (assigned, permissionGroup: BusterUserPermissionGroup) => {
return ( return (
<div className="flex justify-end"> <div className="flex justify-end">
<PermissionAssignedCell <PermissionAssignedCell

View File

@ -31,7 +31,7 @@ export const UserPermissionGroupsListContainer: React.FC<{
await updateUserPermissionGroups([params]); await updateUserPermissionGroups([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterUserPermissionGroup>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -31,7 +31,7 @@ export const UserTeamsListContainer: React.FC<{
await updateUserTeams([params]); await updateUserTeams([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterUserTeamListItem>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',
@ -39,9 +39,9 @@ export const UserTeamsListContainer: React.FC<{
}, },
{ {
title: 'Role', title: 'Role',
dataIndex: 'assigned', dataIndex: 'role',
width: 285, width: 285,
render: (assigned: boolean, permissionGroup: BusterUserTeamListItem) => { render: (_, permissionGroup) => {
const { user_count, id, role } = permissionGroup; const { user_count, id, role } = permissionGroup;
return ( return (
<div className="flex justify-end"> <div className="flex justify-end">

View File

@ -66,10 +66,10 @@ export const ChatItemsContainer: React.FC<{
}); });
}, [logsRecord]); }, [logsRecord]);
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<ChatListItem>[] = useMemo(
() => [ () => [
{ {
dataIndex: 'name', dataIndex: 'title',
title: 'Name', title: 'Name',
render: (name, record) => <TitleCell name={name} chatId={record?.id} /> render: (name, record) => <TitleCell name={name} chatId={record?.id} />
}, },

View File

@ -63,11 +63,11 @@ export const CollectionIndividualContent: React.FC<{
}); });
CollectionIndividualContent.displayName = 'CollectionIndividualContent'; CollectionIndividualContent.displayName = 'CollectionIndividualContent';
const columns: BusterListColumn[] = [ const columns: BusterListColumn<BusterCollectionItemAsset>[] = [
{ {
dataIndex: 'name', dataIndex: 'name',
title: 'Title', title: 'Title',
render: ({ asset_type, name }) => { render: (_, { asset_type, name }) => {
const Icon = CollectionIconRecord[asset_type]; const Icon = CollectionIconRecord[asset_type];
return ( return (
<div className="flex w-full items-center space-x-2 overflow-hidden"> <div className="flex w-full items-center space-x-2 overflow-hidden">
@ -95,7 +95,7 @@ const columns: BusterListColumn[] = [
dataIndex: 'created_by', dataIndex: 'created_by',
title: 'Owner', title: 'Owner',
width: 50, width: 50,
render: (created_by: BusterCollectionListItem['owner']) => { render: (_, { created_by }) => {
return ( return (
<Avatar image={created_by?.avatar_url || undefined} name={created_by?.name} size={18} /> <Avatar image={created_by?.avatar_url || undefined} name={created_by?.name} size={18} />
); );

View File

@ -52,7 +52,7 @@ export const CollectionsListContent: React.FC<{
); );
CollectionsListContent.displayName = 'CollectionsListContent'; CollectionsListContent.displayName = 'CollectionsListContent';
const columns: BusterListColumn[] = [ const columns: BusterListColumn<BusterCollectionListItem>[] = [
{ {
dataIndex: 'name', dataIndex: 'name',
title: 'Title', title: 'Title',

View File

@ -18,7 +18,7 @@ import { formatDate } from '@/lib';
import { BusterRoutes, createBusterRoute } from '@/routes'; import { BusterRoutes, createBusterRoute } from '@/routes';
import { DashboardSelectedOptionPopup } from './DashboardSelectedPopup'; import { DashboardSelectedOptionPopup } from './DashboardSelectedPopup';
const columns: BusterListColumn[] = [ const columns: BusterListColumn<BusterDashboardListItem>[] = [
{ {
dataIndex: 'name', dataIndex: 'name',
title: 'Title', title: 'Title',
@ -51,7 +51,7 @@ const columns: BusterListColumn[] = [
render: (data) => formatDate({ date: data, format: 'lll' }) render: (data) => formatDate({ date: data, format: 'lll' })
}, },
{ {
dataIndex: 'sharing', dataIndex: 'status',
title: 'Sharing', title: 'Sharing',
width: 65, width: 65,
render: (_, data) => getShareStatus(data) render: (_, data) => getShareStatus(data)

View File

@ -31,7 +31,7 @@ export const PermissionListUsersContainer: React.FC<{
updatePermissionUsers([params]); updatePermissionUsers([params]);
}); });
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<ListPermissionUsersResponse>[] = useMemo(
() => [ () => [
{ {
title: 'Name', title: 'Name',

View File

@ -15,7 +15,7 @@ import { formatDate } from '@/lib';
import { BUSTER_DOCS_QUICKSTART, BusterRoutes, createBusterRoute } from '@/routes'; import { BUSTER_DOCS_QUICKSTART, BusterRoutes, createBusterRoute } from '@/routes';
import { DatasetSelectedOptionPopup } from './DatasetSelectedPopup'; import { DatasetSelectedOptionPopup } from './DatasetSelectedPopup';
const columns: BusterListColumn[] = [ const columns: BusterListColumn<BusterDatasetListItem>[] = [
{ {
title: 'Title', title: 'Title',
dataIndex: 'name' dataIndex: 'name'
@ -34,8 +34,9 @@ const columns: BusterListColumn[] = [
}, },
{ {
title: 'Data source', title: 'Data source',
dataIndex: 'data_source.name', dataIndex: 'data_source',
width: 105 width: 105,
render: (v) => v?.name
}, },
{ {
title: 'Status', title: 'Status',
@ -45,7 +46,7 @@ const columns: BusterListColumn[] = [
}, },
{ {
title: 'Owner', title: 'Owner',
dataIndex: 'created_by_name', dataIndex: 'owner',
width: 60, width: 60,
render: (_, dataset: BusterDatasetListItem) => ( render: (_, dataset: BusterDatasetListItem) => (
<div className="flex w-full justify-start"> <div className="flex w-full justify-start">

View File

@ -60,7 +60,7 @@ export const MetricItemsContainer: React.FC<{
}); });
}, [logsRecord]); }, [logsRecord]);
const columns: BusterListColumn[] = useMemo( const columns: BusterListColumn<BusterMetricListItem>[] = useMemo(
() => [ () => [
{ {
dataIndex: 'name', dataIndex: 'name',

View File

@ -16,7 +16,7 @@ import { formatDate } from '@/lib/date';
import { BusterRoutes, createBusterRoute } from '@/routes'; import { BusterRoutes, createBusterRoute } from '@/routes';
import { TermListSelectedOptionPopup } from './TermListSelectedPopup'; import { TermListSelectedOptionPopup } from './TermListSelectedPopup';
const columns: BusterListColumn[] = [ const columns: BusterListColumn<BusterTermListItem>[] = [
{ {
dataIndex: 'name', dataIndex: 'name',
title: 'Term' title: 'Term'
@ -28,13 +28,13 @@ const columns: BusterListColumn[] = [
render: (data) => formatDate({ date: data, format: 'lll' }) render: (data) => formatDate({ date: data, format: 'lll' })
}, },
{ {
dataIndex: 'created_at', dataIndex: 'last_edited',
title: 'Created at', title: 'Last edited',
width: 140, width: 140,
render: (data) => formatDate({ date: data, format: 'lll' }) render: (data) => formatDate({ date: data, format: 'lll' })
}, },
{ {
dataIndex: 'owner', dataIndex: 'created_by',
title: 'Owner', title: 'Owner',
width: 60, width: 60,
render: (_, data: BusterTermListItem) => <Avatar name={data.created_by.name} size={18} /> render: (_, data: BusterTermListItem) => <Avatar name={data.created_by.name} size={18} />

View File

@ -15,6 +15,7 @@ export const ChatListItemSchema = z.object({
latest_file_type: z.enum(['metric', 'dashboard']), latest_file_type: z.enum(['metric', 'dashboard']),
latest_version_number: z.number().optional(), latest_version_number: z.number().optional(),
latest_file_name: z.string().nullable(), latest_file_name: z.string().nullable(),
is_shared: z.boolean(),
}); });
export type ChatListItem = z.infer<typeof ChatListItemSchema>; export type ChatListItem = z.infer<typeof ChatListItemSchema>;