From 109f2dadbb3bb871b43004145d3a121c7cbfb77d Mon Sep 17 00:00:00 2001 From: Carlos Quiroz Date: Sat, 28 Dec 2024 11:28:43 -0300 Subject: [PATCH] Squash migrations --- .../explore/model/ExploreGridLayouts.scala | 30 ++++++++++-- .../main/scala/explore/tabs/ObsTabTiles.scala | 49 +++++++------------ .../down.sql | 1 - .../up.sql | 1 - .../down.sql | 5 ++ .../up.sql | 5 ++ .../down.sql | 1 - .../up.sql | 1 - 8 files changed, 52 insertions(+), 41 deletions(-) delete mode 100644 hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/down.sql delete mode 100644 hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/up.sql rename hasura/user-prefs/migrations/default/{1730765051390_new_table_ids => 1735245383258_calibration_layouts}/down.sql (57%) rename hasura/user-prefs/migrations/default/{1730765051390_new_table_ids => 1735245383258_calibration_layouts}/up.sql (57%) delete mode 100644 hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/down.sql delete mode 100644 hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/up.sql diff --git a/common/src/main/scala/explore/model/ExploreGridLayouts.scala b/common/src/main/scala/explore/model/ExploreGridLayouts.scala index 88dedccfb..f7895b5e2 100644 --- a/common/src/main/scala/explore/model/ExploreGridLayouts.scala +++ b/common/src/main/scala/explore/model/ExploreGridLayouts.scala @@ -11,6 +11,7 @@ import eu.timepit.refined.types.numeric.NonNegInt import explore.model.enums.GridLayoutSection import explore.model.layout.* import explore.model.layout.LayoutsMap +import lucuma.core.enums.CalibrationRole import lucuma.react.gridlayout.BreakpointName import lucuma.react.gridlayout.Layout import lucuma.react.gridlayout.LayoutItem @@ -263,10 +264,29 @@ object ExploreGridLayouts: ) ) - lazy val specPhotoMedium = layoutMedium lazy val twilightRemovedIds = - List(ObsTabTileIds.FinderChartsId, ObsTabTileIds.ItcId, ObsTabTileIds.NotesId).map(_.id.value) - lazy val twilightMedium = layoutMedium.asList.filterNot(l => twilightRemovedIds.contains(l.i)) + List(ObsTabTileIds.FinderChartsId, + ObsTabTileIds.ItcId, + ObsTabTileIds.NotesId, + ObsTabTileIds.TimingWindowsId + ).map(_.id.value) + + lazy val twilightMedium = + layoutMedium.asList + .filterNot(l => twilightRemovedIds.contains(l.i)) + lazy val specPhotoRemovedIds = + List(ObsTabTileIds.FinderChartsId, ObsTabTileIds.NotesId, ObsTabTileIds.TimingWindowsId).map( + _.id.value + ) + lazy val specPhotoMedium = + layoutMedium.asList + .filterNot(l => specPhotoRemovedIds.contains(l.i)) + + def removedTiles(role: Option[CalibrationRole]) = + role match + case Some(CalibrationRole.Twilight) => twilightRemovedIds + case Some(CalibrationRole.SpectroPhotometric) => specPhotoRemovedIds + case _ => Nil lazy val defaultObsLayouts: LayoutsMap = defineStdLayouts( @@ -279,8 +299,8 @@ object ExploreGridLayouts: lazy val specPhotoObsLayouts: LayoutsMap = defineStdLayouts( Map( - (BreakpointName.lg, specPhotoMedium), - (BreakpointName.md, specPhotoMedium) + (BreakpointName.lg, Layout(specPhotoMedium)), + (BreakpointName.md, Layout(specPhotoMedium)) ) ).withMinWidth diff --git a/explore/src/main/scala/explore/tabs/ObsTabTiles.scala b/explore/src/main/scala/explore/tabs/ObsTabTiles.scala index 867d6613b..b7d9c716a 100644 --- a/explore/src/main/scala/explore/tabs/ObsTabTiles.scala +++ b/explore/src/main/scala/explore/tabs/ObsTabTiles.scala @@ -52,6 +52,7 @@ import explore.undo.UndoSetter import japgolly.scalajs.react.* import japgolly.scalajs.react.extra.router.SetRouteVia import japgolly.scalajs.react.vdom.html_<^.* +import lucuma.core.enums.CalibrationRole import lucuma.core.math.Angle import lucuma.core.math.Offset import lucuma.core.math.skycalc.averageParallacticAngle @@ -86,7 +87,6 @@ import queries.schemas.odb.ObsQueries import java.time.Instant import scala.collection.immutable.SortedMap import scala.collection.immutable.SortedSet -import lucuma.core.enums.CalibrationRole case class ObsTabTiles( vault: Option[UserVault], @@ -552,38 +552,23 @@ object ObsTabTiles: props.globalPreferences.get.wavelengthUnits ) + val alltiles = + List( + notesTile.some, + targetTile.some, + if (!props.vault.isGuest) finderChartsTile.some else none, + skyPlotTile, + constraintsTile.some, + schedulingWindowsTile.some, + configurationTile.some, + sequenceTile.some, + itcTile.some + ).flattenOption + + val removedIds = ExploreGridLayouts.observations.removedTiles(props.calibrationRole) + val tiles = - props.observation.zoom(Observation.calibrationRole).get match { - case Some(CalibrationRole.SpectroPhotometric) => - List( - targetTile.some, - skyPlotTile, - constraintsTile.some, - configurationTile.some, - sequenceTile.some, - itcTile.some - ).flattenOption - case Some(CalibrationRole.Twilight) => - List( - targetTile.some, - skyPlotTile, - constraintsTile.some, - configurationTile.some, - sequenceTile.some - ).flattenOption - case _ => - List( - notesTile.some, - targetTile.some, - if (!props.vault.isGuest) finderChartsTile.some else none, - skyPlotTile, - constraintsTile.some, - schedulingWindowsTile.some, - configurationTile.some, - sequenceTile.some, - itcTile.some - ).flattenOption - } + alltiles.filterNot(t => removedIds.contains(t.id)) TileController( props.vault.userId, diff --git a/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/down.sql b/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/down.sql deleted file mode 100644 index 92a3c23ca..000000000 --- a/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/down.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_specphoto'; diff --git a/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/up.sql b/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/up.sql deleted file mode 100644 index 90a6be92a..000000000 --- a/hasura/user-prefs/migrations/default/1735245368319_insert_into_public_lucumaGridLayoutId/up.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_specphoto'); diff --git a/hasura/user-prefs/migrations/default/1730765051390_new_table_ids/down.sql b/hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/down.sql similarity index 57% rename from hasura/user-prefs/migrations/default/1730765051390_new_table_ids/down.sql rename to hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/down.sql index 54f7db2c0..74d84b8ea 100644 --- a/hasura/user-prefs/migrations/default/1730765051390_new_table_ids/down.sql +++ b/hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/down.sql @@ -1,3 +1,8 @@ + +DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_twilight'; + +DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_specphoto'; + DELETE FROM "public"."lucumaTableIds" WHERE "id" = 'observation_validations'; DELETE FROM "public"."lucumaTableIds" WHERE "id" = 'requested_configs'; DELETE FROM "public"."lucumaTableIds" WHERE "id" = 'unrequested_configs'; diff --git a/hasura/user-prefs/migrations/default/1730765051390_new_table_ids/up.sql b/hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/up.sql similarity index 57% rename from hasura/user-prefs/migrations/default/1730765051390_new_table_ids/up.sql rename to hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/up.sql index 0f8762083..2f17ebc23 100644 --- a/hasura/user-prefs/migrations/default/1730765051390_new_table_ids/up.sql +++ b/hasura/user-prefs/migrations/default/1735245383258_calibration_layouts/up.sql @@ -1,3 +1,8 @@ + INSERT INTO "public"."lucumaTableIds"("id") VALUES (E'observation_validations'); INSERT INTO "public"."lucumaTableIds"("id") VALUES (E'requested_configs'); INSERT INTO "public"."lucumaTableIds"("id") VALUES (E'unrequested_configs'); + +INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_specphoto'); + +INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_twilight'); diff --git a/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/down.sql b/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/down.sql deleted file mode 100644 index 08456f5e1..000000000 --- a/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/down.sql +++ /dev/null @@ -1 +0,0 @@ -DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_twilight'; diff --git a/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/up.sql b/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/up.sql deleted file mode 100644 index f7323db95..000000000 --- a/hasura/user-prefs/migrations/default/1735245383258_insert_into_public_lucumaGridLayoutId/up.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_twilight');