Skip to content

Commit f4cf742

Browse files
nam-singhtombrunet
andauthored
fix(extension): Don't show full data:text/html content on generated HTML report page (#2140)
* truncating url * remove unused import * Adjust tooltip location --------- Co-authored-by: Tom Brunet <thbrunet@us.ibm.com>
1 parent 6946ed2 commit f4cf742

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

report-react/src/SavedReport.tsx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import ScoreCard from './ScoreCard';
2020
import SummScoreCard from './SummScoreCard';
2121
import ReportChecklist from './report/ReportChecklist';
2222
import ReportRules from './report/ReportRules';
23-
import { ComposedModal, ModalHeader, ModalBody, Grid, Column, Theme,Dropdown,MultiSelect} from '@carbon/react';
23+
import { ComposedModal, ModalHeader, ModalBody, Grid, Column, Theme,Dropdown,MultiSelect,CopyButton} from '@carbon/react';
2424
import { UtilIssueReact } from "./util/UtilIssueReact";
2525
import { Violation16,NeedsReview16,Recommendation16,ViewOff16 } from "./util/UtilImages";
2626
import ReportElements from "./report/ReportElements";
@@ -75,6 +75,10 @@ export class SavedReport extends React.Component<SavedReportProps, SavedReportSt
7575
this.setState({selectedItems:[...this.state.selectedItems,updatedFilter]})
7676
}
7777
}
78+
copyToClipboard = () => {
79+
if(this.props.reportData)
80+
navigator.clipboard.writeText(this.props.reportData.tabURL)
81+
};
7882

7983
render() {
8084

@@ -173,10 +177,45 @@ const filteredReport = {
173177
</Grid>
174178
<section aria-label="Report overview: score cards">
175179
<Grid>
176-
<Column sm={4} md={4} lg={4}>
177-
<div className="time" style={{paddingTop:"12px"}}>{new Date(this.props.reportData.report.timestamp).toLocaleString()}</div>
178-
<div className="url"><strong>Scanned page:</strong> {this.props.reportData.tabURL}</div>
179-
</Column>
180+
<Column sm={4} md={4} lg={4}>
181+
<div className="time" style={{ paddingTop: "12px" }}>
182+
{new Date(this.props.reportData.report.timestamp).toLocaleString()}
183+
</div>
184+
<div
185+
style={{
186+
gap: "8px", // Add spacing between elements
187+
}}
188+
>
189+
{/* URL with ellipsis */}
190+
<div
191+
className="url"
192+
style={{
193+
display: "-webkit-box",
194+
WebkitLineClamp: 4, // Limit text to 4 lines
195+
WebkitBoxOrient: "vertical",
196+
overflow: "hidden",
197+
textOverflow: "ellipsis",
198+
wordBreak: "break-word", // Handle long URLs gracefully
199+
}}
200+
>
201+
<strong>Scanned page:</strong>{" "}
202+
<span title={this.props.reportData.tabURL}>{this.props.reportData.tabURL}</span>
203+
</div>
204+
205+
{/* Copy button */}
206+
<CopyButton
207+
align="bottom-left"
208+
iconDescription="Copy page URL to clipboard"
209+
onClick={this.copyToClipboard}
210+
feedback="Copied!"
211+
feedbackTimeout={2000}
212+
style={{
213+
alignSelf: "flex-start",
214+
marginTop: "4px",
215+
}}
216+
/>
217+
</div>
218+
</Column>
180219
<Column sm={4} md={4} lg={4}>
181220
<ScoreCard count={violations} title="Violations" icon={Violation16} checked={this.state.selectedItems.some((item)=>item.text==="Violations")}
182221
handleCardClick={this.handleCardClick}>

0 commit comments

Comments
 (0)