-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return links to a new UI which is now a default.
- Loading branch information
Showing
2 changed files
with
48 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
teamcity-rest-client-impl/src/main/kotlin/org/jetbrains/teamcity/rest/coroutines/webLinks.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jetbrains.teamcity.rest.coroutines | ||
|
||
import org.jetbrains.teamcity.rest.* | ||
import java.net.URLEncoder | ||
|
||
class WebLinks(private val serverUrl: String) { | ||
fun buildConfigurationPage(id: BuildConfigurationId, branch: String? = null) = | ||
"$serverUrl/buildConfiguration/$id" + if (branch != null) "?${branch.urlencode()}" else "" | ||
|
||
fun buildPage(id: BuildId, configurationId: BuildConfigurationId? = null) = | ||
if (configurationId != null) { | ||
"$serverUrl/buildConfiguration/$configurationId/$id" | ||
} else { | ||
"$serverUrl/build/$id" | ||
} | ||
|
||
fun changePage(id: ChangeId, configurationId: BuildConfigurationId? = null, personal: Boolean? = null): String { | ||
val params = mutableListOf<String>() | ||
if (configurationId != null) | ||
params.add("buildTypeId=$configurationId") | ||
if (personal != null) | ||
params.add("personal=$personal") | ||
|
||
return "$serverUrl/change/$id" + | ||
if (params.isNotEmpty()) params.joinToString("&", prefix = "?") else "" | ||
} | ||
|
||
fun projectPage(id: ProjectId, branch: String? = null) = | ||
"$serverUrl/project/$id" + if (branch != null) "?${branch.urlencode()}" else "" | ||
|
||
fun testHistoryPage(id: TestId, projectId: ProjectId) = | ||
"$serverUrl/test/$id?currentProjectId=$projectId" | ||
|
||
fun userPage(id: UserId) = | ||
"$serverUrl/admin/editUser.html?userId=$id" | ||
} | ||
|
||
private fun String.urlencode(): String = URLEncoder.encode(this, "UTF-8") |