Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/backstage-plugin-flux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"luxon": "^3.3.0",
"react-use": "^17.4.0",
"styled-components": "^6.1.1",
"use-deep-compare": "^1.1.0",
"use-deep-compare": "^1.2.1",
"yaml": "^2.3.1"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard } from '@backstage/core-components';
import { WeaveGitOpsContext } from '../WeaveGitOpsContext';
import { useFluxDeployments } from '../../hooks';
import { FluxDeploymentsTable, defaultColumns } from './FluxDeploymentsTable';
import SuspendMessageModal from '../SuspendMessageModal';

const DeploymentsPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useFluxDeployments(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -29,6 +31,12 @@ const DeploymentsPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={defaultColumns}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ type Props = {
isLoading: boolean;
columns: TableColumn<Deployment>[];
many?: boolean;
setSelectedRow: React.Dispatch<React.SetStateAction<string>>;
};

export const FluxDeploymentsTable = ({
deployments,
isLoading,
columns,
many,
setSelectedRow,
}: Props) => {
let helmChart = {} as HelmChart;
let path = '';
Expand Down Expand Up @@ -99,6 +101,7 @@ export const FluxDeploymentsTable = ({
isLoading={isLoading}
filters={filters}
many={many}
setSelectedRow={setSelectedRow}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard, TableColumn } from '@backstage/core-components';
import { useGitRepositories } from '../../hooks/query';
Expand All @@ -8,10 +8,12 @@ import {
FluxSourcesTable,
} from '../EntityFluxSourcesCard/FluxSourcesTable';
import { Source } from '../helpers';
import SuspendMessageModal from '../SuspendMessageModal';

const GitRepositoriesPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useGitRepositories(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -33,6 +35,12 @@ const GitRepositoriesPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={gitOciDefaultColumns as TableColumn<Source>[]}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard } from '@backstage/core-components';
import { useHelmReleases } from '../../hooks/query';
Expand All @@ -7,10 +7,12 @@ import {
FluxDeploymentsTable,
defaultColumns,
} from '../EntityFluxDeploymentsCard/FluxDeploymentsTable';
import SuspendMessageModal from '../SuspendMessageModal';

const HelmReleasePanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useHelmReleases(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -32,6 +34,12 @@ const HelmReleasePanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={defaultColumns}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard, TableColumn } from '@backstage/core-components';
import { useHelmRepositories } from '../../hooks';
Expand All @@ -8,10 +8,12 @@ import {
FluxSourcesTable,
} from '../EntityFluxSourcesCard/FluxSourcesTable';
import { Source } from '../helpers';
import SuspendMessageModal from '../SuspendMessageModal';

const HelmRepositoriesPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useHelmRepositories(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -33,6 +35,12 @@ const HelmRepositoriesPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={helmDefaultColumns as TableColumn<Source>[]}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const FluxImagePoliciesTable = ({
isLoading={isLoading}
filters={filters}
many={many}
setSelectedRow={() => {}}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard } from '@backstage/core-components';
import { WeaveGitOpsContext } from '../WeaveGitOpsContext';
Expand All @@ -7,10 +7,12 @@ import {
FluxDeploymentsTable,
defaultColumns,
} from '../EntityFluxDeploymentsCard/FluxDeploymentsTable';
import SuspendMessageModal from '../SuspendMessageModal';

const KustomizationPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useKustomizations(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -32,6 +34,12 @@ const KustomizationPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={defaultColumns}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { InfoCard, TableColumn } from '@backstage/core-components';
import { WeaveGitOpsContext } from '../WeaveGitOpsContext';
Expand All @@ -8,10 +8,12 @@ import {
FluxSourcesTable,
} from '../EntityFluxSourcesCard/FluxSourcesTable';
import { Source } from '../helpers';
import SuspendMessageModal from '../SuspendMessageModal';

const OCIRepositoryPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useOCIRepositories(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -33,6 +35,12 @@ const OCIRepositoryPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={gitOciDefaultColumns as TableColumn<Source>[]}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React from 'react';
import React, { useState } from 'react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { useFluxSources } from '../../hooks';
import {
FluxSourcesTable,
sourceDefaultColumns,
} from './FluxSourcesTable';
import { FluxSourcesTable, sourceDefaultColumns } from './FluxSourcesTable';
import { WeaveGitOpsContext } from '../WeaveGitOpsContext';
import { InfoCard, TableColumn } from '@backstage/core-components';
import { GitRepository, HelmRepository, OCIRepository } from '../../objects';
import SuspendMessageModal from '../SuspendMessageModal';

export type GH = GitRepository & HelmRepository;
export type OH = OCIRepository & HelmRepository;

const SourcesPanel = ({ many }: { many?: boolean }) => {
const { entity } = useEntity();
const { data, loading, errors } = useFluxSources(entity);
const [selectedRow, setSelectedRow] = useState<string>('');

if (errors) {
return (
Expand All @@ -36,6 +35,12 @@ const SourcesPanel = ({ many }: { many?: boolean }) => {
isLoading={loading && !data}
columns={sourceDefaultColumns as TableColumn<GH | OH>[]}
many={many}
setSelectedRow={setSelectedRow}
/>
<SuspendMessageModal
data={data}
selectedRow={selectedRow}
setSelectedRow={setSelectedRow}
/>
</InfoCard>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ type Props = {
isLoading: boolean;
columns: TableColumn<any>[];
many?: boolean;
setSelectedRow: React.Dispatch<React.SetStateAction<string>>;
};

export const FluxSourcesTable = ({
sources,
isLoading,
columns,
many,
setSelectedRow,
}: Props) => {
let provider = '';
let isVerifiable = false;
Expand Down Expand Up @@ -117,6 +119,7 @@ export const FluxSourcesTable = ({
isLoading={isLoading}
filters={filters}
many={many}
setSelectedRow={setSelectedRow}
/>
);
};
24 changes: 22 additions & 2 deletions plugins/backstage-plugin-flux/src/components/FluxEntityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export function FluxEntityTable<T extends object = {}>({
columns,
filters,
many,
}: TableProps<T> & { many?: boolean }) {
setSelectedRow,
}: TableProps<T> & {
many?: boolean;
setSelectedRow: React.Dispatch<React.SetStateAction<string>>;
}) {
const classes = useStyles();

// We use this memo not really for performance, but to avoid
Expand All @@ -33,6 +37,13 @@ export function FluxEntityTable<T extends object = {}>({
emptyRowsWhenPaging: false,
columnsButton: true,
}}
onRowClick={row => {
const { id } = row?.target as HTMLButtonElement;
const resource = id.split(' ')[1];
if (id.includes('suspend')) {
setSelectedRow(resource);
}
}}
data={data}
isLoading={isLoading}
emptyContent={
Expand All @@ -46,5 +57,14 @@ export function FluxEntityTable<T extends object = {}>({
filters={Boolean(many) ? filters : []}
/>
);
}, [data, title, isLoading, classes.empty, columns]);
}, [
data,
title,
isLoading,
classes.empty,
columns,
many,
filters,
setSelectedRow,
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const FluxRuntimeTable = ({
isLoading={isLoading}
filters={filters}
many={many}
setSelectedRow={() => {}}
/>
);
};
Loading