diff --git a/common/src/main/scala/explore/components/Tile.scala b/common/src/main/scala/explore/components/Tile.scala index e68f7eccc0..8190a0165e 100644 --- a/common/src/main/scala/explore/components/Tile.scala +++ b/common/src/main/scala/explore/components/Tile.scala @@ -24,7 +24,6 @@ case class Tile[A]( initialState: A, title: String, back: Option[VdomNode] = None, - // control: TileSizeState => Option[VdomNode] = _ => None, canMinimize: Boolean = true, canMaximize: Boolean = true, hidden: Boolean = false, @@ -34,8 +33,10 @@ case class Tile[A]( bodyClass: Css = Css.Empty, // applied to tile body tileClass: Css = Css.Empty, // applied to the tile tileTitleClass: Css = Css.Empty // applied to the title -)(val tileBody: View[A] => VdomNode, val tileTitle: View[A] => VdomNode = (_: View[A]) => EmptyVdom) - extends ReactFnProps(Tile.component) { +)( + val tileBody: View[A] => VdomNode, + val tileTitle: (View[A], TileSizeState) => VdomNode = (_: View[A], _: TileSizeState) => EmptyVdom +) extends ReactFnProps(Tile.component) { def showMaximize: Boolean = sizeState === TileSizeState.Minimized || (canMaximize && sizeState === TileSizeState.Minimized) @@ -107,9 +108,8 @@ object Tile: <.div( ExploreStyles.TileTitleControlArea, <.div(ExploreStyles.TileTitleStrip |+| ExploreStyles.TileControl, - p.tileTitle(sharedState) + p.tileTitle(sharedState, p.sizeState) ), - // .map(b => <.div(ExploreStyles.TileTitleStrip |+| ExploreStyles.TileControl, b)), <.div(^.key := s"tileTitle-${p.id.value}", ^.untypedRef(setInfoRef).when(infoRef.value.isEmpty) )( diff --git a/explore/src/main/scala/explore/attachments/ObsAttachmentsTableBody.scala b/explore/src/main/scala/explore/attachments/ObsAttachmentsTableBody.scala index 36b0cfd3ba..18dc075bef 100644 --- a/explore/src/main/scala/explore/attachments/ObsAttachmentsTableBody.scala +++ b/explore/src/main/scala/explore/attachments/ObsAttachmentsTableBody.scala @@ -59,6 +59,7 @@ import org.typelevel.log4cats.Logger import scala.collection.immutable.SortedSet import lucuma.core.util.NewType +import explore.model.enums.TileSizeState object ObsAttachmentsTableTileState extends NewType[Action]: def apply(): ObsAttachmentsTableTileState = ObsAttachmentsTableTileState(Action.None) @@ -368,7 +369,8 @@ case class ObsAttachmentsTableTitle( obsAttachments: View[ObsAttachmentList], readOnly: Boolean )( - val state: View[ObsAttachmentsTableTileState] + val state: View[ObsAttachmentsTableTileState], + tileSize: TileSizeState ) extends ReactFnProps(ObsAttachmentsTableTitle.component) object ObsAttachmentsTableTitle extends ObsAttachmentUtils: diff --git a/explore/src/main/scala/explore/proposal/ProgramUsers.scala b/explore/src/main/scala/explore/proposal/ProgramUsers.scala index 216d5e9ee4..fe934d6c65 100644 --- a/explore/src/main/scala/explore/proposal/ProgramUsers.scala +++ b/explore/src/main/scala/explore/proposal/ProgramUsers.scala @@ -51,7 +51,10 @@ case class ProgramUsers( object ProgramUsers: - def inviteControl(readOnly: Boolean, ref: OverlayPanelRef)(state: View[ProgramUsersState]) = + def inviteControl(readOnly: Boolean, ref: OverlayPanelRef)( + state: View[ProgramUsersState], + s: TileSizeState + ) = Button( severity = Button.Severity.Secondary, size = Button.Size.Small, @@ -73,7 +76,7 @@ object ProgramUsers: ProposalTabTileIds.UsersId.id, ProgramUsersState(CreateInviteProcess.Idle), "Investigators" - )(ProgramUsers(pid, readOnly, users, invitations)(_), inviteControl(readOnly, ref)(_)) + )(ProgramUsers(pid, readOnly, users, invitations), inviteControl(readOnly, ref)) private type Props = ProgramUsers diff --git a/explore/src/main/scala/explore/proposal/ProposalDetailsTile.scala b/explore/src/main/scala/explore/proposal/ProposalDetailsTile.scala index fcb714d708..9a01951451 100644 --- a/explore/src/main/scala/explore/proposal/ProposalDetailsTile.scala +++ b/explore/src/main/scala/explore/proposal/ProposalDetailsTile.scala @@ -62,6 +62,7 @@ import lucuma.ui.syntax.all.given import lucuma.ui.syntax.pot.* import org.typelevel.log4cats.Logger import spire.std.any.* +import explore.model.enums.TileSizeState case class ProposalDetailsTileState() @@ -519,7 +520,8 @@ object ProposalDetailsBody: )(using ctx.logger) case class ProposalDetailsTitle(undoCtx: UndoContext[Proposal])( - state: View[ProposalDetailsTileState] + state: View[ProposalDetailsTileState], + val tileSize: TileSizeState ) extends ReactFnProps(ProposalDetailsTitle.component) object ProposalDetailsTitle: @@ -527,4 +529,5 @@ object ProposalDetailsTitle: private val component = ScalaFnComponent[Props]: props => - <.div(ExploreStyles.TitleUndoButtons)(UndoButtons(props.undoCtx)) + if (props.tileSize === TileSizeState.Minimized) EmptyVdom + else <.div(ExploreStyles.TitleUndoButtons)(UndoButtons(props.undoCtx)) diff --git a/explore/src/main/scala/explore/proposal/ProposalEditor.scala b/explore/src/main/scala/explore/proposal/ProposalEditor.scala index 9b4e133b35..d267bfb817 100644 --- a/explore/src/main/scala/explore/proposal/ProposalEditor.scala +++ b/explore/src/main/scala/explore/proposal/ProposalEditor.scala @@ -98,7 +98,8 @@ object ProposalEditor: props.timeEstimateRange, props.cfps, props.readonly - )(_), ProposalDetailsTitle(undoCtx)(_) + ), + ProposalDetailsTitle(undoCtx) ) val usersTile = diff --git a/explore/src/main/scala/explore/tabs/OverviewTabContents.scala b/explore/src/main/scala/explore/tabs/OverviewTabContents.scala index 13d29d6f81..16f5217d66 100644 --- a/explore/src/main/scala/explore/tabs/OverviewTabContents.scala +++ b/explore/src/main/scala/explore/tabs/OverviewTabContents.scala @@ -76,14 +76,12 @@ object OverviewTabContents { props.obsAttachmentAssignments, props.obsAttachments, props.readonly - )( - _ ), ObsAttachmentsTableTitle(props.programId, vault.token, props.obsAttachments, props.readonly - )(_) + ) ) ) .filterNot(_ => props.userVault.isGuest) diff --git a/explore/src/main/scala/explore/timingwindows/TimingWindowsTile.scala b/explore/src/main/scala/explore/timingwindows/TimingWindowsTile.scala index 62b2067ebe..5e3b7bdc39 100644 --- a/explore/src/main/scala/explore/timingwindows/TimingWindowsTile.scala +++ b/explore/src/main/scala/explore/timingwindows/TimingWindowsTile.scala @@ -53,6 +53,7 @@ import java.time.Duration import java.time.Instant import java.time.ZoneOffset import java.time.ZonedDateTime +import explore.model.enums.TileSizeState case class TimingWindowsTileState( setRowSelection: RowSelection => Callback = _ => Callback.empty @@ -73,8 +74,8 @@ object TimingWindowsTile: val title = if (timingWindows.get.isEmpty) base else s"$base (${timingWindows.get.length})" Tile(ObsTabTilesIds.TimingWindowsId.id, TimingWindowsTileState(), title)( - TimingWindowsBody(timingWindows, readOnly)(_), - TimingWindowsTitle(timingWindows, readOnly)(_) + TimingWindowsBody(timingWindows, readOnly), + TimingWindowsTitle(timingWindows, readOnly) ) object TimingWindowsBody: @@ -425,7 +426,7 @@ object TimingWindowsBody: case class TimingWindowsTitle( windows: View[List[TimingWindow]], readOnly: Boolean -)(val state: View[TimingWindowsTileState]) +)(val state: View[TimingWindowsTileState], val tileSize: TileSizeState) extends ReactFnProps(TimingWindowsTitle.component) object TimingWindowsTitle: @@ -433,7 +434,7 @@ object TimingWindowsTitle: private val component = ScalaFnComponent[Props]: props => - if (props.readOnly) EmptyVdom + if (props.readOnly || props.tileSize === TileSizeState.Minimized) EmptyVdom else Button( severity = Button.Severity.Success, diff --git a/explore/src/main/scala/explore/validations/ObservationValidationsTableBody.scala b/explore/src/main/scala/explore/validations/ObservationValidationsTableBody.scala index b3258258d4..958c497ec1 100644 --- a/explore/src/main/scala/explore/validations/ObservationValidationsTableBody.scala +++ b/explore/src/main/scala/explore/validations/ObservationValidationsTableBody.scala @@ -33,6 +33,7 @@ import lucuma.ui.table.* import scala.scalajs.js import lucuma.core.util.NewType +import explore.model.enums.TileSizeState object ObservationValidationsTableTileState extends NewType[Boolean => Callback] type ObservationValidationsTableTileState = ObservationValidationsTableTileState.Type @@ -233,25 +234,30 @@ object ObservationValidationsTableBody { } } -case class ObservationValidationsTableTitle(state: View[ObservationValidationsTableTileState]) - extends ReactFnProps(ObservationValidationsTableTitle.component) +case class ObservationValidationsTableTitle( + state: View[ObservationValidationsTableTileState], + tileSize: TileSizeState +) extends ReactFnProps(ObservationValidationsTableTitle.component) object ObservationValidationsTableTitle: private type Props = ObservationValidationsTableTitle private val component = ScalaFnComponent[Props]: p => - <.div( - ExploreStyles.TableSelectionToolbar, - Button( - size = Button.Size.Small, - icon = Icons.SquarePlus, - tooltip = "Expand All", - onClick = p.state.get.value(true) - ).compact, - Button( - size = Button.Size.Small, - icon = Icons.SquareMinus, - tooltip = "Collapse All", - onClick = p.state.get.value(false) - ).compact - ) + if (p.tileSize === TileSizeState.Minimized) + EmptyVdom + else + <.div( + ExploreStyles.TableSelectionToolbar, + Button( + size = Button.Size.Small, + icon = Icons.SquarePlus, + tooltip = "Expand All", + onClick = p.state.get.value(true) + ).compact, + Button( + size = Button.Size.Small, + icon = Icons.SquareMinus, + tooltip = "Collapse All", + onClick = p.state.get.value(false) + ).compact + )