-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renaming components, moving testHistory into a separate file
- Loading branch information
1 parent
b11d1fa
commit 370d978
Showing
5 changed files
with
178 additions
and
153 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,166 @@ | ||
import React from "react" | ||
import useSWR from "swr" | ||
import ExpandMoreIcon from "@material-ui/icons/ExpandMore" | ||
import MuiExpansionPanel from "@material-ui/core/ExpansionPanel" | ||
import MuiExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary" | ||
import MuiExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails" | ||
import Container from "@material-ui/core/Container" | ||
import { Typography, withStyles } from "@material-ui/core" | ||
import { | ||
showStatusText, | ||
showResolutionText, | ||
showDateText, | ||
TestErrorMessageExpansionPanel, | ||
TestMediaExpansionPanel, | ||
} from "." | ||
|
||
const fetcher = url => fetch(url).then(res => res.json()) | ||
|
||
const ExpandablePanel = withStyles({ | ||
root: { | ||
width: "100%", | ||
boxShadow: "none", | ||
"&:not(:last-child)": { | ||
borderBottom: 0, | ||
}, | ||
"&:before": { | ||
display: "none", | ||
}, | ||
"&$expanded": { | ||
margin: "auto", | ||
}, | ||
}, | ||
expanded: {}, | ||
})(MuiExpansionPanel) | ||
|
||
const CollapsedLineSummary = withStyles({ | ||
root: { | ||
marginBottom: -1, | ||
minHeight: 56, | ||
"&$expanded": { | ||
minHeight: 56, | ||
}, | ||
width: "100%", | ||
}, | ||
content: { | ||
"&$expanded": { | ||
margin: "12px 0", | ||
}, | ||
}, | ||
expanded: {}, | ||
})(MuiExpansionPanelSummary) | ||
|
||
const PanelDetails = withStyles(theme => ({ | ||
root: { | ||
padding: theme.spacing(2), | ||
width: "100%", | ||
}, | ||
}))(MuiExpansionPanelDetails) | ||
|
||
export const HistoricalTests = function(testId) { | ||
const { data, error } = useSWR( | ||
`${process.env.publicDeltaCore}/api/v1/test_history/test_id/${testId.children}`, | ||
fetcher | ||
) | ||
|
||
const loading = !data && !error | ||
const noData = !data | ||
const [ | ||
historicalTestsExpandedPanel, | ||
setHistoricalTestsExpandedPanel, | ||
] = React.useState<string | false>(false) | ||
const expandCollapsePanel = (historicalTestsPanel: string) => ( | ||
_event: React.ChangeEvent<{}>, | ||
isExpanded: boolean | ||
) => { | ||
setHistoricalTestsExpandedPanel(isExpanded ? historicalTestsPanel : false) | ||
} | ||
|
||
if (noData) { | ||
return ( | ||
<Typography | ||
align="center" | ||
variant="subtitle2" | ||
style={{ | ||
paddingTop: "1em", | ||
paddingBottom: "1em", | ||
color: "#48D1CC", | ||
margin: "5px", | ||
border: "1px #48D1CC solid", | ||
backgroundColor: "white", | ||
}} | ||
> | ||
No historical data was found | ||
</Typography> | ||
) | ||
} else { | ||
return ( | ||
<div style={{ paddingTop: "10px" }}> | ||
{loading | ||
? "Loading historical tests..." | ||
: data.map(test => ( | ||
<ExpandablePanel | ||
key={test.test_history_id} | ||
expanded={historicalTestsExpandedPanel === test.test_history_id} | ||
onChange={expandCollapsePanel(test.test_history_id)} | ||
TransitionProps={{ unmountOnExit: true }} | ||
style={{ | ||
backgroundColor: "#F3EFEE", // media block expandable color | ||
borderBottom: "1px solid #F3EFEE", | ||
}} | ||
> | ||
<CollapsedLineSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
style={{ | ||
backgroundColor: "#F3EFEE", // media block collapsed color | ||
borderBottom: "1px solid #F3EFEE", | ||
}} | ||
> | ||
<Typography color="textPrimary"> | ||
{showStatusText(test.status)}{" "} | ||
{showResolutionText(test.resolution)}{" "} | ||
{showDateText(test.end_datetime)} | ||
</Typography> | ||
</CollapsedLineSummary> | ||
<PanelDetails> | ||
<Container maxWidth="sm"> | ||
{test.error_type ? ( | ||
<Typography | ||
align="center" | ||
variant="subtitle2" | ||
style={{ | ||
paddingTop: "1em", | ||
paddingBottom: "1em", | ||
color: "#C71585", | ||
margin: "5px", | ||
border: "1px #C71585 solid", | ||
backgroundColor: "white", | ||
}} | ||
> | ||
{test.error_type} | ||
</Typography> | ||
) : ( | ||
<div></div> | ||
)} | ||
{test.trace ? ( | ||
<TestErrorMessageExpansionPanel> | ||
{test} | ||
</TestErrorMessageExpansionPanel> | ||
) : ( | ||
<div></div> | ||
)} | ||
{test.media ? ( | ||
<TestMediaExpansionPanel key={test.file_id}> | ||
{test} | ||
</TestMediaExpansionPanel> | ||
) : ( | ||
<div></div> | ||
)} | ||
</Container> | ||
</PanelDetails> | ||
</ExpandablePanel> | ||
))} | ||
</div> | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
export * from "./BasePage" | ||
export * from "./PageHeader" | ||
export * from "./SpacingPaper" | ||
export * from "./TestExpanded" | ||
export * from "./Test" | ||
export * from "./Pagination" | ||
export * from "./showDate" | ||
export * from "./showResolution" | ||
export * from "./showStatusIcon" | ||
export * from "./showTestStats" | ||
export * from "./TestExpansionPanel" | ||
export * from "./TestExpandablePanels" | ||
export * from "./TestResolution" | ||
export * from "./ListOfSuites" | ||
export * from "./TestHistory" |