Skip to content

Firefly-2024: New MOC features in DCE and code clean up - #1995

Merged
robyww merged 1 commit into
devfrom
FIREFLY-2024-moc-outline
Aug 20, 2026
Merged

Firefly-2024: New MOC features in DCE and code clean up#1995
robyww merged 1 commit into
devfrom
FIREFLY-2024-moc-outline

Conversation

@robyww

@robyww robyww commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Firefly-2024: new moc features in DCE and code clean up

  • refactor and some clean up of code cleanup, created new file CisxSerDescUtils.js and moved some functions to it.
  • support:
  <PARAM name="moc_style" datatype="char" arraysize="*" value="outline"/>
  <PARAM name="moc_short_description" datatype="char" arraysize="*" value="herschel_pep"/>

Testing

Test File

dustpedia.xml

@robyww robyww self-assigned this Aug 18, 2026
@robyww robyww added enhancement Refactor Refactoring or code cleanup labels Aug 18, 2026
@robyww
robyww requested a review from jaladh-singhal August 18, 2026 16:43
@robyww robyww changed the title Firefly-2024: new moc features in DCE and code clean up Firefly-2024: New MOC features in DCE and code clean up Aug 18, 2026
@robyww robyww added multi-ticket This PR implements multiple Jira tickets bug labels Aug 18, 2026
@robyww
robyww force-pushed the FIREFLY-2024-moc-outline branch from d7b6b8a to 2231fbf Compare August 18, 2026 22:13
@robyww robyww removed bug multi-ticket This PR implements multiple Jira tickets labels Aug 18, 2026
@robyww robyww added this to the 2026.3 milestone Aug 19, 2026

@jaladh-singhal jaladh-singhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tested the builds, working as described. @lrebull can test in depth when she's back.

I left some minor code improvement comments, otherwise good to go.

Comment thread src/firefly/js/visualize/HiPSMocUtil.js Outdated
@@ -1,4 +1,6 @@
import {get, set, isEmpty, flatten, isArray} from 'lodash';
import React from 'react';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see the use of React import in this file. Also it's a .js not .jsx so either we should remove it or change file extension?


if (sd?.serDefParams) {
for (const param of sd.serDefParams) {
productUrl.inputParams[param?.name] = {value: param.value, ref: param.ref};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You may wanna check param?.name before doing assignment otherwise there will be a "undefined" key in inputParams. I've noticed this issue in some of our other code as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will put an if around it.

targetPanelExampleRow2: examples.slice(Math.trunc(cnt / 2))
};
} else {
return {targetPanelExampleRow1: [inExample], targetPanelExampleRow2: []};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This probably out of scope since it will change data structure everywhere else but instead of breaking examples to two rows we can let CSS handle that during rendering based on line wrapping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That could be really complex and often they want more control. It is something we could look at in the future.

Comment on lines +34 to +58
.reduce((obj, {name, value, desc}) => {
const key = itemsList.find((k) => name.startsWith(k));
if (key) {
obj[translateXml[key] + name.substring(key.length, name.length)] = value;
} else {
obj[name] = value;
obj['mocTitle' + name.substring(3, name.length)] = desc;
}
return obj;
}, {});
}

function getMOCList(searchAreaInfo) {
const mocAry= Object.keys(searchAreaInfo)
.filter( (k) => k.toLowerCase()==='moc' || k.match(/moc\d+$/i) )
.map( (k) => {
const cnt= k.substring(3,k.length);
return {
mocUrl : searchAreaInfo[k],
title : searchAreaInfo['mocTitle'+cnt] ?? 'MOC'+cnt,
[SHORT_TITLE]: searchAreaInfo[SHORT_TITLE+cnt],
[MOC_COLOR]: searchAreaInfo[MOC_COLOR+cnt],
maxFetchDepth: searchAreaInfo['maxFetchDepth'+cnt],
[MOC_STYLE]: searchAreaInfo[MOC_STYLE+cnt],
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this code can be improved:

  • You can omit second argument in substring - it will default to string.length instead of you specifying it again and again
  • There seems to be some string parsing and reverse parsing association between these two functions for object keys e.g. cnt= k.substring(3,k.length); searchAreaInfo['mocTitle'+cnt] and obj['mocTitle' + name.substring(3, name.length)] = desc;. It might be worth abstracting those associations out to helper functions so that they don't go out of sync and are more readable.

(I recommend feeding it to AI, it's usually good at this kind of things)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This processing was happening at two different places in the code. I realize it could be combined and happen very early.
I will look at cleaning it up some more.

 - includes response to feedback

support:
  <PARAM name="moc_style" datatype="char" arraysize="*" value="outline"/>
  <PARAM name="moc_short_description" datatype="char" arraysize="*" value="herschel_pep"/>
@robyww
robyww force-pushed the FIREFLY-2024-moc-outline branch from 2231fbf to 7cb06cd Compare August 20, 2026 16:41
@robyww
robyww merged commit f0f97eb into dev Aug 20, 2026
@robyww
robyww deleted the FIREFLY-2024-moc-outline branch August 20, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Refactor Refactoring or code cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants