-
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.
Merge pull request #1522 from weaveworks/1520-source-detail
Add GitRepositoryDetail page
- Loading branch information
Showing
12 changed files
with
306 additions
and
55 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,40 @@ | ||
import _ from "lodash"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import Text from "./Text"; | ||
|
||
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: 200px; | ||
} | ||
tr { | ||
height: 16px; | ||
} | ||
`; | ||
|
||
export default InfoList; |
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,18 @@ | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import { Interval as IntervalType } from "../lib/api/core/types.pb"; | ||
|
||
type Props = { | ||
className?: string; | ||
interval: IntervalType; | ||
}; | ||
|
||
function Interval({ className, interval }: Props) { | ||
return ( | ||
<span className={className}> | ||
{interval.hours}h {interval.minutes}m | ||
</span> | ||
); | ||
} | ||
|
||
export default styled(Interval).attrs({ className: Interval.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import _ from "lodash"; | ||
import * as React from "react"; | ||
import styled from "styled-components"; | ||
import { useListAutomations } from "../hooks/automations"; | ||
import { useListSources } from "../hooks/sources"; | ||
import { SourceRefSourceKind } from "../lib/api/core/types.pb"; | ||
import Alert from "./Alert"; | ||
import AutomationsTable from "./AutomationsTable"; | ||
import Flex from "./Flex"; | ||
import Icon, { IconType } from "./Icon"; | ||
import InfoList from "./InfoList"; | ||
import { computeMessage, computeReady } from "./KubeStatusIndicator"; | ||
import LoadingPage from "./LoadingPage"; | ||
import Text from "./Text"; | ||
|
||
type Props = { | ||
className?: string; | ||
type: SourceRefSourceKind; | ||
name: string; | ||
namespace: string; | ||
children?: JSX.Element; | ||
info: <T>(s: T) => { [key: string]: any }; | ||
}; | ||
|
||
function SourceDetail({ className, name, info }: Props) { | ||
const { data: sources, isLoading, error } = useListSources(); | ||
const { data: automations } = useListAutomations(); | ||
|
||
if (isLoading) { | ||
return <LoadingPage />; | ||
} | ||
|
||
const s = _.find(sources, { name }); | ||
|
||
const items = info(s); | ||
|
||
const relevantAutomations = _.filter(automations, (a) => { | ||
if (!s) { | ||
return false; | ||
} | ||
|
||
if (a?.sourceRef?.kind == s.type && a.sourceRef.name == name) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
const ok = computeReady(s.conditions); | ||
const msg = computeMessage(s.conditions); | ||
|
||
return ( | ||
<div className={className}> | ||
<Flex align wide between> | ||
<div> | ||
<h2>{s.name}</h2> | ||
</div> | ||
<div className="page-status"> | ||
{ok ? ( | ||
<Icon | ||
color="success" | ||
size="medium" | ||
type={IconType.CheckMark} | ||
text={msg} | ||
/> | ||
) : ( | ||
<Icon | ||
color="alert" | ||
size="medium" | ||
type={IconType.ErrorIcon} | ||
text={`Error: ${msg}`} | ||
/> | ||
)} | ||
</div> | ||
</Flex> | ||
{error && ( | ||
<Alert severity="error" title="Error" message={error.message} /> | ||
)} | ||
<div> | ||
<h3>{s.type}</h3> | ||
</div> | ||
<div> | ||
<InfoList items={items} /> | ||
</div> | ||
<div> | ||
<AutomationsTable automations={relevantAutomations} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default styled(SourceDetail).attrs({ className: SourceDetail.name })` | ||
h3 { | ||
margin-bottom: 24px; | ||
} | ||
${InfoList} { | ||
margin-bottom: 60px; | ||
} | ||
.page-status ${Icon} ${Text} { | ||
color: ${(props) => props.theme.colors.black}; | ||
font-weight: normal; | ||
} | ||
`; |
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
Oops, something went wrong.