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

Transform addons reducer/actions/action creators into a ducks module #3025

Merged
merged 1 commit into from Aug 30, 2017
Merged

Transform addons reducer/actions/action creators into a ducks module #3025

merged 1 commit into from Aug 30, 2017

Conversation

willdurand
Copy link
Member

@willdurand willdurand commented Aug 29, 2017

Refs mozilla/addons#10708


Edit: fixed by rebase

Current build fails because of a locale test fixed by #3023:

Summary of all failing tests
 FAIL  tests/unit/TestLocalesConfig.js
  ● Locale Config › should have a corresponding ka entry the locale dir in the config

    expect(array).toContain(value)
    
    Expected array:
      ["af", "ar", "ast", "bg", "bn-BD", "ca", "cs", "da", "de", "dbl", "dbr", "dsb", "el", "en-GB", "en-US", "es", "eu", "fa", "fi", "fr", "fy-NL", "ga-IE", "he", "hsb", "hu", "id", "it", "ja", "kab", "ko", "mk", "mn", "ms", "nl", "nb-NO", "nn-NO", "pl", "pt-BR", "pt-PT", "ro", "ru", "sk", "sl", "sq", "sv-SE", "te", "th", "tr", "uk", "ur", "vi", "zh-CN", "zh-TW"]
    To contain value:
      "ka"
      
      at Object.<anonymous> (tests/unit/TestLocalesConfig.js:32:25)
      at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)

import type { AddonType } from 'core/types/addons';


export const FETCH_ADDON = 'FETCH_ADDON';
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a naming pattern for action types btw? poke @tofumatt

Copy link
Contributor

Choose a reason for hiding this comment

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

We have been inconsistent but we want VERB_NOUN so FETCH_ADDON, LOAD_ADDON, etc. makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

FETCH_ADDON to trigger the API call, and LOAD_ADDON to update the state with the API results, is that correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, that's what we want. And when starting things like autocomplete or a search it would probably be START_SEARCH, START_AUTOCOMPLETE

Copy link
Member Author

Choose a reason for hiding this comment

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

wonderful!

Copy link
Contributor

@kumar303 kumar303 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. I just have one small change request.

import { createStubErrorHandler } from 'tests/unit/helpers';

describe('core.actions.addons', () => {

describe(__filename, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this file should just be merged into tests/unit/core/reducers/test_addons.js.

export default function addon(state = initialState, action) {
export default function addon(
state: Object = initialState,
action: Object = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

heh, yeah. I will adjust this when fixing the reducer. I'll also move loadEntities over here but only after bathing it in bleach and renaming it to loadAddons 💥

@kumar303
Copy link
Contributor

Current build fails because of a locale test fixed by #3023

d'oh. I thought that failure was only in my build. It landed so you can merge in master.

@willdurand
Copy link
Member Author

Thanks for the review, this should be ok now.

Copy link
Contributor

@kumar303 kumar303 left a comment

Choose a reason for hiding this comment

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

Looks great

@willdurand willdurand merged commit ab08cc8 into mozilla:master Aug 30, 2017
@willdurand willdurand deleted the reducer-addon branch August 30, 2017 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants