-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c057ab7
commit 958f98d
Showing
8 changed files
with
261 additions
and
15 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
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
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
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,69 @@ | ||
import _ from "lodash"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import { useGetReconciledObjects } from "../hooks/flux"; | ||
import { | ||
AutomationKind, | ||
GroupVersionKind, | ||
UnstructuredObject, | ||
} from "../lib/api/core/types.pb"; | ||
import DataTable from "./DataTable"; | ||
import KubeStatusIndicator from "./KubeStatusIndicator"; | ||
|
||
type Props = { | ||
className?: string; | ||
automationName: string; | ||
namespace: string; | ||
automationKind: AutomationKind; | ||
kinds: GroupVersionKind[]; | ||
}; | ||
|
||
function ReconciledObjectsTable({ | ||
className, | ||
automationName, | ||
namespace, | ||
automationKind, | ||
kinds, | ||
}: Props) { | ||
const objs = useGetReconciledObjects( | ||
automationName, | ||
namespace, | ||
automationKind, | ||
kinds | ||
); | ||
|
||
return ( | ||
<div className={className}> | ||
<DataTable | ||
sortFields={["name", "type", "namespace", "status"]} | ||
fields={[ | ||
{ value: "name", label: "Name" }, | ||
{ | ||
label: "Type", | ||
value: (u: UnstructuredObject) => `${u.groupVersionKind.kind}`, | ||
}, | ||
{ | ||
label: "Namespace", | ||
value: "namespace", | ||
}, | ||
{ | ||
label: "Status", | ||
value: (u: UnstructuredObject) => | ||
u.conditions.length > 0 ? ( | ||
<KubeStatusIndicator conditions={u.conditions} /> | ||
) : null, | ||
}, | ||
{ | ||
label: "Message", | ||
value: (u: UnstructuredObject) => _.first(u.conditions)?.message, | ||
}, | ||
]} | ||
rows={objs} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default styled(ReconciledObjectsTable).attrs({ | ||
className: ReconciledObjectsTable.name, | ||
})``; |
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
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
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
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,114 @@ | ||
import _ from "lodash"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import Flex from "../../components/Flex"; | ||
import KubeStatusIndicator from "../../components/KubeStatusIndicator"; | ||
import Link from "../../components/Link"; | ||
import Page from "../../components/Page"; | ||
import ReconciledObjectsTable from "../../components/ReconciledObjectsTable"; | ||
import Text from "../../components/Text"; | ||
import { useGetKustomization } from "../../hooks/automations"; | ||
import { AutomationKind } from "../../lib/api/core/types.pb"; | ||
import { formatURL } from "../../lib/nav"; | ||
import { V2Routes, WeGONamespace } from "../../lib/types"; | ||
|
||
type Props = { | ||
name: string; | ||
className?: string; | ||
}; | ||
|
||
const Info = styled.div` | ||
padding-bottom: 32px; | ||
`; | ||
|
||
const InfoList = styled( | ||
({ | ||
items, | ||
className, | ||
}: { | ||
className?: string; | ||
items: { [key: string]: any }; | ||
}) => { | ||
return ( | ||
<table className={className}> | ||
<tbody> | ||
{_.map(items, (v, k) => ( | ||
<tr key={k}> | ||
<td> | ||
<Text capitalize bold> | ||
{k}: | ||
</Text> | ||
</td> | ||
<td>{v}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
} | ||
)` | ||
tbody tr td:first-child { | ||
min-width: 100px; | ||
} | ||
tr { | ||
height: 16px; | ||
} | ||
`; | ||
|
||
function KustomizationDetail({ className, name }: Props) { | ||
const { data, isLoading, error } = useGetKustomization(name); | ||
|
||
const kustomization = data?.kustomization; | ||
|
||
return ( | ||
<Page | ||
title={kustomization?.name} | ||
loading={isLoading} | ||
error={error} | ||
className={className} | ||
> | ||
<Info> | ||
<h3>{kustomization?.namespace}</h3> | ||
<InfoList | ||
items={{ | ||
Source: ( | ||
<Link | ||
to={formatURL(V2Routes.GitRepo, { | ||
name: kustomization?.sourceRef.name, | ||
})} | ||
> | ||
GitRepository/{kustomization?.sourceRef.name} | ||
</Link> | ||
), | ||
Status: ( | ||
<Flex start> | ||
<KubeStatusIndicator conditions={kustomization?.conditions} /> | ||
<div> | ||
Applied revision {kustomization?.lastAppliedRevision} | ||
</div> | ||
</Flex> | ||
), | ||
Cluster: "", | ||
Path: kustomization?.path, | ||
}} | ||
/> | ||
</Info> | ||
<ReconciledObjectsTable | ||
kinds={kustomization?.inventory} | ||
automationName={kustomization?.name} | ||
namespace={WeGONamespace} | ||
automationKind={AutomationKind.KustomizationAutomation} | ||
/> | ||
</Page> | ||
); | ||
} | ||
|
||
export default styled(KustomizationDetail).attrs({ | ||
className: KustomizationDetail.name, | ||
})` | ||
h3 { | ||
color: #737373; | ||
font-weight: 200; | ||
margin-top: 12px; | ||
} | ||
`; |