Skip to content

[WIP] : DO NOT MERGE! Kpmp 6434 web component#616

Closed
rlreamy wants to merge 2 commits intodevelopfrom
KPMP-6434_WebComponent
Closed

[WIP] : DO NOT MERGE! Kpmp 6434 web component#616
rlreamy wants to merge 2 commits intodevelopfrom
KPMP-6434_WebComponent

Conversation

@rlreamy
Copy link
Contributor

@rlreamy rlreamy commented Jan 9, 2026

Summary by CodeRabbit

  • New Features
    • Added HubMap cell type schema explorer with interactive medical illustrations
    • New /explorer/hubmap route for accessing the schema visualization
    • Integrated external medical illustration web component with click event tracking

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Walkthrough

The changes integrate HubMap's medical illustration web component into the application. External CDN resources (stylesheet and JavaScript module) are loaded in the HTML head. A new route /explorer/hubmap is registered in the app, rendering a HubMapSchema component that wraps the external <hra-medical-illustration> web component with configuration attributes and click event handling.

Changes

Cohort / File(s) Summary
HubMap CDN Resources
public/index.html
Added stylesheet link and module script references to HubMap CDN for the medical illustration web component
Route Registration
src/App.js
Imported HubMapSchemaComponent and registered new route at /explorer/hubmap
HubMap Schema Component
src/components/Explorer/HubMapSchema.js
New functional component that renders <hra-medical-illustration> custom element with string attributes (selected-illustration, illustrations); attaches click event listener that logs element's target id; includes proper cleanup and null-checks
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/components/Explorer/HubMapSchema.js (3)

24-30: Consider making illustration URLs configurable.

The URLs on lines 27-28 are hard-coded, which reduces flexibility for different environments or use cases. Consider accepting these as props or loading them from environment variables.

♻️ Proposed refactor to use props with defaults
-function HubMapSchema(props) {
+function HubMapSchema({ 
+  selectedIllustration = "https://purl.humanatlas.io/2d-ftu/kidney-renal-corpuscle",
+  illustrations = "https://cdn.humanatlas.io/digital-objects/graph/2d-ftu-illustrations/latest/assets/2d-ftu-illustrations.jsonld"
+}) {
   const ref = useRef(null);

   useEffect(() => {
     // Manually attach event listeners or call imperative methods if needed
     const element = ref.current;
     if (!element) return;

     const handleClick = (event) => {
       console.log('HubMapSchema clicked', event.target.id);
     };

     element.addEventListener('click', handleClick);

     return () => {
       element.removeEventListener('click', handleClick);
     };
   }, []);

   // Pass properties as attributes (which are treated as strings)

   return (
     <hra-medical-illustration
       ref={ref}
-      selected-illustration="https://purl.humanatlas.io/2d-ftu/kidney-renal-corpuscle"
-      illustrations="https://cdn.humanatlas.io/digital-objects/graph/2d-ftu-illustrations/latest/assets/2d-ftu-illustrations.jsonld"
+      selected-illustration={selectedIllustration}
+      illustrations={illustrations}
     />
   );
   
 }

11-13: Is this console logging temporary?

The click handler only logs to the console without any functional logic. If this is temporary debugging code, consider removing it before merging. If you need to implement actual click handling logic, consider what action should be taken.

If you need help implementing click handling logic (e.g., navigation, state updates, or analytics tracking), I can provide suggestions.


34-43: Consider removing the unnecessary class wrapper.

The HubMapSchemaComponent class simply renders the functional component without adding any additional logic. You can export the functional component directly.

♻️ Proposed simplification
-class HubMapSchemaComponent extends Component {
-
-  render() {
-    return (
-      <HubMapSchema />
-    );
-  }
-}
-
-export default HubMapSchemaComponent;  
+export default HubMapSchema;  

Then update the import in src/App.js:

-import HubMapSchemaComponent from './components/Explorer/HubMapSchema';
+import HubMapSchema from './components/Explorer/HubMapSchema';

And the route:

-<Route exact path="/explorer/hubmap" component={HubMapSchemaComponent} />
+<Route exact path="/explorer/hubmap" component={HubMapSchema} />
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb2bb43 and 1389b91.

📒 Files selected for processing (3)
  • public/index.html
  • src/App.js
  • src/components/Explorer/HubMapSchema.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (20.19.0)
🔇 Additional comments (4)
src/App.js (2)

28-28: LGTM!

The import is correctly structured and follows the established naming conventions in the file.


86-86: Store prop omission is correct.

HubMapSchemaComponent does not use Redux and has no need for store access. The route configuration is appropriate as-is.

src/components/Explorer/HubMapSchema.js (1)

1-1: LGTM!

All imports are correctly specified and utilized in the component.

public/index.html (1)

33-35: Code follows official HRA documentation; SRI consideration is optional hardening.

This implementation matches the official medical-illustration embedding guide from HubMAP's HRA UI repository. However, consider these optional security improvements:

  1. SRI hashes are not documented by HRA but can be added if you require strict integrity verification. Note that this requires manual hash computation and will break if HRA updates the resources (they appear to be continuously deployed without fixed version releases).
  2. A local fallback or bundled copy could improve resilience if cdn.humanatlas.io becomes temporarily unavailable, though this is a design trade-off for external component usage.

If you choose to implement stricter security than the official guidance recommends, document the decision and establish a maintenance process for updating SRI hashes when resources change.

Comment on lines +6 to +20
useEffect(() => {
// Manually attach event listeners or call imperative methods if needed
const element = ref.current;
if (!element) return;

const handleClick = (event) => {
console.log('HubMapSchema clicked', event.explicitOriginalTarget.id);
};

element.addEventListener('click', handleClick);

return () => {
element.removeEventListener('click', handleClick);
};
}, []);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical browser compatibility issue: explicitOriginalTarget is Firefox-only.

Line 12 uses event.explicitOriginalTarget, which is a non-standard Firefox-only property. This will cause runtime errors in Chrome, Safari, and Edge browsers where this property is undefined.

🔧 Proposed fix for cross-browser compatibility
     const handleClick = (event) => {
-      console.log('HubMapSchema clicked', event.explicitOriginalTarget.id);
+      console.log('HubMapSchema clicked', event.target.id);
     };

Alternatively, if you need to access the original target within a shadow DOM:

     const handleClick = (event) => {
-      console.log('HubMapSchema clicked', event.explicitOriginalTarget.id);
+      const target = event.composedPath?.()?.[0] || event.target;
+      console.log('HubMapSchema clicked', target.id);
     };

@rlreamy rlreamy closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant