Skip to content

Commit

Permalink
Diktat fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 committed Sep 6, 2023
1 parent 2f8becb commit a989310
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ enum class VulnerabilityDateType(val value: String) {
PUBLISHED("Published"),

/**
* Date from [com.saveourtool.osv4k.OsvSchema.withdrawn] in COSV schema
* Date when the vuln was submitted to our archive, our platform specific
*/
WITHDRAWN("Withdrawn"),
SUBMITTED("Submitted"),

/**
* Date when the vuln was submitted to our archive, our platform specific
* Date from [com.saveourtool.osv4k.OsvSchema.withdrawn] in COSV schema
*/
SUBMITTED("Submitted")
WITHDRAWN("Withdrawn"),
;

override fun toString(): String = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.saveourtool.save.frontend.externals.animations.ringLoader
import com.saveourtool.save.info.UserInfo

import js.core.jso
import kotlinx.browser.window
import org.w3c.fetch.Response
import react.*
import react.dom.html.ReactHTML.button
Expand All @@ -21,6 +20,8 @@ import react.router.useNavigate
import web.cssom.ClassName
import web.html.ButtonType

import kotlinx.browser.window

/**
* Loader animation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import kotlinx.datetime.LocalDateTime
const val HOVERABLE_CONST = "hoverable"

val timelineComponent: FC<TimelineComponentProps> = FC { props ->
console.log(props.dates)
if (props.dates != undefined) {
val hoverable = props.onNodeClick?.let { HOVERABLE_CONST }.orEmpty()

div {
Expand Down Expand Up @@ -55,7 +53,7 @@ val timelineComponent: FC<TimelineComponentProps> = FC { props ->
.forEach { (label, dateTime) ->
div {
className =
ClassName(if (!label.isSubmittedType()) "step $hoverable" else "step-non-editable")
ClassName(if (!label.isSubmittedType()) "step $hoverable" else "step-non-editable")
if (!label.isSubmittedType()) {
props.onNodeClick?.let { onClickCallback ->
onClick = { onClickCallback(dateTime, label) }
Expand All @@ -80,13 +78,8 @@ val timelineComponent: FC<TimelineComponentProps> = FC { props ->
}
}
}
} else {

}
}

private fun String.isSubmittedType() = this == VulnerabilityDateType.SUBMITTED.value

/**
* [Props] of [timelineComponent]
*/
Expand Down Expand Up @@ -117,3 +110,5 @@ external interface TimelineComponentProps : Props {
*/
var vulnerability: VulnerabilityDto
}

private fun String.isSubmittedType() = this == VulnerabilityDateType.SUBMITTED.value
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.validation.FrontendRoutes

import js.core.jso
import kotlinx.browser.window
import react.*
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.div
Expand All @@ -28,6 +27,7 @@ import web.cssom.*
import web.html.ButtonType
import web.html.InputType

import kotlinx.browser.window
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@ import com.saveourtool.save.frontend.externals.fontawesome.*
import com.saveourtool.save.frontend.utils.*
import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.utils.toUnixCalendarFormat
import js.core.jso

import js.core.jso
import react.*
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h6
import react.dom.html.ReactHTML.hr
import react.dom.html.ReactHTML.label
import react.dom.html.ReactHTML.p
import react.dom.html.ReactHTML.textarea
import react.router.dom.Link
import web.cssom.ClassName
import web.cssom.TextDecoration.Companion.underline
import web.cssom.rem

import kotlinx.datetime.TimeZone
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import react.dom.html.ReactHTML.p
import web.cssom.Color
import web.cssom.TextDecoration.Companion.underline

/**
* [FC] that is used to display some general vulnerability information
Expand Down Expand Up @@ -60,13 +59,13 @@ val vulnerabilityGeneralInfo: FC<VulnerabilityGeneralInfo> = FC { props ->
if (props.isEditDisabled) {
// only Super Users and owners of unapproved vuln. can edit it
if (props.userInfo?.isSuperAdmin() == true ||
(props.userInfo?.name == userInfo.name && props.vulnerability.status != VulnerabilityStatus.APPROVED)) {
(props.userInfo?.name == userInfo.name && props.vulnerability.status != VulnerabilityStatus.APPROVED)) {
buttonBuilder(
labelBuilder = {
p {
className = ClassName("mb-0")
style = jso {
textDecoration = underline;
textDecoration = underline
}
+"Edit "
fontAwesomeIcon(icon = faEdit)
Expand Down Expand Up @@ -221,7 +220,7 @@ external interface VulnerabilityGeneralInfo : Props {
var vulnerability: VulnerabilityDto

/**
*
* Vulnerabilities setter
*/
var setVulnerability: StateSetter<VulnerabilityDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ import react.dom.html.ReactHTML.h6
import react.dom.html.ReactHTML.textarea
import react.router.useNavigate
import react.useState
import web.cssom.*

import kotlinx.browser.window
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import react.dom.html.ReactHTML.h4
import react.dom.html.ReactHTML.img
import web.cssom.*
import web.cssom.HtmlAttributes.Companion.src

internal val headerMenu: FC<HeaderMenuProps> = FC { props ->
val rejectVulnerabilityWindowOpenness = useWindowOpenness()
Expand Down Expand Up @@ -183,7 +180,6 @@ internal val headerMenu: FC<HeaderMenuProps> = FC { props ->
style = jso {
height = "7rem".unsafeCast<Height>()
}

}
}

Expand Down Expand Up @@ -213,7 +209,7 @@ internal val headerMenu: FC<HeaderMenuProps> = FC { props ->
}

if (props.permissions.isSuperAdmin ||
(props.permissions.isOwner && props.vulnerability.status != VulnerabilityStatus.APPROVED)
(props.permissions.isOwner && props.vulnerability.status != VulnerabilityStatus.APPROVED)
) {
buttonBuilder(
faTrash,
Expand Down Expand Up @@ -241,7 +237,6 @@ internal val headerMenu: FC<HeaderMenuProps> = FC { props ->
div {
className = ClassName("col-3")
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.saveourtool.save.frontend.externals.fontawesome.*
import com.saveourtool.save.frontend.utils.*
import com.saveourtool.save.info.UserInfo

import js.core.jso
import react.*
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ import web.cssom.*

const val HEADER_HEIGHT = "9rem"

fun borderEditStyle(pointerCursor: Boolean = false): CSSProperties = jso {
borderColor = "#5711d9".unsafeCast<BorderColor>()
borderStyle = "dashed".unsafeCast<BorderStyle>()
borderWidth = "thin".unsafeCast<BorderWidth>()
if (pointerCursor) {
cursor = "pointer".unsafeCast<Cursor>()
}
}

@Suppress(
"MAGIC_NUMBER",
"TOO_LONG_FUNCTION",
Expand Down Expand Up @@ -188,6 +179,19 @@ private fun ChildrenBuilder.languageSpan(language: VulnerabilityLanguage) {
}
}

/**
* @param pointerCursor
* @return returns the css for editable text form
*/
fun borderEditStyle(pointerCursor: Boolean = false): CSSProperties = jso {
borderColor = "#5711d9".unsafeCast<BorderColor>()
borderStyle = "dashed".unsafeCast<BorderStyle>()
borderWidth = "thin".unsafeCast<BorderWidth>()
if (pointerCursor) {
cursor = "pointer".unsafeCast<Cursor>()
}
}

/**
* @param currentUserInfo
* @param vulnerability
Expand Down

0 comments on commit a989310

Please sign in to comment.