Skip to content

Firefly-2085: Refactor FootprintToolUI to Use a Functional Component - #2008

Open
aventura121 wants to merge 3 commits into
devfrom
FIREFLY-2085-refactor-FootprintToolUI
Open

Firefly-2085: Refactor FootprintToolUI to Use a Functional Component#2008
aventura121 wants to merge 3 commits into
devfrom
FIREFLY-2085-refactor-FootprintToolUI

Conversation

@aventura121

@aventura121 aventura121 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Firefly-2085: Refactor FootprintToolUi to Use A Functional Component

Description

This PR refactors the component as specified while also bolstering its implementation over the class component version. We also make the footprint panel shorter per the ticket as shown below.

Testing

  1. Navigate to the Survey Maps (HiPS) view
  2. Input a target object, e.g. m81 and load an image search (e.g. 2MASS Color J).
  3. Select the Hammer and Wrench icon, then the rightmost Overlay Markers icon in the Layers row.
  4. Select a footprint, e.g. JWST NIRCAM.
  5. Once the footprint is drawn, it's easier to zoom in to validate.
  6. Now, select the Layers Icon in the top menu, this will open the FootprintToolUI panel.
  7. Try typing in the angle, changing the label position, or changing the title. All changes should be reflected in the plot.
  8. Dragging the plot should update the center coordinates.

Style Change

  • For the layout change to make it more vertically shortened, the panel now makes of more use of one of the rows, placing the angle input alongside coordinates.
Before before
After after

@aventura121 aventura121 self-assigned this Sep 9, 2026
@aventura121 aventura121 added this to the 2026.3 milestone Sep 9, 2026
@aventura121
aventura121 marked this pull request as ready for review September 9, 2026 15:09
@aventura121 aventura121 changed the title Firefly 2085 refactor footprint tool UI Firefly-2085: Refactor FootprintToolUI as a Functional Component Sep 9, 2026
@aventura121 aventura121 changed the title Firefly-2085: Refactor FootprintToolUI as a Functional Component Firefly-2085: Refactor FootprintToolUI to Use a Functional Component Sep 9, 2026

@robyww robyww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good. My feedback was mainly for cleanup and readability.

the ticket was too vague but you changed too much in the UI to get the tighter vertical packing. It is alwaus good to ask about stuff like that.

  • keep the text the same (Label Location -> Corner), stuff like this should go through @lrebull
  • Keep the vertical label orientation the same as before, when it makes sense the vertical looks nicer.
  • Putting angle on the first line overlaps in to the color area.
  • Overall it should look like it did before but experiment to see if you can get a little tighter spacing. I was only looking for a few pixels. If it does not make sense, that is fine.


case MODIFY_CUSTOM_FIELD:
const {fpText, fpTextLoc, angleDeg} = action.payload.changes;
const {fpText, fpTextLoc, angleDeg, activePlotId} = action.payload.changes;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not there before but for safety.

const {fpText, fpTextLoc, angle Deg, activePlotId} = action.payload.changes ?? {}

} else {
return updateMarkerText(fpText, fpTextLoc, dd[DataTypes.DATA], plotIdAry);
// only update the layer title if there is a footprint in the active plot
const textApplied = isGoodPlot(activePlotId) &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to move away from get

 !isEmpty(dd.[DataTypes.DATA]?.activePlotId])

!isEmpty(get(dd, [DataTypes.DATA, activePlotId]));

// the layer title tracks the label; an empty label falls back to the title with which it was created
return {...updateMarkerText(fpText, fpTextLoc, dd[DataTypes.DATA], plotIdAry),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a cool but very complex line. Maybe you should simplify it to.

const title= {...(textApplied && {title: fpText || drawLayer.defaultTitle})};
return {...updateMarkerText(fpText, fpTextLoc, dd[DataTypes.DATA], plotIdAry), ...title};

I think it would be easier to read.

Comment on lines +36 to +41
const dl = getDrawLayerById(flux.getState()[DRAWING_LAYER_KEY], drawLayerId);
const fpObj = dl?.drawData?.data?.[plotId];
const {angle = 0.0, angleUnit = ANGLE_UNIT.radian, angleFromUI = false,
text = '', textLoc = defaultFootprintTextLoc} = fpObj ?? {};
return {hasData: Boolean(fpObj), currentPt: fpObj?.actionInfo?.currentPt,
angle, angleUnit, angleFromUI, text, textLoc};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this in a function outside of the component, then

... = useStoreConnector(() -> getXXX(drawLayerId,plotId))

It make the component easier to read.

Comment on lines +117 to +120
const textOnLink = fpInfo?.fromFile ? `Add another ${fpInfo.fromFile}`
: fpInfo?.fromRegionAry
? `Add another ${drawLayer.title}`
: `Add another ${fpInfo?.footprint}${fpInfo?.instrument ? ' '+fpInfo.instrument : ''}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use another line to keep style consistent

const textOnLink = fpInfo?.fromFile 
                     ? `Add another ${fpInfo.fromFile}`
                     : fpInfo?.fromRegionAry
                                    ? `Add another ${drawLayer.title}`
                                    : `Add another ${fpInfo?.footprint}${fpInfo?.instrument ? ' '+fpInfo.instrument : ''}`;

: `Add another ${fpInfo?.footprint}${fpInfo?.instrument ? ' '+fpInfo.instrument : ''}`;

return (
<Stack {...{py:1, spacing:1}}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally we would always want to use spacing:1, however the way this component is layed out it might not be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants