From 322931f5f529ffb65dcec8f6e27a90f2f424c8d3 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Mon, 18 Mar 2024 22:54:48 +0100 Subject: [PATCH] WIP: repositories --- src/api/api.ts | 44 ++++++++++++++++++++++++++++ src/components/repositories/list.tsx | 19 ++++++++++++ src/interfaces/IRepository.tsx | 7 +++++ 3 files changed, 70 insertions(+) diff --git a/src/api/api.ts b/src/api/api.ts index 3373276..aa2cef1 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -386,6 +386,18 @@ export interface Repository { * @memberof Repository */ 'id'?: string; + /** + * + * @type {string} + * @memberof Repository + */ + 'type'?: RepositoryTypeEnum; + /** + * + * @type {RepositoryAttributes} + * @memberof Repository + */ + 'attributes'?: RepositoryAttributes; /** * * @type {Links} @@ -393,6 +405,38 @@ export interface Repository { */ 'links'?: Links; } + +export const RepositoryTypeEnum = { + Repository: 'Repository' +} as const; + +export type RepositoryTypeEnum = typeof RepositoryTypeEnum[keyof typeof RepositoryTypeEnum]; + +/** + * + * @export + * @interface RepositoryAttributes + */ +export interface RepositoryAttributes { + /** + * + * @type {string} + * @memberof RepositoryAttributes + */ + 'description'?: string; + /** + * + * @type {string} + * @memberof RepositoryAttributes + */ + 'maintainer'?: string; + /** + * + * @type {{ [key: string]: any; }} + * @memberof RepositoryAttributes + */ + 'attributes'?: { [key: string]: any; }; +} /** * * @export diff --git a/src/components/repositories/list.tsx b/src/components/repositories/list.tsx index a9809c0..a932031 100644 --- a/src/components/repositories/list.tsx +++ b/src/components/repositories/list.tsx @@ -20,11 +20,30 @@ const columns: Array<GridColDef<IRepository>> = [ renderCell: (params) => { return <Link href={'./repositories/' + params.value}>{params.value}</Link> } + }, { + field: 'description', + headerName: 'Description', + type: 'string', + minWidth: 250, + flex: 1, + valueGetter: (params): string => { + return params?.row?.attributes?.description + } + }, { + field: 'maintainer', + headerName: 'Maintainer', + type: 'string', + minWidth: 200, + flex: 1, + valueGetter: (params): string => { + return params?.row?.attributes?.maintainer + } } ] export const RepositoriesList: React.FC<IResourceComponentsProps> = () => { const { dataGridProps } = useDataGrid<IRepository>() + console.log('repositoriesList', dataGridProps) return ( <List> diff --git a/src/interfaces/IRepository.tsx b/src/interfaces/IRepository.tsx index dde8ae7..590a788 100644 --- a/src/interfaces/IRepository.tsx +++ b/src/interfaces/IRepository.tsx @@ -1,5 +1,12 @@ +export interface IRepositoryAttributes { + description: string + maintainer: string + attributes: any +} + export interface IRepository { id: string + attributes: IRepositoryAttributes } export default IRepository -- GitLab