Skip to content

Commit

Permalink
Upgraded Scala.js to v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-podzigun committed Apr 20, 2022
1 parent 15b6e2c commit 8371c12
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 237 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ jobs:
restore-keys: |
${{ runner.os }}-node_modules-cache-v2-
- name: Extract Tag Name
run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: ${{ startsWith(github.ref, 'refs/tags') }}

- name: Run tests
run: |
sbt ";project scommons-admin-server ;set test in Test := {} ;project scommons-admin" coverage test
sbt "project scommons-admin-server" coverage test it:test
sbt ";project scommons-admin-server ;set Test / test := {} ;project scommons-admin" coverage test
sbt coverageAggregate coveralls
if: ${{ env.TAG_NAME == '' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Extract Tag Name
run: echo "TAG_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
if: ${{ startsWith(github.ref, 'refs/tags') }}

- name: Publish SNAPSHOT
run:
echo "TODO - Publish latest version"
Expand All @@ -74,7 +75,7 @@ jobs:
run: |
VERSION="$(echo "$TAG_NAME" | cut -d'v' -f 2)"
echo "Publish a release version=$VERSION for tag $TAG_NAME"
version=$VERSION sbt clean "project scommons-admin-server" docker:publishLocal
version=$VERSION sbt clean ";set Global / scalaJSStage := FullOptStage ;project scommons-admin-server" docker:publishLocal
docker tag scommons-admin-server:$VERSION scommons/admin:$VERSION
docker tag scommons/admin:$VERSION scommons/admin:latest
docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_TOKEN
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[![CI](https://github.com/scommons/scommons-admin/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/scommons/scommons-admin/actions/workflows/ci.yml?query=workflow%3Aci+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/scommons/scommons-admin/badge.svg?branch=master)](https://coveralls.io/github/scommons/scommons-admin?branch=master)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.1.0.svg)](https://www.scala-js.org)
[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.5.0.svg)](https://www.scala-js.org)
[![Docker image](https://img.shields.io/docker/v/scommons/admin?label=docker%20image&sort=date)](https://hub.docker.com/r/scommons/admin)

# scommons-admin
Expand Down Expand Up @@ -29,9 +29,9 @@ docker run -d --name scommons-admin -p 9000:9000 \

## How to Build and Run locally

To build and run tests use the following command:
To build and run ALL tests use the following command:
```bash
sbt -mem 2048 test it:test
sbt -mem 2048 clean "project scommons-admin-server" test it:test && sbt -mem 2048 ";project scommons-admin-server ;set Test / test := {} ;project scommons-admin" test
```

#### How to Run Server locally in DEV mode
Expand All @@ -40,7 +40,7 @@ Before you can run server, please, make sure you have PostgreSQL DB up and runni

To start the application server locally in development mode with refresh workflow:
```bash
sbt -mem 2048 ';project scommons-admin-server ;set WebKeys.exportedMappings in Assets := Seq()' run
sbt -mem 2048 clean ';project scommons-admin-server ;set Assets / WebKeys.exportedMappings := Seq()' run
```

## Admin Client UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package scommons.admin.client.user

import scala.collection.mutable

class UserDetailsTab private(val id: String) extends AnyVal {
sealed abstract class UserDetailsTab private(val id: String) {

UserDetailsTab.values += id -> this

override def toString: String = id
}
Expand All @@ -13,12 +15,6 @@ object UserDetailsTab {

def of(id: String): Option[UserDetailsTab] = values.get(id)

def apply(id: String): UserDetailsTab = {
val tab = new UserDetailsTab(id)
UserDetailsTab.values += id -> tab
tab
}

val apps = UserDetailsTab("apps")
val profile = UserDetailsTab("profile")
case object apps extends UserDetailsTab("apps")
case object profile extends UserDetailsTab("profile")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ case class UserProfilePanelProps(data: UserProfileData)

object UserProfilePanel extends FunctionComponent[UserProfilePanelProps] {

private[user] var firstNameComp: UiComponent[TextFieldProps] = TextField
private[user] var lastNameComp: UiComponent[TextFieldProps] = TextField
private[user] var emailComp: UiComponent[TextFieldProps] = TextField
private[user] var phoneComp: UiComponent[TextFieldProps] = TextField

override protected def create(): ReactClass = {
ReactMemo[Props](super.create(), { (prevProps, nextProps) =>
prevProps.wrapped == nextProps.wrapped
Expand All @@ -22,7 +27,7 @@ object UserProfilePanel extends FunctionComponent[UserProfilePanelProps] {
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("First Name"),
<.div(^.className := "controls")(
<(TextField())(^.wrapped := TextFieldProps(
<(firstNameComp())(^.wrapped := TextFieldProps(
text = props.data.firstName,
onChange = onChange,
readOnly = true
Expand All @@ -32,7 +37,7 @@ object UserProfilePanel extends FunctionComponent[UserProfilePanelProps] {
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("Last Name"),
<.div(^.className := "controls")(
<(TextField())(^.wrapped := TextFieldProps(
<(lastNameComp())(^.wrapped := TextFieldProps(
text = props.data.lastName,
onChange = onChange,
readOnly = true
Expand All @@ -42,7 +47,7 @@ object UserProfilePanel extends FunctionComponent[UserProfilePanelProps] {
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("E-mail"),
<.div(^.className := "controls")(
<(TextField())(^.wrapped := TextFieldProps(
<(emailComp())(^.wrapped := TextFieldProps(
text = props.data.email,
onChange = onChange,
readOnly = true
Expand All @@ -52,7 +57,7 @@ object UserProfilePanel extends FunctionComponent[UserProfilePanelProps] {
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("Phone"),
<.div(^.className := "controls")(
<(TextField())(^.wrapped := TextFieldProps(
<(phoneComp())(^.wrapped := TextFieldProps(
text = props.data.phone.getOrElse(""),
onChange = onChange,
readOnly = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class UserDetailsPanelSpec extends TestSpec with TestRendererUtils {
}
}

assertTestComponent(result, tabPanelComp) {
assertTestComponent(result, tabPanelComp)(inside(_) {
case TabPanelProps(List(systemsItem, profileItem), selectedIndex, _, direction) =>
selectedIndex shouldBe props.selectedTab.map {
case UserDetailsTab.`apps` => 0
Expand All @@ -115,6 +115,6 @@ class UserDetailsPanelSpec extends TestSpec with TestRendererUtils {

assertUserProfilePanel(render.get.apply(null), props.profile)
}
}
})
}
}
212 changes: 101 additions & 111 deletions client/src/test/scala/scommons/admin/client/user/UserEditPanelSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -283,116 +283,106 @@ class UserEditPanelSpec extends TestSpec with TestRendererUtils {
private def assertUserEditPanel(result: TestInstance, props: UserEditPanelProps): Unit = {
val data = props.initialData

assertNativeComponent(result, <.div(^.className := "form-horizontal")(), {
case List(
loginComp,
passwordComp,
companyComp,
firstNameComp,
lastNameComp,
emailComp,
phoneComp,
noteComp
) =>
assertNativeComponent(loginComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*Login"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, textFieldComp) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.user.login
requestFocus shouldBe props.requestFocus
requestSelect shouldBe props.requestFocus
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(passwordComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*Password"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, passwordFieldComp) {
case PasswordFieldProps(password, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
password shouldBe data.user.password
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(companyComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*Company"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, searchSelectComp) {
case SearchSelectProps(selected, _, _, isClearable, readOnly) =>
selected shouldBe {
if (data.user.company.id == -1) None
else Some(SelectData(data.user.company.id.toString, data.user.company.name))
}
isClearable shouldBe false
readOnly shouldBe false
}
})
})
assertNativeComponent(firstNameComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*First Name"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, textFieldComp) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.firstName
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(lastNameComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*Last Name"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, textFieldComp) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.lastName
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(emailComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("*E-mail"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, textFieldComp) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.email
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(phoneComp, <.div(^.className := "control-group")(), inside(_) { case List(labelComp, controls) =>
assertNativeComponent(labelComp, <.label(^.className := "control-label")("Phone"))
assertNativeComponent(controls, <.div(^.className := "controls")(), inside(_) { case List(fieldComp) =>
assertTestComponent(fieldComp, textFieldComp) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.phone.getOrElse("")
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}
})
})
assertNativeComponent(noteComp, <.p()(<.small()("(*) Indicates required fields")))
})
assertNativeComponent(result, <.div(^.className := "form-horizontal")(
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*Login"),
<.div(^.className := "controls")(
<(textFieldComp())(^.assertWrapped(inside(_) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.user.login
requestFocus shouldBe props.requestFocus
requestSelect shouldBe props.requestFocus
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*Password"),
<.div(^.className := "controls")(
<(passwordFieldComp())(^.assertWrapped(inside(_) {
case PasswordFieldProps(password, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
password shouldBe data.user.password
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*Company"),
<.div(^.className := "controls")(
<(searchSelectComp())(^.assertWrapped(inside(_) {
case SearchSelectProps(selected, _, _, isClearable, readOnly) =>
selected shouldBe {
if (data.user.company.id == -1) None
else Some(SelectData(data.user.company.id.toString, data.user.company.name))
}
isClearable shouldBe false
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*First Name"),
<.div(^.className := "controls")(
<(textFieldComp())(^.assertWrapped(inside(_) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.firstName
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*Last Name"),
<.div(^.className := "controls")(
<(textFieldComp())(^.assertWrapped(inside(_) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.lastName
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("*E-mail"),
<.div(^.className := "controls")(
<(textFieldComp())(^.assertWrapped(inside(_) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.email
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.div(^.className := "control-group")(
<.label(^.className := "control-label")("Phone"),
<.div(^.className := "controls")(
<(textFieldComp())(^.assertWrapped(inside(_) {
case TextFieldProps(text, _, requestFocus, requestSelect, className, placeholder, _, readOnly) =>
text shouldBe data.profile.phone.getOrElse("")
requestFocus shouldBe false
requestSelect shouldBe false
className shouldBe None
placeholder shouldBe None
readOnly shouldBe false
}))()
)
),
<.p()(<.small()("(*) Indicates required fields"))
))
}
}
Loading

0 comments on commit 8371c12

Please sign in to comment.