Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store Refactor (Draft) #231

Closed
6 tasks done
jarmoza opened this issue Nov 23, 2022 · 4 comments
Closed
6 tasks done

Store Refactor (Draft) #231

jarmoza opened this issue Nov 23, 2022 · 4 comments
Labels
data store Epic A collection of issues that are related by topic and can be addressed together. flag:discuss Flag issue that needs to be discussed before it can be implemented. refactor Simplifying or restructuring existing code or documentation.

Comments

@jarmoza
Copy link
Contributor

jarmoza commented Nov 23, 2022

We're (mostly) done with refactoring individual components. Now we want to find overlap in the getters and mutations that the components expect to access in the store, so that we can reuse these store methods as much as possible. We would like to reuse them so much, that we will consider small refactors of components to allow them to reuse an existing getter/mutation instead of needing a custom one (within reason).

This Epic is a place to track the work and to have some discussion about the overall approach.

Codeshare for our original I/O store refactor spec'ing: https://codeshare.io/r9WllY

@jarmoza
Copy link
Contributor Author

jarmoza commented Nov 23, 2022

Summary

  1. new action alterColumnCategoryRelation
  2. former actions changed to mutations linkColumnWithCategory and unlinkColumnFromCategory

Description

The table click functionality of the column-linking-table used to emit click data back up to the categorization page, which would in turn use conditional logic to determine if a column should be linked with a category or unlinked.

This occurred via the actions linkColumnWithCategory and unlinkColumnFromCategory.

// 1. Link or unlink the currently-selected category and the clicked column
if ( this.selectedCategory !== this.columnToCategoryMap[p_row.column] ) {
    this.linkColumnWithCategory({...dataForStore, category: this.selectedCategory});
} else {
    this.unlinkColumnFromCategory(dataForStore);
}

This logic will now be relocated to the store via overarching action alterColumnCategoryRelation that was introduced in #230. linkColumnWithCategory and unlinkColumnFromCategory should now become mutations that directly manipulate the columnToCategoryMap in the store.

@jarmoza
Copy link
Contributor Author

jarmoza commented Nov 23, 2022

Summary

  1. new store getter columns, a list of objects that contain a column name and column description (empty string if none) parsed from the dataTable and dataDictionary
  2. Removal of columns list in the dataTable store field

Description

In order to produce the table rows of the column-linking-table, a function located in the categorization page setupColumnToCategoryTable was run and its return value passed to the column-linking-table as prop.

Instead, the refactored column-linking-table now utilizes a new store getters columns (which parses this information, name and description of each column from the dataTable and dataDictionary store fields). See computed tableRows in column-linking-table for how it is being used (#230).

@jarmoza
Copy link
Contributor Author

jarmoza commented Nov 25, 2022

The functions below were removed from the categorization page relating to the categ-tool-group component. Depending on what we end up doing with that component and its functionality, these functions may be need to moved to the store and/or altered.

            removeToolGroup(p_toolGroupData) {

                // Remove this tool group from the store
                this.$store.dispatch("removeToolGroup", p_toolGroupData);
            },

            saveNewToolGroup(p_toolGroupData) {

                // Create this new tool group in the store
                this.$store.dispatch("createToolGroup", p_toolGroupData);
            },

            setSelectedCategory(p_clickData) {

                // Save the name of the selected category
                this.selectedCategory = p_clickData.category;
            },

            toolGroupAction(p_event) {

                // Create, modify, or remove this tool group in the store
                this.$store.dispatch(p_event.action, p_event.data);
            }

@surchs surchs added feature:enhancement refactor Simplifying or restructuring existing code or documentation. Epic A collection of issues that are related by topic and can be addressed together. flag:discuss Flag issue that needs to be discussed before it can be implemented. and removed improvement labels Nov 28, 2022
@surchs surchs moved this from Inbox to Backlog in Neurobagel Nov 28, 2022
@surchs surchs moved this from Backlog to Ready in Neurobagel Dec 13, 2022
@surchs
Copy link
Contributor

surchs commented Dec 13, 2022

Hey @jarmoza and @rmanaem: we have our sketch of the store refactor from the miro board. Now we should implement what's on the board as state variables, mutations, and getters in the store. Ideally we can do this in very small and easy to understand increments, maybe even one mutation/getter/action/variable at a time.

One problem will be (I think) that the end-to-end tests will continue failing until we have successfully stitched everything back together. That's a bit too wobbly for my taste - if a mutation is bugged, we'd ideally catch that right away. One answer is to use unit tests for the store methods (see #250) - and I think we should do that. Another (parallel) idea might be to figure out partial e2e tests that might already work even though the rest of the app is still broken (e.g. getting up to the categorization page, even though annotation is still broken). @jarmoza: any idea how feasible this might be?

Let's collect some thoughts here on:

  • how to break up the work on the miro board into (ideally) independent chunks
  • how to assure that new / refactored code works, even though the whole app is still broken (testing)

and then discuss

@surchs surchs moved this from Ready to Doing in Neurobagel Dec 14, 2022
@surchs surchs moved this from Doing to Review in Neurobagel Dec 15, 2022
@surchs surchs closed this as completed Dec 20, 2022
Repository owner moved this from Review to Done in Neurobagel Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data store Epic A collection of issues that are related by topic and can be addressed together. flag:discuss Flag issue that needs to be discussed before it can be implemented. refactor Simplifying or restructuring existing code or documentation.
Projects
Archived in project
Development

No branches or pull requests

2 participants