Firefly-2085: Refactor FootprintToolUI to Use a Functional Component - #2008
Firefly-2085: Refactor FootprintToolUI to Use a Functional Component#2008aventura121 wants to merge 3 commits into
Conversation
robyww
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) && |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
| 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}; |
There was a problem hiding this comment.
put this in a function outside of the component, then
... = useStoreConnector(() -> getXXX(drawLayerId,plotId))It make the component easier to read.
| const textOnLink = fpInfo?.fromFile ? `Add another ${fpInfo.fromFile}` | ||
| : fpInfo?.fromRegionAry | ||
| ? `Add another ${drawLayer.title}` | ||
| : `Add another ${fpInfo?.footprint}${fpInfo?.instrument ? ' '+fpInfo.instrument : ''}`; |
There was a problem hiding this comment.
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}}> |
There was a problem hiding this comment.
normally we would always want to use spacing:1, however the way this component is layed out it might not be necessary.
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
Build: https://firefly-2085-refactor-footprinttoolui.irsakubedev.ipac.caltech.edu/firefly
Steps
Style Change
Before
After