Skip to content

Commit 36f1632

Browse files
committed
Use #summary hash for run hrefs
1 parent a48cb1b commit 36f1632

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

frontend/src/components/fileupload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const FileUpload = (props) => {
5050
let action = null;
5151
if (data.metadata.run_id) {
5252
const RunButton = () => (
53-
<AlertActionLink component='a' href={'/project/' + (data.metadata.project_id || primaryObject.id) + '/runs/' + data.metadata.run_id}>
53+
<AlertActionLink component='a' href={`/project/${(data.metadata.project_id || primaryObject.id)}/runs/${data.metadata.run_id}#summary`}>
5454
Go to Run
5555
</AlertActionLink>
5656
);

frontend/src/components/result.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useContext, useMemo } from 'react';
1+
import React, { useState, useEffect, useContext, useMemo, useCallback } from 'react';
22
import PropTypes from 'prop-types';
33

44
import {
@@ -75,9 +75,14 @@ const ResultView = ({
7575
)
7676
), [artifacts]);
7777

78+
const artifactKeys = useCallback(() => {
79+
if (artifactTabs && artifactTabs?.length !== 0) {return(artifactTabs.map((tab) => tab.key));}
80+
else {return([]);}
81+
}, [artifactTabs]);
82+
7883
// Tab state and navigation hooks/effects
7984
const {activeTab, onTabSelect} = useTabHook(
80-
['summary', 'testHistory', 'testObject', ...artifactTabs.map((tab) => tab.key)],
85+
['summary', 'testHistory', 'testObject', ...artifactKeys()],
8186
defaultTab
8287
);
8388

@@ -101,7 +106,7 @@ const ResultView = ({
101106
resultIcon = getIconForResult(testResult.result);
102107
startTime = new Date(testResult.start_time);
103108
parameters = Object.keys(testResult.params).map((key) => <div key={key}>{key} = {testResult.params[key]}</div>);
104-
runLink = <Link to={`../runs/${testResult.run_id}`} relative="Path">{testResult.run_id}</Link>;
109+
runLink = <Link to={`../runs/${testResult.run_id}#summary`} relative="Path">{testResult.run_id}</Link>;
105110
}
106111

107112
const testJson = useMemo(() => JSON.stringify(testResult, null, '\t'), [testResult]);

frontend/src/run-list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const runToRow = (run, filterFunc) => {
7777
}
7878
return {
7979
'cells': [
80-
{title: <React.Fragment><Link to={`${run.id}`}>{run.id}</Link> {badges}</React.Fragment>},
80+
{title: <React.Fragment><Link to={`${run.id}#summary`}>{run.id}</Link> {badges}</React.Fragment>},
8181
{title: round(run.duration) + 's'},
8282
{title: <RunSummary summary={run.summary} />},
8383
{title: created.toLocaleString()},
@@ -442,7 +442,7 @@ const RunList = () => {
442442
onApplyFilter={applyFilter}
443443
onRemoveFilter={removeFilter}
444444
onClearFilters={clearFilters}
445-
onApplyReport={() => navigate('/project/' + params.project_id + '/reports?' + buildParams(filters).join('&'))}
445+
onApplyReport={() => navigate(`/project/${params.project_id}/reports?${buildParams(filters).join('&')}`)}
446446
onSetPage={setPage}
447447
onSetPageSize={setPageSize}
448448
hideFilters={['project_id']}

frontend/src/run.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useState, useEffect, useCallback, useContext, useMemo } from 'react';
2-
import { useParams, useNavigate, useLocation, Link } from 'react-router-dom';
1+
import React, { useState, useEffect, useContext, useMemo, useCallback } from 'react';
2+
import { useParams, Link } from 'react-router-dom';
33

44
import {
55
Badge,
@@ -55,11 +55,12 @@ import ClassifyFailuresTable from './components/classify-failures';
5555
import ArtifactTab from './components/artifact-tab';
5656
import { IbutsuContext } from './services/context';
5757
import { useTabHook } from './components/tabHook';
58+
import PropTypes from 'prop-types';
5859

5960

6061
const COLUMNS = ['Test', 'Run', 'Result', 'Duration', 'Started'];
6162

62-
const Run = (defaultTab='summary') => {
63+
const Run = ({defaultTab='summary'}) => {
6364
const { run_id } = useParams();
6465

6566
const context = useContext(IbutsuContext);
@@ -138,10 +139,14 @@ const Run = (defaultTab='summary') => {
138139
</Tab>))
139140
), [artifacts]);
140141

142+
const artifactKeys = useCallback(() => {
143+
if (artifactTabs && artifactTabs?.length !== 0) {return(artifactTabs.map((tab) => tab.key));}
144+
else {return([]);}
145+
}, [artifactTabs]);
146+
141147
// Tab state and navigation hooks/effects
142148
const {activeTab, onTabSelect} = useTabHook(
143-
['summary', 'results-list', 'results-tree', 'classify-failures', 'run-object',
144-
...artifactTabs.map((tab) => tab.key)],
149+
['summary', 'results-list', 'results-tree', 'classify-failures', 'run-object', ...artifactKeys()],
145150
defaultTab
146151
);
147152

@@ -520,6 +525,8 @@ const Run = (defaultTab='summary') => {
520525
);
521526
};
522527

523-
Run.propTypes = {};
528+
Run.propTypes = {
529+
defaultTab: PropTypes.string
530+
};
524531

525532
export default Run;

frontend/src/utilities.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ChevronRightIcon,
1212
ClockIcon,
1313
ExclamationCircleIcon,
14+
FileIcon,
1415
InfoAltIcon,
1516
QuestionCircleIcon,
1617
TimesCircleIcon
@@ -285,7 +286,7 @@ export function resultToRow (result, filterFunc) {
285286
}
286287
}
287288
if (result.metadata && result.metadata.run) {
288-
runLink = <Link to={`../runs/${result.run_id}`} relative="Path">{result.run_id}</Link>;
289+
runLink = <Link to={`../runs/${result.run_id}#summary`} relative="Path">{result.run_id}</Link>;
289290
}
290291
if (result.metadata && result.metadata.classification) {
291292
classification = <Badge isRead>{result.metadata.classification.split('_')[0]}</Badge>;

0 commit comments

Comments
 (0)