Skip to content

Commit

Permalink
Merge pull request #1034 from akto-api-security/fix/improve_testing_f…
Browse files Browse the repository at this point in the history
…lyoutpage

Fix/improve testing flyoutpage
  • Loading branch information
notshivansh authored Apr 19, 2024
2 parents e0d9f5d + c280e77 commit a785da4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import "./style.css"

function FlyLayout(props) {

const { title, show, setShow, components,loading, showDivider, newComp} = props
const { title, show, setShow, components,loading, showDivider, newComp, handleClose, isHandleClose} = props
const handleExit = () => {
setShow(!show)
if(isHandleClose){
handleClose()
}
}
return (
<div className={"flyLayout " + (show ? "show" : "")}>
<div className="innerFlyLayout">
Expand All @@ -18,7 +24,7 @@ function FlyLayout(props) {
<Text variant="headingMd">
{title}
</Text>
<Button icon={CancelMajor} onClick={() => { setShow(!show) }} plain></Button>
<Button icon={CancelMajor} onClick={() => { handleExit()}} plain></Button>
</HorizontalStack>
</Box>
<Scrollable style={{ height: "92vh" }} shadow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ function GithubServerTable(props) {
const setFiltersMap = PersistStore(state => state.setFiltersMap)
const tableInitialState = PersistStore(state => state.tableInitialState)
const setTableInitialState = PersistStore(state => state.setTableInitialState)

const currentPageKey = window.location.href

const currentPageKey = props?.filterStateUrl || window.location.href
const pageFiltersMap = filtersMap[currentPageKey]

const filterMode = (pageFiltersMap?.filters.length > 0) ? IndexFiltersMode.Filtering : (props?.mode ? props.mode : IndexFiltersMode.Filtering)
const initialStateFilters = tableFunc.mergeFilters(props.appliedFilters || [], (pageFiltersMap?.filters || []),props.disambiguateLabel)
const { mode, setMode } = useSetIndexFiltersMode(props?.mode ? props.mode : IndexFiltersMode.Filtering);
const { mode, setMode } = useSetIndexFiltersMode(filterMode);
const [sortSelected, setSortSelected] = useState(tableFunc.getInitialSortSelected(props.sortOptions, pageFiltersMap))
const [data, setData] = useState([]);
const [total, setTotal] = useState([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function GithubSimpleTable(props) {
tableTabs={props?.tableTabs}
notHighlightOnselected={props.notHighlightOnselected}
hasZebraStriping={props.hasZebraStriping}
filterStateUrl={props?.filterStateUrl}
/>

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ function IssuesPage(){
getNextUrl={getNextUrl}
rowClickable={true}
getStatus={func.getTestResultStatus}
filterStateUrl={"/dashboard/issues"}
/>
]}
primaryAction={<Button primary onClick={() => openVulnerabilityReport()} disabled={showEmptyScreen}>Export vulnerability report</Button>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ const promotedBulkActions = (selectedDataHexIds) => {
selected={selected}
tableTabs={tableTabs}
onSelect={handleSelectedTab}
filterStateUrl={"dashboard/testing/" + selectedTestRun?.id + "/" + selectedTab}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { Avatar, Badge, Box, Button, Divider, HorizontalStack, Icon, Popover, Te
import api from '../../observe/api'
import issuesApi from "../../issues/api"
import GridRows from '../../../components/shared/GridRows'
import { useNavigate } from 'react-router-dom'

function TestRunResultFlyout(props) {


const { selectedTestRunResult, loading, issueDetails ,getDescriptionText, infoState, createJiraTicket, jiraIssueUrl, showDetails, setShowDetails} = props
const { selectedTestRunResult, loading, issueDetails ,getDescriptionText, infoState, createJiraTicket, jiraIssueUrl, showDetails, setShowDetails, isIssuePage} = props
const [fullDescription, setFullDescription] = useState(false)
const [rowItems, setRowItems] = useState([])
const [popoverActive, setPopoverActive] = useState(false)
Expand All @@ -37,6 +38,8 @@ function TestRunResultFlyout(props) {
}
}

const navigate = useNavigate()

useEffect(() => {
if(issueDetails && Object.keys(issueDetails).length > 0){
fetchApiInfo(issueDetails.id.apiInfoKey)
Expand Down Expand Up @@ -72,6 +75,11 @@ function TestRunResultFlyout(props) {
content: 'Reopen',
onAction: () => { reopenAction() }
}]

const handleClose = () => {
const navigateUrl = isIssuePage ? "/dashboard/issues" : window.location.pathname.split("result")[0]
navigate(navigateUrl)
}

function ActionsComp (){
const issuesActions = issueDetails?.testRunIssueStatus === "IGNORED" ? [...issues, ...reopen] : issues
Expand Down Expand Up @@ -244,15 +252,19 @@ function TestRunResultFlyout(props) {
<TitleComponent/>, tabsComponent
]

const title = isIssuePage ? "Issue details" : "Test result"

return (
<FlyLayout
title={"Test result"}
title={title}
show={showDetails}
setShow={setShowDetails}
components={currentComponents}
loading={loading}
showDivider={true}
newComp={true}
handleClose={handleClose}
isHandleClose={true}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function TestRunResultPage(props) {
let res = await api.fetchIssueFromTestRunResultDetails(hexId2)
runIssues = res.runIssues;
}
setShowDetails(true)
}
setData(testingRunResult, runIssues);
setTimeout(() => {
Expand Down Expand Up @@ -198,11 +199,6 @@ function TestRunResultPage(props) {

useEffect(() => {
fetchData();
setShowDetails(true)
setLoading(true)
setTimeout(() => {
setLoading(false)
},200)
}, [subCategoryMap, subCategoryFromSourceConfigMap, props, hexId2])

return (
Expand All @@ -222,6 +218,7 @@ function TestRunResultPage(props) {
source={props?.source}
setShowDetails={setShowDetails}
showDetails={showDetails}
isIssuePage={location.pathname.includes("issues")}
/>
</>
:
Expand Down

0 comments on commit a785da4

Please sign in to comment.