ability to configure refresh interval on Kubernetes tab

Signed-off-by: goenning <me@goenning.net>
This commit is contained in:
goenning
2022-05-18 19:56:50 +01:00
parent 8d2f531f10
commit 5553f09e80
6 changed files with 54 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-kubernetes': patch
---
ability to configure refresh interval on Kubernetes tab
+10 -3
View File
@@ -111,7 +111,14 @@ export interface DeploymentResources {
// Warning: (ae-missing-release-tag) "EntityKubernetesContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityKubernetesContent: (_props: {}) => JSX.Element;
export const EntityKubernetesContent: (
props: EntityKubernetesContentProps,
) => JSX.Element;
// @public
export type EntityKubernetesContentProps = {
refreshIntervalMs?: number;
};
// Warning: (ae-forgotten-export) The symbol "ErrorPanelProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "ErrorPanel" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -300,6 +307,7 @@ export class KubernetesBackendClient implements KubernetesApi {
// @public (undocumented)
export const KubernetesContent: ({
entity,
refreshIntervalMs,
}: KubernetesContentProps) => JSX.Element;
// Warning: (ae-forgotten-export) The symbol "KubernetesDrawerable" needs to be exported by the entry point index.d.ts
@@ -370,11 +378,10 @@ export const PodsTable: ({
extraColumns,
}: PodsTablesProps) => JSX.Element;
// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const Router: (_props: Props) => JSX.Element;
export const Router: (props: { refreshIntervalMs?: number }) => JSX.Element;
// Warning: (ae-missing-release-tag) "ServiceAccountKubernetesAuthProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
+10 -4
View File
@@ -32,9 +32,7 @@ export const isKubernetesAvailable = (entity: Entity) =>
entity.metadata.annotations?.[KUBERNETES_LABEL_SELECTOR_QUERY_ANNOTATION],
);
type Props = {};
export const Router = (_props: Props) => {
export const Router = (props: { refreshIntervalMs?: number }) => {
const { entity } = useEntity();
const kubernetesAnnotationValue =
@@ -49,7 +47,15 @@ export const Router = (_props: Props) => {
) {
return (
<Routes>
<Route path="/" element={<KubernetesContent entity={entity} />} />
<Route
path="/"
element={
<KubernetesContent
entity={entity}
refreshIntervalMs={props.refreshIntervalMs}
/>
}
/>
</Routes>
);
}
@@ -25,10 +25,20 @@ import EmptyStateImage from '../assets/emptystate.svg';
import { useKubernetesObjects } from '../hooks';
import { Content, Page, Progress } from '@backstage/core-components';
type KubernetesContentProps = { entity: Entity; children?: React.ReactNode };
type KubernetesContentProps = {
entity: Entity;
refreshIntervalMs?: number;
children?: React.ReactNode;
};
export const KubernetesContent = ({ entity }: KubernetesContentProps) => {
const { kubernetesObjects, error } = useKubernetesObjects(entity);
export const KubernetesContent = ({
entity,
refreshIntervalMs,
}: KubernetesContentProps) => {
const { kubernetesObjects, error } = useKubernetesObjects(
entity,
refreshIntervalMs,
);
const clustersWithErrors =
kubernetesObjects?.items.filter(r => r.errors.length > 0) ?? [];
+1
View File
@@ -25,6 +25,7 @@ export {
kubernetesPlugin as plugin,
EntityKubernetesContent,
} from './plugin';
export type { EntityKubernetesContentProps } from './plugin';
export { Router, isKubernetesAvailable } from './Router';
export * from './api';
export * from './kubernetes-auth-provider';
+15 -1
View File
@@ -76,7 +76,21 @@ export const kubernetesPlugin = createPlugin({
},
});
export const EntityKubernetesContent = kubernetesPlugin.provide(
/**
* Props of EntityKubernetesContent
*
* @public
*/
export type EntityKubernetesContentProps = {
/**
* Sets the refresh interval in milliseconds. The default value is 10000 (10 seconds)
*/
refreshIntervalMs?: number;
};
export const EntityKubernetesContent: (
props: EntityKubernetesContentProps,
) => JSX.Element = kubernetesPlugin.provide(
createRoutableExtension({
name: 'EntityKubernetesContent',
component: () => import('./Router').then(m => m.Router),