diff --git a/.changeset/khaki-shrimps-tell.md b/.changeset/khaki-shrimps-tell.md new file mode 100644 index 0000000000..cad03e2ae5 --- /dev/null +++ b/.changeset/khaki-shrimps-tell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-kubernetes': patch +--- + +ability to configure refresh interval on Kubernetes tab diff --git a/plugins/kubernetes/api-report.md b/plugins/kubernetes/api-report.md index 99bee06165..80c30ed489 100644 --- a/plugins/kubernetes/api-report.md +++ b/plugins/kubernetes/api-report.md @@ -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) // diff --git a/plugins/kubernetes/src/Router.tsx b/plugins/kubernetes/src/Router.tsx index deb6475ad5..fd3a4bd0ce 100644 --- a/plugins/kubernetes/src/Router.tsx +++ b/plugins/kubernetes/src/Router.tsx @@ -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 ( - } /> + + } + /> ); } diff --git a/plugins/kubernetes/src/components/KubernetesContent.tsx b/plugins/kubernetes/src/components/KubernetesContent.tsx index 036bcdb608..3fabfae604 100644 --- a/plugins/kubernetes/src/components/KubernetesContent.tsx +++ b/plugins/kubernetes/src/components/KubernetesContent.tsx @@ -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) ?? []; diff --git a/plugins/kubernetes/src/index.ts b/plugins/kubernetes/src/index.ts index 688d52d7e1..6e8de777ca 100644 --- a/plugins/kubernetes/src/index.ts +++ b/plugins/kubernetes/src/index.ts @@ -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'; diff --git a/plugins/kubernetes/src/plugin.ts b/plugins/kubernetes/src/plugin.ts index b54850307e..124bff831b 100644 --- a/plugins/kubernetes/src/plugin.ts +++ b/plugins/kubernetes/src/plugin.ts @@ -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),