constellation-app / constellation

A graph-focused data visualisation and interactive analysis application.
https://constellation-app.com
Apache License 2.0
385 stars 59 forks source link

Word cloud view fix for no graph #2152

Closed antares1470 closed 1 month ago

antares1470 commented 1 month ago

Prerequisites

Description of the Change

Word Cloud threw an exception if the Generate button was clicked when there was no graph open. Rather than simply alerting the user that a graph needs to be open when the button is clicked, I've instead opted for something similar to Layers View in which with no graph open, the view instead simply displays a message saying that a graph needs to be open in order to use the view.

To do this, I've abstracted the NoGraphPane from the Layers View into the View Framework which enables us to add the same thing for the Word Cloud View. It also enables other views to take advantage, should we decide to include it for other views down the line.

Alternate Designs

I could've simply added a null check where the exception occurred (since it was the graph that was null), but given the view has no use without a graph, I felt it made more sense to prevent use of the view altogether in that case.

I could've added the check, even with the changes I've made, but in theory the trouble code shouldn't ever be able to be executed without a graph now and so adding that check feels redundant.

Why Should This Be In Core?

Fixes a bug in Core

Benefits

View can only be used properly when a graph is open, prevents use when no graph is open. Abstraction enables potential use of NoGraphPane for other views

Possible Drawbacks

Verification Process

  1. Open Word Cloud View without a graph open
  2. Open a graph and verify the word cloud view can now be used
  3. Close the graph and verify it goes back to displaying the message.
  4. Can also run checks with Word Cloud View in focus/not in focus, close and open view, multiple graphs, etc.
  5. Do a similar thing with Layers View to verify it still runs as expected

Applicable Issues

2130

sonarcloud[bot] commented 1 month ago

Quality Gate Failed Quality Gate failed

Failed conditions
21.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud