-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from weaveworks/deployments-card
Deployments Card
- Loading branch information
Showing
16 changed files
with
744 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...s/backstage-plugin-flux/src/components/FluxEntityDeploymentsCard/FluxDeploymentsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React from 'react'; | ||
import { TableColumn } from '@backstage/core-components'; | ||
import { | ||
idColumn, | ||
nameAndClusterNameColumn, | ||
statusColumn, | ||
updatedColumn, | ||
syncColumn, | ||
Deployment, | ||
repoColumn, | ||
referenceColumn, | ||
typeColumn, | ||
} from '../helpers'; | ||
import { HelmChart, HelmRelease, Kustomization } from '../../objects'; | ||
import { FluxEntityTable } from '../FluxEntityTable'; | ||
|
||
export const defaultColumns: TableColumn<Deployment>[] = [ | ||
idColumn(), | ||
typeColumn(), | ||
nameAndClusterNameColumn(), | ||
repoColumn(), | ||
referenceColumn(), | ||
statusColumn(), | ||
updatedColumn(), | ||
syncColumn(), | ||
]; | ||
|
||
type Props = { | ||
deployments: Deployment[]; | ||
isLoading: boolean; | ||
columns: TableColumn<Deployment>[]; | ||
kinds: string[]; | ||
}; | ||
|
||
export const FluxDeploymentsTable = ({ | ||
kinds, | ||
deployments, | ||
isLoading, | ||
columns, | ||
}: Props) => { | ||
const getTitle = () => { | ||
if (kinds.length === 1) { | ||
return `${kinds[0]}s`; | ||
} | ||
return 'Deployments'; | ||
}; | ||
|
||
let helmChart = {} as HelmChart; | ||
let path = ''; | ||
|
||
const data = deployments.map(d => { | ||
const { | ||
clusterName, | ||
namespace, | ||
name, | ||
conditions, | ||
suspended, | ||
sourceRef, | ||
type, | ||
lastAppliedRevision, | ||
} = d; | ||
if (d instanceof Kustomization) { | ||
path = d.path; | ||
return { | ||
id: `${clusterName}/${namespace}/${name}`, | ||
conditions, | ||
suspended, | ||
name, | ||
namespace, | ||
lastAppliedRevision, | ||
clusterName, | ||
sourceRef, | ||
type, | ||
path, | ||
} as Kustomization & { id: string }; | ||
} else if (d instanceof HelmRelease) { | ||
helmChart = d.helmChart; | ||
return { | ||
id: `${clusterName}/${namespace}/${name}`, | ||
conditions, | ||
suspended, | ||
name, | ||
namespace, | ||
lastAppliedRevision, | ||
clusterName, | ||
sourceRef, | ||
type, | ||
helmChart, | ||
} as HelmRelease & { id: string }; | ||
} | ||
return null; | ||
}); | ||
|
||
return ( | ||
<FluxEntityTable | ||
columns={columns} | ||
title={getTitle()} | ||
data={ | ||
data as ( | ||
| (HelmRelease & { id: string }) | ||
| (Kustomization & { id: string }) | ||
)[] | ||
} | ||
isLoading={isLoading} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.