Skip to content

Commit 2a3aab7

Browse files
committed
feat(model-server): added links for permission management to the repository overview page
1 parent da25835 commit 2a3aab7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

model-server/src/main/kotlin/org/modelix/model/server/handlers/ui/RepositoryOverview.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.ktor.utils.io.charsets.Charsets
1616
import kotlinx.html.FlowContent
1717
import kotlinx.html.FlowOrInteractiveOrPhrasingContent
1818
import kotlinx.html.HTML
19+
import kotlinx.html.HTMLTag
1920
import kotlinx.html.a
2021
import kotlinx.html.button
2122
import kotlinx.html.h1
@@ -26,6 +27,8 @@ import kotlinx.html.p
2627
import kotlinx.html.script
2728
import kotlinx.html.span
2829
import kotlinx.html.stream.createHTML
30+
import kotlinx.html.style
31+
import kotlinx.html.svg
2932
import kotlinx.html.table
3033
import kotlinx.html.tbody
3134
import kotlinx.html.td
@@ -34,6 +37,7 @@ import kotlinx.html.thead
3437
import kotlinx.html.title
3538
import kotlinx.html.tr
3639
import kotlinx.html.unsafe
40+
import kotlinx.html.visit
3741
import org.modelix.authorization.hasPermission
3842
import org.modelix.authorization.requiresLogin
3943
import org.modelix.model.lazy.RepositoryId
@@ -112,7 +116,7 @@ class RepositoryOverview(private val repoManager: IRepositoriesManager) {
112116
}
113117
th { +"Branch" }
114118
th {
115-
colSpan = "3"
119+
colSpan = "4"
116120
+"Actions"
117121
}
118122
}
@@ -125,6 +129,7 @@ class RepositoryOverview(private val repoManager: IRepositoriesManager) {
125129
td {
126130
rowSpan = repoRowSpan
127131
+repository.id
132+
buildPermissionManagementLink(repository.id, null)
128133
}
129134
td {
130135
rowSpan = repoRowSpan
@@ -145,6 +150,7 @@ class RepositoryOverview(private val repoManager: IRepositoriesManager) {
145150
span {
146151
+branch.branchName
147152
}
153+
buildPermissionManagementLink(repository.id, branch.branchName)
148154
}
149155
td {
150156
buildHistoryLink(repository.id, branch.branchName)
@@ -177,6 +183,19 @@ internal fun FlowOrInteractiveOrPhrasingContent.buildExploreLatestLink(repositor
177183
}
178184
}
179185

186+
internal fun FlowOrInteractiveOrPhrasingContent.buildPermissionManagementLink(repositoryId: String, branchName: String?) {
187+
val resourceId = ModelServerPermissionSchema.repository(repositoryId)
188+
.let { if (branchName == null) it.resource else it.branch(branchName).resource }
189+
.fullId
190+
a("../permissions/resources/${resourceId.encodeURLPathPart()}/") {
191+
svg {
192+
style = "color: rgba(0, 0, 0, 0.87); fill: rgba(0, 0, 0, 0.87); width: 20px; height: 20px;"
193+
attributes["viewBox"] = "0 0 24 24"
194+
HTMLTag("path", consumer, mapOf("d" to "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"), null, false, false).visit {}
195+
}
196+
}
197+
}
198+
180199
internal fun FlowContent.buildDeleteRepositoryForm(repositoryId: String) {
181200
button {
182201
name = "delete"

0 commit comments

Comments
 (0)