cbioportal-frontend icon indicating copy to clipboard operation
cbioportal-frontend copied to clipboard

RFC87: add button to load GroupComparison table data in external tool

Open pappde opened this issue 7 months ago • 1 comments

Summary

This PR addresses all requirements for RFC87, which involves conditionally adding a button to the GroupComparison data tables (only visible to relevant users), then launching the external tool with the data.

  • Check if External Tool is installed.
  • Inject button to launch External Tool to data table
  • Launch External Tool with the data
  • Config-Driven: no tool-specific logic.
  • Visualize your Data page (which also checks the config)
  • Configuration for ‘AVM for cBioPortal’ (Windows software for interactive 3D visualization and analysis)

Testing Notes

  • Visualize Your Data page: additional section at bottom
  • If the tool is not installed, then there will be no other visible impact to the website.
  • If the tool is installed, then the button will appear
  • Clicking the button will launch the tool.

With the AVM configuration, the button will only appear on a windows system with the software (and custom font) installed. So there are two ways to test:

  • A) On a Windows system, install the software.
  • B) Enable the 'Test Tool' config

Notable Changes

  • Added module to shared/components/ExternalTools/
  • Added open source utility for checking if a font is installed to …/ExternalTools/utils. Since we can’t check if a URL protocol is supported, we instead use the solution from the specification for checking if a custom font is installed.
  • OPEN-SOURCE-DOCUMENTATION: file updated with note about (modified) code that is used
  • Added icon to …/ExternalTools/images to avoid external dependency
  • CopyDownloadButtons: added buttonsExternalTools() to conditionally render
  • CopyDownloadControls: we pass along the downloadData function. Previously, it was hidden behind handleDownload/handleCopy but the implementation needs access to the actual data.
  • GroupComparisonStore: added functions for caching whether ExternalTool is installed.
  • Sending Data: instead of passing the download path through the URL, we instead use the clipboard. We don’t have access to exactly where the browser downloads the file, or how it names it. The clipboard works well and it can easily hold the data files we are sending (which generally are less than 1.5MB)
  • Clipboard: we use the window.clipboard API. It is supported on all major browsers
  • ExternalTool leverages the fact that the GroupComparisonPage reference is injected into the window. It uses this to: determine the study name, caching the “is installed” check. Unit tests added for ExternalTool
  • IAppConfig: added external_tools[] section

Considerations

Some things to consider that we could update.

  • FontDetector: is the update to OPEN-SOURCE-DOCUMENTATION needed? Is there a more appropriate location for the module itself?
  • Commit Log: we could squash
  • Console.Log: noticed that generally the codebase avoids this, but there are a couple of logs I left in there, specifically when you click the button. That is a rare and important event so it seemed appropriate, but we could remove it.
  • Error Handling: there are a couple of places that console.error(). There is one place where if the launch fails we use alert(). There is precedent in the codebase, but we could use a different reporting mechanism if desired.

Dependent PRs

Commits from some other PRs are redundantly included here. They are not actually dependencies, but that is why some unrelated files will appear in the diffs.

  • PR #4927
  • PR #4932
  • PR #4937

Checks

  • Tests: Added unit tests for ExternalTool. Did not add unit tests for FontDetector since it depends on jest to render the test HTML which wasn’t happening.
  • Commit Log: There are a lot of commits and many in the middle are merely iterative. We could definitely squash - perhaps after review.

Notify reviewers

@alisman, @jjgao

pappde avatar Jul 04 '24 00:07 pappde