Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class CogboardConstants {
const val JQL_QUERY = "jqlQuery"
const val BUCKET_QUERIES = "bucketQueries"
const val BUCKET_NAME = "bucketName"
const val PULL_REQUESTS = "pullRequests"
const val REPOSITORY_HUB = "repositoryHub"
Copy link
Contributor

@szymon-owczarzak szymon-owczarzak Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after the introduction of apiType dropdown this will not be required.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.cognifide.cogboard.widget.type.WorldClockWidget
import com.cognifide.cogboard.widget.type.randompicker.RandomPickerWidget
import com.cognifide.cogboard.widget.type.sonarqube.SonarQubeWidget
import com.cognifide.cogboard.widget.type.zabbix.ZabbixWidget
import com.cognifide.cogboard.widget.type.PullRequestReminderWidget
import io.vertx.core.Vertx
import io.vertx.core.json.JsonArray
import io.vertx.core.json.JsonObject
Expand Down Expand Up @@ -48,7 +49,8 @@ class WidgetIndex {
"Jira Buckets" to JiraBucketsWidget::class.java,
"Service Check" to ServiceCheckWidget::class.java,
"SonarQube" to SonarQubeWidget::class.java,
"White Space" to WhiteSpaceWidget::class.java
"White Space" to WhiteSpaceWidget::class.java,
"Pull Request Reminder" to PullRequestReminderWidget::class.java,
)

fun availableWidgets(): JsonArray {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.cognifide.cogboard.widget.type

import com.cognifide.cogboard.config.service.BoardsConfigService
import com.cognifide.cogboard.widget.AsyncWidget
import io.vertx.core.Vertx
import io.vertx.core.json.JsonObject
import com.cognifide.cogboard.CogboardConstants.Props
class PullRequestReminderWidget(
vertx: Vertx,
config: JsonObject,
serv: BoardsConfigService
) : AsyncWidget(vertx, config, serv) {

private val path: String = config.getString("path", "")

override fun handleResponse(responseBody: JsonObject) {
var pullRequests = responseBody

if (url.contains("github")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use switch-case on apiType instead

pullRequests = pullRequests
.put(Props.PULL_REQUESTS, responseBody.remove("array"))
.put(Props.REPOSITORY_HUB, "github")
} else {
pullRequests = pullRequests
.put(Props.PULL_REQUESTS, responseBody.remove("values"))
.put(Props.REPOSITORY_HUB, "bitbucket")
}

send(pullRequests)
}

override fun updateState() {
if (url.isNotBlank() && path.isNotBlank()) {
if (url.contains("github")) {
val apiUrl = url.replace("github.com/", "api.github.com")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work for commertial repos i think you should be replacing :// with ://api.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my project repo as an example: https://github.company.com/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit f03e91e

httpGet(url = "$apiUrl/repos$path/pulls")
} else {
httpGet(url = "https://api.bitbucket.org/2.0/repositories$path/pullrequests")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be able to setup some repos from here:
https://bitbucket.cognifide.com/dashboard

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f03e91e

}
} else {
sendConfigurationError("Endpoint URL or Path is blank.")
}
Comment on lines +38 to +48
Copy link
Contributor

@szymon-owczarzak szymon-owczarzak Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this logic to a seprate class so we can just:

httpGet(UrlUtil.getApiUrl(apiType, url, project, repository))

You can do this as an extension method on string class also.
httpGet(url.getApiUrl(apiType, project, repository))
https://kotlinlang.org/docs/extensions.html#extension-functions
write Unit tests for supported examples

}
}
4 changes: 2 additions & 2 deletions cogboard-local-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ services:
- "./mnt:/data"
networks:
- cognet
# ports:
# - "18092:18092"
# ports:
# - "18092:18092"

frontend:
image: "cogboard/cogboard-web:${COGBOARD_VERSION}"
Expand Down
Loading