From 9a6b0c46d8a77e20ba3cd221e0ac92b84f5b51be Mon Sep 17 00:00:00 2001 From: "Guillaume DESPREZ (T0128193)" Date: Thu, 6 Jun 2024 13:41:34 +0200 Subject: [PATCH 1/4] feat: Analysis is hidden if W3C Validator is not enabled --- EcoSonar-API/services/retrieveAnalysisService.js | 1 + .../js/ecosonar_analysis_page/components/AnalysisPerUrlPanel.js | 2 +- .../ecosonar_analysis_page/components/EcoSonarAnalysisPage.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/EcoSonar-API/services/retrieveAnalysisService.js b/EcoSonar-API/services/retrieveAnalysisService.js index c2fc2e5..318b3f7 100644 --- a/EcoSonar-API/services/retrieveAnalysisService.js +++ b/EcoSonar-API/services/retrieveAnalysisService.js @@ -130,6 +130,7 @@ RetrieveAnalysisService.prototype.getUrlAnalysis = async function (projectName, reject(new SystemError()) } else { const analysis = { + allowW3c: process.env.ECOSONAR_ENV_ALLOW_EXTERNAL_API || 'false', deployments: { greenit: greenitAnalysisDeployment, lighthouse: lighthouseResultDeployment, diff --git a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPerUrlPanel.js b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPerUrlPanel.js index 6f54000..bd3d970 100644 --- a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPerUrlPanel.js +++ b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPerUrlPanel.js @@ -66,7 +66,7 @@ export default class AnalysisPerUrlPanel extends React.PureComponent { }) getAnalysisUrlConfiguration(this.state.projectName, this.state.selectedUrl) .then((res) => { - if (res !== undefined) { + if (res !== undefined && res.lastAnalysis.greenit !== null && res.lastAnalysis.lighthouse !== null && res.deployments.greenit.length !== 0 && res.deployments.lighthouse.length !== 0) { this.setState({ greenItLastAnalysis: res.lastAnalysis.greenit, lighthouseLastAnalysis: res.lastAnalysis.lighthouse, diff --git a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js index 6accff8..5bb0f59 100644 --- a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js +++ b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js @@ -69,7 +69,7 @@ export default class EcoSonarAnalysisPage extends React.PureComponent { initEcoSonarAnalysisPage (projectName) { getAnalysisForProjectConfiguration(projectName) .then((analysis) => { - if (analysis !== undefined && analysis.lastAnalysis.greenit !== null && analysis.deployments.greenit.length !== 0) { + if (analysis !== undefined && analysis.lastAnalysis.greenit !== null && analysis.lastAnalysis.lighthouse !== null && (analysis.allowW3c === 'false' || analysis.lastAnalysis.w3c !== null) && analysis.deployments.greenit.length !== 0 && analysis.deployments.lighthouse.length !== 0 && (analysis.allowW3c === 'false' || analysis.deployments.lighthouse.w3c.length !== 0)) { const dateGreenitLastAnalysis = analysis.lastAnalysis.greenit !== null && analysis.lastAnalysis.greenit.dateAnalysis ? `${new Date(analysis.lastAnalysis.greenit.dateAnalysis).toDateString()} - ${new Date(analysis.lastAnalysis.greenit.dateAnalysis).toLocaleTimeString([], { hour12: false })} ` : null From c26278b17b6ee2a703b3296504d9f22f4f8f9a20 Mon Sep 17 00:00:00 2001 From: "Guillaume DESPREZ (T0128193)" Date: Thu, 6 Jun 2024 14:04:56 +0200 Subject: [PATCH 2/4] fix: #10 Export for Maven project (projectName = groupId:artifactId) --- EcoSonar-API/services/exportAuditService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EcoSonar-API/services/exportAuditService.js b/EcoSonar-API/services/exportAuditService.js index ec9d63a..b6ab990 100644 --- a/EcoSonar-API/services/exportAuditService.js +++ b/EcoSonar-API/services/exportAuditService.js @@ -137,7 +137,7 @@ function formatExcelSheet (urlName, index, workbook, projectName, analysis, date if (urlName !== '') { sheet = workbook.addWorksheet('url' + index) } else { - sheet = workbook.addWorksheet(projectName) + sheet = workbook.addWorksheet(projectName.replace(":", " ")) } let row = sheet.getRow(1) row.getCell(1).value = 'EcoSonar Analysis' From e9eb4d64697b16aa6eeae2e1a8ecdd69a5961fc1 Mon Sep 17 00:00:00 2001 From: "Guillaume DESPREZ (T0128193)" Date: Thu, 6 Jun 2024 14:05:00 +0200 Subject: [PATCH 3/4] feat: Improve export name --- .../main/js/ecosonar_analysis_page/components/AnalysisPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPanel.js b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPanel.js index 83b34b7..b4e02a3 100644 --- a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPanel.js +++ b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/AnalysisPanel.js @@ -67,7 +67,7 @@ export default function AnalysisPanel (props) { const fileType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' const fileExtension = '.xlsx' const blob = new Blob([buffer], { type: fileType }) - saveAs(blob, './audits' + fileExtension) + saveAs(blob, projectName + ' - EcoSonar Audit' + fileExtension) setLoading(false) }) .catch((err) => { From 6d9f1d6d17b1025205510a69be1f97e93bb73c9c Mon Sep 17 00:00:00 2001 From: "Guillaume DESPREZ (T0128193)" Date: Thu, 8 Aug 2024 10:41:34 +0200 Subject: [PATCH 4/4] Fix deployments.lighthouse.w3c is undefined --- .../ecosonar_analysis_page/components/EcoSonarAnalysisPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js index 5bb0f59..e54d152 100644 --- a/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js +++ b/EcoSonar-SonarQube/src/main/js/ecosonar_analysis_page/components/EcoSonarAnalysisPage.js @@ -69,7 +69,7 @@ export default class EcoSonarAnalysisPage extends React.PureComponent { initEcoSonarAnalysisPage (projectName) { getAnalysisForProjectConfiguration(projectName) .then((analysis) => { - if (analysis !== undefined && analysis.lastAnalysis.greenit !== null && analysis.lastAnalysis.lighthouse !== null && (analysis.allowW3c === 'false' || analysis.lastAnalysis.w3c !== null) && analysis.deployments.greenit.length !== 0 && analysis.deployments.lighthouse.length !== 0 && (analysis.allowW3c === 'false' || analysis.deployments.lighthouse.w3c.length !== 0)) { + if (analysis !== undefined && analysis.lastAnalysis.greenit !== null && analysis.lastAnalysis.lighthouse !== null && (analysis.allowW3c === 'false' || analysis.lastAnalysis.w3c !== null) && analysis.deployments.greenit.length !== 0 && analysis.deployments.lighthouse.length !== 0 && (analysis.allowW3c === 'false' || analysis.deployments.w3c.length !== 0)) { const dateGreenitLastAnalysis = analysis.lastAnalysis.greenit !== null && analysis.lastAnalysis.greenit.dateAnalysis ? `${new Date(analysis.lastAnalysis.greenit.dateAnalysis).toDateString()} - ${new Date(analysis.lastAnalysis.greenit.dateAnalysis).toLocaleTimeString([], { hour12: false })} ` : null