Skip to content

Commit d48efe7

Browse files
authored
Fixed text displaying in tables on user and organization pages (#2860)
### What's done: - vulnerabilities and users tabs are now only displayed if there are new users to approve. - added text centering in tables on user, organization and project pages. - added colors for `Status` field depending on its value in the vulnerability table. - added colors for `Criticality` field depending on its value in the vulnerability table.
1 parent ebad7c8 commit d48efe7

7 files changed

Lines changed: 44 additions & 26 deletions

File tree

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/organizations/OrganizationContestsMenu.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private val contestsTable: FC<OrganizationContestsTableProps<ContestDto>> = tabl
4040
column(id = "name", header = "Contest Name", { name }) { cellContext ->
4141
Fragment.create {
4242
td {
43+
className = ClassName("align-middle text-center")
4344
Link {
4445
to = "/contests/${cellContext.row.original.name}"
4546
+cellContext.value
@@ -50,27 +51,31 @@ private val contestsTable: FC<OrganizationContestsTableProps<ContestDto>> = tabl
5051
column(id = "description", header = "Description", { description }) { cellContext ->
5152
Fragment.create {
5253
td {
54+
className = ClassName("align-middle text-center")
5355
+(cellContext.value ?: "Description is not provided")
5456
}
5557
}
5658
}
5759
column(id = "start_time", header = "Start Time", { startTime.toString() }) { cellContext ->
5860
Fragment.create {
5961
td {
62+
className = ClassName("align-middle text-center")
6063
+cellContext.value.replace("T", " ")
6164
}
6265
}
6366
}
6467
column(id = "end_time", header = "End Time", { endTime.toString() }) { cellContext ->
6568
Fragment.create {
6669
td {
70+
className = ClassName("align-middle text-center")
6771
+cellContext.value.replace("T", " ")
6872
}
6973
}
7074
}
7175
column("checkBox", "") { cellContext ->
7276
Fragment.create {
7377
td {
78+
className = ClassName("align-middle text-center")
7479
input {
7580
className = ClassName("mx-auto")
7681
type = InputType.checkbox
@@ -89,8 +94,6 @@ private val contestsTable: FC<OrganizationContestsTableProps<ContestDto>> = tabl
8994
}
9095
}
9196
},
92-
initialPageSize = 10,
93-
useServerPaging = false
9497
) {
9598
arrayOf(it.isContestCreated)
9699
}

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/organizations/OrganizationToolsMenu.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private fun organizationToolsMenu() = FC<OrganizationToolsMenuProps> { props ->
9999
Fragment.create {
100100
val projectDto = cellContext.row.original
101101
td {
102+
className = ClassName("align-middle text-center")
102103
when (projectDto.status) {
103104
ProjectStatus.CREATED -> div {
104105
Link {
@@ -124,13 +125,15 @@ private fun organizationToolsMenu() = FC<OrganizationToolsMenuProps> { props ->
124125
column(id = "description", header = "Description") {
125126
Fragment.create {
126127
td {
128+
className = ClassName("align-middle text-center")
127129
+it.value.description
128130
}
129131
}
130132
}
131133
column(id = "rating", header = "Contest Rating") {
132134
Fragment.create {
133135
td {
136+
className = ClassName("align-middle text-center")
134137
+"0"
135138
}
136139
}
@@ -143,6 +146,7 @@ private fun organizationToolsMenu() = FC<OrganizationToolsMenuProps> { props ->
143146
column(id = DELETE_BUTTON_COLUMN_ID, header = EMPTY_COLUMN_HEADER) { cellProps ->
144147
Fragment.create {
145148
td {
149+
className = ClassName("align-middle text-center")
146150
val project = cellProps.row.original
147151
val projectName = project.name
148152

@@ -260,7 +264,6 @@ private fun organizationToolsMenu() = FC<OrganizationToolsMenuProps> { props ->
260264
}
261265
}
262266
},
263-
useServerPaging = false
264267
) { tableProps ->
265268
/*-
266269
* Necessary for the table to get re-rendered once a project gets

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/projects/ProjectStatisticMenu.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,29 @@ private val executionDetailsTable: FC<TableProps<TestSuiteExecutionStatisticDto>
3030
column(id = "name", header = "Test suite", { testSuiteName }) {
3131
Fragment.create {
3232
td {
33+
className = ClassName("align-middle text-center")
3334
+it.value
3435
}
3536
}
3637
}
3738
column(id = "tests", header = "Number of tests", { countTest }) {
3839
Fragment.create {
3940
td {
41+
className = ClassName("align-middle text-center")
4042
+"${it.value}"
4143
}
4244
}
4345
}
4446
column(id = "rate", header = "Passed tests", { countWithStatusTest }) {
4547
Fragment.create {
4648
td {
49+
className = ClassName("align-middle text-center")
4750
+"${it.value}"
4851
}
4952
}
5053
}
5154
}
5255
},
53-
initialPageSize = 10,
54-
useServerPaging = false,
5556
)
5657

5758
/**

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/table/filters/VulnerabilitiesFiltersRow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ val vulnerabilitiesFiltersRow: FC<VulnerabilitiesFiltersProps> = FC { props ->
8888
border = "none".unsafeCast<Border>()
8989
boxShadow = "none".unsafeCast<BoxShadow>()
9090
}
91-
barLeftColor = "red"
92-
barRightColor = "green"
91+
barLeftColor = "green"
92+
barRightColor = "red"
9393
barInnerColor = Colors.WHITE.value
9494
thumbLeftColor = Colors.VULN_PRIMARY.value
9595
thumbRightColor = Colors.VULN_PRIMARY.value

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ val renderNewUsersTableForProfileView: FC<Props> = FC {
2929
Fragment.create {
3030
td {
3131
className = ClassName("align-middle")
32-
renderUserAvatarWithName(cellContext.row.original, isHorizontal = true, classes = "mr-2") {
32+
renderUserAvatarWithName(cellContext.row.original) {
3333
height = 3.rem
3434
width = 3.rem
3535
}
@@ -39,23 +39,21 @@ val renderNewUsersTableForProfileView: FC<Props> = FC {
3939
column(id = "originalName", header = "Original login") { cellContext ->
4040
Fragment.create {
4141
td {
42-
className = ClassName("align-middle")
42+
className = ClassName("align-middle text-center")
4343
+cellContext.value.originalLogins.firstNotNullOfOrNull { it.value }
4444
}
4545
}
4646
}
4747
column(id = "source", header = "Source") { cellContext ->
4848
Fragment.create {
4949
td {
50-
className = ClassName("align-middle")
50+
className = ClassName("align-middle text-center")
5151
+cellContext.value.originalLogins.firstNotNullOfOrNull { it.key }
5252
}
5353
}
5454
}
5555
}
5656
},
57-
initialPageSize = 10,
58-
useServerPaging = false,
5957
isTransparentGrid = true,
6058
)
6159

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileView.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,16 @@ val userProfileView: FC<UserProfileViewProps> = FC { props ->
9494
div {
9595
className = ClassName("col-7 mb-4 mt-2")
9696
props.currentUserInfo?.globalRole?.let { role ->
97-
@Suppress("MISSING_KDOC_ON_FUNCTION")
98-
fun UserProfileTab.toTabName() = if (this == UserProfileTab.USERS) "${this.name} ($countUsers)" else this.name
97+
if (role.isSuperAdmin() && props.currentUserInfo?.name == user?.name && countUsers > 0) {
98+
@Suppress("MISSING_KDOC_ON_FUNCTION")
99+
fun UserProfileTab.toTabName() = if (this == UserProfileTab.USERS) "${this.name} ($countUsers)" else this.name
99100

100-
val tabList = if (role.isSuperAdmin() && props.currentUserInfo?.name == user?.name) {
101-
UserProfileTab.entries.map { it.toTabName() }
102-
} else {
103-
UserProfileTab.entries.filter { it != UserProfileTab.USERS }.map { it.name }
104-
}
105-
tab(selectedMenu.toTabName(), tabList, "nav nav-tabs mt-3") { value ->
106-
val newValue = if (value.contains(UserProfileTab.USERS.name)) UserProfileTab.USERS.name else value
107-
setSelectedMenu { UserProfileTab.valueOf(newValue) }
101+
val tabList = UserProfileTab.entries.map { it.toTabName() }
102+
103+
tab(selectedMenu.toTabName(), tabList, "nav nav-tabs mt-3") { value ->
104+
val newValue = if (value.contains(UserProfileTab.USERS.name)) UserProfileTab.USERS.name else value
105+
setSelectedMenu { UserProfileTab.valueOf(newValue) }
106+
}
108107
}
109108
}
110109

save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/VulnerabilityTableComponent.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,15 @@ val vulnerabilityTableComponent: FC<VulnerabilityTableComponentProps> = FC { pro
138138
column(id = "severityNum", header = "Criticality".t(), { severityNum }) { cellContext ->
139139
Fragment.create {
140140
td {
141-
className = ClassName("align-middle text-center")
142-
+"${cellContext.row.original.severityNum}"
141+
val severityNum = cellContext.row.original.severityNum
142+
val severityNumColor = when (severityNum) {
143+
in 0.0f..4.9f -> "text-success"
144+
in 5.0f..7.5f -> "text-warning"
145+
in 7.6f..10.0f -> "text-danger"
146+
else -> ""
147+
}
148+
className = ClassName("align-middle $severityNumColor text-center")
149+
+(severityNum.toString())
143150
}
144151
}
145152
}
@@ -185,8 +192,15 @@ val vulnerabilityTableComponent: FC<VulnerabilityTableComponentProps> = FC { pro
185192
column(id = "status", header = "Status".t(), { status }) { cellContext ->
186193
Fragment.create {
187194
td {
188-
className = ClassName("align-middle text-center text-nowrap")
189-
+cellContext.row.original.status.value
195+
val status = cellContext.row.original.status.value
196+
val statusColor = when (status) {
197+
"Approved" -> "text-success"
198+
"Created", "Pending review" -> "text-warning"
199+
"Rejected" -> "text-danger"
200+
else -> ""
201+
}
202+
className = ClassName("align-middle $statusColor text-center text-nowrap")
203+
+status
190204
}
191205
}
192206
}

0 commit comments

Comments
 (0)