Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Make most of the Vuex store modules namespaced #244

Merged
merged 9 commits into from
Sep 21, 2021

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Sep 19, 2021

Fixes

Related to #205 by @dhruv

Description

This PR moves most of the Vuex store modules from store-modules to store directory. This way, Nuxt creates namespaced modules out of them, which are easier to maintain.

Technical details

To make the transition to namespaced modules more atomic, one large #229 is replaced with #242 and this PR. Also, the filter-store and search-store are left as is because they are tightly coupled, and will be refactored in a later PR.
There are two things that needed to be changed in every store module:

  • namespaced modules require state to be a function that returns the state object, instead of an object
  • namespaced modules require actions to be plain object, so to pass data fetcher services into actions, createAction functions were added. This makes it possible to switch services with mocks when testing.

Tests

Run the tests, and run the app to verify that no error messages appear in the console.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@obulat obulat added 💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Sep 19, 2021
@obulat obulat self-assigned this Sep 19, 2021
@obulat obulat requested a review from a team as a code owner September 19, 2021 05:00
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

Excellent. Tests pass and everything is working. I went through a little manual integration test suite haha, and everything works as it should. What a large amount of work!

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

What's the difference between this PR and #229?

Comment on lines -101 to -109
isReportingBug() {
return this.$store.state.isReportingBug
},
bugReported() {
return this.$store.state.bugReported
},
bugReportFailed() {
return this.$store.state.bugReportFailed
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a curiosity, but why were these not using mapState before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, probably because that was the understanding at the time of writing of this code.

@sarayourfriend
Copy link
Contributor

What's the difference between this PR and #229?

Oh sorry, I should have read the description more closely. Never mind!

# Conflicts:
#	src/components/NotificationBanner.vue
#	src/pages/search.vue
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Looks good to me! Code changes make sense and it tested well locally. Nice refactor!

@obulat obulat merged commit 8e9b7cd into use_map_helpers_in_components Sep 21, 2021
@obulat obulat deleted the namespaced_store branch September 21, 2021 03:47
@obulat obulat mentioned this pull request Sep 21, 2021
7 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants