Skip to content

Commit

Permalink
Merge branch 'master' into update/fs2-data-csv-1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lucuma-steward[bot] committed Oct 12, 2023
2 parents 86aba37 + 974587e commit c15de9d
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 178 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ jobs:
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt -v -J-Xmx6g +update

- name: Use Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
restore-keys: node_modules

- name: npm clean-install
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm clean-install --verbose

- name: Check that workflows are up to date
Expand Down Expand Up @@ -111,18 +120,27 @@ jobs:
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt -v -J-Xmx6g +update

- name: Use Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Stage
run: sbt -v -J-Xmx6g '++ ${{ matrix.scala }}' stage
- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
restore-keys: node_modules

- name: npm clean-install
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm clean-install --verbose

- name: Stage
run: sbt -v -J-Xmx6g '++ ${{ matrix.scala }}' stage

- name: Build application
env:
NODE_OPTIONS: '--max-old-space-size=8192'
Expand Down Expand Up @@ -174,13 +192,22 @@ jobs:
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt -v -J-Xmx6g +update

- name: Use Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
restore-keys: node_modules

- name: npm clean-install
if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm clean-install --verbose

- name: Extract CSS files
Expand Down
48 changes: 28 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ ThisBuild / ScalafixConfig / bspEnabled.withRank(KeyRanks.Invisible) := false
ThisBuild / evictionErrorLevel := Level.Info
ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots")

ThisBuild / coverageEnabled := false

ThisBuild / lucumaCssExts += "svg"

addCommandAlias(
Expand Down Expand Up @@ -63,6 +61,7 @@ lazy val model = crossProject(JVMPlatform, JSPlatform)
.settings(commonSettings: _*)
.settings(commonLibSettings: _*)
.jvmSettings(commonJVMSettings)
.jsSettings(commonJsLibSettings)

lazy val modelTestkit = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Full)
Expand Down Expand Up @@ -111,7 +110,6 @@ lazy val common = project
.settings(
libraryDependencies ++=
LucumaSSO.value ++
LucumaBC.value ++
LucumaCatalog.value ++
LucumaSchemas.value ++
LucumaReact.value ++
Expand Down Expand Up @@ -256,22 +254,35 @@ def anyConds(conds: String*) = conds.mkString("(", " || ", ")")

val faNpmAuthToken = "FONTAWESOME_NPM_AUTH_TOKEN" -> "${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}"

lazy val setupNode = WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v3"),
name = Some("Use Node.js"),
params = Map("node-version" -> "20", "cache" -> "npm")
)
// https://github.com/actions/setup-node/issues/835#issuecomment-1753052021
lazy val setupNodeNpmInstall =
List(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v3"),
name = Some("Setup Node.js"),
params = Map("node-version" -> "20", "cache" -> "npm")
),
WorkflowStep.Use(
UseRef.Public("actions", "cache", "v3"),
name = Some("Cache node_modules"),
id = Some("cache-node_modules"),
params = {
val prefix = "node_modules"
val key = s"$prefix-$${{ hashFiles('package-lock.json') }}"
Map("path" -> "node_modules", "key" -> key, "restore-keys" -> prefix)
}
),
WorkflowStep.Run(
List("npm clean-install --verbose"),
name = Some("npm clean-install"),
cond = Some("steps.cache-node_modules.outputs.cache-hit != 'true'")
)
)

lazy val sbtStage = WorkflowStep.Sbt(List("stage"), name = Some("Stage"))

lazy val lucumaCssStep = WorkflowStep.Sbt(List("lucumaCss"), name = Some("Extract CSS files"))

// https://stackoverflow.com/a/55610612
lazy val npmInstall = WorkflowStep.Run(
List("npm clean-install --verbose"),
name = Some("npm clean-install")
)

lazy val npmBuild = WorkflowStep.Run(
List("npm run build"),
name = Some("Build application"),
Expand Down Expand Up @@ -348,7 +359,7 @@ def runLinters(mode: String) = WorkflowStep.Use(

ThisBuild / githubWorkflowGeneratedUploadSteps := Seq.empty
ThisBuild / githubWorkflowSbtCommand := "sbt -v -J-Xmx6g"
ThisBuild / githubWorkflowBuildPreamble ++= Seq(setupNode, npmInstall)
ThisBuild / githubWorkflowBuildPreamble ++= setupNodeNpmInstall
ThisBuild / githubWorkflowEnv += faNpmAuthToken

ThisBuild / githubWorkflowAddedJobs +=
Expand All @@ -357,10 +368,8 @@ ThisBuild / githubWorkflowAddedJobs +=
"full",
WorkflowStep.Checkout ::
WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList.take(1)) :::
setupNode ::
githubWorkflowGeneratedCacheSteps.value.toList :::
setupNodeNpmInstall :::
sbtStage ::
npmInstall ::
npmBuild ::
overrideCiCommit ::
bundlemon ::
Expand All @@ -378,8 +387,7 @@ ThisBuild / githubWorkflowAddedJobs +=
"Run linters",
WorkflowStep.Checkout ::
WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList.take(1)) :::
setupNode ::
npmInstall ::
setupNodeNpmInstall :::
lucumaCssStep ::
setupVars("dark") ::
runLinters("dark") ::
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/webapp/sass/explore.scss
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ body.hide-reusability {
transform 0.25s,
filter 0.25s ease-in;

&:enabled:focus {
&:enabled:focus-visible {
border: none;
box-shadow: none;
}
Expand Down Expand Up @@ -1610,7 +1610,7 @@ input[type='file'].explore-fileupload {
margin-left: 0.5rem;
}

&:focus {
&:focus-visible {
box-shadow: none;
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/webapp/sass/visualization.scss
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ $brightness: var(--aladin-image-brightness);
max-width: 30px;
max-height: 30px;

&:enabled:focus,
&:enabled:focus-visible,
&:enabled:hover {
background: var(--gray-700);
border-color: var(--gray-200);
Expand Down
11 changes: 3 additions & 8 deletions explore/src/main/scala/explore/Explore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import explore.model.RoutingInfo
import explore.model.WorkerClients
import explore.model.enums.AppTab
import explore.utils.*
import fs2.dom.BroadcastChannel
import japgolly.scalajs.react.*
import japgolly.scalajs.react.extra.router.*
import japgolly.scalajs.react.vdom.html_<^.*
import log4cats.loglevel.LogLevelLogger
import lucuma.broadcastchannel.*
import lucuma.core.model.Program
import lucuma.react.primereact.ToastRef
import lucuma.ui.enums.ExecutionEnvironment
Expand Down Expand Up @@ -107,11 +107,6 @@ object ExploreMain {
lucuma.react.highcharts.HighchartsAccesibility
}.void

def broadcastChannel[F[_]: Sync]: Resource[F, BroadcastChannel[ExploreEvent]] =
Resource.make(Sync[F].delay(new BroadcastChannel[ExploreEvent]("explore")))(c =>
Sync[F].delay(c.close()).void
)

def run: IO[Unit] = {

def setupReusabilityOverlay(env: ExecutionEnvironment): IO[Unit] =
Expand All @@ -135,7 +130,7 @@ object ExploreMain {
dispatcher: Dispatcher[IO],
workerClients: WorkerClients[IO],
localPreferences: ExploreLocalPreferences,
bc: BroadcastChannel[ExploreEvent]
bc: BroadcastChannel[IO, ExploreEvent]
)(using Logger[IO]): IO[Unit] = {
given FetchJSBackend[IO] = FetchJSBackend[IO](FetchMethod.GET)
given WebSocketJSBackend[IO] = WebSocketJSBackend[IO](dispatcher)
Expand Down Expand Up @@ -188,7 +183,7 @@ object ExploreMain {
prefs <- Resource.eval(ExploreLocalPreferences.loadPreferences[IO])
given Logger[IO] <- Resource.eval(setupLogger[IO](prefs))
workerClients <- WorkerClients.build[IO](dispatcher)
bc <- broadcastChannel[IO]
bc <- BroadcastChannel[IO, ExploreEvent]("explore")
_ <- Resource.eval(buildPage(dispatcher, workerClients, prefs, bc))
} yield ()).useForever
}
Expand Down
69 changes: 31 additions & 38 deletions explore/src/main/scala/explore/ExploreLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import japgolly.scalajs.react.*
import japgolly.scalajs.react.extra.router.ResolutionWithProps
import japgolly.scalajs.react.extra.router.SetRouteVia
import japgolly.scalajs.react.vdom.html_<^.*
import lucuma.broadcastchannel.*
import lucuma.core.util.Display
import lucuma.react.common.*
import lucuma.react.hotkeys.*
Expand Down Expand Up @@ -96,45 +95,39 @@ object ExploreLayout:
_.map(_ => ctx.toastRef.complete(toastRef).void.runAsync).orEmpty
)
)
.useEffectOnMountBy: (props, _, ctx, toastRef) =>
Callback {
ctx.broadcastChannel.onmessage = (
(x: ExploreEvent) =>
// This is coming from the js world, we can't match the type
x.event match {
// TODO: Handle logout events
case ExploreEvent.PWAUpdateId =>
// Clear other toasts first
toastRef.clear().toAsync *>
toastRef
.upgradePrompt(
<.span(
"A new version of ",
<.a(
ExploreStyles.UpgradeLink,
"Explore",
^.href := s"https://github.com/gemini-hlsw/explore/compare/${utils.gitHash.orEmpty}...HEAD",
^.target := "_blank"
),
" is available!"
),
IO(
ctx.broadcastChannel.postMessage(ExploreEvent.PWAReload)
)
.handleErrorWith(e => IO(e.printStackTrace()))
.runAsyncAndForget
)
.toAsync
case _ => IO.unit
}
): (ExploreEvent => IO[Unit])
// Scala 3 infers the return type as Any if we don't ascribe

ctx.broadcastChannel.postMessage(ExploreEvent.ExploreUIReady)
}
.useStreamOnMountBy: (_, _, ctx, toastRef) =>
ctx.broadcastChannel.messages.evalTap(
// This is coming from the js world, we can't match the type
_.data.event match {
// TODO: Handle logout events
case ExploreEvent.PWAUpdateId =>
// Clear other toasts first
toastRef.clear().toAsync *>
toastRef
.upgradePrompt(
<.span(
"A new version of ",
<.a(
ExploreStyles.UpgradeLink,
"Explore",
^.href := s"https://github.com/gemini-hlsw/explore/compare/${utils.gitHash.orEmpty}...HEAD",
^.target := "_blank"
),
" is available!"
),
ctx.broadcastChannel
.postMessage(ExploreEvent.PWAReload)
.runAsyncAndForget
)
.toAsync
case _ => IO.unit
}
)
.useEffectOnMountBy: (_, _, ctx, _, _) =>
ctx.broadcastChannel.postMessage(ExploreEvent.ExploreUIReady)
.useStateView(none[NonEmptyString]) // userSelectionMessage
.useTheme(Theme.Dark)
.render: (props, helpCtx, ctx, toastRef, userSelectionMessage, theme) =>
.render: (props, helpCtx, ctx, toastRef, _, userSelectionMessage, theme) =>
import ctx.given

// Creates a "profile" for user preferences.
Expand Down
Loading

0 comments on commit c15de9d

Please sign in to comment.