extended EntityJenkinsContent Table to support passing of columns from top level to modify table.

Signed-off-by: Abhay-soni-developer <abhaysoni.developer@gmail.com>
This commit is contained in:
Abhay-soni-developer
2023-09-14 20:36:55 +05:30
parent 047785165d
commit 1a05cf34f6
4 changed files with 27 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-jenkins': minor
---
Extend EntityJenkinsContent to recieve columns as prop
+1 -1
View File
@@ -16,4 +16,4 @@
export { JenkinsClient, jenkinsApiRef } from './JenkinsApi';
export type { JenkinsApi } from './JenkinsApi';
export type { JenkinsApi, Project } from './JenkinsApi';
@@ -239,6 +239,7 @@ type Props = {
total: number;
pageSize: number;
onChangePageSize: (pageSize: number) => void;
columns: TableColumn[];
};
export const CITableView = ({
@@ -249,6 +250,7 @@ export const CITableView = ({
projects,
onChangePage,
onChangePageSize,
columns,
total,
}: Props) => {
const projectsInPage = projects?.slice(
@@ -279,17 +281,22 @@ export const CITableView = ({
<Typography variant="h6">Projects</Typography>
</Box>
}
columns={generatedColumns}
columns={columns && columns.length !== 0 ? columns : generatedColumns}
/>
);
};
export const CITable = () => {
type CITableProps = {
columns?: TableColumn[];
};
export const CITable = ({ columns }: CITableProps) => {
const [tableProps, { setPage, retry, setPageSize }] = useBuilds();
return (
<CITableView
{...tableProps}
columns={columns || ([] as TableColumn[])}
retry={retry}
onChangePageSize={setPageSize}
onChangePage={setPage}
+12 -3
View File
@@ -15,7 +15,10 @@
*/
import { Entity } from '@backstage/catalog-model';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
import {
MissingAnnotationEmptyState,
TableColumn,
} from '@backstage/core-components';
import { useEntity } from '@backstage/plugin-catalog-react';
import React from 'react';
import { Route, Routes } from 'react-router-dom';
@@ -29,16 +32,22 @@ export const isJenkinsAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[JENKINS_ANNOTATION]) ||
Boolean(entity.metadata.annotations?.[LEGACY_JENKINS_ANNOTATION]);
export const Router = () => {
type Props = {
columns?: TableColumn[];
};
export const Router = (props: Props) => {
const { entity } = useEntity();
if (!isJenkinsAvailable(entity)) {
return <MissingAnnotationEmptyState annotation={JENKINS_ANNOTATION} />;
}
const columns = props.columns;
return (
<Routes>
<Route path="/" element={<CITable />} />
<Route path="/" element={<CITable columns={columns} />} />
<Route path={`/${buildRouteRef.path}`} element={<DetailedViewPage />} />
</Routes>
);