[COMPASS-582] Convert collection store into a proper reflux store with associated actions Created: 20/Dec/16  Updated: 27/Oct/23  Resolved: 13/Oct/20

Status: Closed
Project: Compass
Component/s: Tech debt
Affects Version/s: None
Fix Version/s: No version

Type: Task Priority: Major - P3
Reporter: Satyendra Sinha Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on COMPASS-1347 Consistently call namespaces througho... Closed
Documentation Changes: Not Needed

 Description   

The standard reflux pattern is the unidirectional cycle from component to action to store to component.

Currently the collection store (internal-packages/app/stores/collection.js) is not using this reflux pattern properly.

Primary reason to do this ticket are two folds:

  • It is being used less as a store and more of a setter/getter in multiple different places, which breaks the reflux pattern
  • It currently sets the namespace, when it should listen to the namespace store instead (This was a challenge in completing COMPASS-548).

There are two issues here:

  • collection index component sets active tab onto the store, which is accessed in a few different places via getActiveTab, which really isn't a clean pattern. The solution is to add an isActive property to the the tabs to flag whether it is visible/active/displayed or not
  • a collection dump from the instance store is being cached onto this collection store every time a new collection is viewed, only to access the 'readonly' property. The solution is to store instance state in the home store. The collection store gets a list of instance collections every time the home store changes, and sets a readonly status when namespace is a collection.

Here are where the calls are being made:

  • getActiveTab
    • chart-builder
    • chart store
    • schema component
  • setCollection
    • databases-table
    • collections-table
    • sidebar-collection
    • sidebar-database
  • isReadonly
    • collectionStats store
    • document-list
    • compass-explain
    • explain store
    • indexes index-header component
    • indexes component
    • load-indexes store

After this we can either get rid of the collection store or convert it to a proper store that lives in /internal-packages/collections/lib/store



 Comments   
Comment by Satyendra Sinha [ 09/Jul/17 ]

PR attempted to resolve this ticket but it was solving several problems at once and made it difficult to review. So let's split it into separate tickets:

  • COMPASS-1347: So that namespace is used properly
  • COMPASS-1360: So that there is no awkward loop to retrieve the readonly status of a collection
  • COMPASS-1138: So that a particular tabbed component need to peek into the collection store and check against a number to determine whether it is focused or not (This wasn't handled in the above PR but is definitely an improvement to the current design that removes the need for getActiveTab which is one of the problems mentioned in this ticket)

After the above 3 are done explicitly add collection store to the collection package and connect to the component. as done in this and this commit.

You may notice that the above PR funnels the instance store into the home store. This made sense at the time because then the sidebar, collection and collections store all listen to changes in the home store. The changes in the ticket mentioned above can also be done without making these 3 store listen to the home store and listening to the instance store directly but the way it is setup maybe less clean.

Generated at Wed Feb 07 22:25:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.