-
Notifications
You must be signed in to change notification settings - Fork 9
#353 | Pull request reminder widget (github / bitbucket) #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
3ec904f
13f9028
aa3ec40
78867d8
53ffcf5
53f7cc8
fe5980b
1d44b5a
f03e91e
791ba63
572ddb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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")) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use switch-case on |
||
| 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") | ||
|
||
| httpGet(url = "$apiUrl/repos$path/pulls") | ||
| } else { | ||
| httpGet(url = "https://api.bitbucket.org/2.0/repositories$path/pullrequests") | ||
|
||
| } | ||
| } else { | ||
| sendConfigurationError("Endpoint URL or Path is blank.") | ||
| } | ||
|
Comment on lines
+38
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this logic to a seprate class so we can just:
You can do this as an extension method on string class also. |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the introduction of
apiTypedropdown this will not be required.