Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Sep 23, 2024
1 parent 78d9f76 commit d2f9519
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
12 changes: 7 additions & 5 deletions explore/src/main/scala/explore/observationtree/ObsList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ case class ObsList(
clipboardObsContents: Option[ObsIdSet],
readonly: Boolean
) extends ReactFnProps(ObsList.component):
private val activeGroup: Option[Group.Id] = focusedGroup.orElse(focusedObs.flatMap(obsId => observations.get.getValue(obsId).flatMap(_.groupId)))
private val activeGroup: Option[Group.Id] = focusedGroup.orElse:
focusedObs.flatMap(obsId => observations.get.getValue(obsId).flatMap(_.groupId))

private val copyDisabled: Boolean = focusedObs.isEmpty
private val pasteDisabled: Boolean = clipboardObsContents.isEmpty
Expand All @@ -85,14 +86,15 @@ case class ObsList(
private def observationText(obsId: Observation.Id): String = s"observation $obsId"
private def groupText(groupId: Group.Id): String = s"group $groupId"

private val copyText: Option[String] = focusedObs.map(observationText)
private val selectedText: Option[String] =
private val copyText: Option[String] = focusedObs.map(observationText)
private val selectedText: Option[String] =
clipboardObsContents.map: obdIdSet =>
obdIdSet.idSet.size match
case 1 => s"observation ${obdIdSet.idSet.head}"
case more => s"$more observations"
private val pasteText: Option[String] = selectedText.map(_ + activeGroup.map(gid => s" into ${groupText(gid)}").orEmpty)
private val deleteText: Option[String] =
private val pasteText: Option[String] =
selectedText.map(_ + activeGroup.map(gid => s" into ${groupText(gid)}").orEmpty)
private val deleteText: Option[String] =
focusedObs.map(observationText).orElse(focusedGroup.map(groupText))

object ObsList:
Expand Down
40 changes: 22 additions & 18 deletions explore/src/main/scala/explore/tabs/ObsTabContents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ case class ObsTabContents(
private val focusedObs: Option[Observation.Id] = focused.obsSet.map(_.head)
private val focusedTarget: Option[Target.Id] = focused.target
private val focusedGroup: Option[Group.Id] = focused.group
private val observations: UndoSetter[ObservationList] = programSummaries.zoom(ProgramSummaries.observations)
private val activeGroup: Option[Group.Id] = focusedGroup.orElse(focusedObs.flatMap(obsId => observations.get.getValue(obsId).flatMap(_.groupId)))
private val observations: UndoSetter[ObservationList] =
programSummaries.zoom(ProgramSummaries.observations)
private val activeGroup: Option[Group.Id] = focusedGroup.orElse:
focusedObs.flatMap(obsId => observations.get.getValue(obsId).flatMap(_.groupId))
private val obsExecutions: ObservationExecutionMap = programSummaries.get.obsExecutionPots
private val groupTimeRanges: GroupTimeRangeMap = programSummaries.get.groupTimeRangePots
private val groups: UndoSetter[GroupTree] = programSummaries.zoom(ProgramSummaries.groups)
Expand Down Expand Up @@ -129,23 +131,25 @@ object ObsTabContents extends TwoPanels:
.orUnit
.runAsync
.useCallbackWithDepsBy((props, _, _, _, _, _) => // PASTE Action Callback
(Reusable.explicitly(props.observations)(Reusability.by(_.get)), props.activeGroup, props.readonly)
):
(props, ctx, _, _, _, _) =>
(observations, activeGroup, readonly) =>
import ctx.given
(Reusable.explicitly(props.observations)(Reusability.by(_.get)),
props.activeGroup,
props.readonly
)
): (props, ctx, _, _, _, _) =>
(observations, activeGroup, readonly) =>
import ctx.given

ExploreClipboard.get
.flatMap:
case LocalClipboard.CopiedObservations(obsIdSet) =>
obsIdSet.idSet.toList
.traverse: oid =>
cloneObs(props.programId, oid, activeGroup, observations, ctx)
.void
.withToast(s"Duplicating obs ${obsIdSet.idSet.mkString_(", ")}")
case _ => IO.unit
.runAsync
.unless_(readonly)
ExploreClipboard.get
.flatMap:
case LocalClipboard.CopiedObservations(obsIdSet) =>
obsIdSet.idSet.toList
.traverse: oid =>
cloneObs(props.programId, oid, activeGroup, observations, ctx)
.void
.withToast(s"Duplicating obs ${obsIdSet.idSet.mkString_(", ")}")
case _ => IO.unit
.runAsync
.unless_(readonly)
.useGlobalHotkeysWithDepsBy((props, _, _, _, _, copyCallback, pasteCallback) =>
(copyCallback, pasteCallback, props.focusedObs, props.observationIdsWithIndices)
): (props, ctx, _, _, _, _, _) =>
Expand Down

0 comments on commit d2f9519

Please sign in to comment.