Skip to content

Commit

Permalink
WelcomeView -> saveWelcomeView (#2328)
Browse files Browse the repository at this point in the history
### What's done:
 * Refactored WelcomeView - now it is FC instead of ClassComponent
 * Fixed frontend compiler warnings
  • Loading branch information
sanyavertolet authored Jul 13, 2023
1 parent 753c9c4 commit cf68fc0
Show file tree
Hide file tree
Showing 23 changed files with 378 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ val graphEvents: FC<GraphEventsProps> = FC { props ->
enterNode = { event: dynamic ->
setHoveredNode(event.node)
}
leaveNode = { event: dynamic ->
leaveNode = { _: dynamic ->
setHoveredNode(undefined)
}
clickNode = { event: dynamic ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import react.useEffect
/**
* Component that is used to load the graph into sigma
*/
@Suppress("MAGIC_NUMBER", "COMPLEX_EXPRESSION")
@Suppress("MAGIC_NUMBER", "COMPLEX_EXPRESSION", "REDUNDANT_ELSE_IN_WHEN")
val graphLoader: FC<GraphLoaderProps> = FC { props ->
val loadGraph = useLoadGraph()
val circularAssign = useLayoutCircular().getPositions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private fun organizationToolsMenu() = FC<OrganizationToolsMenuProps> { props ->
column(id = "description", header = "Description") {
Fragment.create {
td {
+(it.value.description ?: "Description not provided")
+it.value.description
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
@file:Suppress("HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE")

package com.saveourtool.save.frontend.components.mobile

import com.saveourtool.save.frontend.components.views.welcome.chevron
import com.saveourtool.save.frontend.components.views.welcome.pagers.allWelcomePagers
import com.saveourtool.save.frontend.components.views.welcome.pagers.renderReadMorePage
import com.saveourtool.save.frontend.components.views.welcome.welcomeMarketingTitle
import com.saveourtool.save.frontend.externals.animations.animator
import com.saveourtool.save.frontend.externals.animations.scrollContainer
import com.saveourtool.save.frontend.externals.animations.scrollPage
import com.saveourtool.save.frontend.utils.particles

import js.core.jso
import react.ChildrenBuilder
import react.VFC
import react.dom.html.ReactHTML.b
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h4
import react.dom.html.ReactHTML.img
import web.cssom.*

/**
* As a temp stub it was decided to make several views to make SAVE looking nice on mobile devices
*/
val saveWelcomeMobileView: VFC = VFC {
div {
style = jso {
background =
"-webkit-linear-gradient(270deg, rgb(209, 229, 235), rgb(217, 215, 235))".unsafeCast<Background>()
}
particles()
sorryYourScreenIsTooSmall()
}
}

private fun ChildrenBuilder.sorryYourScreenIsTooSmall() {
notSupportedMobileYet()
title()
chevron("rgb(6, 7, 89)")

@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR")
scrollContainer {
scrollPage {}
allWelcomePagers.forEach { pager ->
scrollPage { }
pager.forEach {
scrollPage {
div {
animator {
animation = it.animation
it.renderPage(this)
}
}
}
}
}
}

renderReadMorePage()
}

private fun ChildrenBuilder.notSupportedMobileYet() {
div {
className = ClassName("row d-flex justify-content-center mx-auto text-danger mt-2")
h4 {
className = ClassName("text-center")
+"We do not "
b {
+"yet "
}
+"support devices with small screen size. But you can get familiar with SAVE using the information below."
}
}
div {
className = ClassName("row d-flex justify-content-center mx-auto")
img {
src = "img/sad_cat.gif"
@Suppress("MAGIC_NUMBER")
style = jso {
width = 12.rem
}
}
}
}

private fun ChildrenBuilder.title() {
div {
className = ClassName("row justify-content-center mx-auto")
// Marketing information
welcomeMarketingTitle("text-primary", true)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ open class AboutUsView : AbstractView<AboutUsViewProps, AboutUsViewState>(true)
protected val devCard = cardComponent(hasBg = true, isPaddingBottomNull = true)

/**
* card with an infor about SAVE with padding
* card with an info about SAVE with padding
*/
protected val infoCard = cardComponent(hasBg = true, isPaddingBottomNull = true, isNoPadding = false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ val contestTemplateView: FC<ContestTemplateViewProps> = FC { props ->

val (contestTemplate, setContestTemplate) = useState(ContestSampleDto.empty)
val (contestTemplateField, setContestTemplateField) = useState<List<ContestSampleFieldDto>>(emptyList())
val (user, setUser) = useState(props.currentUserInfo)

useRequest {
val contestTemplateNew: ContestSampleDto = get(
Expand All @@ -51,15 +50,6 @@ val contestTemplateView: FC<ContestTemplateViewProps> = FC { props ->
}

setContestTemplateField(contestTemplateFieldNew)

val userInfo: UserInfo = get(
url = "$apiUrl/users/${props.currentUserInfo?.name}",
headers = jsonHeaders,
loadingHandler = ::noopLoadingHandler,
)
.decodeFromJsonString()

setUser(userInfo)
}

div {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ external interface CountDownProps : Props {
var contests: Array<ContestDto>
}

internal val countDownTimer: FC<CountDownProps> = FC {props ->
internal val countDownTimer: FC<CountDownProps> = FC {_ ->
console.log(Date().toLocaleString())
TODO("This will be finished in phaze 2: this countdown timer should be in a featured contest")
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ internal val newContests = VFC {
className = ClassName("card-img-right flex-auto d-none d-md-block")
src = "img/undraw_exciting_news_re_y1iw.svg"
style = jso {
@Suppress("MAGIC_NUMBER") width = 12.rem
@Suppress("MAGIC_NUMBER")
width = 12.rem
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ val indexView: FC<IndexViewProps> = FC { props ->
*/
external interface IndexViewProps : Props {
/**
* Currently logged in user or null
* Currently logged-in user or null
*/
var userInfo: UserInfo?
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import web.cssom.rem

import kotlinx.browser.window

val indexAuth: FC<IndexViewProps> = FC { props ->
val indexAuth: FC<IndexViewProps> = FC { _ ->
val (oauthProviders, setOauthProviders) = useState(emptyList<OauthProviderInfo>())
val getOauthProviders = useDeferredRequest {
val usersFromDb: List<OauthProviderInfo> = get(
val availableProviders: List<OauthProviderInfo> = get(
"${window.location.origin}/sec/oauth-providers",
Headers(),
loadingHandler = ::noopLoadingHandler,
Expand All @@ -31,7 +31,7 @@ val indexAuth: FC<IndexViewProps> = FC { props ->
if (ok) decodeFromJsonString() else emptyList()
}

setOauthProviders(usersFromDb)
setOauthProviders(availableProviders)
}

useOnce {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import web.cssom.*
val userProfileView: FC<UserProfileViewProps> = FC { props ->
useBackground(Style.WHITE)

val (userName, setUserName) = useStateFromProps(props.userName)
val (userName, _) = useStateFromProps(props.userName)
val (user, setUser) = useState<UserInfo?>(null)
val (organizations, setOrganizations) = useState<List<OrganizationDto>>(emptyList())
val (selectedMenu, setSelectedMenu) = useState(UserProfileTab.VULNERABILITIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.saveourtool.save.frontend.components.views.usersettings
import com.saveourtool.save.frontend.components.basic.cardComponent
import com.saveourtool.save.frontend.components.inputform.InputTypes

import react.FC
import react.VFC
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.hr
Expand All @@ -16,7 +16,7 @@ import web.html.InputType
class UserSettingsEmailMenuView : UserSettingsView() {
private val emailCard = cardComponent(isBordered = false, hasBg = true)
@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR", "TOO_LONG_FUNCTION")
override fun renderMenu(): FC<UserSettingsProps> = FC { props ->
override fun renderMenu(): VFC = VFC {
emailCard {
div {
className = ClassName("row mt-2 ml-2 mr-2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UserSettingsOrganizationsMenuView : UserSettingsView() {
organizationWithUsers.copy(organization = organizationWithUsers.organization.copy(status = newStatus))

@Suppress("CyclomaticComplexMethod")
override fun renderMenu(): FC<UserSettingsProps> = FC { props ->
override fun renderMenu(): VFC = VFC {
organizationListCard {
div {
className = ClassName("d-sm-flex align-items-center justify-content-center mb-4 mt-4")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.saveourtool.save.frontend.components.views.usersettings
import com.saveourtool.save.frontend.components.basic.cardComponent
import com.saveourtool.save.frontend.components.inputform.InputTypes

import react.FC
import react.VFC
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.hr
Expand All @@ -16,7 +16,7 @@ import web.html.InputType
class UserSettingsProfileMenuView : UserSettingsView() {
private val card = cardComponent(isBordered = false, hasBg = true)
@Suppress("TOO_LONG_FUNCTION", "LongMethod", "EMPTY_BLOCK_STRUCTURE_ERROR")
override fun renderMenu(): FC<UserSettingsProps> = FC { props ->
override fun renderMenu(): VFC = VFC {
card {
div {
className = ClassName("row mt-2 ml-2 mr-2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.saveourtool.save.frontend.utils.noopLoadingHandler
import com.saveourtool.save.frontend.utils.post

import kotlinext.js.assign
import react.FC
import react.VFC
import react.dom.html.ReactHTML.button
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.h1
Expand All @@ -21,7 +21,7 @@ import kotlinx.coroutines.launch
class UserSettingsTokenMenuView : UserSettingsView() {
private val tokenCard = cardComponent(isBordered = false, hasBg = true)
@Suppress("TOO_LONG_FUNCTION")
override fun renderMenu(): FC<UserSettingsProps> = FC { props ->
override fun renderMenu(): VFC = VFC {
tokenCard {
div {
className = ClassName("d-sm-flex align-items-center justify-content-center mb-4")
Expand Down
Loading

0 comments on commit cf68fc0

Please sign in to comment.