From 9463f76f178fd45f57278fcf61a707d9f144287a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:23:28 +0000 Subject: [PATCH 01/41] Update all non-major dependencies (except core Kotlin) --- gradle/libs.versions.toml | 46 +++++++++++++++++------------------ save-backend/build.gradle.kts | 2 +- settings.gradle.kts | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1d50286794..e802b66e37 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,47 +2,47 @@ kotlin = "1.9.0" jetbrains-annotations = "24.0.1" save-cli = "0.4.0-SNAPSHOT" -ktor = "2.3.1" +ktor = "2.3.5" okio = "3.3.0" serialization = "1.5.1" kotlinx-datetime = "0.4.0" kotlinx-coroutines = "1.7.2" -kotlin-wrappers = "1.0.0-pre.566" -spring-boot = "2.7.12" -spring-cloud = "3.1.7" -spring-cloud-kubernetes = "2.1.7" -kafka-client = "3.5.0" -junit = "5.9.3" +kotlin-wrappers = "1.0.0-pre.635" +spring-boot = "2.7.17" +spring-cloud = "3.1.8" +spring-cloud-kubernetes = "2.1.8" +kafka-client = "3.6.0" +junit = "5.10.0" assertj = "3.24.2" diktat = "1.2.5" -detekt = "1.23.0" -liquibase-core = "4.22.0" -docker-java = "3.3.1" -jgit = "6.6.0.202305301015-r" +detekt = "1.23.1" +liquibase-core = "4.24.0" +docker-java = "3.3.3" +jgit = "6.7.0.202309050840-r" mockito = "5.3.1" mockito-kotlin = "5.0.0" # only in save-cli -log4j = "2.20.0" +log4j = "2.21.0" jpa = "1.0.2" mySql = "8.0.33" -testcontainers = "1.18.3" +testcontainers = "1.19.1" okhttp3 = "4.11.0" -reckon = "0.18.0" -commons-compress = "1.23.0" +reckon = "0.18.1" +commons-compress = "1.24.0" zip4j = "2.11.5" ktoml = "0.5.0" springdoc = "1.7.0" kotlinx-cli = "0.3.5" -spotless = "6.19.0" -fabric8 = "6.7.1" -arrow-kt = "1.1.5" +spotless = "6.22.0" +fabric8 = "6.9.0" +arrow-kt = "1.2.1" publish = "1.3.0" -download = "5.4.0" -cpg = "7.0.0" +download = "5.5.0" +cpg = "7.1.2" # should be taken from cpg cpg-neo4j-ogm = { strictly = "4.0.4" } cpg-neo4j-java-driver = { strictly = "5.6.0" } -aws-sdk = "2.20.84" +aws-sdk = "2.21.5" cosv4k = "0.0.14" [plugins] @@ -52,7 +52,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kotlin-plugin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" } kotlin-plugin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" } -talaiot-base = { id = "io.github.cdsap.talaiot.plugin.base", version = "2.0.1" } +talaiot-base = { id = "io.github.cdsap.talaiot.plugin.base", version = "2.0.3" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } spotless = { id = "com.diffplug.gradle.spotless", version.ref = "spotless" } download = { id = "de.undercouch.download", version.ref = "download" } @@ -121,7 +121,7 @@ springdoc-openapi-ui = { module = "org.springdoc:springdoc-openapi-ui", version. springdoc-openapi-webflux-ui = { module = "org.springdoc:springdoc-openapi-webflux-ui", version.ref = "springdoc" } springdoc-openapi-security = { module = "org.springdoc:springdoc-openapi-security", version.ref = "springdoc" } springdoc-openapi-kotlin = { module = "org.springdoc:springdoc-openapi-kotlin", version.ref = "springdoc" } -swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version = "2.2.11" } +swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version = "2.2.17" } ktor-client-apache = { module = "io.ktor:ktor-client-apache", version.ref = "ktor" } ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" } diff --git a/save-backend/build.gradle.kts b/save-backend/build.gradle.kts index 20fb7c5f48..0316899d2a 100644 --- a/save-backend/build.gradle.kts +++ b/save-backend/build.gradle.kts @@ -9,7 +9,7 @@ plugins { id("com.saveourtool.save.buildutils.code-quality-convention") // this plugin will generate generateOpenApiDocs task // running this task, it will write the OpenAPI spec into a backend-api-docs.json file in save-backend dir. - id("org.springdoc.openapi-gradle-plugin") version "1.6.0" + id("org.springdoc.openapi-gradle-plugin") version "1.8.0" } openApi { diff --git a/settings.gradle.kts b/settings.gradle.kts index e8546687fe..12b40171a1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -31,7 +31,7 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.13.3" + id("com.gradle.enterprise") version "3.15.1" } includeBuild("gradle/plugins") From 8ea5a2b8b54c396c67e24bcaf157b2cbc028afe6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 23 Oct 2023 11:28:09 +0000 Subject: [PATCH 02/41] Update yarn.lock --- yarn.lock | 350 ++++++++++++++++++++++-------------------------------- 1 file changed, 145 insertions(+), 205 deletions(-) diff --git a/yarn.lock b/yarn.lock index e4a64bbdb0..66e40fb1c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,7 +66,7 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/runtime@^7.12.5", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.18.9", "@babel/runtime@^7.20.13", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7": +"@babel/runtime@^7.12.5", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.13", "@babel/runtime@^7.22.5", "@babel/runtime@^7.23.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7": version "7.23.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.2.tgz#062b0ac103261d68a966c4c7baf2ae3e62ec3885" integrity sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg== @@ -87,39 +87,6 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== -"@date-io/core@^2.15.0": - version "2.15.0" - resolved "https://registry.yarnpkg.com/@date-io/core/-/core-2.15.0.tgz#8133860c8ce163b8d0cca3c1caed8d5d1fbfb14e" - integrity sha512-3CRvQUEK7aF87NUOwcTtmJ2Rc1kN0D4jFQUfRoanuAnE4o5HzHx4E2YenjaKjSPWeZYiWG6ZhDomx5hp1AaCJA== - -"@date-io/date-fns@^2.15.0": - version "2.15.0" - resolved "https://registry.yarnpkg.com/@date-io/date-fns/-/date-fns-2.15.0.tgz#2541144f4fc40365efd7d0b7affa5d77dbe59102" - integrity sha512-hkVeLm0jijHS2F9YVQcf0LSlD55w9xPvvIfuxDE0XWNXOTcRAAhqw2aqOxyeGbmHxc5U4HqyPZaqs9tfeTsomQ== - dependencies: - "@date-io/core" "^2.15.0" - -"@date-io/dayjs@^2.15.0": - version "2.15.0" - resolved "https://registry.yarnpkg.com/@date-io/dayjs/-/dayjs-2.15.0.tgz#474a42586e67be1108a6f68b0a2e5e6088620fb6" - integrity sha512-wgYzwaXr9KxkHNYxrOb1t8fYLfAdjIf0Q86qdVCwANObcvyGcPBm0uFtpPK7ApeE4DJUlbuG0IX75TtO+uITwQ== - dependencies: - "@date-io/core" "^2.15.0" - -"@date-io/luxon@^2.15.0": - version "2.15.0" - resolved "https://registry.yarnpkg.com/@date-io/luxon/-/luxon-2.15.0.tgz#ad5bea9c46b46230bd780dc91413f31d1967830f" - integrity sha512-CxTRCo5AM96ainnYaTpe1NS9GiA78SIgXBScgeAresCS20AvMcOd5XKerDj+y/KLhbSQbU6WUDqG9QcsrImXyQ== - dependencies: - "@date-io/core" "^2.15.0" - -"@date-io/moment@^2.15.0": - version "2.15.0" - resolved "https://registry.yarnpkg.com/@date-io/moment/-/moment-2.15.0.tgz#d6c2c88b58534d0c44644abcfefc27cb32182dd8" - integrity sha512-AcYBjl3EnEGsByaM5ir644CKbhgJsgc1iWFa9EXfdb4fQexxOC8oCdPAurK2ZDTwg62odyyKa/05YE7ElYh5ag== - dependencies: - "@date-io/core" "^2.15.0" - "@discoveryjs/json-ext@^0.5.0": version "0.5.5" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.5.tgz#9283c9ce5b289a3c4f61c12757469e59377f81f3" @@ -169,14 +136,7 @@ resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.9.1.tgz#4ffb0055f7ef676ebc3a5a91fb621393294e2f43" integrity sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ== -"@emotion/is-prop-valid@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz#7f2d35c97891669f7e276eb71c83376a5dc44c83" - integrity sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg== - dependencies: - "@emotion/memoize" "^0.8.0" - -"@emotion/memoize@^0.8.0", "@emotion/memoize@^0.8.1": +"@emotion/memoize@^0.8.1": version "0.8.1" resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.1.tgz#c1ddb040429c6d21d38cc945fe75c818cfb68e17" integrity sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA== @@ -212,6 +172,33 @@ resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.3.1.tgz#d0fce5d07b0620caa282b5131c297bb60f9d87e6" integrity sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww== +"@floating-ui/core@^1.4.2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.5.0.tgz#5c05c60d5ae2d05101c3021c1a2a350ddc027f8c" + integrity sha512-kK1h4m36DQ0UHGj5Ah4db7R0rHemTqqO0QLvUqi1/mUUp3LuAWbWxdxSIf/XsnH9VS6rRVPLJCncjRzUvyCLXg== + dependencies: + "@floating-ui/utils" "^0.1.3" + +"@floating-ui/dom@^1.5.1": + version "1.5.3" + resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.5.3.tgz#54e50efcb432c06c23cd33de2b575102005436fa" + integrity sha512-ClAbQnEqJAKCJOEbbLo5IUlZHkNszqhuxS4fHAVxRPXPya6Ysf2G8KypnYcOTpx6I8xcgF9bbHb6g/2KpbV8qA== + dependencies: + "@floating-ui/core" "^1.4.2" + "@floating-ui/utils" "^0.1.3" + +"@floating-ui/react-dom@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-2.0.2.tgz#fab244d64db08e6bed7be4b5fcce65315ef44d20" + integrity sha512-5qhlDvjaLmAst/rKb3VdlCinwTF4EYMiVxuuc/HVUjs46W0zgtbMmAZ1UTsDrRTxRmUEzl92mOtWbeeXL26lSQ== + dependencies: + "@floating-ui/dom" "^1.5.1" + +"@floating-ui/utils@^0.1.3": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.1.6.tgz#22958c042e10b67463997bd6ea7115fe28cbcaf9" + integrity sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A== + "@fortawesome/fontawesome-common-types@^0.2.35", "@fortawesome/fontawesome-common-types@^0.2.36": version "0.2.36" resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.36.tgz#b44e52db3b6b20523e0c57ef8c42d315532cb903" @@ -315,145 +302,110 @@ outvariant "^1.2.1" strict-event-emitter "^0.2.0" -"@mui/base@5.0.0-alpha.125": - version "5.0.0-alpha.125" - resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.125.tgz#6bb3df0760d87aa9186ed9add29b3ae96dee4aa8" - integrity sha512-hAHJJ97SATu6SrkLH/HsAayK1zMZt89lrWyKuAInBKVyn363H78d1MnwyZwre9vDK5MrPoDL/NnZxtAXhwTnBA== - dependencies: - "@babel/runtime" "^7.21.0" - "@emotion/is-prop-valid" "^1.2.0" - "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.0" - "@popperjs/core" "^2.11.7" - clsx "^1.2.1" +"@mui/base@5.0.0-beta.18": + version "5.0.0-beta.18" + resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-beta.18.tgz#f95d393cf80974e77c0823170cc15c854d5af84b" + integrity sha512-e9ZCy/ndhyt5MTshAS3qAUy/40UiO0jX+kAo6a+XirrPJE+rrQW+mKPSI0uyp+5z4Vh+z0pvNoJ2S2gSrNz3BQ== + dependencies: + "@babel/runtime" "^7.23.1" + "@floating-ui/react-dom" "^2.0.2" + "@mui/types" "^7.2.5" + "@mui/utils" "^5.14.12" + "@popperjs/core" "^2.11.8" + clsx "^2.0.0" prop-types "^15.8.1" - react-is "^18.2.0" - -"@mui/base@5.0.0-alpha.126": - version "5.0.0-alpha.126" - resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.126.tgz#99555a5876a60e7dad772d75eb171e3d1336321d" - integrity sha512-I5e52A0Muv9Gaoy2GcqbYrQ6dpRyC2UXeA00brT3HuW0nF0E4fiTOIqdNTN+N5gyaYK0z3O6jtLt/97CCrIxVA== - dependencies: - "@babel/runtime" "^7.21.0" - "@emotion/is-prop-valid" "^1.2.0" - "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.0" - "@popperjs/core" "^2.11.7" - clsx "^1.2.1" - prop-types "^15.8.1" - react-is "^18.2.0" -"@mui/core-downloads-tracker@^5.12.1": - version "5.13.4" - resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.13.4.tgz#7e4b491d8081b6d45ae51556d82cb16b31315a19" - integrity sha512-yFrMWcrlI0TqRN5jpb6Ma9iI7sGTHpytdzzL33oskFHNQ8UgrtPas33Y1K7sWAMwCrr1qbWDrOHLAQG4tAzuSw== - -"@mui/icons-material@5.11.16": - version "5.11.16" - resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.11.16.tgz#417fa773c56672e39d6ccfed9ac55591985f0d38" - integrity sha512-oKkx9z9Kwg40NtcIajF9uOXhxiyTZrrm9nmIJ4UjkU2IdHpd4QVLbCc/5hZN/y0C6qzi2Zlxyr9TGddQx2vx2A== - dependencies: - "@babel/runtime" "^7.21.0" - -"@mui/lab@5.0.0-alpha.126": - version "5.0.0-alpha.126" - resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.126.tgz#70b35fa0c6be7a0516d5e1b2252c4a31b6f98474" - integrity sha512-Hdv0q0mO2B+S1NGkEBJcBYiapmNEMlDF4PKko+v5StB0ntLA0+U/hB8RVBbjh7eqbUyZI1/wVvLH9+HxNA6Qyw== - dependencies: - "@babel/runtime" "^7.21.0" - "@mui/base" "5.0.0-alpha.125" - "@mui/system" "^5.12.0" - "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.0" - clsx "^1.2.1" +"@mui/base@^5.0.0-beta.18": + version "5.0.0-beta.20" + resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-beta.20.tgz#14fcdfe0350f2aad06ab6c37c4c91dacaab8f600" + integrity sha512-CS2pUuqxST7ch9VNDCklRYDbJ3rru20Tx7na92QvVVKfu3RL4z/QLuVIc8jYGsdCnauMaeUSlFNLAJNb0yXe6w== + dependencies: + "@babel/runtime" "^7.23.1" + "@floating-ui/react-dom" "^2.0.2" + "@mui/types" "^7.2.6" + "@mui/utils" "^5.14.13" + "@popperjs/core" "^2.11.8" + clsx "^2.0.0" prop-types "^15.8.1" - react-is "^18.2.0" -"@mui/material@5.12.1": - version "5.12.1" - resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.12.1.tgz#3297ffc6836f426a26568332d68357c1398f0630" - integrity sha512-m+G9J6+FzIMhRqKV2y30yONH97wX107z9EWgiNCeS1/+y1CnytFZNG1ENdOuaJo1NimCRnmB/iXPvoOaSo6dOg== - dependencies: - "@babel/runtime" "^7.21.0" - "@mui/base" "5.0.0-alpha.126" - "@mui/core-downloads-tracker" "^5.12.1" - "@mui/system" "^5.12.1" - "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.0" - "@types/react-transition-group" "^4.4.5" - clsx "^1.2.1" +"@mui/core-downloads-tracker@^5.14.12": + version "5.14.14" + resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.14.14.tgz#a54894e9b4dc908ab2d59eac543219d9018448e6" + integrity sha512-Rw/xKiTOUgXD8hdKqj60aC6QcGprMipG7ne2giK6Mz7b4PlhL/xog9xLeclY3BxsRLkZQ05egFnIEY1CSibTbw== + +"@mui/icons-material@5.14.12": + version "5.14.12" + resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.14.12.tgz#6634cdc3198bc438e8d38ce591c96d63d5df99a0" + integrity sha512-aFm6g/AIB3RQN9h/4MKoBoBybLZXeR3aDHWNx6KzemEpIlElUxv5uXRX5Qk1VC6v/YPkhbaPsiLLjsRSTiZF3w== + dependencies: + "@babel/runtime" "^7.23.1" + +"@mui/material@5.14.12": + version "5.14.12" + resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.14.12.tgz#8fa5bebd1a096796a288b548f1ba867e068601c8" + integrity sha512-EelF2L46VcVqhg3KjzIGBBpOtcBgRh0MMy9Efuk6Do81QdcZsFC9RebCVAflo5jIdbHiBmxBs5/l5Q9NjONozg== + dependencies: + "@babel/runtime" "^7.23.1" + "@mui/base" "5.0.0-beta.18" + "@mui/core-downloads-tracker" "^5.14.12" + "@mui/system" "^5.14.12" + "@mui/types" "^7.2.5" + "@mui/utils" "^5.14.12" + "@types/react-transition-group" "^4.4.6" + clsx "^2.0.0" csstype "^3.1.2" prop-types "^15.8.1" react-is "^18.2.0" react-transition-group "^4.4.5" -"@mui/private-theming@^5.13.1": - version "5.13.1" - resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.13.1.tgz#c3e9a0b44f9c5a51b92cfcfb660536060cb61ed7" - integrity sha512-HW4npLUD9BAkVppOUZHeO1FOKUJWAwbpy0VQoGe3McUYTlck1HezGHQCfBQ5S/Nszi7EViqiimECVl9xi+/WjQ== +"@mui/private-theming@^5.14.14": + version "5.14.14" + resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.14.14.tgz#035dde1eb30c896c69a12b7dee1dce3a323c66e9" + integrity sha512-n77au3CQj9uu16hak2Y+rvbGSBaJKxziG/gEbOLVGrAuqZ+ycVSkorCfN6Y/4XgYOpG/xvmuiY3JwhAEOzY3iA== dependencies: - "@babel/runtime" "^7.21.0" - "@mui/utils" "^5.13.1" + "@babel/runtime" "^7.23.1" + "@mui/utils" "^5.14.13" prop-types "^15.8.1" -"@mui/styled-engine@^5.13.2": - version "5.13.2" - resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.13.2.tgz#c87bd61c0ab8086d34828b6defe97c02bcd642ef" - integrity sha512-VCYCU6xVtXOrIN8lcbuPmoG+u7FYuOERG++fpY74hPpEWkyFQG97F+/XfTQVYzlR2m7nPjnwVUgATcTCMEaMvw== +"@mui/styled-engine@^5.14.13": + version "5.14.14" + resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.14.14.tgz#b0ededf531fff1ef110f7b263c2d3d95a0b8ec9a" + integrity sha512-sF3DS2PVG+cFWvkVHQQaGFpL1h6gSwOW3L91pdxPLQDHDZ5mZ/X0SlXU5XA+WjypoysG4urdAQC7CH/BRvUiqg== dependencies: - "@babel/runtime" "^7.21.0" + "@babel/runtime" "^7.23.1" "@emotion/cache" "^11.11.0" csstype "^3.1.2" prop-types "^15.8.1" -"@mui/system@^5.12.0", "@mui/system@^5.12.1": - version "5.13.5" - resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.13.5.tgz#9f67ea0c4f6974713f90b7b94c999fd3f40f8de3" - integrity sha512-n0gzUxoZ2ZHZgnExkh2Htvo9uW2oakofgPRQrDoa/GQOWyRD0NH9MDszBwOb6AAoXZb+OV5TE7I4LeZ/dzgHYA== - dependencies: - "@babel/runtime" "^7.21.0" - "@mui/private-theming" "^5.13.1" - "@mui/styled-engine" "^5.13.2" - "@mui/types" "^7.2.4" - "@mui/utils" "^5.13.1" - clsx "^1.2.1" +"@mui/system@^5.14.12": + version "5.14.14" + resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.14.14.tgz#f33327e74230523169107ace960e8bb51cbdbab7" + integrity sha512-y4InFmCgGGWXnz+iK4jRTWVikY0HgYnABjz4wgiUgEa2W1H8M4ow+27BegExUWPkj4TWthQ2qG9FOGSMtI+PKA== + dependencies: + "@babel/runtime" "^7.23.1" + "@mui/private-theming" "^5.14.14" + "@mui/styled-engine" "^5.14.13" + "@mui/types" "^7.2.6" + "@mui/utils" "^5.14.13" + clsx "^2.0.0" csstype "^3.1.2" prop-types "^15.8.1" -"@mui/types@^7.2.4": - version "7.2.4" - resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.2.4.tgz#b6fade19323b754c5c6de679a38f068fd50b9328" - integrity sha512-LBcwa8rN84bKF+f5sDyku42w1NTxaPgPyYKODsh01U1fVstTClbUoSA96oyRBnSNyEiAVjKm6Gwx9vjR+xyqHA== +"@mui/types@^7.2.5", "@mui/types@^7.2.6": + version "7.2.6" + resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.2.6.tgz#d72b9e9eb0032e107e76033932d65c3f731d2608" + integrity sha512-7sjLQrUmBwufm/M7jw/quNiPK/oor2+pGUQP2CULRcFCArYTq78oJ3D5esTaL0UMkXKJvDqXn6Ike69yAOBQng== -"@mui/utils@^5.10.3", "@mui/utils@^5.12.0", "@mui/utils@^5.13.1": - version "5.13.1" - resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.13.1.tgz#86199e46014215f95da046a5ec803f4a39c96eee" - integrity sha512-6lXdWwmlUbEU2jUI8blw38Kt+3ly7xkmV9ljzY4Q20WhsJMWiNry9CX8M+TaP/HbtuyR8XKsdMgQW7h7MM3n3A== +"@mui/utils@^5.14.12", "@mui/utils@^5.14.13": + version "5.14.14" + resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.14.14.tgz#7b2a0bcfb44c3376fc81f85500f9bd01706682ac" + integrity sha512-3AKp8uksje5sRfVrtgG9Q/2TBsHWVBUtA0NaXliZqGcXo8J+A+Agp0qUW2rJ+ivgPWTCCubz9FZVT2IQZ3bGsw== dependencies: - "@babel/runtime" "^7.21.0" - "@types/prop-types" "^15.7.5" - "@types/react-is" "^18.2.0" + "@babel/runtime" "^7.23.1" + "@types/prop-types" "^15.7.7" prop-types "^15.8.1" react-is "^18.2.0" -"@mui/x-date-pickers@5.0.4": - version "5.0.4" - resolved "https://registry.yarnpkg.com/@mui/x-date-pickers/-/x-date-pickers-5.0.4.tgz#79a509354eea4bedaa955ee52f37d80256d7e415" - integrity sha512-Co4tbwqXSdHfR8UoZSHQpDZqnFdikzQr0lQPG2AjGh9BdB4EdY3YE2+sZyAltjk/AXxp5JzIWDZ2Kj83ClzjwA== - dependencies: - "@babel/runtime" "^7.18.9" - "@date-io/core" "^2.15.0" - "@date-io/date-fns" "^2.15.0" - "@date-io/dayjs" "^2.15.0" - "@date-io/luxon" "^2.15.0" - "@date-io/moment" "^2.15.0" - "@mui/utils" "^5.10.3" - "@types/react-transition-group" "^4.4.5" - clsx "^1.2.1" - prop-types "^15.7.2" - react-transition-group "^4.4.5" - rifm "^0.12.1" - "@open-draft/until@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca" @@ -464,7 +416,7 @@ resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1" integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g== -"@popperjs/core@^2.0.0", "@popperjs/core@^2.11.7", "@popperjs/core@^2.11.8": +"@popperjs/core@^2.0.0", "@popperjs/core@^2.11.8": version "2.11.8" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== @@ -502,27 +454,27 @@ dependencies: "@react-sigma/layout-core" "^3.1.0" -"@remix-run/router@1.6.3", "@remix-run/router@^1.6.3": - version "1.6.3" - resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.6.3.tgz#8205baf6e17ef93be35bf62c37d2d594e9be0dad" - integrity sha512-EXJysQ7J3veRECd0kZFQwYYd5sJMcq2O/m60zu1W2l3oVQ9xtub8jTOtYRE0+M2iomyG/W3Ps7+vp2kna0C27Q== +"@remix-run/router@1.10.0", "@remix-run/router@^1.10.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.10.0.tgz#e2170dc2049b06e65bbe883adad0e8ddf8291278" + integrity sha512-Lm+fYpMfZoEucJ7cMxgt4dYt8jLfbpwRCzAjm9UgSLOkmlqo9gupxt6YX3DY0Fk155NT9l17d/ydi+964uS9Lw== "@socket.io/base64-arraybuffer@~1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#568d9beae00b0d835f4f8c53fd55714986492e61" integrity sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ== -"@tanstack/react-table@^8.9.2": - version "8.9.2" - resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.9.2.tgz#31b9e72387b888fca200d3397d11cc1baf7fa841" - integrity sha512-Irvw4wqVF9hhuYzmNrlae4IKdlmgSyoRWnApSLebvYzqHoi5tEsYzBj6YPd0hX78aB/L+4w/jgK2eBQVpGfThQ== +"@tanstack/react-table@^8.10.0": + version "8.10.7" + resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.10.7.tgz#733f4bee8cf5aa19582f944dd0fd3224b21e8c94" + integrity sha512-bXhjA7xsTcsW8JPTTYlUg/FuBpn8MNjiEPhkNhIGCUR6iRQM2+WEco4OBpvDeVcR9SE+bmWLzdfiY7bCbCSVuA== dependencies: - "@tanstack/table-core" "8.9.2" + "@tanstack/table-core" "8.10.7" -"@tanstack/table-core@8.9.2", "@tanstack/table-core@^8.9.2": - version "8.9.2" - resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.9.2.tgz#0402364a2a9692edf04e05ee6f385dfa27271da5" - integrity sha512-ajc0OF+karBAdaSz7OK09rCoAHB1XI1+wEhu+tDNMPc+XcO+dTlXXN/Vc0a8vym4kElvEjXEDd9c8Zfgt4bekA== +"@tanstack/table-core@8.10.7", "@tanstack/table-core@^8.10.0": + version "8.10.7" + resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.10.7.tgz#577e8a635048875de4c9d6d6a3c21d26ff9f9d08" + integrity sha512-KQk5OMg5OH6rmbHZxuNROvdI+hKDIUxANaHlV+dPlNN7ED3qYQ/WkpY2qlXww1SIdeMlkIhpN/2L00rof0fXFw== "@testing-library/dom@^8.5.0": version "8.13.0" @@ -725,10 +677,10 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== -"@types/prop-types@*", "@types/prop-types@^15.0.0", "@types/prop-types@^15.7.5": - version "15.7.5" - resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" - integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== +"@types/prop-types@*", "@types/prop-types@^15.0.0", "@types/prop-types@^15.7.7": + version "15.7.9" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.9.tgz#b6f785caa7ea1fe4414d9df42ee0ab67f23d8a6d" + integrity sha512-n1yyPsugYNSmHgxDFjicaI2+gCNjsBck8UX9kuofAKlc0h1bL+20oSF72KeNaW2DUlesbEVCFgyV2dPGTiY42g== "@types/qs@*": version "6.9.7" @@ -747,17 +699,10 @@ dependencies: "@types/react" "*" -"@types/react-is@^18.2.0": - version "18.2.0" - resolved "https://registry.yarnpkg.com/@types/react-is/-/react-is-18.2.0.tgz#2f5137853a46017b3d56447940fb3eb92bbf24a5" - integrity sha512-1vz2yObaQkLL7YFe/pme2cpvDsCwI1WXIfL+5eLz0MI9gFG24Re16RzUsI8t9XZn9ZWvgLNDrJBmrqXJO7GNQQ== - dependencies: - "@types/react" "*" - -"@types/react-transition-group@^4.4.5": - version "4.4.5" - resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.5.tgz#aae20dcf773c5aa275d5b9f7cdbca638abc5e416" - integrity sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA== +"@types/react-transition-group@^4.4.6": + version "4.4.8" + resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.8.tgz#46f87d80512959cac793ecc610a93d80ef241ccf" + integrity sha512-QmQ22q+Pb+HQSn04NL3HtrqHwYMf4h3QKArOy5F8U5nEVMaihBs3SR10WiOM1iwPz5jIo8x/u11al+iEGZZrvg== dependencies: "@types/react" "*" @@ -1710,10 +1655,10 @@ clone@^1.0.2: resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= -clsx@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12" - integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg== +clsx@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.0.0.tgz#12658f3fd98fafe62075595a5c30e43d18f3d00b" + integrity sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q== co@^4.6.0: version "4.6.0" @@ -5321,20 +5266,20 @@ react-modal@^3.0.0: react-lifecycles-compat "^3.0.0" warning "^4.0.3" -react-router-dom@6.12.0: - version "6.12.0" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.12.0.tgz#372279caaaa1ffb0204926c83e93a139b112d861" - integrity sha512-UzLwZ3ZVaDr6YV0HdjwxuwtDKgwpJx9o1ea9fU0HV4tTvzdB8WPHzlLFMo5orchpIS84e8G4Erlhu7Rl84XDFQ== +react-router-dom@^6.17.0: + version "6.17.0" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.17.0.tgz#ea73f89186546c1cf72b10fcb7356d874321b2ad" + integrity sha512-qWHkkbXQX+6li0COUUPKAUkxjNNqPJuiBd27dVwQGDNsuFBdMbrS6UZ0CLYc4CsbdLYTckn4oB4tGDuPZpPhaQ== dependencies: - "@remix-run/router" "1.6.3" - react-router "6.12.0" + "@remix-run/router" "1.10.0" + react-router "6.17.0" -react-router@6.12.0: - version "6.12.0" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.12.0.tgz#1afae9219c24c8611809469d7a386c8023ade39a" - integrity sha512-/tCGtLq9umxRvbYeIx3j94CmpQfue0E3qnetVm9luKhu58cR4t+3O4ZrQXBdXfJrBATOAj+wF/1ihJJQI8AoTw== +react-router@6.17.0, react-router@^6.17.0: + version "6.17.0" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.17.0.tgz#7b680c4cefbc425b57537eb9c73bedecbdc67c1e" + integrity sha512-YJR3OTJzi3zhqeJYADHANCGPUu9J+6fT5GLv82UWRGSxu6oJYCKVmxUcaBQuGm9udpWmPsvpme/CdHumqgsoaA== dependencies: - "@remix-run/router" "1.6.3" + "@remix-run/router" "1.10.0" react-scroll-motion@^0.3.0: version "0.3.0" @@ -5538,11 +5483,6 @@ rfdc@^1.3.0: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== -rifm@^0.12.1: - version "0.12.1" - resolved "https://registry.yarnpkg.com/rifm/-/rifm-0.12.1.tgz#8fa77f45b7f1cda2a0068787ac821f0593967ac4" - integrity sha512-OGA1Bitg/dSJtI/c4dh90svzaUPt228kzFsUkJbtA2c964IqEAwWXeL9ZJi86xWv3j5SMqRvGULl7bA6cK0Bvg== - rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" From 20c9a758e8973c2b9e1590d350a0ae1d327ed983 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 14:38:10 +0300 Subject: [PATCH 03/41] upgraded neo4j libs with cpg --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e802b66e37..c8ba5356e5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -40,8 +40,8 @@ publish = "1.3.0" download = "5.5.0" cpg = "7.1.2" # should be taken from cpg -cpg-neo4j-ogm = { strictly = "4.0.4" } -cpg-neo4j-java-driver = { strictly = "5.6.0" } +cpg-neo4j-ogm = { strictly = "4.0.6" } +cpg-neo4j-java-driver = { strictly = "5.7.0" } aws-sdk = "2.21.5" cosv4k = "0.0.14" From 19804814d7aca7ad71d57ac8fed7836073f6e172 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 15:36:42 +0300 Subject: [PATCH 04/41] detektAll --- .../save/orchestrator/docker/DockerContainerRunner.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/save-orchestrator-common/src/main/kotlin/com/saveourtool/save/orchestrator/docker/DockerContainerRunner.kt b/save-orchestrator-common/src/main/kotlin/com/saveourtool/save/orchestrator/docker/DockerContainerRunner.kt index 48028af105..7223cc81b1 100644 --- a/save-orchestrator-common/src/main/kotlin/com/saveourtool/save/orchestrator/docker/DockerContainerRunner.kt +++ b/save-orchestrator-common/src/main/kotlin/com/saveourtool/save/orchestrator/docker/DockerContainerRunner.kt @@ -61,7 +61,7 @@ class DockerContainerRunner( throw ContainerRunnerException("Failed to fetch image ${configuration.imageTag}", dex) } - (1..replicas).forEach { number -> + for (number in 1..replicas) { log.info("Creating a container #$number for execution.id=$executionId") val containerId = try { createContainerFromImage(configuration, containerName(executionId, number)) From d1d23b984707b98973c466c2ec5d1de9839cdb4a Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 17:54:57 +0300 Subject: [PATCH 05/41] removed usage VFC --- .../com/saveourtool/save/frontend/components/Footer.kt | 2 +- .../save/frontend/components/basic/CookieBanner.kt | 4 ++-- .../save/frontend/components/basic/LanguageSelector.kt | 4 ++-- .../save/frontend/components/basic/TestStatusComponent.kt | 7 ++++--- .../components/basic/VulnerabilityIntroductionComponent.kt | 4 ++-- .../basic/demo/welcome/DemoIntroductionComponent.kt | 5 +++-- .../components/basic/demo/welcome/DemoListComponent.kt | 5 +++-- .../components/basic/demo/welcome/DemoStatistics.kt | 5 +++-- .../components/basic/demo/welcome/FeaturedDemos.kt | 5 +++-- .../frontend/components/mobile/SaveWelcomeMobileView.kt | 5 +++-- .../frontend/components/views/CreateOrganizationView.kt | 2 +- .../save/frontend/components/views/CreateProjectView.kt | 2 +- .../save/frontend/components/views/SandboxView.kt | 2 +- .../frontend/components/views/TestExecutionDetailsView.kt | 2 +- .../components/views/agreements/CookiesTermsOfUse.kt | 4 ++-- .../frontend/components/views/agreements/TermsOfUsage.kt | 5 +++-- .../frontend/components/views/contests/ContestListCard.kt | 2 +- .../components/views/contests/ContestSampleListCard.kt | 4 ++-- .../components/views/contests/ContestsStatistics.kt | 5 +++-- .../components/views/contests/CreateContestTemplateView.kt | 5 +++-- .../components/views/contests/CreateNewContestTemplate.kt | 5 +++-- .../frontend/components/views/contests/FeaturedContests.kt | 2 +- .../frontend/components/views/contests/GlobalRating.kt | 2 +- .../save/frontend/components/views/contests/NewContests.kt | 5 +++-- .../components/views/contests/WelcomeToSaveContests.kt | 5 +++-- .../save/frontend/components/views/demo/CpgView.kt | 2 +- .../frontend/components/views/demo/DemoCollectionView.kt | 5 +++-- .../frontend/components/views/index/IndexLogoButtons.kt | 5 +++-- .../save/frontend/components/views/index/IndexViewAuth.kt | 4 ++-- .../save/frontend/components/views/test/analysis/Utils.kt | 5 +++-- .../frontend/components/views/toprating/TopRatingView.kt | 5 +++-- .../views/usersettings/SettingsViewLeftColumn.kt | 2 +- .../save/frontend/components/views/vuln/CosvSchemaView.kt | 5 +++-- .../components/views/vuln/CreateVulnerabilityView.kt | 5 +++-- .../components/views/vuln/UploadVulnerabilityView.kt | 5 +++-- .../com/saveourtool/save/frontend/routing/MobileRouting.kt | 6 ++---- .../com/saveourtool/save/frontend/utils/RouterUtils.kt | 2 +- .../saveourtool/save/frontend/utils/ServerSentEventTest.kt | 5 +++-- 38 files changed, 86 insertions(+), 68 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt index 0d9dda1c74..74329ab899 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt @@ -16,7 +16,7 @@ import web.cssom.ClassName @JsExport @OptIn(ExperimentalJsExport::class) @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -val footer: VFC = VFC { +val footer: FC = FC { footer { className = ClassName("sticky-footer bg-white") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt index fe421b3eff..ca3e2f52c3 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt @@ -12,14 +12,14 @@ import com.saveourtool.save.frontend.utils.buttonBuilder import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.FC -import react.VFC +import react.Props import react.dom.html.ReactHTML.div import react.router.useNavigate import react.useState import web.cssom.ClassName import web.cssom.ZIndex -val cookieBanner: VFC = FC { +val cookieBanner: FC = FC { val (isOpen, setIsOpen) = useState(!cookie.isAccepted()) val navigate = useNavigate() val (t) = useTranslation("cookies") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt index 2de44c47d3..365eb67415 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt @@ -11,7 +11,7 @@ import com.saveourtool.save.frontend.externals.i18next.language import com.saveourtool.save.frontend.externals.i18next.useTranslation import js.core.jso import react.FC -import react.VFC +import react.Props import react.dom.aria.AriaHasPopup import react.dom.aria.ariaExpanded import react.dom.aria.ariaHasPopup @@ -29,7 +29,7 @@ private const val LANG_DROPDOWN_ID = "lang-dropdown" /** * A [FC] that is responsible for language selection */ -val languageSelector: VFC = FC { +val languageSelector: FC = FC { val (_, i18n) = useTranslation("topbar") val languageFromCookie = if (cookie.isAccepted()) { PlatformLanguages.getByCodeOrDefault(cookie.getLanguageCode()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt index d67df79aba..b42dcdc5d0 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt @@ -14,7 +14,8 @@ import com.saveourtool.save.frontend.components.tables.visibleColumnsCount import com.saveourtool.save.frontend.externals.fontawesome.faExternalLinkAlt import com.saveourtool.save.frontend.utils.buttonBuilder -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.samp import react.dom.html.ReactHTML.small import react.dom.html.ReactHTML.td @@ -40,7 +41,7 @@ fun testStatusComponent( testResultDebugInfo: TestResultDebugInfo, tableInstance: Table, testExecutionDto: TestExecutionDto, -) = VFC { +) = FC { val shortMessage: String = when (val status: TestStatus = testResultDebugInfo.testStatus) { is Pass -> (status.shortMessage ?: "").ifBlank { "Completed successfully without additional information" } is Fail -> status.shortReason @@ -120,7 +121,7 @@ fun testStatusComponent( fun executionStatusComponent( failReason: String, tableInstance: Table -) = VFC { +: FC = FC { tr { td { colSpan = 2 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt index f9482cd64b..614e14b6b8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt @@ -6,14 +6,14 @@ import com.saveourtool.save.frontend.components.views.vuln.columnHeight import com.saveourtool.save.frontend.externals.i18next.useTranslation import js.core.jso import react.FC -import react.VFC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.img import react.dom.html.ReactHTML.strong import web.cssom.ClassName @Suppress("IDENTIFIER_LENGTH") -val vulnerabilityIntroductionComponent: VFC = FC { +val vulnerabilityIntroductionComponent: FC = FC { val (t) = useTranslation("vulnerability-collection") div { className = ClassName("card flex-md-column box-shadow") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt index 186ed4cd2e..3e3a3a268a 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt @@ -7,7 +7,8 @@ package com.saveourtool.save.frontend.components.basic.demo.welcome import com.saveourtool.save.frontend.components.basic.markdown import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.img import react.dom.html.ReactHTML.strong @@ -33,7 +34,7 @@ private val saveDemoHowToMd = """ """.trimMargin() @Suppress("MAGIC_NUMBER") -internal val introductionSection = VFC { +internal val introductionSectio: FC = FC { div { className = ClassName("card flex-md-column mb-1 box-shadow") style = jso { minHeight = 25.rem } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt index 8be83de3db..3fc130a6d7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt @@ -11,7 +11,8 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.noopLoadingHandler import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.input import react.dom.html.ReactHTML.ul @@ -25,7 +26,7 @@ import kotlinx.serialization.json.Json private val withBackground = cardComponent(isBordered = true, hasBg = true, isPaddingBottomNull = true) -val demoList = VFC { +val demoList = FC { val (filter, setFilter) = useState(DemoFilter.running) val (demoDtos, setDemoDtos) = useState>(emptyList()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt index b036f7b56f..29b8fd2896 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt @@ -8,7 +8,8 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.noopLoadingHandler import com.saveourtool.save.frontend.utils.noopResponseHandler -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.strong @@ -16,7 +17,7 @@ import react.useState import web.cssom.ClassName @Suppress("TOO_LONG_FUNCTION", "LongMethod") -internal val statistics = VFC { +internal val statistics = FC { val (activeDemoAmount, setActiveDemoAmount) = useState(0) useRequest { val active: Int = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt index c987e76aaa..7c9e984938 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt @@ -10,7 +10,8 @@ import com.saveourtool.save.frontend.components.basic.carousel import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.noopResponseHandler -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.h3 @@ -21,7 +22,7 @@ import react.useEffect import react.useState import web.cssom.ClassName -internal val featuredDemos = VFC { +internal val featuredDemos = FC { val (featuredDemos, setFeaturedDemos) = useState( listOf( DemoDto.emptyForProject("saveourtool", "Diktat"), diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt index da913bfd12..92fbad5a32 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt @@ -14,7 +14,8 @@ import com.saveourtool.save.frontend.utils.particles import js.core.jso import react.ChildrenBuilder -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.b import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h4 @@ -24,7 +25,7 @@ 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 { +val saveWelcomeMobileView: FC = FC { div { style = jso { background = SAVE_LIGHT_GRADIENT.unsafeCast() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt index 9dfea4840e..36a21fdd4b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt @@ -33,7 +33,7 @@ import web.html.ButtonType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createOrganizationView = VFC { +val createOrganizationVie: FC = FC { useBackground(Style.SAVE_DARK) particles() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt index a90693af44..510a302fc5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt @@ -46,7 +46,7 @@ import kotlinx.serialization.json.Json private val organizationSelectForm: SelectFormFunctionalComponent = selectFormRequired() -val createProjectView = VFC { +val createProjectVie: FC = FC { useBackground(Style.SAVE_DARK) particles() val params = useParams() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt index a7b0cb2ded..8bf1c8c98f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt @@ -38,7 +38,7 @@ val sandboxApiUrl = "${window.location.origin}/api/sandbox" /** * A view for testing config files */ -val sandboxView = VFC { +val sandboxVie: FC = FC { useBackground(Style.SAVE_DARK) val (debugInfo, setDebugInfo) = useState(null) val (selectedSdk, setSelectedSdk) = useState(Sdk.Default) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt index d0f026ab4d..cf9bb39b35 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt @@ -30,7 +30,7 @@ import web.cssom.ClassName * @return a function component */ @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION", "TOO_LONG_FUNCTION") -val testExecutionDetailsView = VFC { +val testExecutionDetailsVie: FC = FC { val (status, setStatus) = useState("Loading...") val (testResultDebugInfo, setTestResultDebugInfo) = useState(null) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt index 1d0b3e5bcc..b5bb5c3292 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt @@ -11,11 +11,11 @@ import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.buttonBuilder import com.saveourtool.save.frontend.utils.useBackground import react.FC -import react.VFC +import react.Props import react.dom.html.ReactHTML.div import web.cssom.ClassName -val cookieTermsOfUse: VFC = FC { +val cookieTermsOfUse: FC = FC { useBackground(Style.INDEX) val (t) = useTranslation("cookies") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt index 0419aacfe7..9cb9d84d98 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt @@ -7,7 +7,8 @@ package com.saveourtool.save.frontend.components.views.agreements import com.saveourtool.save.frontend.components.basic.markdown import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.useBackground -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import web.cssom.ClassName @@ -129,7 +130,7 @@ private val termsOfUsageContent = listOf( generalProvisions, ) -val termsOfUsageView: VFC = VFC { +val termsOfUsageView: FC = FC { useBackground(Style.INDEX) div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt index 93e7980e91..1916bafc42 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt @@ -32,7 +32,7 @@ import web.html.ButtonType /** * [FC] that renders the stylish table with contests */ -val contestList = VFC { +val contestLis: FC = FC { val (isContestEnrollerModalOpen, setIsContestEnrollerModalOpen) = useState(false) val (isConfirmationModalOpen, setIsConfirmationModalOpen) = useState(false) val (enrollmentResponseString, setEnrollmentResponseString) = useState("") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt index 2da2136efe..0a0d11072d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt @@ -11,7 +11,7 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.validation.FrontendRoutes import react.FC import react.Fragment -import react.VFC +import react.Props import react.create import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.td @@ -45,7 +45,7 @@ private val contestSampleTable: FC> = tableComponen useServerPaging = false, ) -internal val contestSampleList = VFC { +internal val contestSampleList: FC = FC { div { className = ClassName("col") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt index 519dffc161..58c521d31d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt @@ -9,7 +9,8 @@ import com.saveourtool.save.frontend.utils.* import js.core.jso import react.ChildrenBuilder -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.strong @@ -17,7 +18,7 @@ import react.useState import web.cssom.ClassName import web.cssom.rem -internal val statistics = VFC { +internal val statistics: FC = FC { val (activeContests, setActiveContests) = useState>(emptySet()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt index 6fc5ea889f..8b3291dbf4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt @@ -10,7 +10,8 @@ import com.saveourtool.save.frontend.components.inputform.inputTextFormRequired import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.validation.FrontendRoutes -import react.VFC +import react.FC +import react.Props import react.dom.aria.ariaDescribedBy import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form @@ -29,7 +30,7 @@ import web.html.InputType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createContestTemplateView: VFC = VFC { +val createContestTemplateView: FC = FC{ useBackground(Style.SAVE_DARK) val (contestTemplate, setContestTemplate) = useState(ContestSampleDto.empty) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt index abda232be5..fdc6776b14 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt @@ -4,14 +4,15 @@ package com.saveourtool.save.frontend.components.views.contests import com.saveourtool.save.validation.FrontendRoutes import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 import react.dom.html.ReactHTML.img import react.router.dom.Link import web.cssom.* -internal val createNewContestTemplate = VFC { +internal val createNewContestTemplate: FC = FC { div { className = ClassName("col-2 text-center") Link { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt index a6b702e9cb..3ae70abf11 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt @@ -27,7 +27,7 @@ import web.cssom.* import web.html.ButtonType @Suppress("MAGIC_NUMBER") -internal val featuredContests = VFC { +internal val featuredContest: FC = FC { val (featuredContests, setFeaturedContests) = useState>(emptyList()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt index a7958c44a5..d8bf77706d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt @@ -32,7 +32,7 @@ private const val MAX_AMOUNT_OF_RECORDS = 3 /** * @return functional component for the rating card */ -internal val globalRating = VFC { +internal val globalRatin: FC = FC { val (selectedTab, setSelectedTab) = useState(UserRatingTab.ORGS) val (organizationsWithRating, setOrganizationsWithRating) = useState>(emptySet()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt index 356d41fe39..26a0d10305 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt @@ -8,7 +8,8 @@ import com.saveourtool.save.entities.contest.ContestDto import com.saveourtool.save.frontend.utils.* import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 import react.dom.html.ReactHTML.img @@ -22,7 +23,7 @@ import web.cssom.rem /** * rendering of newly added contests */ -internal val newContests = VFC { +internal val newContests: FC = FC { val (newContests, setNewContests) = useState>(emptyList()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt index 0cc4cda594..fb2c84ecfc 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt @@ -6,7 +6,8 @@ package com.saveourtool.save.frontend.components.views.contests import js.core.jso import react.ChildrenBuilder -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.b import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 @@ -19,7 +20,7 @@ import web.cssom.rem /** * Rendering of featured contest card */ -internal val welcomeToSaveContests = VFC { +internal val welcomeToSaveContest: FC = FC { div { className = ClassName("col-5") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt index 2554ed53dd..562f9558b1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt @@ -42,7 +42,7 @@ private val backgroundCard = cardComponent(hasBg = false, isPaddingBottomNull = @Suppress( "EMPTY_BLOCK_STRUCTURE_ERROR", ) -val cpgView: VFC = VFC { +val cpgView: FC = FC { useBackground(Style.SAVE_LIGHT) val (cpgResult, setCpgResult) = useState(CpgResult.empty) val (isLogs, setIsLogs) = useState(false) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt index 4060907ce5..b643f014b5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt @@ -9,12 +9,13 @@ import com.saveourtool.save.frontend.components.basic.demo.welcome.featuredDemos import com.saveourtool.save.frontend.components.basic.demo.welcome.introductionSection import com.saveourtool.save.frontend.utils.* -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.main import web.cssom.ClassName -val demoCollectionView: VFC = VFC { +val demoCollectionView: FC = FC { useBackground(Style.SAVE_DARK) main { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt index b13024cb30..a9be300808 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt @@ -8,7 +8,8 @@ import com.saveourtool.save.frontend.externals.i18next.useTranslation import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.ChildrenBuilder -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.button import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h4 @@ -17,7 +18,7 @@ import react.dom.html.ReactHTML.span import react.router.dom.Link import web.cssom.* -val logoButtons = VFC { +val logoButton: FC = FC { val (t) = useTranslation("index") div { className = ClassName("row logo-parent mb-5 d-flex justify-content-center") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt index 049b4ed469..9f5fc70eac 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt @@ -11,7 +11,7 @@ import com.saveourtool.save.info.OauthProviderInfo import org.w3c.fetch.Headers import react.FC -import react.VFC +import react.Props import react.dom.html.ReactHTML.div import react.useState import web.cssom.ClassName @@ -69,7 +69,7 @@ val indexAuth: FC = FC { _ -> } } -val separator = VFC { +val separato: FC = FC { val (t) = useTranslation("welcome") div { className = ClassName("row mt-2") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt index 70678dd394..b3c66ecc24 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt @@ -8,7 +8,8 @@ import react.CSSProperties import react.ChildrenBuilder import react.FC import react.Props -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.abbr import react.dom.html.ReactHTML.span import web.cssom.ClassName @@ -35,7 +36,7 @@ internal val listStyle: CSSProperties = jso { /** * The placeholder displayed when there's no data available. */ -internal val noDataAvailable: FC = VFC { +internal val noDataAvailable: FC = FC { span { className = ClassName("noDataAvailable") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt index f4f0d83e20..a17d885c52 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt @@ -13,13 +13,14 @@ import com.saveourtool.save.frontend.externals.fontawesome.faTrophy import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.useBackground import com.saveourtool.save.validation.FrontendRoutes -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.useState import web.cssom.ClassName -val topRatingView = VFC { +val topRatingVie: FC = FC { useBackground(Style.SAVE_LIGHT) val (selectedMenu, setSelectedMenu) = useState(TopRatingTab.USERS) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt index 666cf3a819..6866bfbf06 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt @@ -98,7 +98,7 @@ val leftSettingsColumn: FC = FC { props -> } } -val settingsTabs = VFC { +val settingsTab: FC = FC { val (t) = useTranslation("profile") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt index 652d863e44..bd397b846d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt @@ -10,7 +10,8 @@ import com.saveourtool.save.frontend.components.views.vuln.utils.keysOnlyFromCos import com.saveourtool.save.frontend.utils.* import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.a import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 @@ -21,7 +22,7 @@ import react.useState import web.cssom.* @Suppress("TOO_MANY_LINES_IN_LAMBDA", "PARAMETER_NAME_IN_OUTER_LAMBDA") -val cosvSchemaView = VFC { +val cosvSchemaVie: FC = FC { particles() useBackground(Style.VULN_DARK) val (textInModal, setTextInModal) = useState>() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt index 6c98bc95ce..6c777c0352 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt @@ -31,7 +31,8 @@ import com.saveourtool.osv4k.Severity import com.saveourtool.osv4k.SeverityType import js.core.jso import react.ChildrenBuilder -import react.VFC +import react.FC +import react.Props import react.dom.aria.ariaDescribedBy import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form @@ -58,7 +59,7 @@ import kotlinx.serialization.json.Json "LONG_LINE", "MaxLineLength", ) -val createVulnerabilityView: VFC = VFC { +val createVulnerabilityView: FC = FC { useBackground(Style.VULN_DARK) val navigate = useNavigate() useTooltip() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt index 009cd840ea..878d7e9604 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt @@ -9,7 +9,8 @@ import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.particles import com.saveourtool.save.frontend.utils.useBackground import js.core.jso -import react.VFC +import react.FC +import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form import react.dom.html.ReactHTML.h1 @@ -17,7 +18,7 @@ import react.dom.html.ReactHTML.span import web.cssom.ClassName import web.cssom.ZIndex -val uploadVulnerabilityView: VFC = VFC { +val uploadVulnerabilityView: FC = FC { useBackground(Style.VULN_DARK) val (t) = useTranslation("vulnerability-upload") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt index d2a4e7858c..c9990479fd 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt @@ -7,16 +7,14 @@ package com.saveourtool.save.frontend.routing import com.saveourtool.save.frontend.components.mobile.AboutUsMobileView import com.saveourtool.save.frontend.components.mobile.saveWelcomeMobileView import com.saveourtool.save.validation.FrontendRoutes -import react.VFC -import react.create -import react.react +import react.* import react.router.PathRoute import react.router.Routes /** * Just put a map: View -> Route URL to this list */ -val mobileRoutes = VFC { +val mobileRoutes = FC { Routes { listOf( AboutUsMobileView::class.react.create() to FrontendRoutes.ABOUT_US, diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt index 43b74b8ecc..64c6da70ce 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt @@ -26,7 +26,7 @@ interface NavigateFunctionContext { * @param handler DOM builder that can consume [NavigateFunctionContext] */ fun ChildrenBuilder.withNavigate(handler: ChildrenBuilder.(NavigateFunctionContext) -> Unit) { - val wrapper: VFC = VFC { + val wrapper: FC = FC { val navigate = useNavigate() val ctx = object : NavigateFunctionContext { override val navigate: NavigateFunction = navigate diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt index 17f65c39dd..8b8e24e0f7 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt @@ -3,7 +3,8 @@ package com.saveourtool.save.frontend.utils import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.rest import com.saveourtool.save.frontend.externals.setupWorker -import react.VFC +import react.FC +import react.Props import react.create import kotlin.js.Promise import kotlin.test.Test @@ -60,7 +61,7 @@ class ServerSentEventTest { val messages = mutableListOf() var responseStatus: Short = 0 - val testComponent: VFC = VFC { + val testComponent: FC = FC { useNdjson( url = "${window.location.origin}/test", onCompletion = { responseStatus = OK }, From bcaaf89f76b56b79b9d0ef4d4faa2c72d4621e06 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 18:31:25 +0300 Subject: [PATCH 06/41] support new routing --- .../components/basic/TestStatusComponent.kt | 4 +- .../demo/welcome/DemoIntroductionComponent.kt | 2 +- .../basic/demo/welcome/DemoListComponent.kt | 2 +- .../basic/demo/welcome/DemoStatistics.kt | 2 +- .../basic/demo/welcome/FeaturedDemos.kt | 2 +- .../views/CreateOrganizationView.kt | 2 +- .../components/views/CreateProjectView.kt | 2 +- .../frontend/components/views/SandboxView.kt | 2 +- .../views/TestExecutionDetailsView.kt | 2 +- .../views/contests/ContestListCard.kt | 2 +- .../components/views/contests/GlobalRating.kt | 2 +- .../components/views/index/IndexViewAuth.kt | 2 +- .../views/toprating/TopRatingView.kt | 2 +- .../usersettings/SettingsViewLeftColumn.kt | 2 +- .../components/views/vuln/CosvSchemaView.kt | 2 +- .../save/frontend/routing/BasicRouting.kt | 100 ++++++++++-------- .../save/frontend/routing/MobileRouting.kt | 32 +++--- .../save/frontend/utils/RouterUtils.kt | 2 +- 18 files changed, 90 insertions(+), 76 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt index b42dcdc5d0..473ea59cf0 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt @@ -41,7 +41,7 @@ fun testStatusComponent( testResultDebugInfo: TestResultDebugInfo, tableInstance: Table, testExecutionDto: TestExecutionDto, -) = FC { +): FC = FC { val shortMessage: String = when (val status: TestStatus = testResultDebugInfo.testStatus) { is Pass -> (status.shortMessage ?: "").ifBlank { "Completed successfully without additional information" } is Fail -> status.shortReason @@ -121,7 +121,7 @@ fun testStatusComponent( fun executionStatusComponent( failReason: String, tableInstance: Table -: FC = FC { +): FC = FC { tr { td { colSpan = 2 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt index 3e3a3a268a..2d6cd4a7e7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt @@ -34,7 +34,7 @@ private val saveDemoHowToMd = """ """.trimMargin() @Suppress("MAGIC_NUMBER") -internal val introductionSectio: FC = FC { +internal val introductionSection: FC = FC { div { className = ClassName("card flex-md-column mb-1 box-shadow") style = jso { minHeight = 25.rem } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt index 3fc130a6d7..e94ed6ec7d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt @@ -26,7 +26,7 @@ import kotlinx.serialization.json.Json private val withBackground = cardComponent(isBordered = true, hasBg = true, isPaddingBottomNull = true) -val demoList = FC { +val demoList: FC = FC { val (filter, setFilter) = useState(DemoFilter.running) val (demoDtos, setDemoDtos) = useState>(emptyList()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt index 29b8fd2896..25e27f9902 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt @@ -17,7 +17,7 @@ import react.useState import web.cssom.ClassName @Suppress("TOO_LONG_FUNCTION", "LongMethod") -internal val statistics = FC { +internal val statistics: FC = FC { val (activeDemoAmount, setActiveDemoAmount) = useState(0) useRequest { val active: Int = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt index 7c9e984938..855fd62859 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt @@ -22,7 +22,7 @@ import react.useEffect import react.useState import web.cssom.ClassName -internal val featuredDemos = FC { +internal val featuredDemos: FC = FC { val (featuredDemos, setFeaturedDemos) = useState( listOf( DemoDto.emptyForProject("saveourtool", "Diktat"), diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt index 36a21fdd4b..605933df7f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt @@ -33,7 +33,7 @@ import web.html.ButtonType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createOrganizationVie: FC = FC { +val createOrganizationView: FC = FC { useBackground(Style.SAVE_DARK) particles() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt index 510a302fc5..b4b09bcfde 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt @@ -46,7 +46,7 @@ import kotlinx.serialization.json.Json private val organizationSelectForm: SelectFormFunctionalComponent = selectFormRequired() -val createProjectVie: FC = FC { +val createProjectView: FC = FC { useBackground(Style.SAVE_DARK) particles() val params = useParams() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt index 8bf1c8c98f..54cd13a9ae 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt @@ -38,7 +38,7 @@ val sandboxApiUrl = "${window.location.origin}/api/sandbox" /** * A view for testing config files */ -val sandboxVie: FC = FC { +val sandboxView: FC = FC { useBackground(Style.SAVE_DARK) val (debugInfo, setDebugInfo) = useState(null) val (selectedSdk, setSelectedSdk) = useState(Sdk.Default) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt index cf9bb39b35..486b87e19d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt @@ -30,7 +30,7 @@ import web.cssom.ClassName * @return a function component */ @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION", "TOO_LONG_FUNCTION") -val testExecutionDetailsVie: FC = FC { +val testExecutionDetailsView: FC = FC { val (status, setStatus) = useState("Loading...") val (testResultDebugInfo, setTestResultDebugInfo) = useState(null) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt index 1916bafc42..dd9a8466e2 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt @@ -32,7 +32,7 @@ import web.html.ButtonType /** * [FC] that renders the stylish table with contests */ -val contestLis: FC = FC { +val contestList: FC = FC { val (isContestEnrollerModalOpen, setIsContestEnrollerModalOpen) = useState(false) val (isConfirmationModalOpen, setIsConfirmationModalOpen) = useState(false) val (enrollmentResponseString, setEnrollmentResponseString) = useState("") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt index d8bf77706d..649603ec99 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt @@ -32,7 +32,7 @@ private const val MAX_AMOUNT_OF_RECORDS = 3 /** * @return functional component for the rating card */ -internal val globalRatin: FC = FC { +internal val globalRating: FC = FC { val (selectedTab, setSelectedTab) = useState(UserRatingTab.ORGS) val (organizationsWithRating, setOrganizationsWithRating) = useState>(emptySet()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt index 9f5fc70eac..ef3a1dd554 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt @@ -69,7 +69,7 @@ val indexAuth: FC = FC { _ -> } } -val separato: FC = FC { +val separator: FC = FC { val (t) = useTranslation("welcome") div { className = ClassName("row mt-2") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt index a17d885c52..58487606f1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt @@ -20,7 +20,7 @@ import react.dom.html.ReactHTML.h1 import react.useState import web.cssom.ClassName -val topRatingVie: FC = FC { +val topRatingView: FC = FC { useBackground(Style.SAVE_LIGHT) val (selectedMenu, setSelectedMenu) = useState(TopRatingTab.USERS) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt index 6866bfbf06..153bc1a283 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt @@ -98,7 +98,7 @@ val leftSettingsColumn: FC = FC { props -> } } -val settingsTab: FC = FC { +val settingsTabs: FC = FC { val (t) = useTranslation("profile") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt index bd397b846d..8dda804953 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt @@ -22,7 +22,7 @@ import react.useState import web.cssom.* @Suppress("TOO_MANY_LINES_IN_LAMBDA", "PARAMETER_NAME_IN_OUTER_LAMBDA") -val cosvSchemaVie: FC = FC { +val cosvSchemaView: FC = FC { particles() useBackground(Style.VULN_DARK) val (textInModal, setTextInModal) = useState>() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index f64bb40def..6a5d6bdbee 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -11,6 +11,7 @@ import com.saveourtool.save.domain.TestResultStatus import com.saveourtool.save.filters.TestExecutionFilter import com.saveourtool.save.frontend.components.basic.projects.createProjectProblem import com.saveourtool.save.frontend.components.basic.projects.projectProblem +import com.saveourtool.save.frontend.components.mobile.AboutUsMobileView import com.saveourtool.save.frontend.components.views.* import com.saveourtool.save.frontend.components.views.agreements.cookieTermsOfUse import com.saveourtool.save.frontend.components.views.agreements.termsOfUsageView @@ -29,25 +30,28 @@ import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.isSuperAdmin import com.saveourtool.save.info.UserInfo +import com.saveourtool.save.validation.FrontendRoutes import com.saveourtool.save.validation.FrontendRoutes.* +import js.core.jso import org.w3c.dom.url.URLSearchParams import react.* import react.router.* +import react.router.dom.createBrowserRouter /** * Just put a map: View -> Route URL to this list */ val basicRouting: FC = FC { props -> useUserStatusRedirects(props.userInfo?.status) - val userProfileView: VFC = withRouter { _, params -> + val userProfileView: FC = withRouter { _, params -> userProfileView { userName = params["name"]!! currentUserInfo = props.userInfo } } - val contestView: VFC = withRouter { location, params -> + val contestView: FC = withRouter { location, params -> ContestView::class.react { currentUserInfo = props.userInfo currentContestName = params["contestName"] @@ -55,7 +59,7 @@ val basicRouting: FC = FC { props -> } } - val contestExecutionView: VFC = withRouter { _, params -> + val contestExecutionView: FC = withRouter { _, params -> ContestExecutionView::class.react { currentUserInfo = props.userInfo contestName = params["contestName"]!! @@ -64,7 +68,7 @@ val basicRouting: FC = FC { props -> } } - val projectView: VFC = withRouter { location, params -> + val projectView: FC = withRouter { location, params -> ProjectView::class.react { name = params["name"]!! owner = params["owner"]!! @@ -73,14 +77,14 @@ val basicRouting: FC = FC { props -> } } - val historyView: VFC = withRouter { _, params -> + val historyView: FC = withRouter { _, params -> HistoryView::class.react { name = params["name"]!! organizationName = params["owner"]!! } } - val executionView: VFC = withRouter { location, params -> + val executionView: FC = withRouter { location, params -> ExecutionView::class.react { organization = params["organization"]!! project = params["project"]!! @@ -97,7 +101,7 @@ val basicRouting: FC = FC { props -> } } - val organizationView: VFC = withRouter { location, params -> + val organizationView: FC = withRouter { location, params -> OrganizationView::class.react { organizationName = params["owner"]!! currentUserInfo = props.userInfo @@ -105,13 +109,13 @@ val basicRouting: FC = FC { props -> } } - val awesomeBenchmarksView: VFC = withRouter { location, _ -> + val awesomeBenchmarksView: FC = withRouter { location, _ -> AwesomeBenchmarksView::class.react { this.location = location } } - val contestGlobalRatingView: VFC = withRouter { location, _ -> + val contestGlobalRatingView: FC = withRouter { location, _ -> ContestGlobalRatingView::class.react { organizationName = URLSearchParams(location.search).get("organizationName") projectName = URLSearchParams(location.search).get("projectName") @@ -119,14 +123,14 @@ val basicRouting: FC = FC { props -> } } - val contestTemplateView: VFC = withRouter { _, params -> + val contestTemplateView: FC = withRouter { _, params -> contestTemplateView { id = requireNotNull(params["id"]).toLong() currentUserInfo = props.userInfo } } - val demoView: VFC = withRouter { _, params -> + val demoView: FC = withRouter { _, params -> demoView { projectCoordinates = ProjectCoordinates( requireNotNull(params["organizationName"]), @@ -135,28 +139,28 @@ val basicRouting: FC = FC { props -> } } - val vulnerabilityCollectionView: VFC = withRouter { location, _ -> + val vulnerabilityCollectionView: FC = withRouter { location, _ -> vulnerabilityCollectionView { currentUserInfo = props.userInfo filter = URLSearchParams(location.search).toVulnerabilitiesFilter() } } - val vulnerabilityView: VFC = withRouter { _, params -> + val vulnerabilityView: FC = withRouter { _, params -> vulnerabilityView { identifier = requireNotNull(params["identifier"]) currentUserInfo = props.userInfo } } - val createProjectProblemView: VFC = withRouter { _, params -> + val createProjectProblemView: FC = withRouter { _, params -> createProjectProblem { organizationName = requireNotNull(params["owner"]) projectName = requireNotNull(params["name"]) } } - val projectProblemView: VFC = withRouter { _, params -> + val projectProblemView: FC = withRouter { _, params -> projectProblem { organizationName = requireNotNull(params["owner"]) projectName = requireNotNull(params["name"]) @@ -164,8 +168,8 @@ val basicRouting: FC = FC { props -> } } - Routes { - listOf( + createBrowserRouter( + routes = listOf( indexView.create { userInfo = props.userInfo } to "/", saveWelcomeView.create { userInfo = props.userInfo } to SAVE, vulnWelcomeView.create { userInfo = props.userInfo } to VULN, @@ -240,37 +244,43 @@ val basicRouting: FC = FC { props -> type = SETTINGS_DELETE } to SETTINGS_DELETE, - ).forEach { (view, route) -> - PathRoute { - this.element = view - this.path = "/$route" + ).map { (view, route) -> + jso { + path = "/$route" + element = view } } - - props.userInfo?.name?.run { - PathRoute { - path = "/$this" - element = Navigate.create { to = "/$this/$SETTINGS_PROFILE" } - } - } - - PathRoute { - path = "/$MANAGE_ORGANIZATIONS" - element = when (props.userInfo.isSuperAdmin()) { - true -> OrganizationAdminView::class.react.create() - else -> fallbackNode - } - } - - PathRoute { - path = "*" - element = FallbackView::class.react.create { - bigText = "404" - smallText = "Page not found" - withRouterLink = true + .let { routes -> + props.userInfo?.name?.let { userName -> + routes.plus( + jso { + path = "/$userName" + element = Navigate.create { to = "/$this/$SETTINGS_PROFILE" } + } + ) + } ?: routes } - } - } + .plus( + jso { + path = "/$MANAGE_ORGANIZATIONS" + element = when (props.userInfo.isSuperAdmin()) { + true -> OrganizationAdminView::class.react.create() + else -> fallbackNode + } + } + ) + .plus( + jso { + path = "*" + element = FallbackView::class.react.create { + bigText = "404" + smallText = "Page not found" + withRouterLink = true + } + } + ) + .toTypedArray() + ) } private val fallbackNode = FallbackView::class.react.create { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt index c9990479fd..9928a1e2c8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt @@ -7,23 +7,27 @@ package com.saveourtool.save.frontend.routing import com.saveourtool.save.frontend.components.mobile.AboutUsMobileView import com.saveourtool.save.frontend.components.mobile.saveWelcomeMobileView import com.saveourtool.save.validation.FrontendRoutes -import react.* -import react.router.PathRoute -import react.router.Routes +import js.core.jso +import react.FC +import react.Props +import react.create +import react.react +import react.router.dom.createBrowserRouter /** * Just put a map: View -> Route URL to this list */ -val mobileRoutes = FC { - Routes { - listOf( - AboutUsMobileView::class.react.create() to FrontendRoutes.ABOUT_US, - saveWelcomeMobileView.create() to "*", - ).forEach { - PathRoute { - this.element = it.first - this.path = "/${it.second}" +val mobileRoutes: FC = FC { + createBrowserRouter( + arrayOf( + jso { + path = FrontendRoutes.ABOUT_US.path + element = AboutUsMobileView::class.react.create() + }, + jso { + path = "*" + element = saveWelcomeMobileView.create() } - } - } + ) + ) } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt index 64c6da70ce..74032f971f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt @@ -44,7 +44,7 @@ fun ChildrenBuilder.withNavigate(handler: ChildrenBuilder.(NavigateFunctionConte * @return a function component */ @Suppress("TYPE_ALIAS") -fun withRouter(handler: ChildrenBuilder.(Location, Params) -> Unit) = FC { +fun withRouter(handler: ChildrenBuilder.(Location<*>, Params) -> Unit) = FC { val location = useLocation() val params = useParams() handler(location, params) From 4ddb6ed1e3dbeaec8b1b45817eaa1630d8e0e61e Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 18:33:18 +0300 Subject: [PATCH 07/41] diktatFix --- .../components/views/contests/CreateContestTemplateView.kt | 2 +- .../save/frontend/components/views/test/analysis/Utils.kt | 2 -- .../com/saveourtool/save/frontend/routing/BasicRouting.kt | 4 +--- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt index 8b3291dbf4..e36e3e5316 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt @@ -30,7 +30,7 @@ import web.html.InputType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createContestTemplateView: FC = FC{ +val createContestTemplateView: FC = FC { useBackground(Style.SAVE_DARK) val (contestTemplate, setContestTemplate) = useState(ContestSampleDto.empty) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt index b3c66ecc24..0d5e1c027d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt @@ -8,8 +8,6 @@ import react.CSSProperties import react.ChildrenBuilder import react.FC import react.Props -import react.FC -import react.Props import react.dom.html.ReactHTML.abbr import react.dom.html.ReactHTML.span import web.cssom.ClassName diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 6a5d6bdbee..6ea6fd4360 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.domain.TestResultStatus import com.saveourtool.save.filters.TestExecutionFilter import com.saveourtool.save.frontend.components.basic.projects.createProjectProblem import com.saveourtool.save.frontend.components.basic.projects.projectProblem -import com.saveourtool.save.frontend.components.mobile.AboutUsMobileView import com.saveourtool.save.frontend.components.views.* import com.saveourtool.save.frontend.components.views.agreements.cookieTermsOfUse import com.saveourtool.save.frontend.components.views.agreements.termsOfUsageView @@ -30,7 +29,6 @@ import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.isSuperAdmin import com.saveourtool.save.info.UserInfo -import com.saveourtool.save.validation.FrontendRoutes import com.saveourtool.save.validation.FrontendRoutes.* import js.core.jso @@ -244,7 +242,7 @@ val basicRouting: FC = FC { props -> type = SETTINGS_DELETE } to SETTINGS_DELETE, - ).map { (view, route) -> + ).map { (view, route) -> jso { path = "/$route" element = view From cbf310a7f042da35fc60dbc3c458b3d52586b022 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 23 Oct 2023 18:48:03 +0300 Subject: [PATCH 08/41] fixed renaming --- .../frontend/components/views/contests/WelcomeToSaveContests.kt | 2 +- .../save/frontend/components/views/index/IndexLogoButtons.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt index fb2c84ecfc..c16cb319a1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt @@ -20,7 +20,7 @@ import web.cssom.rem /** * Rendering of featured contest card */ -internal val welcomeToSaveContest: FC = FC { +internal val welcomeToSaveContests: FC = FC { div { className = ClassName("col-5") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt index a9be300808..b4960419b9 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt @@ -18,7 +18,7 @@ import react.dom.html.ReactHTML.span import react.router.dom.Link import web.cssom.* -val logoButton: FC = FC { +val logoButtons: FC = FC { val (t) = useTranslation("index") div { className = ClassName("row logo-parent mb-5 d-flex justify-content-center") From ed449a7f92b88fdaa9c8ad97a17adcbec06a8f91 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 10:41:21 +0300 Subject: [PATCH 09/41] renamed `FC = FC {` to `FC {` --- .../com/saveourtool/save/frontend/App.kt | 20 +++++++++++++++---- .../save/frontend/components/Footer.kt | 2 +- .../frontend/components/basic/CookieBanner.kt | 2 +- .../components/basic/LanguageSelector.kt | 2 +- .../components/basic/TestStatusComponent.kt | 4 ++-- .../VulnerabilityIntroductionComponent.kt | 2 +- .../demo/welcome/DemoIntroductionComponent.kt | 2 +- .../basic/demo/welcome/DemoListComponent.kt | 2 +- .../basic/demo/welcome/DemoStatistics.kt | 2 +- .../basic/demo/welcome/FeaturedDemos.kt | 2 +- .../fileuploader/CosvFileManagerComponent.kt | 2 +- .../mobile/SaveWelcomeMobileView.kt | 2 +- .../components/topbar/TopBarUrlSplits.kt | 2 +- .../components/views/AwesomeBenchmarksView.kt | 2 +- .../views/CreateOrganizationView.kt | 2 +- .../components/views/CreateProjectView.kt | 2 +- .../frontend/components/views/SandboxView.kt | 2 +- .../views/TestExecutionDetailsView.kt | 2 +- .../views/agreements/CookiesTermsOfUse.kt | 2 +- .../views/agreements/TermsOfUsage.kt | 2 +- .../views/contests/ContestListCard.kt | 2 +- .../views/contests/ContestSampleListCard.kt | 2 +- .../views/contests/ContestsStatistics.kt | 2 +- .../contests/CreateContestTemplateView.kt | 2 +- .../contests/CreateNewContestTemplate.kt | 2 +- .../views/contests/FeaturedContests.kt | 2 +- .../components/views/contests/GlobalRating.kt | 2 +- .../components/views/contests/NewContests.kt | 2 +- .../views/contests/WelcomeToSaveContests.kt | 2 +- .../frontend/components/views/demo/CpgView.kt | 2 +- .../views/demo/DemoCollectionView.kt | 2 +- .../views/index/IndexLogoButtons.kt | 2 +- .../components/views/index/IndexViewAuth.kt | 2 +- .../components/views/test/analysis/Utils.kt | 2 +- .../views/toprating/OrganizationRatingTab.kt | 2 +- .../views/toprating/TopRatingView.kt | 2 +- .../views/toprating/UserRatingTab.kt | 2 +- .../userprofile/UserProfileNewUsersTab.kt | 2 +- .../usersettings/SettingsViewLeftColumn.kt | 2 +- .../components/views/vuln/CosvSchemaView.kt | 2 +- .../views/vuln/CreateVulnerabilityView.kt | 2 +- .../views/vuln/UploadVulnerabilityView.kt | 2 +- .../save/frontend/routing/MobileRouting.kt | 2 +- .../save/frontend/utils/RequestUtils.kt | 1 + .../save/frontend/utils/RouterUtils.kt | 2 +- .../frontend/utils/ServerSentEventTest.kt | 2 +- .../save/frontend/utils/UseRequestTest.kt | 2 +- 47 files changed, 63 insertions(+), 50 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 682e2fb2ab..a923234bab 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -14,11 +14,11 @@ import com.saveourtool.save.frontend.routing.basicRouting import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes +import js.core.jso import react.* import react.dom.client.createRoot import react.dom.html.ReactHTML.div -import react.router.dom.BrowserRouter import web.cssom.ClassName import web.dom.document import web.html.HTMLElement @@ -26,6 +26,8 @@ import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json +import react.router.dom.RouterProvider +import react.router.dom.createBrowserRouter /** * Main component for the whole App @@ -33,7 +35,7 @@ import kotlinx.serialization.json.Json @JsExport @OptIn(ExperimentalJsExport::class) @Suppress("VARIABLE_NAME_INCORRECT_FORMAT", "NULLABLE_PROPERTY_TYPE", "EMPTY_BLOCK_STRUCTURE_ERROR") -val App: VFC = FC { +val App = FC { val (userInfo, setUserInfo) = useState(null) useRequest { get( @@ -48,8 +50,8 @@ val App: VFC = FC { } } } - BrowserRouter { - basename = "/" + + val index = FC { requestModalHandler { this.userInfo = userInfo div { @@ -74,6 +76,16 @@ val App: VFC = FC { } scrollToTopButton() } + RouterProvider { + router = createBrowserRouter( + routes = arrayOf( + jso { + path = "/" + element = index.create() + } + ) + ) + } } fun main() { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt index 74329ab899..a1b5920dab 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/Footer.kt @@ -16,7 +16,7 @@ import web.cssom.ClassName @JsExport @OptIn(ExperimentalJsExport::class) @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -val footer: FC = FC { +val footer = FC { footer { className = ClassName("sticky-footer bg-white") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt index ca3e2f52c3..d1cddd7b4a 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt @@ -19,7 +19,7 @@ import react.useState import web.cssom.ClassName import web.cssom.ZIndex -val cookieBanner: FC = FC { +val cookieBanner = FC { val (isOpen, setIsOpen) = useState(!cookie.isAccepted()) val navigate = useNavigate() val (t) = useTranslation("cookies") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt index 365eb67415..27fde4ea0f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt @@ -29,7 +29,7 @@ private const val LANG_DROPDOWN_ID = "lang-dropdown" /** * A [FC] that is responsible for language selection */ -val languageSelector: FC = FC { +val languageSelector = FC { val (_, i18n) = useTranslation("topbar") val languageFromCookie = if (cookie.isAccepted()) { PlatformLanguages.getByCodeOrDefault(cookie.getLanguageCode()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt index 473ea59cf0..617e946d2e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt @@ -41,7 +41,7 @@ fun testStatusComponent( testResultDebugInfo: TestResultDebugInfo, tableInstance: Table, testExecutionDto: TestExecutionDto, -): FC = FC { +) = FC { val shortMessage: String = when (val status: TestStatus = testResultDebugInfo.testStatus) { is Pass -> (status.shortMessage ?: "").ifBlank { "Completed successfully without additional information" } is Fail -> status.shortReason @@ -121,7 +121,7 @@ fun testStatusComponent( fun executionStatusComponent( failReason: String, tableInstance: Table -): FC = FC { +) = FC { tr { td { colSpan = 2 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt index 614e14b6b8..a540ed3e36 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt @@ -13,7 +13,7 @@ import react.dom.html.ReactHTML.strong import web.cssom.ClassName @Suppress("IDENTIFIER_LENGTH") -val vulnerabilityIntroductionComponent: FC = FC { +val vulnerabilityIntroductionComponent = FC { val (t) = useTranslation("vulnerability-collection") div { className = ClassName("card flex-md-column box-shadow") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt index 2d6cd4a7e7..d0063180b6 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt @@ -34,7 +34,7 @@ private val saveDemoHowToMd = """ """.trimMargin() @Suppress("MAGIC_NUMBER") -internal val introductionSection: FC = FC { +internal val introductionSection = FC { div { className = ClassName("card flex-md-column mb-1 box-shadow") style = jso { minHeight = 25.rem } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt index e94ed6ec7d..686cac6c5b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt @@ -26,7 +26,7 @@ import kotlinx.serialization.json.Json private val withBackground = cardComponent(isBordered = true, hasBg = true, isPaddingBottomNull = true) -val demoList: FC = FC { +val demoList = FC { val (filter, setFilter) = useState(DemoFilter.running) val (demoDtos, setDemoDtos) = useState>(emptyList()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt index 25e27f9902..0004045c77 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt @@ -17,7 +17,7 @@ import react.useState import web.cssom.ClassName @Suppress("TOO_LONG_FUNCTION", "LongMethod") -internal val statistics: FC = FC { +internal val statistics = FC { val (activeDemoAmount, setActiveDemoAmount) = useState(0) useRequest { val active: Int = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt index 855fd62859..c2a9cf06a1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt @@ -22,7 +22,7 @@ import react.useEffect import react.useState import web.cssom.ClassName -internal val featuredDemos: FC = FC { +internal val featuredDemos = FC { val (featuredDemos, setFeaturedDemos) = useState( listOf( DemoDto.emptyForProject("saveourtool", "Diktat"), diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt index f1f2f41f73..9775161cef 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt @@ -46,7 +46,7 @@ import kotlinx.serialization.json.Json private const val DEFAULT_SIZE = 10 -val cosvFileManagerComponent: FC = FC { _ -> +val cosvFileManagerComponent = FC { _ -> useTooltip() val (t) = useTranslation("vulnerability-upload") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt index 92fbad5a32..8c8e42d26e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt @@ -25,7 +25,7 @@ import web.cssom.* /** * As a temp stub it was decided to make several views to make SAVE looking nice on mobile devices */ -val saveWelcomeMobileView: FC = FC { +val saveWelcomeMobileView = FC { div { style = jso { background = SAVE_LIGHT_GRADIENT.unsafeCast() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUrlSplits.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUrlSplits.kt index 00e06180f6..39166dbdc7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUrlSplits.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUrlSplits.kt @@ -87,5 +87,5 @@ external interface TopBarUrlSplitsProps : Props { /** * User location for url analysis. */ - var location: Location + var location: Location<*> } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/AwesomeBenchmarksView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/AwesomeBenchmarksView.kt index 67608c30a9..8885024774 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/AwesomeBenchmarksView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/AwesomeBenchmarksView.kt @@ -56,7 +56,7 @@ const val ALL_LANGS = "all" */ @Suppress("MISSING_KDOC_CLASS_ELEMENTS") external interface AwesomeBenchmarksProps : PropsWithChildren { - var location: Location + var location: Location<*> } /** diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt index 605933df7f..6b621c6f18 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateOrganizationView.kt @@ -33,7 +33,7 @@ import web.html.ButtonType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createOrganizationView: FC = FC { +val createOrganizationView = FC { useBackground(Style.SAVE_DARK) particles() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt index b4b09bcfde..109cc3e590 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/CreateProjectView.kt @@ -46,7 +46,7 @@ import kotlinx.serialization.json.Json private val organizationSelectForm: SelectFormFunctionalComponent = selectFormRequired() -val createProjectView: FC = FC { +val createProjectView = FC { useBackground(Style.SAVE_DARK) particles() val params = useParams() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt index 54cd13a9ae..f343251db2 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/SandboxView.kt @@ -38,7 +38,7 @@ val sandboxApiUrl = "${window.location.origin}/api/sandbox" /** * A view for testing config files */ -val sandboxView: FC = FC { +val sandboxView = FC { useBackground(Style.SAVE_DARK) val (debugInfo, setDebugInfo) = useState(null) val (selectedSdk, setSelectedSdk) = useState(Sdk.Default) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt index 486b87e19d..dad2752a7e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/TestExecutionDetailsView.kt @@ -30,7 +30,7 @@ import web.cssom.ClassName * @return a function component */ @Suppress("GENERIC_VARIABLE_WRONG_DECLARATION", "TOO_LONG_FUNCTION") -val testExecutionDetailsView: FC = FC { +val testExecutionDetailsView = FC { val (status, setStatus) = useState("Loading...") val (testResultDebugInfo, setTestResultDebugInfo) = useState(null) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt index b5bb5c3292..96137f5225 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt @@ -15,7 +15,7 @@ import react.Props import react.dom.html.ReactHTML.div import web.cssom.ClassName -val cookieTermsOfUse: FC = FC { +val cookieTermsOfUse = FC { useBackground(Style.INDEX) val (t) = useTranslation("cookies") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt index 9cb9d84d98..1fb7ffc53f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt @@ -130,7 +130,7 @@ private val termsOfUsageContent = listOf( generalProvisions, ) -val termsOfUsageView: FC = FC { +val termsOfUsageView = FC { useBackground(Style.INDEX) div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt index dd9a8466e2..2304fb150a 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestListCard.kt @@ -32,7 +32,7 @@ import web.html.ButtonType /** * [FC] that renders the stylish table with contests */ -val contestList: FC = FC { +val contestList = FC { val (isContestEnrollerModalOpen, setIsContestEnrollerModalOpen) = useState(false) val (isConfirmationModalOpen, setIsConfirmationModalOpen) = useState(false) val (enrollmentResponseString, setEnrollmentResponseString) = useState("") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt index 0a0d11072d..fb6c123b88 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt @@ -45,7 +45,7 @@ private val contestSampleTable: FC> = tableComponen useServerPaging = false, ) -internal val contestSampleList: FC = FC { +internal val contestSampleList = FC { div { className = ClassName("col") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt index 58c521d31d..aa5fb1664b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt @@ -18,7 +18,7 @@ import react.useState import web.cssom.ClassName import web.cssom.rem -internal val statistics: FC = FC { +internal val statistics = FC { val (activeContests, setActiveContests) = useState>(emptySet()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt index e36e3e5316..8d336154ca 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt @@ -30,7 +30,7 @@ import web.html.InputType import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -val createContestTemplateView: FC = FC { +val createContestTemplateView = FC { useBackground(Style.SAVE_DARK) val (contestTemplate, setContestTemplate) = useState(ContestSampleDto.empty) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt index fdc6776b14..59c35b50ff 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt @@ -12,7 +12,7 @@ import react.dom.html.ReactHTML.img import react.router.dom.Link import web.cssom.* -internal val createNewContestTemplate: FC = FC { +internal val createNewContestTemplate = FC { div { className = ClassName("col-2 text-center") Link { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt index 3ae70abf11..f112ae17af 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt @@ -27,7 +27,7 @@ import web.cssom.* import web.html.ButtonType @Suppress("MAGIC_NUMBER") -internal val featuredContest: FC = FC { +internal val featuredContest = FC { val (featuredContests, setFeaturedContests) = useState>(emptyList()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt index 649603ec99..e17176f533 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/GlobalRating.kt @@ -32,7 +32,7 @@ private const val MAX_AMOUNT_OF_RECORDS = 3 /** * @return functional component for the rating card */ -internal val globalRating: FC = FC { +internal val globalRating = FC { val (selectedTab, setSelectedTab) = useState(UserRatingTab.ORGS) val (organizationsWithRating, setOrganizationsWithRating) = useState>(emptySet()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt index 26a0d10305..62ee45332c 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt @@ -23,7 +23,7 @@ import web.cssom.rem /** * rendering of newly added contests */ -internal val newContests: FC = FC { +internal val newContests = FC { val (newContests, setNewContests) = useState>(emptyList()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt index c16cb319a1..2acc607141 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt @@ -20,7 +20,7 @@ import web.cssom.rem /** * Rendering of featured contest card */ -internal val welcomeToSaveContests: FC = FC { +internal val welcomeToSaveContests = FC { div { className = ClassName("col-5") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt index 562f9558b1..c81f829209 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/CpgView.kt @@ -42,7 +42,7 @@ private val backgroundCard = cardComponent(hasBg = false, isPaddingBottomNull = @Suppress( "EMPTY_BLOCK_STRUCTURE_ERROR", ) -val cpgView: FC = FC { +val cpgView = FC { useBackground(Style.SAVE_LIGHT) val (cpgResult, setCpgResult) = useState(CpgResult.empty) val (isLogs, setIsLogs) = useState(false) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt index b643f014b5..4e688d3320 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt @@ -15,7 +15,7 @@ import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.main import web.cssom.ClassName -val demoCollectionView: FC = FC { +val demoCollectionView = FC { useBackground(Style.SAVE_DARK) main { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt index b4960419b9..fd8c96494d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt @@ -18,7 +18,7 @@ import react.dom.html.ReactHTML.span import react.router.dom.Link import web.cssom.* -val logoButtons: FC = FC { +val logoButtons = FC { val (t) = useTranslation("index") div { className = ClassName("row logo-parent mb-5 d-flex justify-content-center") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt index ef3a1dd554..c8f8a2b7b1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt @@ -69,7 +69,7 @@ val indexAuth: FC = FC { _ -> } } -val separator: FC = FC { +val separator = FC { val (t) = useTranslation("welcome") div { className = ClassName("row mt-2") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt index 0d5e1c027d..fc7a8d47c1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/test/analysis/Utils.kt @@ -34,7 +34,7 @@ internal val listStyle: CSSProperties = jso { /** * The placeholder displayed when there's no data available. */ -internal val noDataAvailable: FC = FC { +internal val noDataAvailable = FC { span { className = ClassName("noDataAvailable") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt index 96ce3c848a..46ecd426a6 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt @@ -26,7 +26,7 @@ import kotlinx.serialization.json.Json private const val DEFAULT_PAGE_SIZE = 10_000 -val organizationRatingTab: FC = FC { _ -> +val organizationRatingTab = FC { _ -> val (organizationFilter, setOrganizationFilter) = useState(OrganizationFilter.created) val fetchOrganizationRequest: suspend WithRequestStatusContext.(OrganizationFilter) -> OrganizationArray = { filter -> diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt index 58487606f1..a4259184e6 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt @@ -20,7 +20,7 @@ import react.dom.html.ReactHTML.h1 import react.useState import web.cssom.ClassName -val topRatingView: FC = FC { +val topRatingView = FC { useBackground(Style.SAVE_LIGHT) val (selectedMenu, setSelectedMenu) = useState(TopRatingTab.USERS) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt index ba76def598..a501016287 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt @@ -17,7 +17,7 @@ import web.cssom.* private const val DEFAULT_PAGE_SIZE = 10_000 -val userRatingTable: FC = FC { _ -> +val userRatingTable = FC { _ -> val (userNamePrefix, setUserNamePrefix) = useState("") val fetchUserRequest: suspend WithRequestStatusContext.(String) -> UserArray = { prefix -> diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt index 1430f5d871..19d3f7955a 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt @@ -17,7 +17,7 @@ import react.dom.html.ReactHTML.td import web.cssom.ClassName import web.cssom.rem -val renderNewUsersTableForProfileView: FC = FC { _ -> +val renderNewUsersTableForProfileView = FC { _ -> @Suppress( "TYPE_ALIAS", diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt index 153bc1a283..2478ea8a30 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt @@ -98,7 +98,7 @@ val leftSettingsColumn: FC = FC { props -> } } -val settingsTabs: FC = FC { +val settingsTabs = FC { val (t) = useTranslation("profile") div { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt index 8dda804953..f686e21e96 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt @@ -22,7 +22,7 @@ import react.useState import web.cssom.* @Suppress("TOO_MANY_LINES_IN_LAMBDA", "PARAMETER_NAME_IN_OUTER_LAMBDA") -val cosvSchemaView: FC = FC { +val cosvSchemaView = FC { particles() useBackground(Style.VULN_DARK) val (textInModal, setTextInModal) = useState>() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt index 6c777c0352..5278e76873 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt @@ -59,7 +59,7 @@ import kotlinx.serialization.json.Json "LONG_LINE", "MaxLineLength", ) -val createVulnerabilityView: FC = FC { +val createVulnerabilityView = FC { useBackground(Style.VULN_DARK) val navigate = useNavigate() useTooltip() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt index 878d7e9604..c2c3dcd95e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt @@ -18,7 +18,7 @@ import react.dom.html.ReactHTML.span import web.cssom.ClassName import web.cssom.ZIndex -val uploadVulnerabilityView: FC = FC { +val uploadVulnerabilityView = FC { useBackground(Style.VULN_DARK) val (t) = useTranslation("vulnerability-upload") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt index 9928a1e2c8..ee0d1d2da6 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt @@ -17,7 +17,7 @@ import react.router.dom.createBrowserRouter /** * Just put a map: View -> Route URL to this list */ -val mobileRoutes: FC = FC { +val mobileRoutes = FC { createBrowserRouter( arrayOf( jso { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt index 311d3919a1..529c157113 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt @@ -14,6 +14,7 @@ import com.saveourtool.save.v1 import js.buffer.ArrayBuffer import js.core.jso +import js.promise.asDeferred import js.typedarrays.Int8Array import js.typedarrays.Uint8Array import org.w3c.dom.url.URLSearchParams diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt index 74032f971f..de7da525ae 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt @@ -26,7 +26,7 @@ interface NavigateFunctionContext { * @param handler DOM builder that can consume [NavigateFunctionContext] */ fun ChildrenBuilder.withNavigate(handler: ChildrenBuilder.(NavigateFunctionContext) -> Unit) { - val wrapper: FC = FC { + val wrapper = FC { val navigate = useNavigate() val ctx = object : NavigateFunctionContext { override val navigate: NavigateFunction = navigate diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt index 8b8e24e0f7..fd6edda48f 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt @@ -61,7 +61,7 @@ class ServerSentEventTest { val messages = mutableListOf() var responseStatus: Short = 0 - val testComponent: FC = FC { + val testComponent = FC { useNdjson( url = "${window.location.origin}/test", onCompletion = { responseStatus = OK }, diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt index 312c73d55f..615921d7de 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt @@ -31,7 +31,7 @@ class UseRequestTest { @Test fun test(): Promise { val worker = createWorker() - val testComponent: FC = FC { + val testComponent = FC { val (sendSecond, setSendSecond) = useState(false) val (sendThird, setSendThird) = useState(false) useRequest(dependencies = arrayOf(sendSecond)) { From febe2e5acb9d41c50597153ff15a1ae248d92cba Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 10:58:33 +0300 Subject: [PATCH 10/41] fixed Location and require --- .../main/kotlin/com/saveourtool/save/frontend/App.kt | 4 ++-- .../save/frontend/components/views/ContestView.kt | 2 +- .../frontend/components/views/OrganizationView.kt | 2 +- .../save/frontend/components/views/ProjectView.kt | 2 +- .../views/contests/ContestGlobalRatingView.kt | 2 +- .../components/views/contests/FeaturedContests.kt | 2 +- .../externals/calendar/ReactCalendarBuilder.kt | 2 +- .../save/frontend/externals/cookie/Cookie.kt | 2 +- .../externals/graph/cytoscape/CytoscapeWrapper.kt | 2 +- .../save/frontend/externals/reactace/AceBuilder.kt | 2 +- .../save/frontend/externals/reactace/AceThemes.kt | 2 +- .../saveourtool/save/frontend/utils/LocationUtils.kt | 12 ++++++------ .../saveourtool/save/frontend/utils/RequestUtils.kt | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index a923234bab..f60b83b2c8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -95,8 +95,8 @@ fun main() { return } - kotlinext.js.require("../scss/save-frontend.scss") // this is needed for webpack to include resource - kotlinext.js.require("bootstrap") // this is needed for webpack to include bootstrap + kotlinext.js.require("../scss/save-frontend.scss") // this is needed for webpack to include resource + kotlinext.js.require("bootstrap") // this is needed for webpack to include bootstrap ReactModal.setAppElement(document.getElementById("wrapper") as HTMLElement) // required for accessibility in react-modal initI18n() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ContestView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ContestView.kt index e1ea62916a..43f2acd219 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ContestView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ContestView.kt @@ -48,7 +48,7 @@ enum class ContestMenuBar { external interface ContestViewProps : Props { var currentUserInfo: UserInfo? var currentContestName: String? - var location: Location + var location: Location<*> } /** diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/OrganizationView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/OrganizationView.kt index 14caf1a868..ebd41302eb 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/OrganizationView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/OrganizationView.kt @@ -72,7 +72,7 @@ val actionIconClasses: List = listOf("trash-alt") external interface OrganizationProps : PropsWithChildren { var organizationName: String var currentUserInfo: UserInfo? - var location: Location + var location: Location<*> } /** diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt index 960946d0af..5577f680e3 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/ProjectView.kt @@ -44,7 +44,7 @@ external interface ProjectViewProps : PropsWithChildren { var owner: String var name: String var currentUserInfo: UserInfo? - var location: Location + var location: Location<*> } /** diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestGlobalRatingView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestGlobalRatingView.kt index 559520aa51..744536fd75 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestGlobalRatingView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestGlobalRatingView.kt @@ -57,7 +57,7 @@ external interface ContestGlobalRatingProps : Props { /** * Location for checking change url */ - var location: Location + var location: Location<*> } /** diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt index f112ae17af..e8feb3caff 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/FeaturedContests.kt @@ -27,7 +27,7 @@ import web.cssom.* import web.html.ButtonType @Suppress("MAGIC_NUMBER") -internal val featuredContest = FC { +internal val featuredContests = FC { val (featuredContests, setFeaturedContests) = useState>(emptyList()) useRequest { val contests: List = get( diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/calendar/ReactCalendarBuilder.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/calendar/ReactCalendarBuilder.kt index d59f8d2840..f2a8786e13 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/calendar/ReactCalendarBuilder.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/calendar/ReactCalendarBuilder.kt @@ -15,7 +15,7 @@ fun ChildrenBuilder.calendar( onChange: (Date, Event) -> Unit, handler: ChildrenBuilder.(ReactCalendarProps) -> Unit = {}, ) { - kotlinext.js.require("react-calendar/dist/Calendar.css") + kotlinext.js.require("react-calendar/dist/Calendar.css") ReactCalendar::class.react { this.onChange = onChange this.showNeighboringMonth = false diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/cookie/Cookie.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/cookie/Cookie.kt index b6a8da3b55..dbf99b62e4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/cookie/Cookie.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/cookie/Cookie.kt @@ -8,7 +8,7 @@ import kotlinext.js.require /** * Object that manages cookies */ -val cookie: Cookie = require("js-cookie").unsafeCast() +val cookie: Cookie = require("js-cookie") /** * Interface that encapsulates all cookies interactions diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt index 99b5e2c52d..dc3c95bfa3 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt @@ -82,6 +82,6 @@ fun cytoscape( """) } - val cytoscapeJs = kotlinext.js.require("cytoscape") + val cytoscapeJs = kotlinext.js.require("cytoscape") return cytoscapeJs(options) } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceBuilder.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceBuilder.kt index 2b22362d73..14a867f693 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceBuilder.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceBuilder.kt @@ -32,7 +32,7 @@ fun ChildrenBuilder.aceBuilder( onChangeFun: (String) -> Unit, ) { selectedTheme.require() - kotlinext.js.require("ace-builds/src-min-noconflict/mode-${selectedMode.modeName}") + kotlinext.js.require("ace-builds/src-min-noconflict/mode-${selectedMode.modeName}") div { className = ClassName("d-flex justify-content-center flex-fill") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceThemes.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceThemes.kt index 7c7d11c0be..aa0f36db12 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceThemes.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/reactace/AceThemes.kt @@ -25,7 +25,7 @@ enum class AceThemes(val themeName: String) { /** * Method that includes required theme */ - fun require() = kotlinext.js.require("ace-builds/src-min-noconflict/theme-$themeName") + fun require() = kotlinext.js.require("ace-builds/src-min-noconflict/theme-$themeName") companion object { /** * Theme that is recommended to be used everywhere diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/LocationUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/LocationUtils.kt index 338c8cb307..7b04cf454d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/LocationUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/LocationUtils.kt @@ -10,31 +10,31 @@ import remix.run.router.Location * @param url url for comparison * @return true if [Location.pathname] is not [url], false otherwise */ -fun Location.not(url: String) = pathname != url +fun Location<*>.not(url: String) = pathname != url /** * @param urls list of urls * @return true of [Location] is not in [urls] */ -fun Location.notIn(urls: List) = urls.all { not(it) } +fun Location<*>.notIn(urls: List) = urls.all { not(it) } /** * @param routes array of [FrontendRoutes] * @return true of [Location] is not in [FrontendRoutes.path] of [routes] */ -fun Location.notIn(routes: Array) = notIn(routes.map { "/$it" }) +fun Location<*>.notIn(routes: Array) = notIn(routes.map { "/$it" }) /** * @return true if [Location.pathname] starts with `/vuln`, false otherwise */ -fun Location.isVuln() = this.pathname.startsWith("/vuln") +fun Location<*>.isVuln() = this.pathname.startsWith("/vuln") /** * @return true if [Location.pathname] starts with `/settings`, false otherwise */ -fun Location.isSettings() = this.pathname.startsWith("/$SETTINGS") +fun Location<*>.isSettings() = this.pathname.startsWith("/$SETTINGS") /** * @return true if we are on a main (index) page */ -fun Location.isIndex() = pathname == "/" +fun Location<*>.isIndex() = pathname == "/" diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt index 529c157113..c3c7b5a5d4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RequestUtils.kt @@ -23,7 +23,7 @@ import org.w3c.fetch.RequestCredentials import org.w3c.fetch.RequestInit import org.w3c.fetch.Response import web.streams.ReadableStream -import web.streams.ReadableStreamDefaultReadValueResult +import web.streams.ReadableStreamReadValueResult import kotlin.js.Promise import kotlinx.browser.window @@ -49,7 +49,7 @@ val jsonHeaders = Headers() * * @param T the type of the data (usually a byte array). */ -private typealias ResultAsync = Promise> +private typealias ResultAsync = Promise> /** * Interface for objects that have access to [requestStatusContext] From 022b52af4fdc74b700c805492c6a3688610d22e0 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 11:02:17 +0300 Subject: [PATCH 11/41] diktatFix --- .../main/kotlin/com/saveourtool/save/frontend/App.kt | 10 +++++----- .../save/frontend/components/basic/CookieBanner.kt | 1 - .../save/frontend/components/basic/LanguageSelector.kt | 1 - .../frontend/components/basic/TestStatusComponent.kt | 1 - .../basic/VulnerabilityIntroductionComponent.kt | 1 - .../basic/demo/welcome/DemoIntroductionComponent.kt | 1 - .../components/basic/demo/welcome/DemoListComponent.kt | 1 - .../components/basic/demo/welcome/DemoStatistics.kt | 1 - .../components/basic/demo/welcome/FeaturedDemos.kt | 1 - .../basic/fileuploader/CosvFileManagerComponent.kt | 3 +-- .../components/mobile/SaveWelcomeMobileView.kt | 1 - .../components/views/agreements/CookiesTermsOfUse.kt | 1 - .../components/views/agreements/TermsOfUsage.kt | 1 - .../components/views/contests/ContestSampleListCard.kt | 1 - .../components/views/contests/ContestsStatistics.kt | 1 - .../views/contests/CreateContestTemplateView.kt | 1 - .../views/contests/CreateNewContestTemplate.kt | 1 - .../frontend/components/views/contests/NewContests.kt | 1 - .../components/views/contests/WelcomeToSaveContests.kt | 1 - .../components/views/demo/DemoCollectionView.kt | 1 - .../components/views/index/IndexLogoButtons.kt | 1 - .../frontend/components/views/index/IndexViewAuth.kt | 1 - .../views/toprating/OrganizationRatingTab.kt | 2 +- .../components/views/toprating/TopRatingView.kt | 1 - .../components/views/toprating/UserRatingTab.kt | 2 +- .../views/userprofile/UserProfileNewUsersTab.kt | 3 +-- .../frontend/components/views/vuln/CosvSchemaView.kt | 1 - .../components/views/vuln/CreateVulnerabilityView.kt | 1 - .../components/views/vuln/UploadVulnerabilityView.kt | 1 - .../saveourtool/save/frontend/routing/MobileRouting.kt | 1 - 30 files changed, 9 insertions(+), 36 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index f60b83b2c8..91128f5370 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -14,11 +14,13 @@ import com.saveourtool.save.frontend.routing.basicRouting import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes -import js.core.jso +import js.core.jso import react.* import react.dom.client.createRoot import react.dom.html.ReactHTML.div +import react.router.dom.RouterProvider +import react.router.dom.createBrowserRouter import web.cssom.ClassName import web.dom.document import web.html.HTMLElement @@ -26,8 +28,6 @@ import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json -import react.router.dom.RouterProvider -import react.router.dom.createBrowserRouter /** * Main component for the whole App @@ -95,8 +95,8 @@ fun main() { return } - kotlinext.js.require("../scss/save-frontend.scss") // this is needed for webpack to include resource - kotlinext.js.require("bootstrap") // this is needed for webpack to include bootstrap + kotlinext.js.require("../scss/save-frontend.scss") // this is needed for webpack to include resource + kotlinext.js.require("bootstrap") // this is needed for webpack to include bootstrap ReactModal.setAppElement(document.getElementById("wrapper") as HTMLElement) // required for accessibility in react-modal initI18n() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt index d1cddd7b4a..3393be1c52 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/CookieBanner.kt @@ -12,7 +12,6 @@ import com.saveourtool.save.frontend.utils.buttonBuilder import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.router.useNavigate import react.useState diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt index 27fde4ea0f..bb402e90eb 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/LanguageSelector.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.externals.i18next.language import com.saveourtool.save.frontend.externals.i18next.useTranslation import js.core.jso import react.FC -import react.Props import react.dom.aria.AriaHasPopup import react.dom.aria.ariaExpanded import react.dom.aria.ariaHasPopup diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt index 617e946d2e..95d9eb193f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/TestStatusComponent.kt @@ -15,7 +15,6 @@ import com.saveourtool.save.frontend.externals.fontawesome.faExternalLinkAlt import com.saveourtool.save.frontend.utils.buttonBuilder import react.FC -import react.Props import react.dom.html.ReactHTML.samp import react.dom.html.ReactHTML.small import react.dom.html.ReactHTML.td diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt index a540ed3e36..b65eddd7f2 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/VulnerabilityIntroductionComponent.kt @@ -6,7 +6,6 @@ import com.saveourtool.save.frontend.components.views.vuln.columnHeight import com.saveourtool.save.frontend.externals.i18next.useTranslation import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.img import react.dom.html.ReactHTML.strong diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt index d0063180b6..2dfd699107 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoIntroductionComponent.kt @@ -8,7 +8,6 @@ import com.saveourtool.save.frontend.components.basic.markdown import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.img import react.dom.html.ReactHTML.strong diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt index 686cac6c5b..a9dc8687df 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoListComponent.kt @@ -12,7 +12,6 @@ import com.saveourtool.save.frontend.utils.noopLoadingHandler import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.input import react.dom.html.ReactHTML.ul diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt index 0004045c77..536e1be72f 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/DemoStatistics.kt @@ -9,7 +9,6 @@ import com.saveourtool.save.frontend.utils.noopLoadingHandler import com.saveourtool.save.frontend.utils.noopResponseHandler import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.strong diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt index c2a9cf06a1..13726843db 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/demo/welcome/FeaturedDemos.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.noopResponseHandler import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.h3 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt index 9775161cef..db1cc84fad 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/fileuploader/CosvFileManagerComponent.kt @@ -23,7 +23,6 @@ import js.core.asList import js.core.jso import org.w3c.fetch.Headers import react.FC -import react.Props import react.dom.html.ReactHTML.b import react.dom.html.ReactHTML.button import react.dom.html.ReactHTML.div @@ -46,7 +45,7 @@ import kotlinx.serialization.json.Json private const val DEFAULT_SIZE = 10 -val cosvFileManagerComponent = FC { _ -> +val cosvFileManagerComponent = FC { useTooltip() val (t) = useTranslation("vulnerability-upload") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt index 8c8e42d26e..dee3036f54 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/mobile/SaveWelcomeMobileView.kt @@ -15,7 +15,6 @@ import com.saveourtool.save.frontend.utils.particles import js.core.jso import react.ChildrenBuilder import react.FC -import react.Props import react.dom.html.ReactHTML.b import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h4 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt index 96137f5225..7d4cc834a8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/CookiesTermsOfUse.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.buttonBuilder import com.saveourtool.save.frontend.utils.useBackground import react.FC -import react.Props import react.dom.html.ReactHTML.div import web.cssom.ClassName diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt index 1fb7ffc53f..889516f8a8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/agreements/TermsOfUsage.kt @@ -8,7 +8,6 @@ import com.saveourtool.save.frontend.components.basic.markdown import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.useBackground import react.FC -import react.Props import react.dom.html.ReactHTML.div import web.cssom.ClassName diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt index fb6c123b88..01bdf820df 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestSampleListCard.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.validation.FrontendRoutes import react.FC import react.Fragment -import react.Props import react.create import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.td diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt index aa5fb1664b..02c58f7f06 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/ContestsStatistics.kt @@ -10,7 +10,6 @@ import com.saveourtool.save.frontend.utils.* import js.core.jso import react.ChildrenBuilder import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.dom.html.ReactHTML.strong diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt index 8d336154ca..0bdf568b0c 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateContestTemplateView.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.validation.FrontendRoutes import react.FC -import react.Props import react.dom.aria.ariaDescribedBy import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt index 59c35b50ff..6318934a84 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/CreateNewContestTemplate.kt @@ -5,7 +5,6 @@ package com.saveourtool.save.frontend.components.views.contests import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 import react.dom.html.ReactHTML.img diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt index 62ee45332c..c0e770fcbc 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/NewContests.kt @@ -9,7 +9,6 @@ import com.saveourtool.save.frontend.utils.* import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 import react.dom.html.ReactHTML.img diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt index 2acc607141..dcb01c96cb 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/contests/WelcomeToSaveContests.kt @@ -7,7 +7,6 @@ package com.saveourtool.save.frontend.components.views.contests import js.core.jso import react.ChildrenBuilder import react.FC -import react.Props import react.dom.html.ReactHTML.b import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt index 4e688d3320..3f61ece190 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/demo/DemoCollectionView.kt @@ -10,7 +10,6 @@ import com.saveourtool.save.frontend.components.basic.demo.welcome.introductionS import com.saveourtool.save.frontend.utils.* import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.main import web.cssom.ClassName diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt index fd8c96494d..7f9a5d23b7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexLogoButtons.kt @@ -9,7 +9,6 @@ import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.ChildrenBuilder import react.FC -import react.Props import react.dom.html.ReactHTML.button import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h4 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt index c8f8a2b7b1..132b3e8789 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexViewAuth.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.info.OauthProviderInfo import org.w3c.fetch.Headers import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.useState import web.cssom.ClassName diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt index 46ecd426a6..3ff1dd0f82 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/OrganizationRatingTab.kt @@ -26,7 +26,7 @@ import kotlinx.serialization.json.Json private const val DEFAULT_PAGE_SIZE = 10_000 -val organizationRatingTab = FC { _ -> +val organizationRatingTab = FC { val (organizationFilter, setOrganizationFilter) = useState(OrganizationFilter.created) val fetchOrganizationRequest: suspend WithRequestStatusContext.(OrganizationFilter) -> OrganizationArray = { filter -> diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt index a4259184e6..d61ba25bb1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/TopRatingView.kt @@ -14,7 +14,6 @@ import com.saveourtool.save.frontend.utils.Style import com.saveourtool.save.frontend.utils.useBackground import com.saveourtool.save.validation.FrontendRoutes import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h1 import react.useState diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt index a501016287..b6948886b5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/toprating/UserRatingTab.kt @@ -17,7 +17,7 @@ import web.cssom.* private const val DEFAULT_PAGE_SIZE = 10_000 -val userRatingTable = FC { _ -> +val userRatingTable = FC { val (userNamePrefix, setUserNamePrefix) = useState("") val fetchUserRequest: suspend WithRequestStatusContext.(String) -> UserArray = { prefix -> diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt index 19d3f7955a..a5c00fe258 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt @@ -11,13 +11,12 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import react.FC import react.Fragment -import react.Props import react.create import react.dom.html.ReactHTML.td import web.cssom.ClassName import web.cssom.rem -val renderNewUsersTableForProfileView = FC { _ -> +val renderNewUsersTableForProfileView = FC { @Suppress( "TYPE_ALIAS", diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt index f686e21e96..97fffd4c41 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CosvSchemaView.kt @@ -11,7 +11,6 @@ import com.saveourtool.save.frontend.utils.* import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.a import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.h3 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt index 5278e76873..7deb6b2854 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/CreateVulnerabilityView.kt @@ -32,7 +32,6 @@ import com.saveourtool.osv4k.SeverityType import js.core.jso import react.ChildrenBuilder import react.FC -import react.Props import react.dom.aria.ariaDescribedBy import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt index c2c3dcd95e..9e7b8837b4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/vuln/UploadVulnerabilityView.kt @@ -10,7 +10,6 @@ import com.saveourtool.save.frontend.utils.particles import com.saveourtool.save.frontend.utils.useBackground import js.core.jso import react.FC -import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.form import react.dom.html.ReactHTML.h1 diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt index ee0d1d2da6..95f503335e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/MobileRouting.kt @@ -9,7 +9,6 @@ import com.saveourtool.save.frontend.components.mobile.saveWelcomeMobileView import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.FC -import react.Props import react.create import react.react import react.router.dom.createBrowserRouter From 50c475df1427fcdd86324341f31f52ddca8d64fc Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 11:03:05 +0300 Subject: [PATCH 12/41] diktatFix 2 --- .../save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt index dc3c95bfa3..fbdf1447b5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/externals/graph/cytoscape/CytoscapeWrapper.kt @@ -82,6 +82,6 @@ fun cytoscape( """) } - val cytoscapeJs = kotlinext.js.require("cytoscape") + val cytoscapeJs: dynamic = kotlinext.js.require("cytoscape") return cytoscapeJs(options) } From 4a4614e2f40fbc6c39c1856753c51ae2c1184eee Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 11:04:20 +0300 Subject: [PATCH 13/41] diktatFix 3 --- .../components/views/userprofile/UserProfileNewUsersTab.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt index a5c00fe258..4618e2121b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/userprofile/UserProfileNewUsersTab.kt @@ -17,7 +17,6 @@ import web.cssom.ClassName import web.cssom.rem val renderNewUsersTableForProfileView = FC { - @Suppress( "TYPE_ALIAS", "MAGIC_NUMBER", From 00202f24748a3811aa654ae55f7cf0cf89595784 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 11:45:06 +0300 Subject: [PATCH 14/41] fixed child and missed location --- .../saveourtool/save/frontend/components/HasErrorModal.kt | 2 +- .../saveourtool/save/frontend/components/basic/Markdown.kt | 4 ++-- .../components/basic/contests/PublicTestCardComponent.kt | 2 +- .../frontend/components/basic/graph/SigmaGraphVisualizer.kt | 4 ++-- .../save/frontend/components/tables/TableComponent.kt | 6 ++---- .../save/frontend/components/topbar/TopBarLinks.kt | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/HasErrorModal.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/HasErrorModal.kt index d7f9f7c8c5..7770e7b7d4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/HasErrorModal.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/HasErrorModal.kt @@ -128,7 +128,7 @@ val requestModalHandler: FC = FC { props -> div { className = ClassName("d-flex justify-content-center mt-4") div { - child(ringLoader) + +ringLoader span { className = ClassName("sr-only") +"Loading..." diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/Markdown.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/Markdown.kt index d76e8d9c2d..c4dfd48772 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/Markdown.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/Markdown.kt @@ -15,8 +15,8 @@ import react.ChildrenBuilder * @param classes class names that should be applied to high-level div */ fun ChildrenBuilder.markdown(text: String, classes: String? = null) { - child(reactMarkdown(jso { + +reactMarkdown(jso { this.children = text this.className = classes - })) + }) } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/contests/PublicTestCardComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/contests/PublicTestCardComponent.kt index 20356a3cc0..6a25a72bb0 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/contests/PublicTestCardComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/contests/PublicTestCardComponent.kt @@ -49,7 +49,7 @@ private fun ChildrenBuilder.displayTestLines(header: String, lines: List this.rehypePlugins = arrayOf(::rehypeHighlightPlugin) } publicTestCard { - child(reactMarkdown(reactMarkdownOptions)) + +reactMarkdown(reactMarkdownOptions) } } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt index 9198e03242..f036c42934 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt @@ -19,9 +19,9 @@ import web.cssom.* * Graph visualizer based on Sigma and Graphology libs */ val sigmaGraphVisualizer: FC = FC { props -> - kotlinext.js.require("@react-sigma/core/lib/react-sigma.min.css") + kotlinext.js.require("@react-sigma/core/lib/react-sigma.min.css") val (selectedNodeName, setSelectedNodeName) = useState(null) - val graphology = kotlinext.js.require("graphology") + val graphology = kotlinext.js.require("graphology") sigmaContainer { settings = getSigmaContainerSettings() this.graph = graphology.MultiDirectedGraph diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/tables/TableComponent.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/tables/TableComponent.kt index 4a9352c38e..4fd30b98d9 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/tables/TableComponent.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/tables/TableComponent.kt @@ -262,9 +262,7 @@ fun > tableComponent( val column = header.column th { this.className = className - child( - renderHeader(header) - ) + +renderHeader(header) if (column.getCanSort()) { style = style ?: jso() style?.cursor = "pointer".unsafeCast() @@ -287,7 +285,7 @@ fun > tableComponent( tr { spread(getRowProps(row)) row.getVisibleCells().map { cell -> - child(renderCell(cell)) + +renderCell(cell) } } if (row.isExpanded) { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarLinks.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarLinks.kt index c1da1ba070..97b25196e5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarLinks.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarLinks.kt @@ -96,7 +96,7 @@ external interface TopBarLinksProps : Props { /** * The location is needed to change the color of the text. */ - var location: Location + var location: Location<*> } /** @@ -112,7 +112,7 @@ data class TopBarLink( private fun textColor( hrefAnchor: String, - location: Location, + location: Location<*>, ) = if (location.pathname.endsWith(hrefAnchor) && location.pathname.count { it == '/' } < TOP_BAR_PATH_SEGMENTS_HIGHLIGHT) { "text-warning" } else { From 8e76268c1f7eba168107d92d69ee0dbb32e3e72f Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 11:56:11 +0300 Subject: [PATCH 15/41] try to fix router on index --- .../com/saveourtool/save/frontend/App.kt | 56 +++++++++---------- .../frontend/components/views/FallbackView.kt | 2 +- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 91128f5370..ab7e55dbb0 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -51,40 +51,38 @@ val App = FC { } } - val index = FC { - requestModalHandler { - this.userInfo = userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - ErrorBoundary::class.react { - topBarComponent { this.userInfo = userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - basicRouting { - this.userInfo = userInfo - this.userInfoSetter = setUserInfo + RouterProvider { + router = createBrowserRouter( + routes = arrayOf(), + opts = jso { + basename = "/" + } + ) + with(this@FC) { + requestModalHandler { + this.userInfo = userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + ErrorBoundary::class.react { + topBarComponent { this.userInfo = userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + basicRouting { + this.userInfo = userInfo + this.userInfoSetter = setUserInfo + } } + if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } } - if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } } } + scrollToTopButton() } - scrollToTopButton() - } - RouterProvider { - router = createBrowserRouter( - routes = arrayOf( - jso { - path = "/" - element = index.create() - } - ) - ) } } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/FallbackView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/FallbackView.kt index b3f50479f6..d6df76f3f5 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/FallbackView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/FallbackView.kt @@ -76,7 +76,7 @@ class FallbackView : AbstractView(Style.SAVE_LIGHT) { if (props.withRouterLink == true) { Navigate { to = "/" - buttonBuilder("Back to the main page", style = "info") { } + this@render.buttonBuilder("Back to the main page", style = "info") { } } } else { a { From b409fcbe89d23adb6036a7baf71c93a1d9998313 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 12:03:48 +0300 Subject: [PATCH 16/41] try to fix router on index --- .../com/saveourtool/save/frontend/App.kt | 44 +++++++------------ .../save/frontend/routing/BasicRouting.kt | 5 ++- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index ab7e55dbb0..9921898772 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -51,39 +51,29 @@ val App = FC { } } - RouterProvider { - router = createBrowserRouter( - routes = arrayOf(), - opts = jso { - basename = "/" - } - ) - with(this@FC) { - requestModalHandler { - this.userInfo = userInfo + requestModalHandler { + this.userInfo = userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + ErrorBoundary::class.react { + topBarComponent { this.userInfo = userInfo } div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - ErrorBoundary::class.react { - topBarComponent { this.userInfo = userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - basicRouting { - this.userInfo = userInfo - this.userInfoSetter = setUserInfo - } - } - if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } + className = ClassName("container-fluid") + id = "common-save-container" + basicRouting { + this.userInfo = userInfo + this.userInfoSetter = setUserInfo } } + if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } } - scrollToTopButton() } } + scrollToTopButton() } fun main() { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 6ea6fd4360..380a8af0a7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -277,7 +277,10 @@ val basicRouting: FC = FC { props -> } } ) - .toTypedArray() + .toTypedArray(), + opts = jso { + basename = "/" + } ) } From 02ad97f0435dffc9ec9fd90b78c4308235ba1e82 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 12:20:03 +0300 Subject: [PATCH 17/41] small refactoring of routes --- .../save/frontend/routing/BasicRouting.kt | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 380a8af0a7..59f7e55d09 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -166,6 +166,30 @@ val basicRouting: FC = FC { props -> } } + val routeToUserProfileView: RouteObject? = props.userInfo?.name?.let { userName -> + jso { + path = "/$userName" + element = Navigate.create { to = "/$this/$SETTINGS_PROFILE" } + } + } + + val routeToManageOrganizationView: RouteObject = jso { + path = "/$MANAGE_ORGANIZATIONS" + element = when (props.userInfo.isSuperAdmin()) { + true -> OrganizationAdminView::class.react.create() + else -> fallbackNode + } + } + + val routeToFallbackView: RouteObject = jso { + path = "*" + element = FallbackView::class.react.create { + bigText = "404" + smallText = "Page not found" + withRouterLink = true + } + } + createBrowserRouter( routes = listOf( indexView.create { userInfo = props.userInfo } to "/", @@ -249,39 +273,20 @@ val basicRouting: FC = FC { props -> } } .let { routes -> - props.userInfo?.name?.let { userName -> - routes.plus( - jso { - path = "/$userName" - element = Navigate.create { to = "/$this/$SETTINGS_PROFILE" } - } - ) - } ?: routes + routeToUserProfileView?.let { routes + it } ?: routes } - .plus( - jso { - path = "/$MANAGE_ORGANIZATIONS" - element = when (props.userInfo.isSuperAdmin()) { - true -> OrganizationAdminView::class.react.create() - else -> fallbackNode - } - } - ) - .plus( - jso { - path = "*" - element = FallbackView::class.react.create { - bigText = "404" - smallText = "Page not found" - withRouterLink = true - } - } - ) + .plus(routeToManageOrganizationView) + .plus(routeToFallbackView) .toTypedArray(), opts = jso { basename = "/" } ) + .let { + RouterProvider { + router = it + } + } } private val fallbackNode = FallbackView::class.react.create { From eeb2405a338c7811282191daceb575272c31ac3a Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 12:31:23 +0300 Subject: [PATCH 18/41] diktatFix --- .../src/main/kotlin/com/saveourtool/save/frontend/App.kt | 3 --- .../frontend/components/basic/graph/SigmaGraphVisualizer.kt | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 9921898772..4eea67a5f4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -15,12 +15,9 @@ import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes -import js.core.jso import react.* import react.dom.client.createRoot import react.dom.html.ReactHTML.div -import react.router.dom.RouterProvider -import react.router.dom.createBrowserRouter import web.cssom.ClassName import web.dom.document import web.html.HTMLElement diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt index f036c42934..cde13f1bac 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/basic/graph/SigmaGraphVisualizer.kt @@ -21,7 +21,7 @@ import web.cssom.* val sigmaGraphVisualizer: FC = FC { props -> kotlinext.js.require("@react-sigma/core/lib/react-sigma.min.css") val (selectedNodeName, setSelectedNodeName) = useState(null) - val graphology = kotlinext.js.require("graphology") + val graphology: dynamic = kotlinext.js.require("graphology") sigmaContainer { settings = getSigmaContainerSettings() this.graph = graphology.MultiDirectedGraph From 26044c78c5945e2b0b6d0e8025605c533fe5a53a Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 16:41:16 +0300 Subject: [PATCH 19/41] another try --- .../com/saveourtool/save/frontend/App.kt | 65 +++-- .../save/frontend/routing/BasicRouting.kt | 247 ++++++++++-------- .../save/frontend/utils/RouterUtils.kt | 2 +- .../save/frontend/BasicRoutingTest.kt | 16 +- 4 files changed, 188 insertions(+), 142 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 4eea67a5f4..7d924c5d1b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -8,12 +8,17 @@ import com.saveourtool.save.frontend.components.* import com.saveourtool.save.frontend.components.basic.cookieBanner import com.saveourtool.save.frontend.components.basic.scrollToTopButton import com.saveourtool.save.frontend.components.topbar.topBarComponent +import com.saveourtool.save.frontend.components.views.index.indexView +import com.saveourtool.save.frontend.components.views.welcome.saveWelcomeView +import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal import com.saveourtool.save.frontend.routing.basicRouting +import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes +import js.core.jso import react.* import react.dom.client.createRoot @@ -25,6 +30,8 @@ import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json +import react.router.dom.RouterProvider +import react.router.dom.createBrowserRouter /** * Main component for the whole App @@ -48,29 +55,51 @@ val App = FC { } } - requestModalHandler { - this.userInfo = userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - ErrorBoundary::class.react { - topBarComponent { this.userInfo = userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - basicRouting { - this.userInfo = userInfo - this.userInfoSetter = setUserInfo + val root = FC { + requestModalHandler { + this.userInfo = userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + + ErrorBoundary::class.react { + topBarComponent { this.userInfo = userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + indexView { + this.userInfo = userInfo + } } + if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } } - if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } } } + scrollToTopButton() } - scrollToTopButton() + + RouterProvider { + router = createBrowserRouter( + routes = arrayOf( + jso { + path = "/" + element = root.create() + }, + jso { + path = "/${FrontendRoutes.SAVE.path}" + element = saveWelcomeView.create { this.userInfo = userInfo } + }, + jso { + path = "/${FrontendRoutes.VULN.path}" + element = vulnWelcomeView.create { this.userInfo = userInfo } + }, + ) + ) + } + } fun main() { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 59f7e55d09..05e75691a3 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -29,6 +29,7 @@ import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.isSuperAdmin import com.saveourtool.save.info.UserInfo +import com.saveourtool.save.validation.FrontendRoutes import com.saveourtool.save.validation.FrontendRoutes.* import js.core.jso @@ -38,51 +39,54 @@ import react.router.* import react.router.dom.createBrowserRouter /** - * Just put a map: View -> Route URL to this list + * @param userInfo currently logged-in user or null + * @param userInfoSetter setter of user info (it can be updated in settings on several views) */ -val basicRouting: FC = FC { props -> - useUserStatusRedirects(props.userInfo?.status) - val userProfileView: FC = withRouter { _, params -> +fun createBasicRoutes( + userInfo: UserInfo?, + userInfoSetter: StateSetter, +): Array { + val userProfileView = withRouter { _, params -> userProfileView { userName = params["name"]!! - currentUserInfo = props.userInfo + currentUserInfo = userInfo } } - val contestView: FC = withRouter { location, params -> + val contestView = withRouter { location, params -> ContestView::class.react { - currentUserInfo = props.userInfo + currentUserInfo = userInfo currentContestName = params["contestName"] this.location = location } } - val contestExecutionView: FC = withRouter { _, params -> + val contestExecutionView = withRouter { _, params -> ContestExecutionView::class.react { - currentUserInfo = props.userInfo + currentUserInfo = userInfo contestName = params["contestName"]!! organizationName = params["organizationName"]!! projectName = params["projectName"]!! } } - val projectView: FC = withRouter { location, params -> + val projectView = withRouter { location, params -> ProjectView::class.react { name = params["name"]!! owner = params["owner"]!! - currentUserInfo = props.userInfo + currentUserInfo = userInfo this.location = location } } - val historyView: FC = withRouter { _, params -> + val historyView = withRouter { _, params -> HistoryView::class.react { name = params["name"]!! organizationName = params["owner"]!! } } - val executionView: FC = withRouter { location, params -> + val executionView = withRouter { location, params -> ExecutionView::class.react { organization = params["organization"]!! project = params["project"]!! @@ -99,21 +103,21 @@ val basicRouting: FC = FC { props -> } } - val organizationView: FC = withRouter { location, params -> + val organizationView = withRouter { location, params -> OrganizationView::class.react { organizationName = params["owner"]!! - currentUserInfo = props.userInfo + currentUserInfo = userInfo this.location = location } } - val awesomeBenchmarksView: FC = withRouter { location, _ -> + val awesomeBenchmarksView = withRouter { location, _ -> AwesomeBenchmarksView::class.react { this.location = location } } - val contestGlobalRatingView: FC = withRouter { location, _ -> + val contestGlobalRatingView = withRouter { location, _ -> ContestGlobalRatingView::class.react { organizationName = URLSearchParams(location.search).get("organizationName") projectName = URLSearchParams(location.search).get("projectName") @@ -121,14 +125,14 @@ val basicRouting: FC = FC { props -> } } - val contestTemplateView: FC = withRouter { _, params -> + val contestTemplateView = withRouter { _, params -> contestTemplateView { id = requireNotNull(params["id"]).toLong() - currentUserInfo = props.userInfo + currentUserInfo = userInfo } } - val demoView: FC = withRouter { _, params -> + val demoView = withRouter { _, params -> demoView { projectCoordinates = ProjectCoordinates( requireNotNull(params["organizationName"]), @@ -137,28 +141,28 @@ val basicRouting: FC = FC { props -> } } - val vulnerabilityCollectionView: FC = withRouter { location, _ -> + val vulnerabilityCollectionView = withRouter { location, _ -> vulnerabilityCollectionView { - currentUserInfo = props.userInfo + currentUserInfo = userInfo filter = URLSearchParams(location.search).toVulnerabilitiesFilter() } } - val vulnerabilityView: FC = withRouter { _, params -> + val vulnerabilityView = withRouter { _, params -> vulnerabilityView { identifier = requireNotNull(params["identifier"]) - currentUserInfo = props.userInfo + currentUserInfo = userInfo } } - val createProjectProblemView: FC = withRouter { _, params -> + val createProjectProblemView = withRouter { _, params -> createProjectProblem { organizationName = requireNotNull(params["owner"]) projectName = requireNotNull(params["name"]) } } - val projectProblemView: FC = withRouter { _, params -> + val projectProblemView = withRouter { _, params -> projectProblem { organizationName = requireNotNull(params["owner"]) projectName = requireNotNull(params["name"]) @@ -166,16 +170,18 @@ val basicRouting: FC = FC { props -> } } - val routeToUserProfileView: RouteObject? = props.userInfo?.name?.let { userName -> + val routeToUserProfileView: RouteObject? = userInfo?.name?.let { userName -> jso { path = "/$userName" - element = Navigate.create { to = "/$this/$SETTINGS_PROFILE" } + element = Navigate.create { + to = "/$this/$SETTINGS_PROFILE" + } } } val routeToManageOrganizationView: RouteObject = jso { path = "/$MANAGE_ORGANIZATIONS" - element = when (props.userInfo.isSuperAdmin()) { + element = when (userInfo.isSuperAdmin()) { true -> OrganizationAdminView::class.react.create() else -> fallbackNode } @@ -190,101 +196,110 @@ val basicRouting: FC = FC { props -> } } - createBrowserRouter( - routes = listOf( - indexView.create { userInfo = props.userInfo } to "/", - saveWelcomeView.create { userInfo = props.userInfo } to SAVE, - vulnWelcomeView.create { userInfo = props.userInfo } to VULN, - sandboxView.create() to SANDBOX, - AboutUsView::class.react.create() to ABOUT_US, - createOrganizationView.create() to CREATE_ORGANIZATION, - registrationView.create { - userInfo = props.userInfo - userInfoSetter = props.userInfoSetter - } to REGISTRATION, - CollectionView::class.react.create { currentUserInfo = props.userInfo } to PROJECTS, - contestListView.create { currentUserInfo = props.userInfo } to CONTESTS, - - FallbackView::class.react.create { - bigText = "404" - smallText = "Page not found" - withRouterLink = true - } to ERROR_404, - banView.create { userInfo = props.userInfo } to BAN, - contestGlobalRatingView.create() to CONTESTS_GLOBAL_RATING, - contestView.create() to "$CONTESTS/:contestName", - createContestTemplateView.create() to CREATE_CONTESTS_TEMPLATE, - contestTemplateView.create() to "$CONTESTS_TEMPLATE/:id", - contestExecutionView.create() to "$CONTESTS/:contestName/:organizationName/:projectName", - awesomeBenchmarksView.create() to AWESOME_BENCHMARKS, - createProjectView.create() to "$CREATE_PROJECT/:organization?", - organizationView.create() to ":owner", - historyView.create() to ":owner/:name/history", - projectView.create() to ":owner/:name", - createProjectProblemView.create() to "project/:owner/:name/security/problems/new", - projectProblemView.create() to "project/:owner/:name/security/problems/:id", - executionView.create() to ":organization/:project/history/execution/:executionId", - demoView.create() to "$DEMO/:organizationName/:projectName", - cpgView.create() to "$DEMO/cpg", - testExecutionDetailsView.create() to "/:organization/:project/history/execution/:executionId/test/:testId", - vulnerabilityCollectionView.create() to "$VULN/list/:params?", - createVulnerabilityView.create() to VULN_CREATE, - uploadVulnerabilityView.create() to VULN_UPLOAD, - vulnerabilityView.create() to "$VULNERABILITY_SINGLE/:identifier", - demoCollectionView.create() to DEMO, - userProfileView.create() to "$VULN_PROFILE/:name", - topRatingView.create() to VULN_TOP_RATING, - termsOfUsageView.create() to TERMS_OF_USE, - cookieTermsOfUse.create() to COOKIE, - thanksForRegistrationView.create() to THANKS_FOR_REGISTRATION, - cosvSchemaView.create() to VULN_COSV_SCHEMA, - - userSettingsView.create { - this.userInfoSetter = props.userInfoSetter - userInfo = props.userInfo - type = SETTINGS_PROFILE - } to SETTINGS_PROFILE, - - userSettingsView.create { - this.userInfoSetter = props.userInfoSetter - userInfo = props.userInfo - type = SETTINGS_EMAIL - } to SETTINGS_EMAIL, - - userSettingsView.create { - userInfo = props.userInfo - type = SETTINGS_TOKEN - } to SETTINGS_TOKEN, - - userSettingsView.create { - userInfo = props.userInfo - type = SETTINGS_ORGANIZATIONS - } to SETTINGS_ORGANIZATIONS, - - userSettingsView.create { - userInfo = props.userInfo - type = SETTINGS_DELETE - } to SETTINGS_DELETE, - - ).map { (view, route) -> + return listOf( +// indexView.create { this.userInfo = userInfo } to "/", + saveWelcomeView.create { this.userInfo = userInfo } to SAVE, + vulnWelcomeView.create { this.userInfo = userInfo } to VULN, + sandboxView.create() to SANDBOX, + AboutUsView::class.react.create() to ABOUT_US, + createOrganizationView.create() to CREATE_ORGANIZATION, + registrationView.create { + this.userInfo = userInfo + this.userInfoSetter = userInfoSetter + } to REGISTRATION, + CollectionView::class.react.create { currentUserInfo = userInfo } to PROJECTS, + contestListView.create { currentUserInfo = userInfo } to CONTESTS, + + FallbackView::class.react.create { + bigText = "404" + smallText = "Page not found" + withRouterLink = true + } to ERROR_404, + banView.create { this.userInfo = userInfo } to BAN, + contestGlobalRatingView.create() to CONTESTS_GLOBAL_RATING, + contestView.create() to "$CONTESTS/:contestName", + createContestTemplateView.create() to CREATE_CONTESTS_TEMPLATE, + contestTemplateView.create() to "$CONTESTS_TEMPLATE/:id", + contestExecutionView.create() to "$CONTESTS/:contestName/:organizationName/:projectName", + awesomeBenchmarksView.create() to AWESOME_BENCHMARKS, + createProjectView.create() to "$CREATE_PROJECT/:organization?", + organizationView.create() to ":owner", + historyView.create() to ":owner/:name/history", + projectView.create() to ":owner/:name", + createProjectProblemView.create() to "project/:owner/:name/security/problems/new", + projectProblemView.create() to "project/:owner/:name/security/problems/:id", + executionView.create() to ":organization/:project/history/execution/:executionId", + demoView.create() to "$DEMO/:organizationName/:projectName", + cpgView.create() to "$DEMO/cpg", + testExecutionDetailsView.create() to "/:organization/:project/history/execution/:executionId/test/:testId", + vulnerabilityCollectionView.create() to "$VULN/list/:params?", + createVulnerabilityView.create() to VULN_CREATE, + uploadVulnerabilityView.create() to VULN_UPLOAD, + vulnerabilityView.create() to "$VULNERABILITY_SINGLE/:identifier", + demoCollectionView.create() to DEMO, + userProfileView.create() to "$VULN_PROFILE/:name", + topRatingView.create() to VULN_TOP_RATING, + termsOfUsageView.create() to TERMS_OF_USE, + cookieTermsOfUse.create() to COOKIE, + thanksForRegistrationView.create() to THANKS_FOR_REGISTRATION, + cosvSchemaView.create() to VULN_COSV_SCHEMA, + + userSettingsView.create { + this.userInfo = userInfo + this.userInfoSetter = userInfoSetter + type = SETTINGS_PROFILE + } to SETTINGS_PROFILE, + + userSettingsView.create { + this.userInfo = userInfo + this.userInfoSetter = userInfoSetter + type = SETTINGS_EMAIL + } to SETTINGS_EMAIL, + + userSettingsView.create { + this.userInfo = userInfo + type = SETTINGS_TOKEN + } to SETTINGS_TOKEN, + + userSettingsView.create { + this.userInfo = userInfo + type = SETTINGS_ORGANIZATIONS + } to SETTINGS_ORGANIZATIONS, + + userSettingsView.create { + this.userInfo = userInfo + type = SETTINGS_DELETE + } to SETTINGS_DELETE, + + ) + .map { (view, route) -> jso { path = "/$route" element = view } } - .let { routes -> - routeToUserProfileView?.let { routes + it } ?: routes - } - .plus(routeToManageOrganizationView) - .plus(routeToFallbackView) - .toTypedArray(), - opts = jso { - basename = "/" + .toTypedArray() + .let { routes -> + routeToUserProfileView?.let { routes + it } ?: routes } - ) + .plus(routeToManageOrganizationView) + .plus(routeToFallbackView) +} + +/** + * Just put a map: View -> Route URL to this list + */ +val basicRouting: FC = FC { props -> + useUserStatusRedirects(props.userInfo?.status) + createBasicRoutes(props.userInfo, props.userInfoSetter) .let { RouterProvider { - router = it + router = createBrowserRouter( + routes = it, + opts = jso { + basename = "/" + } + ) } } } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt index de7da525ae..84ceff2b4a 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/RouterUtils.kt @@ -44,7 +44,7 @@ fun ChildrenBuilder.withNavigate(handler: ChildrenBuilder.(NavigateFunctionConte * @return a function component */ @Suppress("TYPE_ALIAS") -fun withRouter(handler: ChildrenBuilder.(Location<*>, Params) -> Unit) = FC { +fun withRouter(handler: ChildrenBuilder.(Location<*>, Params) -> Unit) = FC { val location = useLocation() val params = useParams() handler(location, params) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index f7a16fde2f..d17d084ee7 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -6,8 +6,9 @@ import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.screen import com.saveourtool.save.frontend.routing.basicRouting import web.html.HTMLHeadingElement -import react.create -import react.router.MemoryRouter +import react.router.RouterProvider +import react.router.createMemoryRouter +import react.router.dom.RouterProvider import kotlin.js.Promise import kotlin.test.* import kotlin.test.Test @@ -16,12 +17,13 @@ class BasicRoutingTest { @Test fun basicRoutingShouldRenderIndexViewTest(): Promise { // App uses `BrowserRouter`, while `MemoryRouter` should be used for tests. Thus, app cannot be rendered - render( - MemoryRouter.create { - initI18n() + val routerProvider = RouterProvider { + router = createMemoryRouter( basicRouting() - } - ) + ) + initI18n() + } + render(routerProvider) screen.findByTextAndCast( "Cloud Platform for CI and Benchmarking of Code Analyzers" From 2ef6429903c81d9fe0eda5dae17f9147e8915364 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 24 Oct 2023 16:43:59 +0300 Subject: [PATCH 20/41] diktatFix --- .../com/saveourtool/save/frontend/App.kt | 9 +- .../save/frontend/routing/BasicRouting.kt | 101 +++++++++--------- 2 files changed, 53 insertions(+), 57 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 7d924c5d1b..01019eaee7 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -13,16 +13,16 @@ import com.saveourtool.save.frontend.components.views.welcome.saveWelcomeView import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal -import com.saveourtool.save.frontend.routing.basicRouting -import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes -import js.core.jso +import js.core.jso import react.* import react.dom.client.createRoot import react.dom.html.ReactHTML.div +import react.router.dom.RouterProvider +import react.router.dom.createBrowserRouter import web.cssom.ClassName import web.dom.document import web.html.HTMLElement @@ -30,8 +30,6 @@ import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json -import react.router.dom.RouterProvider -import react.router.dom.createBrowserRouter /** * Main component for the whole App @@ -99,7 +97,6 @@ val App = FC { ) ) } - } fun main() { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 05e75691a3..746fb46f62 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -18,7 +18,6 @@ import com.saveourtool.save.frontend.components.views.contests.* import com.saveourtool.save.frontend.components.views.demo.cpgView import com.saveourtool.save.frontend.components.views.demo.demoCollectionView import com.saveourtool.save.frontend.components.views.demo.demoView -import com.saveourtool.save.frontend.components.views.index.indexView import com.saveourtool.save.frontend.components.views.projectcollection.CollectionView import com.saveourtool.save.frontend.components.views.toprating.topRatingView import com.saveourtool.save.frontend.components.views.userprofile.userProfileView @@ -29,7 +28,6 @@ import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.isSuperAdmin import com.saveourtool.save.info.UserInfo -import com.saveourtool.save.validation.FrontendRoutes import com.saveourtool.save.validation.FrontendRoutes.* import js.core.jso @@ -38,9 +36,57 @@ import react.* import react.router.* import react.router.dom.createBrowserRouter +/** + * Just put a map: View -> Route URL to this list + */ +val basicRouting: FC = FC { props -> + useUserStatusRedirects(props.userInfo?.status) + createBasicRoutes(props.userInfo, props.userInfoSetter) + .let { + RouterProvider { + router = createBrowserRouter( + routes = it, + opts = jso { + basename = "/" + } + ) + } + } +} + +private val fallbackNode = FallbackView::class.react.create { + bigText = "404" + smallText = "Page not found" + withRouterLink = false +} + +/** + * Property to propagate user info from App + */ +external interface AppProps : PropsWithChildren { + /** + * Currently logged-in user or null + */ + var userInfo: UserInfo? + + /** + * Setter of user info (it can be updated in settings on several views) + */ + var userInfoSetter: StateSetter +} + +/** + * @param view + * @return a view or a fallback of user info is null + */ +fun AppProps.viewWithFallBack(view: ReactElement<*>) = this.userInfo?.name?.let { + view +} ?: fallbackNode + /** * @param userInfo currently logged-in user or null * @param userInfoSetter setter of user info (it can be updated in settings on several views) + * @return */ fun createBasicRoutes( userInfo: UserInfo?, @@ -197,7 +243,7 @@ fun createBasicRoutes( } return listOf( -// indexView.create { this.userInfo = userInfo } to "/", + // indexView.create { this.userInfo = userInfo } to "/", saveWelcomeView.create { this.userInfo = userInfo } to SAVE, vulnWelcomeView.create { this.userInfo = userInfo } to VULN, sandboxView.create() to SANDBOX, @@ -271,7 +317,7 @@ fun createBasicRoutes( type = SETTINGS_DELETE } to SETTINGS_DELETE, - ) + ) .map { (view, route) -> jso { path = "/$route" @@ -285,50 +331,3 @@ fun createBasicRoutes( .plus(routeToManageOrganizationView) .plus(routeToFallbackView) } - -/** - * Just put a map: View -> Route URL to this list - */ -val basicRouting: FC = FC { props -> - useUserStatusRedirects(props.userInfo?.status) - createBasicRoutes(props.userInfo, props.userInfoSetter) - .let { - RouterProvider { - router = createBrowserRouter( - routes = it, - opts = jso { - basename = "/" - } - ) - } - } -} - -private val fallbackNode = FallbackView::class.react.create { - bigText = "404" - smallText = "Page not found" - withRouterLink = false -} - -/** - * Property to propagate user info from App - */ -external interface AppProps : PropsWithChildren { - /** - * Currently logged-in user or null - */ - var userInfo: UserInfo? - - /** - * Setter of user info (it can be updated in settings on several views) - */ - var userInfoSetter: StateSetter -} - -/** - * @param view - * @return a view or a fallback of user info is null - */ -fun AppProps.viewWithFallBack(view: ReactElement<*>) = this.userInfo?.name?.let { - view -} ?: fallbackNode From 16e585e11208adfaafce4a6902a42b7994053923 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 25 Oct 2023 12:12:44 +0300 Subject: [PATCH 21/41] A single props for all top level FC --- .../com/saveourtool/save/frontend/App.kt | 67 +++++++++++-------- .../components/views/index/CardAboutUs.kt | 3 +- .../components/views/index/IndexView.kt | 2 +- .../views/welcome/SaveWelcomeView.kt | 2 +- .../views/welcome/VulnerabilityWelcomeView.kt | 2 +- .../save/frontend/utils/UserInfoAwareProps.kt | 26 +++++++ 6 files changed, 69 insertions(+), 33 deletions(-) create mode 100644 save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/UserInfoAwareProps.kt diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 01019eaee7..e06aa31539 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -53,52 +53,61 @@ val App = FC { } } - val root = FC { - requestModalHandler { - this.userInfo = userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - - ErrorBoundary::class.react { - topBarComponent { this.userInfo = userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - indexView { - this.userInfo = userInfo - } - } - if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } - } - } - } - scrollToTopButton() - } - RouterProvider { router = createBrowserRouter( routes = arrayOf( jso { path = "/" - element = root.create() + element = wrapView(indexView).create { this.userInfo = userInfo } }, jso { path = "/${FrontendRoutes.SAVE.path}" - element = saveWelcomeView.create { this.userInfo = userInfo } + element = wrapView(saveWelcomeView).create { this.userInfo = userInfo } }, jso { path = "/${FrontendRoutes.VULN.path}" - element = vulnWelcomeView.create { this.userInfo = userInfo } + element = wrapView(vulnWelcomeView).create { this.userInfo = userInfo } }, ) ) } } +private fun wrapView(view: FC): FC = FC { props -> + requestModalHandler { + this.userInfo = props.userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + + ErrorBoundary::class.react { + topBarComponent { this.userInfo = props.userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + view { + this.userInfo = props.userInfo + this.userInfoSetter = props.userInfoSetter + } + } + if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } + } + } + } + scrollToTopButton() +} + +private fun wrapView(view: FC): FC = wrapView(view.asMutable()) + +private fun FC.asMutable(): FC = FC { props -> + this@asMutable { + this.userInfo = props.userInfo + } +} + fun main() { /* Workaround for issue: https://youtrack.jetbrains.com/issue/KT-31888 */ @Suppress("UnsafeCastFromDynamic") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/CardAboutUs.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/CardAboutUs.kt index df75f0a637..ff1bab2401 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/CardAboutUs.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/CardAboutUs.kt @@ -7,6 +7,7 @@ package com.saveourtool.save.frontend.components.views.index import com.saveourtool.save.frontend.externals.fontawesome.faGithub import com.saveourtool.save.frontend.externals.fontawesome.fontAwesomeIcon import com.saveourtool.save.frontend.externals.i18next.useTranslation +import com.saveourtool.save.frontend.utils.UserInfoAwareProps import com.saveourtool.save.frontend.utils.buttonBuilder import com.saveourtool.save.validation.FrontendRoutes import js.core.jso @@ -20,7 +21,7 @@ import react.router.useNavigate import web.cssom.ClassName import web.cssom.TextAlign -val cardAboutUs: FC = FC { props -> +val cardAboutUs: FC = FC { props -> val (t) = useTranslation("index") val navigate = useNavigate() diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexView.kt index bd44988625..c855ac8bd4 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/index/IndexView.kt @@ -20,7 +20,7 @@ import web.cssom.* import kotlinx.browser.window @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -val indexView: FC = FC { props -> +val indexView: FC = FC { props -> val navigate = useNavigate() useEffect { if (window.location.run { isCosvDomain() && pathname == "/" }) { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/SaveWelcomeView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/SaveWelcomeView.kt index d775927d8d..b204609c29 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/SaveWelcomeView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/SaveWelcomeView.kt @@ -33,7 +33,7 @@ import web.cssom.* import kotlinx.browser.window -val saveWelcomeView: FC = FC { props -> +val saveWelcomeView: FC = FC { props -> val (t) = useTranslation("welcome") useBackground(Style.SAVE_DARK) val (oauthProviders, setOauthProviders) = useState>(emptyList()) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/VulnerabilityWelcomeView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/VulnerabilityWelcomeView.kt index 0f6842fefb..5cb988c38d 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/VulnerabilityWelcomeView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/welcome/VulnerabilityWelcomeView.kt @@ -40,7 +40,7 @@ const val FIRST_RAW_HEIGHT = 33 const val SECOND_RAW_HEIGHT = 15 const val BIG_FONT_SIZE = 3.5 -val vulnWelcomeView: FC = FC { props -> +val vulnWelcomeView: FC = FC { props -> useBackground(Style.VULN_DARK) val (t) = useTranslation("welcome") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/UserInfoAwareProps.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/UserInfoAwareProps.kt new file mode 100644 index 0000000000..ec2abcae14 --- /dev/null +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/utils/UserInfoAwareProps.kt @@ -0,0 +1,26 @@ +package com.saveourtool.save.frontend.utils + +import com.saveourtool.save.info.UserInfo +import react.Props +import react.StateSetter + +/** + * Property to propagate user info from App + */ +external interface UserInfoAwareProps : Props { + /** + * Currently logged-in user or null + */ + var userInfo: UserInfo? +} + + +/** + * Property to propagate user info from App with ability to update it + */ +external interface UserInfoAwareMutableProps : UserInfoAwareProps { + /** + * Setter of user info (it can be updated in settings on several views) + */ + var userInfoSetter: StateSetter +} From 89fe70db209e6fee4f34332d57b7c42c39e04dfd Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 25 Oct 2023 14:43:46 +0300 Subject: [PATCH 22/41] removed duplicate method --- .../src/main/kotlin/com/saveourtool/save/frontend/App.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index e06aa31539..ae66e5318e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -102,12 +102,6 @@ private fun wrapView(view: FC): FC): FC = wrapView(view.asMutable()) -private fun FC.asMutable(): FC = FC { props -> - this@asMutable { - this.userInfo = props.userInfo - } -} - fun main() { /* Workaround for issue: https://youtrack.jetbrains.com/issue/KT-31888 */ @Suppress("UnsafeCastFromDynamic") From 79bb2ab1438232517fc1f1130a17422cd26d4322 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 25 Oct 2023 15:58:12 +0300 Subject: [PATCH 23/41] WIP --- .../com/saveourtool/save/frontend/App.kt | 56 +------ .../save/frontend/components/MainView.kt | 2 + .../save/frontend/routing/BasicRouting.kt | 140 ++++++++++++------ 3 files changed, 97 insertions(+), 101 deletions(-) create mode 100644 save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 46c4d5ff6c..a874176d8c 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -4,26 +4,16 @@ package com.saveourtool.save.frontend -import com.saveourtool.save.frontend.components.* -import com.saveourtool.save.frontend.components.basic.cookieBanner -import com.saveourtool.save.frontend.components.basic.scrollToTopButton -import com.saveourtool.save.frontend.components.topbar.topBarComponent -import com.saveourtool.save.frontend.components.views.index.indexView -import com.saveourtool.save.frontend.components.views.welcome.saveWelcomeView -import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal +import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo -import com.saveourtool.save.validation.FrontendRoutes -import js.core.jso import react.* import react.dom.client.createRoot -import react.dom.html.ReactHTML.div import react.router.dom.RouterProvider import react.router.dom.createBrowserRouter -import web.cssom.ClassName import web.dom.document import web.html.HTMLElement @@ -55,53 +45,11 @@ val App: FC = FC { RouterProvider { router = createBrowserRouter( - routes = arrayOf( - jso { - path = "/" - element = wrapView(indexView).create { this.userInfo = userInfo } - }, - jso { - path = "/${FrontendRoutes.SAVE.path}" - element = wrapView(saveWelcomeView).create { this.userInfo = userInfo } - }, - jso { - path = "/${FrontendRoutes.VULN.path}" - element = wrapView(vulnWelcomeView).create { this.userInfo = userInfo } - }, - ) + routes = createBasicRoutes(userInfo, setUserInfo) ) } } -private fun wrapView(view: FC): FC = FC { props -> - requestModalHandler { - this.userInfo = props.userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - - ErrorBoundary::class.react { - topBarComponent { this.userInfo = props.userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - view { - this.userInfo = props.userInfo - this.userInfoSetter = props.userInfoSetter - } - } - if (kotlinx.browser.window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } - } - } - } - scrollToTopButton() -} - -private fun wrapView(view: FC): FC = wrapView(view.asMutable()) - fun main() { /* Workaround for issue: https://youtrack.jetbrains.com/issue/KT-31888 */ @Suppress("UnsafeCastFromDynamic") diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt new file mode 100644 index 0000000000..e910afe27e --- /dev/null +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt @@ -0,0 +1,2 @@ +package com.saveourtool.save.frontend.components + diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 38b6040202..693f6d84df 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -9,8 +9,14 @@ package com.saveourtool.save.frontend.routing import com.saveourtool.save.domain.ProjectCoordinates import com.saveourtool.save.domain.TestResultStatus import com.saveourtool.save.filters.TestExecutionFilter +import com.saveourtool.save.frontend.components.ErrorBoundary +import com.saveourtool.save.frontend.components.basic.cookieBanner import com.saveourtool.save.frontend.components.basic.projects.createProjectProblem import com.saveourtool.save.frontend.components.basic.projects.projectProblem +import com.saveourtool.save.frontend.components.basic.scrollToTopButton +import com.saveourtool.save.frontend.components.footer +import com.saveourtool.save.frontend.components.requestModalHandler +import com.saveourtool.save.frontend.components.topbar.topBarComponent import com.saveourtool.save.frontend.components.views.* import com.saveourtool.save.frontend.components.views.agreements.cookieTermsOfUse import com.saveourtool.save.frontend.components.views.agreements.termsOfUsageView @@ -18,6 +24,7 @@ import com.saveourtool.save.frontend.components.views.contests.* import com.saveourtool.save.frontend.components.views.demo.cpgView import com.saveourtool.save.frontend.components.views.demo.demoCollectionView import com.saveourtool.save.frontend.components.views.demo.demoView +import com.saveourtool.save.frontend.components.views.index.indexView import com.saveourtool.save.frontend.components.views.projectcollection.CollectionView import com.saveourtool.save.frontend.components.views.toprating.topRatingView import com.saveourtool.save.frontend.components.views.userprofile.userProfileView @@ -27,13 +34,18 @@ import com.saveourtool.save.frontend.components.views.welcome.saveWelcomeView import com.saveourtool.save.frontend.components.views.welcome.vulnWelcomeView import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.frontend.utils.isSuperAdmin +import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes.* import js.core.jso +import kotlinx.browser.window import org.w3c.dom.url.URLSearchParams import react.* +import react.dom.html.ReactHTML +import react.dom.html.ReactHTML.div import react.router.* import react.router.dom.createBrowserRouter +import web.cssom.ClassName /** * Just put a map: View -> Route URL to this list @@ -53,7 +65,7 @@ val basicRouting: FC = FC { props -> } } -private val fallbackNode = FallbackView::class.react.create { +private val fallbackNode = FallbackView::class.react.wrapAndCreate { bigText = "404" smallText = "Page not found" withRouterLink = false @@ -212,14 +224,14 @@ fun createBasicRoutes( val routeToManageOrganizationView: RouteObject = jso { path = "/$MANAGE_ORGANIZATIONS" element = when (userInfo.isSuperAdmin()) { - true -> OrganizationAdminView::class.react.create() + true -> OrganizationAdminView::class.react.wrapAndCreate() else -> fallbackNode } } val routeToFallbackView: RouteObject = jso { path = "*" - element = FallbackView::class.react.create { + element = FallbackView::class.react.wrapAndCreate { bigText = "404" smallText = "Page not found" withRouterLink = true @@ -227,76 +239,76 @@ fun createBasicRoutes( } return listOf( - // indexView.create { this.userInfo = userInfo } to "/", - saveWelcomeView.create { this.userInfo = userInfo } to SAVE, - vulnWelcomeView.create { this.userInfo = userInfo } to VULN, - sandboxView.create() to SANDBOX, - AboutUsView::class.react.create() to ABOUT_US, - createOrganizationView.create() to CREATE_ORGANIZATION, - registrationView.create { + indexView.wrapAndCreate { this.userInfo = userInfo } to "/", + saveWelcomeView.wrapAndCreate { this.userInfo = userInfo } to SAVE, + vulnWelcomeView.wrapAndCreate { this.userInfo = userInfo } to VULN, + sandboxView.wrapAndCreate() to SANDBOX, + AboutUsView::class.react.wrapAndCreate() to ABOUT_US, + createOrganizationView.wrapAndCreate() to CREATE_ORGANIZATION, + registrationView.wrapAndCreate { this.userInfo = userInfo this.userInfoSetter = userInfoSetter } to REGISTRATION, - CollectionView::class.react.create { currentUserInfo = userInfo } to PROJECTS, - contestListView.create { currentUserInfo = userInfo } to CONTESTS, + CollectionView::class.react.wrapAndCreate { currentUserInfo = userInfo } to PROJECTS, + contestListView.wrapAndCreate { currentUserInfo = userInfo } to CONTESTS, - FallbackView::class.react.create { + FallbackView::class.react.wrapAndCreate { bigText = "404" smallText = "Page not found" withRouterLink = true } to ERROR_404, - banView.create { this.userInfo = userInfo } to BAN, - contestGlobalRatingView.create() to CONTESTS_GLOBAL_RATING, - contestView.create() to "$CONTESTS/:contestName", - createContestTemplateView.create() to CREATE_CONTESTS_TEMPLATE, - contestTemplateView.create() to "$CONTESTS_TEMPLATE/:id", - contestExecutionView.create() to "$CONTESTS/:contestName/:organizationName/:projectName", - awesomeBenchmarksView.create() to AWESOME_BENCHMARKS, - createProjectView.create() to "$CREATE_PROJECT/:organization?", - organizationView.create() to ":owner", - historyView.create() to ":owner/:name/history", - projectView.create() to ":owner/:name", - createProjectProblemView.create() to "project/:owner/:name/security/problems/new", - projectProblemView.create() to "project/:owner/:name/security/problems/:id", - executionView.create() to ":organization/:project/history/execution/:executionId", - demoView.create() to "$DEMO/:organizationName/:projectName", - cpgView.create() to "$DEMO/cpg", - testExecutionDetailsView.create() to "/:organization/:project/history/execution/:executionId/test/:testId", - vulnerabilityCollectionView.create() to "$VULN/list/:params?", - createVulnerabilityView.create() to VULN_CREATE, - uploadVulnerabilityView.create() to VULN_UPLOAD, - vulnerabilityView.create() to "$VULNERABILITY_SINGLE/:identifier", - demoCollectionView.create() to DEMO, - userProfileView.create() to "$VULN_PROFILE/:name", - topRatingView.create() to VULN_TOP_RATING, - termsOfUsageView.create() to TERMS_OF_USE, - cookieTermsOfUse.create() to COOKIE, - thanksForRegistrationView.create() to THANKS_FOR_REGISTRATION, - cosvSchemaView.create() to VULN_COSV_SCHEMA, - - userSettingsView.create { + banView.wrapAndCreate { this.userInfo = userInfo } to BAN, + contestGlobalRatingView.wrapAndCreate() to CONTESTS_GLOBAL_RATING, + contestView.wrapAndCreate() to "$CONTESTS/:contestName", + createContestTemplateView.wrapAndCreate() to CREATE_CONTESTS_TEMPLATE, + contestTemplateView.wrapAndCreate() to "$CONTESTS_TEMPLATE/:id", + contestExecutionView.wrapAndCreate() to "$CONTESTS/:contestName/:organizationName/:projectName", + awesomeBenchmarksView.wrapAndCreate() to AWESOME_BENCHMARKS, + createProjectView.wrapAndCreate() to "$CREATE_PROJECT/:organization?", + organizationView.wrapAndCreate() to ":owner", + historyView.wrapAndCreate() to ":owner/:name/history", + projectView.wrapAndCreate() to ":owner/:name", + createProjectProblemView.wrapAndCreate() to "project/:owner/:name/security/problems/new", + projectProblemView.wrapAndCreate() to "project/:owner/:name/security/problems/:id", + executionView.wrapAndCreate() to ":organization/:project/history/execution/:executionId", + demoView.wrapAndCreate() to "$DEMO/:organizationName/:projectName", + cpgView.wrapAndCreate() to "$DEMO/cpg", + testExecutionDetailsView.wrapAndCreate() to "/:organization/:project/history/execution/:executionId/test/:testId", + vulnerabilityCollectionView.wrapAndCreate() to "$VULN/list/:params?", + createVulnerabilityView.wrapAndCreate() to VULN_CREATE, + uploadVulnerabilityView.wrapAndCreate() to VULN_UPLOAD, + vulnerabilityView.wrapAndCreate() to "$VULNERABILITY_SINGLE/:identifier", + demoCollectionView.wrapAndCreate() to DEMO, + userProfileView.wrapAndCreate() to "$VULN_PROFILE/:name", + topRatingView.wrapAndCreate() to VULN_TOP_RATING, + termsOfUsageView.wrapAndCreate() to TERMS_OF_USE, + cookieTermsOfUse.wrapAndCreate() to COOKIE, + thanksForRegistrationView.wrapAndCreate() to THANKS_FOR_REGISTRATION, + cosvSchemaView.wrapAndCreate() to VULN_COSV_SCHEMA, + + userSettingsView.wrapAndCreate { this.userInfo = userInfo this.userInfoSetter = userInfoSetter type = SETTINGS_PROFILE } to SETTINGS_PROFILE, - userSettingsView.create { + userSettingsView.wrapAndCreate { this.userInfo = userInfo this.userInfoSetter = userInfoSetter type = SETTINGS_EMAIL } to SETTINGS_EMAIL, - userSettingsView.create { + userSettingsView.wrapAndCreate { this.userInfo = userInfo type = SETTINGS_TOKEN } to SETTINGS_TOKEN, - userSettingsView.create { + userSettingsView.wrapAndCreate { this.userInfo = userInfo type = SETTINGS_ORGANIZATIONS } to SETTINGS_ORGANIZATIONS, - userSettingsView.create { + userSettingsView.wrapAndCreate { this.userInfo = userInfo type = SETTINGS_DELETE } to SETTINGS_DELETE, @@ -315,3 +327,37 @@ fun createBasicRoutes( .plus(routeToManageOrganizationView) .plus(routeToFallbackView) } + +/** + * @param view + * @param block + * @return [ReactElement] created from [view] with wrapping for common parts of all pages + */ +private fun

ElementType

.wrapAndCreate( + block: (@ReactDsl P.() -> Unit)? = null, +): ReactElement

{ + val wrapped: FC

= FC { props -> + requestModalHandler { + this.userInfo = props.userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + + ErrorBoundary::class.react { + topBarComponent { this.userInfo = props.userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + block?.let { this@wrapAndCreate(block) } ?: run { this@wrapAndCreate() } + } + if (window.location.pathname != "/$COOKIE") { + cookieBanner { } + } + footer { } + } + } + } + scrollToTopButton() + } + return block?.let { wrapped.create(block) } ?: run { wrapped.create() } +} \ No newline at end of file From ed48da4d1a3fe8517082b62d37fcb44dcbf65a63 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 25 Oct 2023 16:35:48 +0300 Subject: [PATCH 24/41] set basename --- .../src/main/kotlin/com/saveourtool/save/frontend/App.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index a874176d8c..7aef8b3f35 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -9,6 +9,7 @@ import com.saveourtool.save.frontend.externals.modal.ReactModal import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo +import js.core.jso import react.* import react.dom.client.createRoot @@ -45,7 +46,10 @@ val App: FC = FC { RouterProvider { router = createBrowserRouter( - routes = createBasicRoutes(userInfo, setUserInfo) + routes = createBasicRoutes(userInfo, setUserInfo), + opts = jso { + basename = "/" + } ) } } From 9c9e06d74e4af51bda307005862883d82925f7a2 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 25 Oct 2023 18:59:42 +0300 Subject: [PATCH 25/41] WIP --- .../com/saveourtool/save/frontend/App.kt | 47 ++++++++++++++++-- .../save/frontend/components/MainView.kt | 2 - .../save/frontend/routing/BasicRouting.kt | 49 ++++++++++--------- 3 files changed, 67 insertions(+), 31 deletions(-) delete mode 100644 save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 7aef8b3f35..a0ec17e61b 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -4,11 +4,18 @@ package com.saveourtool.save.frontend +import com.saveourtool.save.frontend.components.ErrorBoundary +import com.saveourtool.save.frontend.components.basic.cookieBanner +import com.saveourtool.save.frontend.components.basic.scrollToTopButton +import com.saveourtool.save.frontend.components.footer +import com.saveourtool.save.frontend.components.requestModalHandler +import com.saveourtool.save.frontend.components.topbar.topBarComponent import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo +import com.saveourtool.save.validation.FrontendRoutes import js.core.jso import react.* @@ -21,6 +28,11 @@ import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json +import react.dom.html.ReactHTML.div +import react.router.Outlet +import react.router.createMemoryRouter +import remix.run.router.createRouter +import web.cssom.ClassName /** * Main component for the whole App @@ -44,13 +56,38 @@ val App: FC = FC { } } + val index: FC = FC { props -> + + } + RouterProvider { - router = createBrowserRouter( - routes = createBasicRoutes(userInfo, setUserInfo), - opts = jso { - basename = "/" + with(this@FC) { + requestModalHandler { + this.userInfo = userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + ErrorBoundary::class.react { + topBarComponent { this.userInfo = userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + this@RouterProvider.router = createBrowserRouter( + routes = createBasicRoutes(userInfo, setUserInfo), + opts = jso { + basename = "/" + } + ) + } + if (window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } + } + } } - ) + scrollToTopButton() + } } } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt deleted file mode 100644 index e910afe27e..0000000000 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/MainView.kt +++ /dev/null @@ -1,2 +0,0 @@ -package com.saveourtool.save.frontend.components - diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 693f6d84df..ff0d7c55d1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -336,28 +336,29 @@ fun createBasicRoutes( private fun

ElementType

.wrapAndCreate( block: (@ReactDsl P.() -> Unit)? = null, ): ReactElement

{ - val wrapped: FC

= FC { props -> - requestModalHandler { - this.userInfo = props.userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - - ErrorBoundary::class.react { - topBarComponent { this.userInfo = props.userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - block?.let { this@wrapAndCreate(block) } ?: run { this@wrapAndCreate() } - } - if (window.location.pathname != "/$COOKIE") { - cookieBanner { } - } - footer { } - } - } - } - scrollToTopButton() - } - return block?.let { wrapped.create(block) } ?: run { wrapped.create() } + return block?.let { this@wrapAndCreate.create(block) } ?: run { this@wrapAndCreate.create() } +// val wrapped: FC

= FC { props -> +// requestModalHandler { +// this.userInfo = props.userInfo +// div { +// className = ClassName("d-flex flex-column") +// id = "content-wrapper" +// +// ErrorBoundary::class.react { +// topBarComponent { this.userInfo = props.userInfo } +// div { +// className = ClassName("container-fluid") +// id = "common-save-container" +// block?.let { this@wrapAndCreate(block) } ?: run { this@wrapAndCreate() } +// } +// if (window.location.pathname != "/$COOKIE") { +// cookieBanner { } +// } +// footer { } +// } +// } +// } +// scrollToTopButton() +// } +// return block?.let { wrapped.create(block) } ?: run { wrapped.create() } } \ No newline at end of file From 581934055bd3e68993c749fdd7d5db1f0f6fd3f0 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 10:54:37 +0300 Subject: [PATCH 26/41] fixed routing --- .../com/saveourtool/save/frontend/App.kt | 72 ++++--- .../save/frontend/components/ErrorView.kt | 27 +++ .../save/frontend/routing/BasicRouting.kt | 191 ++++++------------ 3 files changed, 131 insertions(+), 159 deletions(-) create mode 100644 save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index a0ec17e61b..b121b3000e 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -7,9 +7,11 @@ package com.saveourtool.save.frontend import com.saveourtool.save.frontend.components.ErrorBoundary import com.saveourtool.save.frontend.components.basic.cookieBanner import com.saveourtool.save.frontend.components.basic.scrollToTopButton +import com.saveourtool.save.frontend.components.errorView import com.saveourtool.save.frontend.components.footer import com.saveourtool.save.frontend.components.requestModalHandler import com.saveourtool.save.frontend.components.topbar.topBarComponent +import com.saveourtool.save.frontend.components.views.index.indexView import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal import com.saveourtool.save.frontend.routing.createBasicRoutes @@ -30,8 +32,6 @@ import kotlinx.coroutines.await import kotlinx.serialization.json.Json import react.dom.html.ReactHTML.div import react.router.Outlet -import react.router.createMemoryRouter -import remix.run.router.createRouter import web.cssom.ClassName /** @@ -56,38 +56,50 @@ val App: FC = FC { } } - val index: FC = FC { props -> - + val root = FC { props -> + requestModalHandler { + this.userInfo = props.userInfo + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" +// ErrorBoundary::class.react { + topBarComponent { this.userInfo = props.userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + Outlet() + } + if (window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } +// } + } + } + scrollToTopButton() } - RouterProvider { - with(this@FC) { - requestModalHandler { - this.userInfo = userInfo - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - ErrorBoundary::class.react { - topBarComponent { this.userInfo = userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - this@RouterProvider.router = createBrowserRouter( - routes = createBasicRoutes(userInfo, setUserInfo), - opts = jso { - basename = "/" - } - ) - } - if (window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } - } + router = createBrowserRouter( + routes = arrayOf( + jso { + path = "/" + element = root.create() + errorElement = errorView.create() + children = arrayOf( + jso { + index = true + element = indexView.create { + this.userInfo = userInfo + } + }, + *createBasicRoutes(userInfo, setUserInfo) + ) } + ), + opts = jso { + basename = "/" } - scrollToTopButton() - } + ) } } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt new file mode 100644 index 0000000000..15187d145c --- /dev/null +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt @@ -0,0 +1,27 @@ +/** + * A page for errors + */ +package com.saveourtool.save.frontend.components + +import com.saveourtool.save.frontend.components.topbar.topBarComponent +import com.saveourtool.save.frontend.components.views.FallbackView +import js.errors.JsError +import react.FC +import react.dom.html.ReactHTML.div +import react.react +import react.router.useRouteError +import web.cssom.ClassName + +val errorView = FC { + val error = useRouteError().unsafeCast() + div { + className = ClassName("container-fluid") + topBarComponent() + FallbackView::class.react { + bigText = "Error" + smallText = "Something went wrong" + } + @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") + footer { } + } +} \ No newline at end of file diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index ff0d7c55d1..b2c8b6dd94 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -9,14 +9,8 @@ package com.saveourtool.save.frontend.routing import com.saveourtool.save.domain.ProjectCoordinates import com.saveourtool.save.domain.TestResultStatus import com.saveourtool.save.filters.TestExecutionFilter -import com.saveourtool.save.frontend.components.ErrorBoundary -import com.saveourtool.save.frontend.components.basic.cookieBanner import com.saveourtool.save.frontend.components.basic.projects.createProjectProblem import com.saveourtool.save.frontend.components.basic.projects.projectProblem -import com.saveourtool.save.frontend.components.basic.scrollToTopButton -import com.saveourtool.save.frontend.components.footer -import com.saveourtool.save.frontend.components.requestModalHandler -import com.saveourtool.save.frontend.components.topbar.topBarComponent import com.saveourtool.save.frontend.components.views.* import com.saveourtool.save.frontend.components.views.agreements.cookieTermsOfUse import com.saveourtool.save.frontend.components.views.agreements.termsOfUsageView @@ -37,57 +31,39 @@ import com.saveourtool.save.frontend.utils.isSuperAdmin import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes.* import js.core.jso -import kotlinx.browser.window import org.w3c.dom.url.URLSearchParams import react.* -import react.dom.html.ReactHTML -import react.dom.html.ReactHTML.div import react.router.* import react.router.dom.createBrowserRouter -import web.cssom.ClassName -/** - * Just put a map: View -> Route URL to this list - */ -val basicRouting: FC = FC { props -> - useUserStatusRedirects(props.userInfo?.status) - createBasicRoutes(props.userInfo, props.userInfoSetter) - .let { - RouterProvider { - router = createBrowserRouter( - routes = it, - opts = jso { - basename = "/" - } - ) - } - } -} - -private val fallbackNode = FallbackView::class.react.wrapAndCreate { +private val fallbackElementWithoutRouterLink = FallbackView::class.react.create { bigText = "404" smallText = "Page not found" withRouterLink = false } -/** - * @param view - * @return a view or a fallback of user info is null - */ -fun UserInfoAwareMutablePropsWithChildren.viewWithFallBack(view: ReactElement<*>) = this.userInfo?.name?.let { - view -} ?: fallbackNode +private val fallbackElementWithRouterLink = FallbackView::class.react.create { + bigText = "404" + smallText = "Page not found" + withRouterLink = true +} /** + * Just put a map: View -> Route URL to this list + * * @param userInfo currently logged-in user or null * @param userInfoSetter setter of user info (it can be updated in settings on several views) - * @return + * @return array of [RouteObject] */ fun createBasicRoutes( userInfo: UserInfo?, userInfoSetter: StateSetter, ): Array { + val indexRoute: RouteObject = jso { + index = true + element = indexView.create { this.userInfo = userInfo } + } val userProfileView = withRouter { _, params -> userProfileView { userName = params["name"]!! @@ -224,91 +200,82 @@ fun createBasicRoutes( val routeToManageOrganizationView: RouteObject = jso { path = "/$MANAGE_ORGANIZATIONS" element = when (userInfo.isSuperAdmin()) { - true -> OrganizationAdminView::class.react.wrapAndCreate() - else -> fallbackNode + true -> OrganizationAdminView::class.react.create() + else -> fallbackElementWithoutRouterLink } } val routeToFallbackView: RouteObject = jso { path = "*" - element = FallbackView::class.react.wrapAndCreate { - bigText = "404" - smallText = "Page not found" - withRouterLink = true - } + element = fallbackElementWithRouterLink } + return listOf( - indexView.wrapAndCreate { this.userInfo = userInfo } to "/", - saveWelcomeView.wrapAndCreate { this.userInfo = userInfo } to SAVE, - vulnWelcomeView.wrapAndCreate { this.userInfo = userInfo } to VULN, - sandboxView.wrapAndCreate() to SANDBOX, - AboutUsView::class.react.wrapAndCreate() to ABOUT_US, - createOrganizationView.wrapAndCreate() to CREATE_ORGANIZATION, - registrationView.wrapAndCreate { + saveWelcomeView.create { this.userInfo = userInfo } to SAVE, + vulnWelcomeView.create { this.userInfo = userInfo } to VULN, + sandboxView.create() to SANDBOX, + AboutUsView::class.react.create() to ABOUT_US, + createOrganizationView.create() to CREATE_ORGANIZATION, + registrationView.create { this.userInfo = userInfo this.userInfoSetter = userInfoSetter } to REGISTRATION, - CollectionView::class.react.wrapAndCreate { currentUserInfo = userInfo } to PROJECTS, - contestListView.wrapAndCreate { currentUserInfo = userInfo } to CONTESTS, - - FallbackView::class.react.wrapAndCreate { - bigText = "404" - smallText = "Page not found" - withRouterLink = true - } to ERROR_404, - banView.wrapAndCreate { this.userInfo = userInfo } to BAN, - contestGlobalRatingView.wrapAndCreate() to CONTESTS_GLOBAL_RATING, - contestView.wrapAndCreate() to "$CONTESTS/:contestName", - createContestTemplateView.wrapAndCreate() to CREATE_CONTESTS_TEMPLATE, - contestTemplateView.wrapAndCreate() to "$CONTESTS_TEMPLATE/:id", - contestExecutionView.wrapAndCreate() to "$CONTESTS/:contestName/:organizationName/:projectName", - awesomeBenchmarksView.wrapAndCreate() to AWESOME_BENCHMARKS, - createProjectView.wrapAndCreate() to "$CREATE_PROJECT/:organization?", - organizationView.wrapAndCreate() to ":owner", - historyView.wrapAndCreate() to ":owner/:name/history", - projectView.wrapAndCreate() to ":owner/:name", - createProjectProblemView.wrapAndCreate() to "project/:owner/:name/security/problems/new", - projectProblemView.wrapAndCreate() to "project/:owner/:name/security/problems/:id", - executionView.wrapAndCreate() to ":organization/:project/history/execution/:executionId", - demoView.wrapAndCreate() to "$DEMO/:organizationName/:projectName", - cpgView.wrapAndCreate() to "$DEMO/cpg", - testExecutionDetailsView.wrapAndCreate() to "/:organization/:project/history/execution/:executionId/test/:testId", - vulnerabilityCollectionView.wrapAndCreate() to "$VULN/list/:params?", - createVulnerabilityView.wrapAndCreate() to VULN_CREATE, - uploadVulnerabilityView.wrapAndCreate() to VULN_UPLOAD, - vulnerabilityView.wrapAndCreate() to "$VULNERABILITY_SINGLE/:identifier", - demoCollectionView.wrapAndCreate() to DEMO, - userProfileView.wrapAndCreate() to "$VULN_PROFILE/:name", - topRatingView.wrapAndCreate() to VULN_TOP_RATING, - termsOfUsageView.wrapAndCreate() to TERMS_OF_USE, - cookieTermsOfUse.wrapAndCreate() to COOKIE, - thanksForRegistrationView.wrapAndCreate() to THANKS_FOR_REGISTRATION, - cosvSchemaView.wrapAndCreate() to VULN_COSV_SCHEMA, - - userSettingsView.wrapAndCreate { + CollectionView::class.react.create { currentUserInfo = userInfo } to PROJECTS, + contestListView.create { currentUserInfo = userInfo } to CONTESTS, + fallbackElementWithRouterLink to ERROR_404, + banView.create { this.userInfo = userInfo } to BAN, + contestGlobalRatingView.create() to CONTESTS_GLOBAL_RATING, + contestView.create() to "$CONTESTS/:contestName", + createContestTemplateView.create() to CREATE_CONTESTS_TEMPLATE, + contestTemplateView.create() to "$CONTESTS_TEMPLATE/:id", + contestExecutionView.create() to "$CONTESTS/:contestName/:organizationName/:projectName", + awesomeBenchmarksView.create() to AWESOME_BENCHMARKS, + createProjectView.create() to "$CREATE_PROJECT/:organization?", + organizationView.create() to ":owner", + historyView.create() to ":owner/:name/history", + projectView.create() to ":owner/:name", + createProjectProblemView.create() to "project/:owner/:name/security/problems/new", + projectProblemView.create() to "project/:owner/:name/security/problems/:id", + executionView.create() to ":organization/:project/history/execution/:executionId", + demoView.create() to "$DEMO/:organizationName/:projectName", + cpgView.create() to "$DEMO/cpg", + testExecutionDetailsView.create() to "/:organization/:project/history/execution/:executionId/test/:testId", + vulnerabilityCollectionView.create() to "$VULN/list/:params?", + createVulnerabilityView.create() to VULN_CREATE, + uploadVulnerabilityView.create() to VULN_UPLOAD, + vulnerabilityView.create() to "$VULNERABILITY_SINGLE/:identifier", + demoCollectionView.create() to DEMO, + userProfileView.create() to "$VULN_PROFILE/:name", + topRatingView.create() to VULN_TOP_RATING, + termsOfUsageView.create() to TERMS_OF_USE, + cookieTermsOfUse.create() to COOKIE, + thanksForRegistrationView.create() to THANKS_FOR_REGISTRATION, + cosvSchemaView.create() to VULN_COSV_SCHEMA, + + userSettingsView.create { this.userInfo = userInfo this.userInfoSetter = userInfoSetter type = SETTINGS_PROFILE } to SETTINGS_PROFILE, - userSettingsView.wrapAndCreate { + userSettingsView.create { this.userInfo = userInfo this.userInfoSetter = userInfoSetter type = SETTINGS_EMAIL } to SETTINGS_EMAIL, - userSettingsView.wrapAndCreate { + userSettingsView.create { this.userInfo = userInfo type = SETTINGS_TOKEN } to SETTINGS_TOKEN, - userSettingsView.wrapAndCreate { + userSettingsView.create { this.userInfo = userInfo type = SETTINGS_ORGANIZATIONS } to SETTINGS_ORGANIZATIONS, - userSettingsView.wrapAndCreate { + userSettingsView.create { this.userInfo = userInfo type = SETTINGS_DELETE } to SETTINGS_DELETE, @@ -320,45 +287,11 @@ fun createBasicRoutes( element = view } } - .toTypedArray() .let { routes -> routeToUserProfileView?.let { routes + it } ?: routes } .plus(routeToManageOrganizationView) .plus(routeToFallbackView) + .plus(indexRoute) + .toTypedArray() } - -/** - * @param view - * @param block - * @return [ReactElement] created from [view] with wrapping for common parts of all pages - */ -private fun

ElementType

.wrapAndCreate( - block: (@ReactDsl P.() -> Unit)? = null, -): ReactElement

{ - return block?.let { this@wrapAndCreate.create(block) } ?: run { this@wrapAndCreate.create() } -// val wrapped: FC

= FC { props -> -// requestModalHandler { -// this.userInfo = props.userInfo -// div { -// className = ClassName("d-flex flex-column") -// id = "content-wrapper" -// -// ErrorBoundary::class.react { -// topBarComponent { this.userInfo = props.userInfo } -// div { -// className = ClassName("container-fluid") -// id = "common-save-container" -// block?.let { this@wrapAndCreate(block) } ?: run { this@wrapAndCreate() } -// } -// if (window.location.pathname != "/$COOKIE") { -// cookieBanner { } -// } -// footer { } -// } -// } -// } -// scrollToTopButton() -// } -// return block?.let { wrapped.create(block) } ?: run { wrapped.create() } -} \ No newline at end of file From e093d94fa72bc55c7ad9258af489e859600217d5 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 11:05:16 +0300 Subject: [PATCH 27/41] diktatFix --- .../com/saveourtool/save/frontend/App.kt | 42 ++++++++----------- .../save/frontend/components/ErrorView.kt | 7 ++-- .../save/frontend/routing/BasicRouting.kt | 3 +- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index b121b3000e..90d154cfa0 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -4,7 +4,6 @@ package com.saveourtool.save.frontend -import com.saveourtool.save.frontend.components.ErrorBoundary import com.saveourtool.save.frontend.components.basic.cookieBanner import com.saveourtool.save.frontend.components.basic.scrollToTopButton import com.saveourtool.save.frontend.components.errorView @@ -18,21 +17,21 @@ import com.saveourtool.save.frontend.routing.createBasicRoutes import com.saveourtool.save.frontend.utils.* import com.saveourtool.save.info.UserInfo import com.saveourtool.save.validation.FrontendRoutes -import js.core.jso +import js.core.jso import react.* import react.dom.client.createRoot +import react.dom.html.ReactHTML.div +import react.router.Outlet import react.router.dom.RouterProvider import react.router.dom.createBrowserRouter +import web.cssom.ClassName import web.dom.document import web.html.HTMLElement import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.serialization.json.Json -import react.dom.html.ReactHTML.div -import react.router.Outlet -import web.cssom.ClassName /** * Main component for the whole App @@ -56,28 +55,27 @@ val App: FC = FC { } } - val root = FC { props -> + val root = FC { requestModalHandler { - this.userInfo = props.userInfo + this.userInfo = userInfo div { className = ClassName("d-flex flex-column") id = "content-wrapper" -// ErrorBoundary::class.react { - topBarComponent { this.userInfo = props.userInfo } - div { - className = ClassName("container-fluid") - id = "common-save-container" - Outlet() - } - if (window.location.pathname != "/${FrontendRoutes.COOKIE}") { - cookieBanner { } - } - footer { } -// } + topBarComponent { this.userInfo = userInfo } + div { + className = ClassName("container-fluid") + id = "common-save-container" + Outlet() + } + if (window.location.pathname != "/${FrontendRoutes.COOKIE}") { + cookieBanner { } + } + footer { } } } scrollToTopButton() } + RouterProvider { router = createBrowserRouter( routes = arrayOf( @@ -86,12 +84,6 @@ val App: FC = FC { element = root.create() errorElement = errorView.create() children = arrayOf( - jso { - index = true - element = indexView.create { - this.userInfo = userInfo - } - }, *createBasicRoutes(userInfo, setUserInfo) ) } diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt index 15187d145c..7faf7914ca 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorView.kt @@ -1,6 +1,7 @@ /** * A page for errors */ + package com.saveourtool.save.frontend.components import com.saveourtool.save.frontend.components.topbar.topBarComponent @@ -13,15 +14,15 @@ import react.router.useRouteError import web.cssom.ClassName val errorView = FC { - val error = useRouteError().unsafeCast() + val errorMessage = useRouteError().unsafeCast().message div { className = ClassName("container-fluid") topBarComponent() FallbackView::class.react { bigText = "Error" - smallText = "Something went wrong" + smallText = "Something went wrong: $errorMessage" } @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") footer { } } -} \ No newline at end of file +} diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index b2c8b6dd94..11eb753115 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -35,7 +35,6 @@ import js.core.jso import org.w3c.dom.url.URLSearchParams import react.* import react.router.* -import react.router.dom.createBrowserRouter private val fallbackElementWithoutRouterLink = FallbackView::class.react.create { bigText = "404" @@ -56,6 +55,7 @@ private val fallbackElementWithRouterLink = FallbackView::class.react.create { * @param userInfoSetter setter of user info (it can be updated in settings on several views) * @return array of [RouteObject] */ +@Suppress("TOO_LONG_FUNCTION") fun createBasicRoutes( userInfo: UserInfo?, userInfoSetter: StateSetter, @@ -210,7 +210,6 @@ fun createBasicRoutes( element = fallbackElementWithRouterLink } - return listOf( saveWelcomeView.create { this.userInfo = userInfo } to SAVE, vulnWelcomeView.create { this.userInfo = userInfo } to VULN, From 354996a282311ccf29b40f1e16a4ebc378ebb466 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 11:07:32 +0300 Subject: [PATCH 28/41] diktatFix --- .../src/main/kotlin/com/saveourtool/save/frontend/App.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 90d154cfa0..12e7edfcb1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -10,7 +10,6 @@ import com.saveourtool.save.frontend.components.errorView import com.saveourtool.save.frontend.components.footer import com.saveourtool.save.frontend.components.requestModalHandler import com.saveourtool.save.frontend.components.topbar.topBarComponent -import com.saveourtool.save.frontend.components.views.index.indexView import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.modal.ReactModal import com.saveourtool.save.frontend.routing.createBasicRoutes From 913e01a993b0713cc7f3b2c2badfedb0dd4913c4 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 11:22:45 +0300 Subject: [PATCH 29/41] removed ErrorBoundary + detekt --- .../save/frontend/components/ErrorBoundary.kt | 69 ------------------- .../save/frontend/routing/BasicRouting.kt | 5 +- 2 files changed, 4 insertions(+), 70 deletions(-) delete mode 100644 save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorBoundary.kt diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorBoundary.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorBoundary.kt deleted file mode 100644 index 76f6c89a61..0000000000 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/ErrorBoundary.kt +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Support for [error boundaries](https://reactjs.org/docs/error-boundaries.html) - */ - -package com.saveourtool.save.frontend.components - -import com.saveourtool.save.frontend.components.topbar.topBarComponent -import com.saveourtool.save.frontend.components.views.FallbackView - -import js.core.jso -import react.Component -import react.PropsWithChildren -import react.RStatics -import react.ReactNode -import react.State -import react.create -import react.dom.html.ReactHTML.div -import react.react -import web.cssom.ClassName - -/** - * State of error boundary component - */ -external interface ErrorBoundaryState : State { - /** - * True is there is an error in the wrapped component tree - */ - var hasError: Boolean? -} - -/** - * Component to act as React Error Boundary - */ -class ErrorBoundary : Component() { - init { - state = jso { - hasError = false - } - } - - override fun render(): ReactNode? = if (state.hasError == true) { - div.create { - className = ClassName("container-fluid") - topBarComponent() - FallbackView::class.react { - bigText = "Error" - smallText = "Something went wrong" - } - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - footer { } - } - } else { - props.children - } - - companion object : RStatics(ErrorBoundary::class) { - init { - /* - * From [React docs](https://reactjs.org/docs/error-boundaries.html): - * 'A class component becomes an error boundary if it defines either (or both) of the lifecycle methods static getDerivedStateFromError() or componentDidCatch()' - */ - getDerivedStateFromError = { - jso { - hasError = true - } - } - } - } -} diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt index 11eb753115..cf54386316 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/routing/BasicRouting.kt @@ -55,7 +55,10 @@ private val fallbackElementWithRouterLink = FallbackView::class.react.create { * @param userInfoSetter setter of user info (it can be updated in settings on several views) * @return array of [RouteObject] */ -@Suppress("TOO_LONG_FUNCTION") +@Suppress( + "TOO_LONG_FUNCTION", + "LongMethod", +) fun createBasicRoutes( userInfo: UserInfo?, userInfoSetter: StateSetter, From eeb0660ffa6e176e95d408bd0c4d4a4aa11f1961 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 12:09:18 +0300 Subject: [PATCH 30/41] try to fix tests --- .../save/frontend/BasicRoutingTest.kt | 26 ++++++---- .../frontend/components/topbar/TopBarTest.kt | 47 ++++++++++++------- .../save/frontend/utils/TestUtils.kt | 24 +++++++--- 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index d17d084ee7..3cfad05fea 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -4,11 +4,15 @@ import com.saveourtool.save.frontend.externals.findByTextAndCast import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.screen -import com.saveourtool.save.frontend.routing.basicRouting +import com.saveourtool.save.frontend.routing.createBasicRoutes +import com.saveourtool.save.info.UserInfo +import js.core.jso +import react.FC +import react.create import web.html.HTMLHeadingElement -import react.router.RouterProvider import react.router.createMemoryRouter import react.router.dom.RouterProvider +import react.useState import kotlin.js.Promise import kotlin.test.* import kotlin.test.Test @@ -16,14 +20,20 @@ import kotlin.test.Test class BasicRoutingTest { @Test fun basicRoutingShouldRenderIndexViewTest(): Promise { + val (userInfo, setUserInfo) = useState() // App uses `BrowserRouter`, while `MemoryRouter` should be used for tests. Thus, app cannot be rendered - val routerProvider = RouterProvider { - router = createMemoryRouter( - basicRouting() - ) - initI18n() + val routerProvider = FC { + RouterProvider { + router = createMemoryRouter( + arrayOf(jso { + path = "/" + children = createBasicRoutes(userInfo, setUserInfo) + }) + ) + initI18n() + } } - render(routerProvider) + render(routerProvider.create()) screen.findByTextAndCast( "Cloud Platform for CI and Benchmarking of Code Analyzers" diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt index e3e82fd798..565f6435ca 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt @@ -6,10 +6,11 @@ import com.saveourtool.save.info.UserInfo import web.html.HTMLDivElement import web.html.HTMLSpanElement import react.* -import react.router.MemoryRouter import kotlin.test.* import js.core.jso +import react.router.createMemoryRouter +import react.router.dom.RouterProvider /** * [MemoryRouter] is used to enable usage of `useLocation` hook inside the component @@ -21,16 +22,22 @@ import js.core.jso class TopBarTest { @Test fun topBarShouldRenderWithUserInfo() { - val rr = render( - MemoryRouter.create { - initialEntries = arrayOf( - "/" - ) - topBarComponent { - userInfo = UserInfo(name = "Test User") + val router = createMemoryRouter( + routes = arrayOf( + jso { + path = "/" + element = FC { + topBarComponent { + userInfo = UserInfo(name = "Test User") + } + }.create() } - } + ) ) + val routerProvider = FC { + RouterProvider { router } + } + val rr = render(routerProvider.create()) val userInfoSpan: HTMLSpanElement? = screen.queryByTextAndCast("Test User") assertNotNull(userInfoSpan) @@ -45,16 +52,22 @@ class TopBarTest { @Test fun topBarShouldRenderWithoutUserInfo() { - val rr = render( - MemoryRouter.create { - initialEntries = arrayOf( - "/" - ) - topBarComponent { - userInfo = null + val router = createMemoryRouter( + routes = arrayOf( + jso { + path = "/" + element = FC { + topBarComponent { + userInfo = null + } + }.create() } - } + ) ) + val routerProvider = FC { + RouterProvider { router } + } + val rr = render(routerProvider.create()) val userInfoSpan: HTMLSpanElement? = screen.queryByTextAndCast("Test User") assertNull(userInfoSpan) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt index 3779c49532..6a72487304 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt @@ -6,6 +6,7 @@ package com.saveourtool.save.frontend.utils import com.saveourtool.save.frontend.components.RequestStatusContext import com.saveourtool.save.frontend.components.requestStatusContext +import js.core.jso import org.w3c.fetch.Response import react.FC @@ -16,17 +17,28 @@ import web.timers.setTimeout import kotlin.js.Promise import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import react.router.MemoryRouter +import react.create +import react.router.createMemoryRouter +import react.router.dom.RouterProvider val wrapper: FC = FC { val (_, setMockState) = useState(null) val (_, setRedirectToFallbackView) = useState(false) val (_, setLoadingCounter) = useState(0) - MemoryRouter { - requestStatusContext.Provider { - value = RequestStatusContext(setMockState, setRedirectToFallbackView, setLoadingCounter) - +it.children - } + RouterProvider { + createMemoryRouter( + arrayOf( + jso { + index = true + element = FC { + requestStatusContext.Provider { + value = RequestStatusContext(setMockState, setRedirectToFallbackView, setLoadingCounter) + +children + } + }.create() + } + ) + ) } } From 98ba7df9a0257e7f6a8e2ad7dc541c9b7267bc20 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 12:12:19 +0300 Subject: [PATCH 31/41] removed invalid import in test --- .../save/frontend/components/views/OrganizationViewTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/OrganizationViewTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/OrganizationViewTest.kt index 127861b3b9..c0b0950cd1 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/OrganizationViewTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/OrganizationViewTest.kt @@ -11,7 +11,6 @@ import kotlinx.datetime.LocalDateTime import react.create import react.react -import react.router.MemoryRouter import kotlin.js.Promise import kotlin.test.* From 69f6e4d4a2d568f4039095160d310ec91dc8b9f4 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Thu, 26 Oct 2023 12:22:29 +0300 Subject: [PATCH 32/41] a try to fix tests --- .../com/saveourtool/save/frontend/App.kt | 4 +--- .../save/frontend/BasicRoutingTest.kt | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt index 12e7edfcb1..ff0197c7f1 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/App.kt @@ -82,9 +82,7 @@ val App: FC = FC { path = "/" element = root.create() errorElement = errorView.create() - children = arrayOf( - *createBasicRoutes(userInfo, setUserInfo) - ) + children = createBasicRoutes(userInfo, setUserInfo) } ), opts = jso { diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index 3cfad05fea..14ab4fcd6d 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -5,10 +5,12 @@ import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.screen import com.saveourtool.save.frontend.routing.createBasicRoutes +import com.saveourtool.save.frontend.utils.UserInfoAwareMutableProps import com.saveourtool.save.info.UserInfo import js.core.jso import react.FC import react.create +import react.router.Outlet import web.html.HTMLHeadingElement import react.router.createMemoryRouter import react.router.dom.RouterProvider @@ -20,17 +22,24 @@ import kotlin.test.Test class BasicRoutingTest { @Test fun basicRoutingShouldRenderIndexViewTest(): Promise { - val (userInfo, setUserInfo) = useState() // App uses `BrowserRouter`, while `MemoryRouter` should be used for tests. Thus, app cannot be rendered - val routerProvider = FC { + val routerProvider = FC { props: UserInfoAwareMutableProps -> RouterProvider { router = createMemoryRouter( - arrayOf(jso { - path = "/" - children = createBasicRoutes(userInfo, setUserInfo) - }) + routes = arrayOf( + jso { + path = "/" + element = FC { + initI18n() + Outlet() + }.create() + children = createBasicRoutes(props.userInfo, props.userInfoSetter) + } + ), + opts = jso { + basename = "/" + } ) - initI18n() } } render(routerProvider.create()) From 86ebd7f5e6a0ad0fc484259cafd3f5ee14000931 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Tue, 31 Oct 2023 15:02:38 +0300 Subject: [PATCH 33/41] downgraded kotlin-wrappers-bom --- gradle/libs.versions.toml | 2 +- renovate.json | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4534a9d78c..f148d34ecc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ okio = "3.3.0" serialization = "1.6.0" kotlinx-datetime = "0.4.1" kotlinx-coroutines = "1.7.3" -kotlin-wrappers = "1.0.0-pre.635" +kotlin-wrappers = "1.0.0-pre.634" spring-boot = "2.7.17" spring-cloud = "3.1.8" spring-cloud-kubernetes = "2.1.8" diff --git a/renovate.json b/renovate.json index a113f5112e..7e3c01c616 100644 --- a/renovate.json +++ b/renovate.json @@ -23,7 +23,8 @@ "^org\\.jetbrains\\.kotlinx?[.:]", "^org\\.neo4j\\:neo4j-ogm-bolt-driver", "^org\\.neo4j\\:neo4j-ogm-core", - "^org\\.neo4j\\.driver\\:neo4j-java-driver" + "^org\\.neo4j\\.driver\\:neo4j-java-driver", + "^org\\.jetbrains\\.kotlin-wrappers\\:kotlin-wrappers-bom" ], "matchUpdateTypes": [ "minor", @@ -38,7 +39,7 @@ "^org\\.neo4j\\:neo4j-ogm-bolt-driver", "^org\\.neo4j\\:neo4j-ogm-core" ], - "allowedVersions": "4.0.4", + "allowedVersions": "4.0.6", "groupName": "all non-major dependencies (except core Kotlin)", "groupSlug": "all-minor-patch" }, @@ -47,7 +48,18 @@ "matchPackagePatterns": [ "^org\\.neo4j\\.driver\\:neo4j-java-driver" ], - "allowedVersions": "5.6.0", + "allowedVersions": "5.7.0", + "groupName": "all non-major dependencies (except core Kotlin)", + "groupSlug": "all-minor-patch" + }, + { + "managers": [ + "gradle" + ], + "matchPackagePatterns": [ + "^org\\.jetbrains\\.kotlin-wrappers\\:kotlin-wrappers-bom" + ], + "allowedVersions": "<=1.0.0-pre.634", "groupName": "all non-major dependencies (except core Kotlin)", "groupSlug": "all-minor-patch" }, From 7003d04e771544aa116ef0be3e2c939a0a995045 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 31 Oct 2023 12:09:25 +0000 Subject: [PATCH 34/41] Update yarn.lock --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 66e40fb1c3..966c88b314 100644 --- a/yarn.lock +++ b/yarn.lock @@ -454,7 +454,7 @@ dependencies: "@react-sigma/layout-core" "^3.1.0" -"@remix-run/router@1.10.0", "@remix-run/router@^1.10.0": +"@remix-run/router@1.10.0", "@remix-run/router@^1.9.0": version "1.10.0" resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.10.0.tgz#e2170dc2049b06e65bbe883adad0e8ddf8291278" integrity sha512-Lm+fYpMfZoEucJ7cMxgt4dYt8jLfbpwRCzAjm9UgSLOkmlqo9gupxt6YX3DY0Fk155NT9l17d/ydi+964uS9Lw== @@ -5266,7 +5266,7 @@ react-modal@^3.0.0: react-lifecycles-compat "^3.0.0" warning "^4.0.3" -react-router-dom@^6.17.0: +react-router-dom@^6.16.0: version "6.17.0" resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.17.0.tgz#ea73f89186546c1cf72b10fcb7356d874321b2ad" integrity sha512-qWHkkbXQX+6li0COUUPKAUkxjNNqPJuiBd27dVwQGDNsuFBdMbrS6UZ0CLYc4CsbdLYTckn4oB4tGDuPZpPhaQ== @@ -5274,7 +5274,7 @@ react-router-dom@^6.17.0: "@remix-run/router" "1.10.0" react-router "6.17.0" -react-router@6.17.0, react-router@^6.17.0: +react-router@6.17.0, react-router@^6.16.0: version "6.17.0" resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.17.0.tgz#7b680c4cefbc425b57537eb9c73bedecbdc67c1e" integrity sha512-YJR3OTJzi3zhqeJYADHANCGPUu9J+6fT5GLv82UWRGSxu6oJYCKVmxUcaBQuGm9udpWmPsvpme/CdHumqgsoaA== From 475e45a6c85c4a3f82dc16edbbafca3932d1293c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 31 Oct 2023 14:59:30 +0000 Subject: [PATCH 35/41] Update yarn.lock --- yarn.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0baaa9fdc7..ba0f125d42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -454,10 +454,10 @@ dependencies: "@react-sigma/layout-core" "^3.1.0" -"@remix-run/router@1.10.0", "@remix-run/router@^1.9.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.10.0.tgz#e2170dc2049b06e65bbe883adad0e8ddf8291278" - integrity sha512-Lm+fYpMfZoEucJ7cMxgt4dYt8jLfbpwRCzAjm9UgSLOkmlqo9gupxt6YX3DY0Fk155NT9l17d/ydi+964uS9Lw== +"@remix-run/router@1.11.0", "@remix-run/router@^1.10.0": + version "1.11.0" + resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.11.0.tgz#e0e45ac3fff9d8a126916f166809825537e9f955" + integrity sha512-BHdhcWgeiudl91HvVa2wxqZjSHbheSgIiDvxrF1VjFzBzpTtuDPkOdOi3Iqvc08kXtFkLjhbS+ML9aM8mJS+wQ== "@socket.io/base64-arraybuffer@~1.0.2": version "1.0.2" @@ -5266,20 +5266,20 @@ react-modal@^3.0.0: react-lifecycles-compat "^3.0.0" warning "^4.0.3" -react-router-dom@^6.16.0: - version "6.17.0" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.17.0.tgz#ea73f89186546c1cf72b10fcb7356d874321b2ad" - integrity sha512-qWHkkbXQX+6li0COUUPKAUkxjNNqPJuiBd27dVwQGDNsuFBdMbrS6UZ0CLYc4CsbdLYTckn4oB4tGDuPZpPhaQ== +react-router-dom@^6.17.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.18.0.tgz#0a50c167209d6e7bd2ed9de200a6579ea4fb1dca" + integrity sha512-Ubrue4+Ercc/BoDkFQfc6og5zRQ4A8YxSO3Knsne+eRbZ+IepAsK249XBH/XaFuOYOYr3L3r13CXTLvYt5JDjw== dependencies: - "@remix-run/router" "1.10.0" - react-router "6.17.0" + "@remix-run/router" "1.11.0" + react-router "6.18.0" -react-router@6.17.0, react-router@^6.16.0: - version "6.17.0" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.17.0.tgz#7b680c4cefbc425b57537eb9c73bedecbdc67c1e" - integrity sha512-YJR3OTJzi3zhqeJYADHANCGPUu9J+6fT5GLv82UWRGSxu6oJYCKVmxUcaBQuGm9udpWmPsvpme/CdHumqgsoaA== +react-router@6.18.0, react-router@^6.17.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.18.0.tgz#32e2bedc318e095a48763b5ed7758e54034cd36a" + integrity sha512-vk2y7Dsy8wI02eRRaRmOs9g2o+aE72YCx5q9VasT1N9v+lrdB79tIqrjMfByHiY5+6aYkH2rUa5X839nwWGPDg== dependencies: - "@remix-run/router" "1.10.0" + "@remix-run/router" "1.11.0" react-scroll-motion@^0.3.0: version "0.3.0" From a2db0617895cd23ad4503400b7ed3ca01173c4bd Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 1 Nov 2023 13:15:28 +0300 Subject: [PATCH 36/41] WIP --- .../save/frontend/BasicRoutingTest.kt | 7 +- .../frontend/components/topbar/TopBarTest.kt | 71 ++++++++++--------- .../save/frontend/utils/TestUtils.kt | 10 ++- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index 14ab4fcd6d..b8fce09cef 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -23,21 +23,22 @@ class BasicRoutingTest { @Test fun basicRoutingShouldRenderIndexViewTest(): Promise { // App uses `BrowserRouter`, while `MemoryRouter` should be used for tests. Thus, app cannot be rendered - val routerProvider = FC { props: UserInfoAwareMutableProps -> + val routerProvider = FC { + val (userInfo, userInfoSetter) = useState() RouterProvider { router = createMemoryRouter( routes = arrayOf( jso { path = "/" element = FC { - initI18n() Outlet() }.create() - children = createBasicRoutes(props.userInfo, props.userInfoSetter) + children = createBasicRoutes(userInfo, userInfoSetter) } ), opts = jso { basename = "/" + initialEntries = arrayOf("/") } ) } diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt index 565f6435ca..1ff2cba4a6 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt @@ -1,7 +1,11 @@ package com.saveourtool.save.frontend.components.topbar +import com.saveourtool.save.frontend.components.basic.cookieBanner +import com.saveourtool.save.frontend.components.footer import com.saveourtool.save.frontend.externals.* +import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.info.UserInfo +import com.saveourtool.save.validation.FrontendRoutes import web.html.HTMLDivElement import web.html.HTMLSpanElement @@ -9,11 +13,16 @@ import react.* import kotlin.test.* import js.core.jso +import kotlinx.browser.window +import react.dom.html.ReactHTML +import react.dom.html.ReactHTML.div +import react.router.Outlet import react.router.createMemoryRouter import react.router.dom.RouterProvider +import web.cssom.ClassName /** - * [MemoryRouter] is used to enable usage of `useLocation` hook inside the component + * [createMemoryRouter] is used to enable usage of `useLocation` hook inside the component * todo: functionality that is not covered * * How breadcrumbs are displayed * * `/execution` is trimmed from breadcrumbs @@ -22,22 +31,7 @@ import react.router.dom.RouterProvider class TopBarTest { @Test fun topBarShouldRenderWithUserInfo() { - val router = createMemoryRouter( - routes = arrayOf( - jso { - path = "/" - element = FC { - topBarComponent { - userInfo = UserInfo(name = "Test User") - } - }.create() - } - ) - ) - val routerProvider = FC { - RouterProvider { router } - } - val rr = render(routerProvider.create()) + val rr = render(topBarComponentView(UserInfo(name = "Test User")).create()) val userInfoSpan: HTMLSpanElement? = screen.queryByTextAndCast("Test User") assertNotNull(userInfoSpan) @@ -52,22 +46,7 @@ class TopBarTest { @Test fun topBarShouldRenderWithoutUserInfo() { - val router = createMemoryRouter( - routes = arrayOf( - jso { - path = "/" - element = FC { - topBarComponent { - userInfo = null - } - }.create() - } - ) - ) - val routerProvider = FC { - RouterProvider { router } - } - val rr = render(routerProvider.create()) + val rr = render(topBarComponentView(null).create()) val userInfoSpan: HTMLSpanElement? = screen.queryByTextAndCast("Test User") assertNull(userInfoSpan) @@ -77,4 +56,30 @@ class TopBarTest { val dropdown = rr.container.querySelector("[aria-labelledby=\"userDropdown\"]") as HTMLDivElement assertEquals(1, dropdown.children.length, "When user is not logged in, dropdown menu should contain 1 entry") } + + companion object { + private fun topBarComponentView(userInfo: UserInfo?) = FC { + initI18n() + RouterProvider { + router = createMemoryRouter( + routes = arrayOf( + jso { + path = "/" + element = FC { + div { + className = ClassName("d-flex flex-column") + id = "content-wrapper" + topBarComponent { this.userInfo = userInfo } + } + }.create() + } + ), + opts = jso { + basename = "/" + initialEntries = arrayOf("/") + } + ) + } + } + } } diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt index cf3e838f72..929c9da43c 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt @@ -18,6 +18,7 @@ import kotlin.js.Promise import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import react.create +import react.router.Outlet import react.router.createMemoryRouter import react.router.dom.RouterProvider @@ -26,8 +27,8 @@ val wrapper: FC = FC { props -> val (_, setRedirectToFallbackView) = useState(false) val (_, setLoadingCounter) = useState(0) RouterProvider { - createMemoryRouter( - arrayOf( + router = createMemoryRouter( + routes = arrayOf( jso { index = true element = FC { @@ -37,7 +38,10 @@ val wrapper: FC = FC { props -> } }.create() } - ) + ), + opts = jso { + initialEntries = arrayOf("/") + } ) } } From eb4f409b8acaa81cadf5370bd8500740fb91ca89 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 1 Nov 2023 13:35:17 +0300 Subject: [PATCH 37/41] removed extra imports --- .../save/frontend/components/topbar/TopBarTest.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt index 1ff2cba4a6..ae64d81058 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt @@ -1,11 +1,8 @@ package com.saveourtool.save.frontend.components.topbar -import com.saveourtool.save.frontend.components.basic.cookieBanner -import com.saveourtool.save.frontend.components.footer import com.saveourtool.save.frontend.externals.* import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.info.UserInfo -import com.saveourtool.save.validation.FrontendRoutes import web.html.HTMLDivElement import web.html.HTMLSpanElement @@ -13,10 +10,7 @@ import react.* import kotlin.test.* import js.core.jso -import kotlinx.browser.window -import react.dom.html.ReactHTML import react.dom.html.ReactHTML.div -import react.router.Outlet import react.router.createMemoryRouter import react.router.dom.RouterProvider import web.cssom.ClassName From b3304c53c2bcee774aa622d87cf03ebd01508e1b Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 1 Nov 2023 15:04:01 +0300 Subject: [PATCH 38/41] mock initI18n for tests --- .../save/frontend/BasicRoutingTest.kt | 8 +------ .../frontend/components/topbar/TopBarTest.kt | 20 +++++------------- .../save/frontend/utils/TestUtils.kt | 21 ++++++++++++++++++- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index b8fce09cef..b6d60cd7dc 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -1,11 +1,9 @@ package com.saveourtool.save.frontend import com.saveourtool.save.frontend.externals.findByTextAndCast -import com.saveourtool.save.frontend.externals.i18next.initI18n import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.screen import com.saveourtool.save.frontend.routing.createBasicRoutes -import com.saveourtool.save.frontend.utils.UserInfoAwareMutableProps import com.saveourtool.save.info.UserInfo import js.core.jso import react.FC @@ -35,11 +33,7 @@ class BasicRoutingTest { }.create() children = createBasicRoutes(userInfo, userInfoSetter) } - ), - opts = jso { - basename = "/" - initialEntries = arrayOf("/") - } + ) ) } } diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt index ae64d81058..1acc45515b 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarTest.kt @@ -1,7 +1,7 @@ package com.saveourtool.save.frontend.components.topbar import com.saveourtool.save.frontend.externals.* -import com.saveourtool.save.frontend.externals.i18next.initI18n +import com.saveourtool.save.frontend.utils.stubInitI18n import com.saveourtool.save.info.UserInfo import web.html.HTMLDivElement @@ -10,10 +10,8 @@ import react.* import kotlin.test.* import js.core.jso -import react.dom.html.ReactHTML.div import react.router.createMemoryRouter import react.router.dom.RouterProvider -import web.cssom.ClassName /** * [createMemoryRouter] is used to enable usage of `useLocation` hook inside the component @@ -53,25 +51,17 @@ class TopBarTest { companion object { private fun topBarComponentView(userInfo: UserInfo?) = FC { - initI18n() + stubInitI18n() RouterProvider { router = createMemoryRouter( routes = arrayOf( jso { - path = "/" + index = true element = FC { - div { - className = ClassName("d-flex flex-column") - id = "content-wrapper" - topBarComponent { this.userInfo = userInfo } - } + topBarComponent { this.userInfo = userInfo } }.create() } - ), - opts = jso { - basename = "/" - initialEntries = arrayOf("/") - } + ) ) } } diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt index 929c9da43c..b73224264e 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/TestUtils.kt @@ -18,11 +18,11 @@ import kotlin.js.Promise import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import react.create -import react.router.Outlet import react.router.createMemoryRouter import react.router.dom.RouterProvider val wrapper: FC = FC { props -> + stubInitI18n() val (_, setMockState) = useState(null) val (_, setRedirectToFallbackView) = useState(false) val (_, setLoadingCounter) = useState(0) @@ -67,3 +67,22 @@ inline fun mockMswResponse(response: dynamic, value: T): dynamic { fun wait(millis: Int) = Promise { resolve, _ -> setTimeout({ resolve(Unit) }, millis) } + +/** + * Stub `initI18n` for testing purposes + */ +internal fun stubInitI18n() { + val i18n: dynamic = kotlinext.js.require("i18next"); + val reactI18n: dynamic = kotlinext.js.require("react-i18next"); + val i18nResources: dynamic = jso { + en = jso { + translation = undefined + } + } + + i18n.use(reactI18n.initReactI18next).init(jso { + resources = i18nResources + lng = "en" + fallbackLng = "en" + }) +} From 4a4ec83a5c2c19fe59fcdbcccef4c24047db068c Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 1 Nov 2023 20:17:35 +0300 Subject: [PATCH 39/41] Update save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt --- .../kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index b6d60cd7dc..e9f3d8556e 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -22,6 +22,7 @@ class BasicRoutingTest { fun basicRoutingShouldRenderIndexViewTest(): Promise { // App uses `BrowserRouter`, while `MemoryRouter` should be used for tests. Thus, app cannot be rendered val routerProvider = FC { + stubInitI18n() val (userInfo, userInfoSetter) = useState() RouterProvider { router = createMemoryRouter( From 960c2d2929f817cf3c10a9b21ec33a7f8a96fe25 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Wed, 1 Nov 2023 22:11:33 +0300 Subject: [PATCH 40/41] fixed import issue + warning in gradle --- .../save/frontend/components/topbar/TopBarUserField.kt | 2 +- .../components/views/usersettings/SettingsViewLeftColumn.kt | 4 +--- .../kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUserField.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUserField.kt index aed6c5a9c2..aff78abb45 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUserField.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/topbar/TopBarUserField.kt @@ -87,7 +87,7 @@ val topBarUserField: FC = FC { props -> img { className = ClassName("ml-2 align-self-center avatar avatar-user width-full border color-bg-default rounded-circle fas mr-2") - src = props.userInfo?.avatar?.avatarRenderer() ?: AVATAR_PROFILE_PLACEHOLDER + src = userInfo.avatar?.avatarRenderer() ?: AVATAR_PROFILE_PLACEHOLDER style = logoSize } } ?: fontAwesomeIcon(icon = faUser) { diff --git a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt index 153bc1a283..aceb4407e8 100644 --- a/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt +++ b/save-frontend/src/main/kotlin/com/saveourtool/save/frontend/components/views/usersettings/SettingsViewLeftColumn.kt @@ -28,7 +28,6 @@ import web.cssom.rem internal const val AVATAR_TITLE = "Upload avatar" val leftSettingsColumn: FC = FC { props -> - val (avatarImgLink, setAvatarImgLink) = useState(null) val (t) = useTranslation("profile") div { @@ -50,8 +49,7 @@ val leftSettingsColumn: FC = FC { props -> className = ClassName("row justify-content-center") img { className = ClassName("avatar avatar-user width-full border color-bg-default rounded-circle") - src = avatarImgLink - ?: props.userInfo?.avatar?.avatarRenderer() + src = props.userInfo?.avatar?.avatarRenderer() ?: AVATAR_PROFILE_PLACEHOLDER style = jso { height = 12.rem diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt index e9f3d8556e..947138174c 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/BasicRoutingTest.kt @@ -4,6 +4,7 @@ import com.saveourtool.save.frontend.externals.findByTextAndCast import com.saveourtool.save.frontend.externals.render import com.saveourtool.save.frontend.externals.screen import com.saveourtool.save.frontend.routing.createBasicRoutes +import com.saveourtool.save.frontend.utils.stubInitI18n import com.saveourtool.save.info.UserInfo import js.core.jso import react.FC From 0847dfc88d8692e19e86837025f68e29f339a3f1 Mon Sep 17 00:00:00 2001 From: Nariman Abdullin Date: Mon, 13 Nov 2023 11:15:35 +0300 Subject: [PATCH 41/41] try to fix a test --- .../components/views/ProjectViewTest.kt | 18 ++++++++++++++++++ .../save/frontend/utils/ServerSentEventTest.kt | 1 - .../save/frontend/utils/UseRequestTest.kt | 1 - 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/ProjectViewTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/ProjectViewTest.kt index 49d37df5bf..9637a7a1ea 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/ProjectViewTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/components/views/ProjectViewTest.kt @@ -2,6 +2,7 @@ package com.saveourtool.save.frontend.components.views import com.saveourtool.save.domain.Role import com.saveourtool.save.entities.* +import com.saveourtool.save.entities.contest.ContestResult import com.saveourtool.save.frontend.externals.* import com.saveourtool.save.frontend.utils.apiUrl import com.saveourtool.save.frontend.utils.mockMswResponse @@ -17,6 +18,7 @@ import kotlin.test.* import js.core.jso class ProjectViewTest { + private val testOrganization = OrganizationDto.empty .copy( name = "TestOrg", @@ -47,6 +49,14 @@ class ProjectViewTest { ) } }, + rest.get("$apiUrl/projects/${testOrganization.name}/${testProject.name}/users") { _, res, _ -> + res { response -> + mockMswResponse( + response, + listOf(testUserInfo) + ) + } + }, rest.get("$apiUrl/projects/${testOrganization.name}/${testProject.name}/users/roles") { _, res, _ -> res { response -> mockMswResponse( @@ -71,6 +81,14 @@ class ProjectViewTest { ) } }, + rest.get("$apiUrl/contests/${testOrganization.name}/${testProject.name}/best") { _, res, _ -> + res { response -> + mockMswResponse( + response, + emptyList(), + ) + } + }, ) @Test diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt index 8b8e24e0f7..5495e51ea9 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/ServerSentEventTest.kt @@ -11,7 +11,6 @@ import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals import kotlinx.browser.window -import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json /** diff --git a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt index 615921d7de..3362d6c03d 100644 --- a/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt +++ b/save-frontend/src/test/kotlin/com/saveourtool/save/frontend/utils/UseRequestTest.kt @@ -6,7 +6,6 @@ import com.saveourtool.save.frontend.externals.setupWorker import org.w3c.fetch.Headers import react.FC -import react.Props import react.create import react.useEffect import react.useState