From 6fa0d19656993261fa100d330606ce9b3435abec Mon Sep 17 00:00:00 2001 From: RubenMuellauer Date: Wed, 23 Oct 2024 15:16:15 +0200 Subject: [PATCH] Added Support display for manifest min Versions --- .../webapp/controller/startpage.controller.js | 47 +++-------- .../webapp/libs/SRBGitHub.js | 84 ++++++++----------- 2 files changed, 48 insertions(+), 83 deletions(-) diff --git a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js index fcc3e0a..7c4bef2 100644 --- a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js +++ b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js @@ -124,6 +124,18 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { var minVersion = await SRBGitHub.detectUI5VersionInManifestFile(file); version.version = minVersion; + + if (version.isEvergreenBootstrap === true) { + var versionCheck = SRBGitHub.checkForVersionSupport(undefined, minVersion); + version.eocp = versionCheck.eocp; + version.eom = versionCheck.eom; + } else { + var patchCheck = SRBGitHub.checkForPatchSupport(undefined, minVersion); + if (patchCheck) { + version.eocp = patchCheck.eocp; + version.eom = patchCheck.eom; + } + } that.setResultData(resultRecord, version, file, true); that.addRow(resultsModel, resultRecord); @@ -170,42 +182,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { resultsTable.setVisible(true); loginBox.setVisible(false); - // const repoData = await that.fetchData(); - - // repoData.forEach((repo) => { - // var tableData = resultsModel.getProperty("/results"); - // tableData.push(repo); - // resultsModel.setProperty("/results", tableData); - // sap.ui.core.BusyIndicator.hide(); - // }); - this.fetchData(resultsModel); - - // console.log(resultsModel.getProperty("/results")); - - // Promise.allSettled([getVersionData, getLinterstatus]).then(() => { - // addRow(resultRecord); - - // responseCounter++; - - // if (doneCb && numberOfBootstraps === responseCounter) { - // doneCb(); - // } - // }); - // }); - - // Add row to table. A row with all its meta has been loaded successfully - // function (tableRowData) { - // var tableData = resultsModel.getProperty("/results"); - // tableData.push(tableRowData); - // resultsModel.setProperty("/results", tableData); - // sap.ui.core.BusyIndicator.hide(); - // }, - // // Processing done - // function () { - // console.log(resultsModel.getProperty("/results")); - // sap.ui.core.BusyIndicator.hide(); - // } }, showSupportDialogPressed: function () { diff --git a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js index cde9412..c9f0a1e 100644 --- a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js +++ b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js @@ -43,26 +43,6 @@ var SRBGitHub = (function () { }); return { results: response.data.items, headers: response.headers }; - - // return new Promise(function (resolve, reject) { - // var cdnAQuery = "/sap-ui-core.js in:file org:SRBConsultingTeam filename:/index.html"; - // //var cdnBQuery = "https://ui5.sap.com in:file OR resources/sap-ui-core.js in:file org:SRBConsultingTeam filename:/index.html"; - // //var cdnCQuery = "resources/sap-ui-core.js in:file org:SRBConsultingTeam filename:/index.html"; - - // that.octokit.rest.search - // .code({ - // q: cdnAQuery, - // type: "code", - // // eslint-disable-next-line camelcase - // per_page: 15 - // }) - // .then((response) => { - // var resultsA = response.data.items; - // //var finalResults = resultsA.concat(resultsB); - - // resolve(resultsA); - // }); - // }); }, getUI5ManifestFile: async function (repos, page) { @@ -192,14 +172,10 @@ var SRBGitHub = (function () { var isMinVersion = false; for (var i = 0; i < scriptTags.length; i++) { - var tag = scriptTags[i]; - var src = tag.getAttribute("src"); - - if (src !== null) { - // console.log("This is not a UI5 src tag"); + var src = scriptTags[i].getAttribute("src"); + if (src) { groups = src.match("https://sapui5.hana.ondemand.com/(.*)(/resources)"); if (groups) { - // console.log(groups); versionString = groups[1]; detected = true; } else { @@ -213,8 +189,6 @@ var SRBGitHub = (function () { detected = true; isMinVersion = true; } - // console.log(tag); - // console.log(src); } } @@ -223,27 +197,16 @@ var SRBGitHub = (function () { } if (evergreen === true) { - versions.forEach(function (versionEntry) { - var major = versionEntry.version.split(".")[0]; - var minor = versionEntry.version.split(".")[1]; - var compareVersion = major + "." + minor; - - if (versionString === compareVersion) { - eocp = versionEntry.eocp; - eom = versionEntry.eom === true ? "Reached" : versionEntry.eom; - } - }); + var { eocp, eom } = that.checkForVersionSupport(versions, versionString); + eocp = eocp; + eom = eom; } else { - patches.forEach(function (patch) { - if (patch.version === versionString) { - if (patch.removed === true) { - eocp = "Reached"; // <-- Write true because it has beed removed - eom = "Reached"; - } else { - eocp = patch.eocp; // <-- Write the provided eocp date - } - } - }); + var checks = that.checkForPatchSupport(patches, versionString); + if (checks) { + var { eocp, eom } = checks; + eocp = eocp; + eom = eom; + } } } } @@ -257,6 +220,31 @@ var SRBGitHub = (function () { }; }, + checkForVersionSupport: function (versions, currentVersion) { + if (!versions) versions = availableVersionsModel.getData().versions; + var returnValues; + versions.forEach((versionEntry) => { + var splittedVersion = versionEntry.version.split("."); + var compareVersion = `${splittedVersion[0]}.${splittedVersion[1]}`; + if (currentVersion === compareVersion) { + returnValues = { eocp: versionEntry.eocp, eom: versionEntry.eom === true ? "Reached" : versionEntry.eom }; + } + }); + return returnValues; + }, + + checkForPatchSupport: function (patches, currentVersion) { + if (!patches) patches = availableVersionsModel.getData().patches; + var returnValues; + patches.forEach((patch) => { + if (patch.version === currentVersion) { + if (patch.removed === true) returnValues = { eocp: "Reached", eom: "Reached" }; + else returnValues = { eocp: patch.eocp, eom: "" }; + } + }); + return returnValues; + }, + detectUI5VersionInManifestFile: async function (fileContent) { var that = this;