summaryrefslogtreecommitdiffstats
path: root/devtools/client/application/src/actions
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/application/src/actions')
-rw-r--r--devtools/client/application/src/actions/index.js12
-rw-r--r--devtools/client/application/src/actions/manifest.js48
-rw-r--r--devtools/client/application/src/actions/moz.build11
-rw-r--r--devtools/client/application/src/actions/page.js18
-rw-r--r--devtools/client/application/src/actions/ui.js20
-rw-r--r--devtools/client/application/src/actions/workers.js51
6 files changed, 160 insertions, 0 deletions
diff --git a/devtools/client/application/src/actions/index.js b/devtools/client/application/src/actions/index.js
new file mode 100644
index 0000000000..734cebc0c6
--- /dev/null
+++ b/devtools/client/application/src/actions/index.js
@@ -0,0 +1,12 @@
+/* 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 workers = require("devtools/client/application/src/actions/workers");
+const page = require("devtools/client/application/src/actions/page");
+const ui = require("devtools/client/application/src/actions/ui");
+const manifest = require("devtools/client/application/src/actions/manifest");
+
+Object.assign(exports, workers, page, ui, manifest);
diff --git a/devtools/client/application/src/actions/manifest.js b/devtools/client/application/src/actions/manifest.js
new file mode 100644
index 0000000000..6ff2cb7b5d
--- /dev/null
+++ b/devtools/client/application/src/actions/manifest.js
@@ -0,0 +1,48 @@
+/* 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 { l10n } = require("devtools/client/application/src/modules/l10n");
+
+const {
+ services,
+ ManifestDevToolsError,
+} = require("devtools/client/application/src/modules/application-services");
+const {
+ FETCH_MANIFEST_FAILURE,
+ FETCH_MANIFEST_START,
+ FETCH_MANIFEST_SUCCESS,
+ RESET_MANIFEST,
+} = require("devtools/client/application/src/constants");
+
+function fetchManifest() {
+ return async ({ dispatch, getState }) => {
+ dispatch({ type: FETCH_MANIFEST_START });
+ try {
+ const manifest = await services.fetchManifest();
+ dispatch({ type: FETCH_MANIFEST_SUCCESS, manifest });
+ } catch (error) {
+ let errorMessage = error.message;
+
+ // since Firefox DevTools errors may not make sense for the user, swap
+ // their message for a generic one.
+ if (error instanceof ManifestDevToolsError) {
+ console.error(error);
+ errorMessage = l10n.getString("manifest-loaded-devtools-error");
+ }
+
+ dispatch({ type: FETCH_MANIFEST_FAILURE, error: errorMessage });
+ }
+ };
+}
+
+function resetManifest() {
+ return { type: RESET_MANIFEST };
+}
+
+module.exports = {
+ fetchManifest,
+ resetManifest,
+};
diff --git a/devtools/client/application/src/actions/moz.build b/devtools/client/application/src/actions/moz.build
new file mode 100644
index 0000000000..f2a41f8674
--- /dev/null
+++ b/devtools/client/application/src/actions/moz.build
@@ -0,0 +1,11 @@
+# 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/.
+
+DevToolsModules(
+ "index.js",
+ "manifest.js",
+ "page.js",
+ "ui.js",
+ "workers.js",
+)
diff --git a/devtools/client/application/src/actions/page.js b/devtools/client/application/src/actions/page.js
new file mode 100644
index 0000000000..07e68659a3
--- /dev/null
+++ b/devtools/client/application/src/actions/page.js
@@ -0,0 +1,18 @@
+/* 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_DOMAIN } = require("devtools/client/application/src/constants");
+
+function updateDomain(url) {
+ return {
+ type: UPDATE_DOMAIN,
+ url,
+ };
+}
+
+module.exports = {
+ updateDomain,
+};
diff --git a/devtools/client/application/src/actions/ui.js b/devtools/client/application/src/actions/ui.js
new file mode 100644
index 0000000000..2e1578374a
--- /dev/null
+++ b/devtools/client/application/src/actions/ui.js
@@ -0,0 +1,20 @@
+/* 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_SELECTED_PAGE,
+} = require("devtools/client/application/src/constants");
+
+function updateSelectedPage(selectedPage) {
+ return {
+ type: UPDATE_SELECTED_PAGE,
+ selectedPage,
+ };
+}
+
+module.exports = {
+ updateSelectedPage,
+};
diff --git a/devtools/client/application/src/actions/workers.js b/devtools/client/application/src/actions/workers.js
new file mode 100644
index 0000000000..57cbf2e70b
--- /dev/null
+++ b/devtools/client/application/src/actions/workers.js
@@ -0,0 +1,51 @@
+/* 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 {
+ START_WORKER,
+ UNREGISTER_WORKER,
+ UPDATE_CAN_DEBUG_WORKERS,
+ UPDATE_WORKERS,
+} = require("devtools/client/application/src/constants");
+
+function startWorker(worker) {
+ const { registrationFront } = worker;
+ registrationFront.start();
+
+ return {
+ type: START_WORKER,
+ };
+}
+
+function unregisterWorker(registration) {
+ const { registrationFront } = registration;
+ registrationFront.unregister();
+
+ return {
+ type: UNREGISTER_WORKER,
+ };
+}
+
+function updateWorkers(workers) {
+ return {
+ type: UPDATE_WORKERS,
+ workers,
+ };
+}
+
+function updateCanDebugWorkers(canDebugWorkers) {
+ return {
+ type: UPDATE_CAN_DEBUG_WORKERS,
+ canDebugWorkers,
+ };
+}
+
+module.exports = {
+ startWorker,
+ unregisterWorker,
+ updateCanDebugWorkers,
+ updateWorkers,
+};