diff --git a/explore/src/main/scala/explore/observationtree/ObsList.scala b/explore/src/main/scala/explore/observationtree/ObsList.scala index 34ce869171..e747ef7cd1 100644 --- a/explore/src/main/scala/explore/observationtree/ObsList.scala +++ b/explore/src/main/scala/explore/observationtree/ObsList.scala @@ -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 @@ -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: diff --git a/explore/src/main/scala/explore/tabs/ObsTabContents.scala b/explore/src/main/scala/explore/tabs/ObsTabContents.scala index 515248d04d..156cce7137 100644 --- a/explore/src/main/scala/explore/tabs/ObsTabContents.scala +++ b/explore/src/main/scala/explore/tabs/ObsTabContents.scala @@ -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) @@ -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, _, _, _, _, _) =>