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',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ import { formatDate } from '@/lib/date';
import { BusterRoutes, createBusterRoute } from '@/routes';
import { TermListSelectedOptionPopup } from './TermListSelectedPopup';
const columns: BusterListColumn[] = [
const columns: BusterListColumn<BusterTermListItem>[] = [
{
dataIndex: 'name',
title: 'Term'
@ -28,13 +28,13 @@ const columns: BusterListColumn[] = [
render: (data) => formatDate({ date: data, format: 'lll' })
},
{
dataIndex: 'created_at',
title: 'Created at',
dataIndex: 'last_edited',
title: 'Last edited',
width: 140,
render: (data) => formatDate({ date: data, format: 'lll' })
},
{
dataIndex: 'owner',
dataIndex: 'created_by',
title: 'Owner',
width: 60,
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_version_number: z.number().optional(),
latest_file_name: z.string().nullable(),
is_shared: z.boolean(),
});
export type ChatListItem = z.infer<typeof ChatListItemSchema>;