mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1566007 - Part 1: Create Redux state/reducers/actions to hold manifest data r=Ola
Differential Revision: https://phabricator.services.mozilla.com/D41973 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cf0604278c
commit
fa01c1cf25
@ -7,5 +7,6 @@
|
||||
const workers = require("./workers");
|
||||
const page = require("./page");
|
||||
const ui = require("./ui");
|
||||
const manifest = require("./manifest");
|
||||
|
||||
Object.assign(exports, workers, page, ui);
|
||||
Object.assign(exports, workers, page, ui, manifest);
|
||||
|
19
devtools/client/application/src/actions/manifest.js
Normal file
19
devtools/client/application/src/actions/manifest.js
Normal file
@ -0,0 +1,19 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { UPDATE_MANIFEST } = require("../constants");
|
||||
|
||||
function updateManifest(manifest, errorMessage) {
|
||||
return {
|
||||
type: UPDATE_MANIFEST,
|
||||
manifest,
|
||||
errorMessage,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateManifest,
|
||||
};
|
@ -4,6 +4,7 @@
|
||||
|
||||
DevToolsModules(
|
||||
'index.js',
|
||||
'manifest.js',
|
||||
'page.js',
|
||||
'ui.js',
|
||||
'workers.js',
|
||||
|
@ -5,6 +5,8 @@
|
||||
"use strict";
|
||||
|
||||
const actionTypes = {
|
||||
// manifest substate
|
||||
UPDATE_MANIFEST: "UPDATE_MANIFEST",
|
||||
// page substate
|
||||
UPDATE_DOMAIN: "UPDATE_DOMAIN",
|
||||
// ui substate
|
||||
|
@ -8,9 +8,11 @@ const { combineReducers } = require("devtools/client/shared/vendor/redux");
|
||||
const { workersReducer } = require("./workers-state");
|
||||
const { pageReducer } = require("./page-state");
|
||||
const { uiReducer } = require("./ui-state");
|
||||
const { manifestReducer } = require("./manifest-state");
|
||||
|
||||
module.exports = combineReducers({
|
||||
workers: workersReducer,
|
||||
manifest: manifestReducer,
|
||||
page: pageReducer,
|
||||
workers: workersReducer,
|
||||
ui: uiReducer,
|
||||
});
|
||||
|
32
devtools/client/application/src/reducers/manifest-state.js
Normal file
32
devtools/client/application/src/reducers/manifest-state.js
Normal file
@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { UPDATE_MANIFEST } = require("../constants");
|
||||
|
||||
function ManifestState() {
|
||||
return {
|
||||
manifest: null,
|
||||
errorMessage: "",
|
||||
};
|
||||
}
|
||||
|
||||
function manifestReducer(state = ManifestState(), action) {
|
||||
switch (action.type) {
|
||||
case UPDATE_MANIFEST:
|
||||
const { manifest, errorMessage } = action;
|
||||
return Object.assign({}, state, {
|
||||
manifest,
|
||||
errorMessage,
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ManifestState,
|
||||
manifestReducer,
|
||||
};
|
@ -4,6 +4,7 @@
|
||||
|
||||
DevToolsModules(
|
||||
'index.js',
|
||||
'manifest-state.js',
|
||||
'page-state.js',
|
||||
'ui-state.js',
|
||||
'workers-state.js',
|
||||
|
@ -0,0 +1,23 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
updateManifest,
|
||||
} = require("devtools/client/application/src/actions/manifest.js");
|
||||
|
||||
const {
|
||||
manifestReducer,
|
||||
ManifestState,
|
||||
} = require("devtools/client/application/src/reducers/manifest-state.js");
|
||||
|
||||
add_task(async function() {
|
||||
info("Test manifest reducer: UPDATE_MANIFEST action");
|
||||
const state = ManifestState();
|
||||
|
||||
const action = updateManifest({ name: "foo" }, "some error");
|
||||
const newState = manifestReducer(state, action);
|
||||
equal(newState.manifest.name, "foo");
|
||||
equal(newState.errorMessage, "some error");
|
||||
});
|
@ -4,6 +4,7 @@ head = xpcshell-head.js
|
||||
firefox-appdir = browser
|
||||
skip-if = toolkit == 'android'
|
||||
|
||||
[test_manifest_reducer.js]
|
||||
[test_page_reducer.js]
|
||||
[test_ui_reducer.js]
|
||||
[test_workers_reducer.js]
|
||||
|
Loading…
Reference in New Issue
Block a user