diff --git a/src/core/plugins/deep-linking/index.js b/src/core/plugins/deep-linking/index.js new file mode 100644 index 00000000..8cec4dd5 --- /dev/null +++ b/src/core/plugins/deep-linking/index.js @@ -0,0 +1,18 @@ +// import reducers from "./reducers" +// import * as actions from "./actions" +// import * as selectors from "./selectors" +import * as specWrapActions from "./spec-wrap-actions" +import * as layoutWrapActions from "./layout-wrap-actions" + +export default function() { + return { + statePlugins: { + spec: { + wrapActions: specWrapActions + }, + layout: { + wrapActions: layoutWrapActions + } + } + } +} diff --git a/src/core/plugins/deep-linking/layout-wrap-actions.js b/src/core/plugins/deep-linking/layout-wrap-actions.js new file mode 100644 index 00000000..39a2c8e8 --- /dev/null +++ b/src/core/plugins/deep-linking/layout-wrap-actions.js @@ -0,0 +1,28 @@ +export const show = (ori, system) => (...args) => { + ori(...args) + try { + let [thing, shown] = args + let [type] = thing + + if(type === "operations-tag" || type === "operations") { + if(!shown) { + return window.location.hash = "" + } + + if(type === "operations") { + let [, operationId, tag] = thing + window.location.hash = `/${tag}/${operationId}` + } + + if(type === "operations-tag") { + let [, tag] = thing + window.location.hash = `/${tag}` + } + } + + } catch(e) { + // This functionality is not mission critical, so if something goes wrong + // we'll just move on + console.error(e) + } +} diff --git a/src/core/plugins/deep-linking/spec-wrap-actions.js b/src/core/plugins/deep-linking/spec-wrap-actions.js new file mode 100644 index 00000000..e69de29b diff --git a/src/core/presets/base.js b/src/core/presets/base.js index d5471791..0043b543 100644 --- a/src/core/presets/base.js +++ b/src/core/presets/base.js @@ -10,6 +10,7 @@ import auth from "core/plugins/auth" import util from "core/plugins/util" import SplitPaneModePlugin from "core/plugins/split-pane-mode" import downloadUrlPlugin from "core/plugins/download-url" +import deepLinkingPlugin from "core/plugins/deep-linking" import App from "core/components/app" import AuthorizationPopup from "core/components/auth/authorization-popup" @@ -131,6 +132,7 @@ export default function() { auth, ast, SplitPaneModePlugin, - downloadUrlPlugin + downloadUrlPlugin, + deepLinkingPlugin ] }