Skip to content

Commit

Permalink
Split Organization view (#2868)
Browse files Browse the repository at this point in the history
* Split Organization view
  • Loading branch information
Cheshiriks authored Dec 6, 2023
1 parent 057f959 commit f9e84be
Show file tree
Hide file tree
Showing 44 changed files with 4,721 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum class FrontendCosvRoutes(val path: String) {
ABOUT_US("about"),
BAN("ban"),
COOKIE("cookie"),
CREATE_ORGANIZATION("create-organization"),
ERROR_404("404"),
MANAGE_ORGANIZATIONS("organizations"),
NOT_FOUND("not-found"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.saveourtool.save.cosv.frontend.components.basic

import com.saveourtool.save.frontend.common.components.views.organization.OrganizationMenuBar
import com.saveourtool.save.frontend.common.components.views.organization.OrganizationType

object CosvOrganizationType : OrganizationType {
override val listTab: Array<OrganizationMenuBar> = arrayOf(
OrganizationMenuBar.INFO,
OrganizationMenuBar.VULNERABILITIES,
OrganizationMenuBar.SETTINGS
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

package com.saveourtool.save.cosv.frontend.routing

import com.saveourtool.save.cosv.frontend.components.basic.CosvOrganizationType
import com.saveourtool.save.cosv.frontend.components.views.vuln.*
import com.saveourtool.save.cosv.frontend.components.views.vuln.toprating.topRatingView
import com.saveourtool.save.cosv.frontend.components.views.vuln.vulnerabilityCollectionView
import com.saveourtool.save.cosv.frontend.components.views.welcome.vulnWelcomeView
import com.saveourtool.save.frontend.common.components.views.FallbackView
import com.saveourtool.save.frontend.common.components.views.organization.createOrganizationView
import com.saveourtool.save.frontend.common.components.views.organization.organizationView
import com.saveourtool.save.frontend.common.components.views.registrationView
import com.saveourtool.save.frontend.common.components.views.userprofile.userProfileView
import com.saveourtool.save.frontend.common.components.views.usersettings.userSettingsView
Expand All @@ -29,6 +32,14 @@ import react.router.*
val basicRouting: FC<UserInfoAwareMutablePropsWithChildren> = FC { props ->
useUserStatusRedirects(props.userInfo?.status)

val organizationView = withRouter { location, params ->
organizationView {
organizationName = params["owner"]!!
currentUserInfo = props.userInfo
organizationType = CosvOrganizationType
}
}

val userProfileView = withRouter { _, params ->
userProfileView {
userName = params["name"]!!
Expand Down Expand Up @@ -68,6 +79,9 @@ val basicRouting: FC<UserInfoAwareMutablePropsWithChildren> = FC { props ->
vulnerabilityView.create() to "$VULNERABILITY_SINGLE/:identifier",
cosvSchemaView.create() to VULN_COSV_SCHEMA,
topRatingView.create() to VULN_TOP_RATING,

createOrganizationView.create() to CREATE_ORGANIZATION,
organizationView.create() to ":owner",
userProfileView.create() to "$PROFILE/:name",

userSettingsView.create {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@file:Suppress(
"FILE_NAME_MATCH_CLASS",
"FILE_WILDCARD_IMPORTS",
"WildcardImport",
"HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE",
)

package com.saveourtool.save.frontend.common.components.basic

import com.saveourtool.save.frontend.common.components.basic.testsuiteselector.TestSuiteSelectorMode
import com.saveourtool.save.testsuite.TestSuiteVersioned

import react.ChildrenBuilder
import react.dom.html.ReactHTML.a
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h5
import react.dom.html.ReactHTML.p
import react.dom.html.ReactHTML.small
import web.cssom.ClassName

/**
* @param testSuites
* @param selectedTestSuites
* @param displayMode if used not inside TestSuiteSelector, should be null, otherwise should be mode of TestSuiteSelector
* @param onTestSuiteClick
*/
@Suppress("TOO_LONG_FUNCTION", "LongMethod")
fun ChildrenBuilder.showAvailableTestSuites(
testSuites: List<TestSuiteVersioned>,
selectedTestSuites: List<TestSuiteVersioned>,
displayMode: TestSuiteSelectorMode?,
onTestSuiteClick: (TestSuiteVersioned) -> Unit,
) {
div {
className = ClassName("list-group")
testSuites.forEach { testSuite ->
val active = if (testSuite in selectedTestSuites) {
"active"
} else {
""
}
a {
className = ClassName("btn list-group-item list-group-item-action $active")
onClick = {
onTestSuiteClick(testSuite)
}
div {
className = ClassName("d-flex w-100 justify-content-between")
h5 {
className = ClassName("mb-1")
+(testSuite.name)
}
small {
+testSuite.language
}
}
div {
className = ClassName("clearfix mb-1")
div {
className = ClassName("float-left")
p {
+testSuite.description
}
}
div {
className = ClassName("float-right")
if (displayMode.shouldDisplayVersion()) {
small {
asDynamic()["data-toggle"] = "tooltip"
asDynamic()["data-placement"] = "bottom"
title = "Hash of commit/branch name/tag name"
+testSuite.version
}
}
}
}
div {
className = ClassName("clearfix")
small {
className = ClassName("float-left")
asDynamic()["data-toggle"] = "tooltip"
asDynamic()["data-placement"] = "bottom"
title = "Test suite tags"
+testSuite.tags
}

small {
className = ClassName("float-right")
asDynamic()["data-toggle"] = "tooltip"
asDynamic()["data-placement"] = "bottom"
title = "Plugin type"
+testSuite.plugins
}
}
}
}
}
}

private fun TestSuiteSelectorMode?.shouldDisplayVersion() = this != null && this != TestSuiteSelectorMode.BROWSER
Loading

0 comments on commit f9e84be

Please sign in to comment.