Skip to content

Commit

Permalink
Set of backend/frontend fixes (#343)
Browse files Browse the repository at this point in the history
* Bump version number after failed release workflow

* Removing small widget Icons

* UI fixes requested by Grzegorz

* Jenkins Widget fix - when endpoint has 2 public urls set then private url is not replaced with public for the button

* SonarQube wiremock endpoints fixed

* Widget content fixed - it should now display scroll handle if needed

* ToDo list widget - font decreased

* Cypress tests fixd

* Jenkins Job widget will use last of the branches mentioned in the API response

* CR Fixes + new init config provided by Grzegorz

Co-authored-by: szymon.owczarzak <[email protected]>
  • Loading branch information
szymon-owczarzak and szymon.owczarzak authored Mar 22, 2021
1 parent 2ea494e commit 8e6a215
Show file tree
Hide file tree
Showing 20 changed files with 1,446 additions and 240 deletions.
16 changes: 7 additions & 9 deletions api-mocks/mappings/endpoints-mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
{
"request": {
"method": "GET",
"url": "/api/resources?resource=success&metrics=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/resources(.)resource=success&metrics=alert_status(.*)"
},
"response": {
"status": 200,
Expand All @@ -294,7 +294,7 @@
{
"request": {
"method": "GET",
"url": "/api/resources?resource=fail&metrics=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/resources(.)resource=fail&metrics=alert_status(.*)"
},
"response": {
"status": 200,
Expand All @@ -307,7 +307,7 @@
{
"request": {
"method": "GET",
"url": "/api/resources?resource=warning&metrics=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/resources(.)resource=warning&metrics=alert_status(.*)"
},
"response": {
"status": 200,
Expand All @@ -320,7 +320,7 @@
{
"request": {
"method": "GET",
"url": "/api/measures/component?component=success&metricKeys=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/measures\/component(.)component=success&metricKeys=alert_status(.*)"
},
"response": {
"status": 200,
Expand All @@ -333,7 +333,7 @@
{
"request": {
"method": "GET",
"url": "/api/measures/component?component=fail&metricKeys=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/measures\/component(.)component=fail&metricKeys=alert_status(.*)"
},
"response": {
"status": 200,
Expand All @@ -346,7 +346,7 @@
{
"request": {
"method": "GET",
"url": "/api/measures/component?component=warning&metricKeys=alert_status,blocker_violations,critical_violations,major_violations,minor_violations,bugs,code_smells,info_violations,vulnerabilities"
"urlPattern": "\/api\/measures\/component(.)component=warning&metricKeys=alert_status(.*)"
},
"response": {
"status": 200,
Expand Down Expand Up @@ -420,9 +420,7 @@
"headers": {
"Content-Type": "application/json"
},
"transformers": [
"response-template"
],
"transformers": ["response-template"],
"bodyFileName": "zabbix/cpu.json"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.cognifide.cogboard.widget

fun String.makeUrlPublic(publicDomain: String): String {
if (this == "") return ""
if (publicDomain == "") return this

val rest = this.substringAfter("//").substringAfter("/")
return "${publicDomain.removeSuffix("/")}/$rest"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import com.cognifide.cogboard.config.service.BoardsConfigService
import com.cognifide.cogboard.http.auth.AuthenticationType
import com.cognifide.cogboard.widget.AsyncWidget
import com.cognifide.cogboard.widget.Widget
import com.cognifide.cogboard.widget.makeUrlPublic
import io.vertx.core.Vertx
import io.vertx.core.json.JsonObject
import kotlin.streams.toList
import com.cognifide.cogboard.CogboardConstants as CC

class JenkinsJobWidget(
Expand Down Expand Up @@ -35,28 +37,23 @@ class JenkinsJobWidget(
else Widget.Status.from(lastBuild.getString("result", ""))

lastBuild.put("branch", extractBranchInfo(lastBuild))
.put(CC.PROP_URL, makePublic(lastBuild.getString(CC.PROP_URL, "")))
.put(CC.PROP_URL, lastBuild.getString(CC.PROP_URL, "").makeUrlPublic(publicUrl))
.put(CC.PROP_WIDGET_STATUS, status)

send(lastBuild)
}

private fun makePublic(privateUrl: String): String {
return privateUrl.replace(url, publicUrl)
}

private fun extractBranchInfo(data: JsonObject): String {
var branch = "unknown"
data.getJsonArray("actions")
?.stream()
?.map { it as JsonObject }
?.filter { it.containsKey("lastBuiltRevision") }
?.findFirst()
?.ifPresent { action ->
action.getJsonObject("lastBuiltRevision")
.getJsonArray("branch")
?.first().let { branch = (it as JsonObject).getString("name") }
}
var branch: String
(data.getJsonArray("actions")
?.stream()
?.map { it as JsonObject }
?.filter { it.containsKey("lastBuiltRevision") }
?.toList()
?.last() as JsonObject)
.getJsonObject("lastBuiltRevision")
?.getJsonArray("branch")
?.first().let { branch = (it as JsonObject).getString("name") }
return branch
.replaceFirst("refs/remotes/origin/", "")
.replaceFirst("refs/", "")
Expand Down
Loading

0 comments on commit 8e6a215

Please sign in to comment.