Update URL fragment when operations & tags are shown or hidden
This commit is contained in:
18
src/core/plugins/deep-linking/index.js
Normal file
18
src/core/plugins/deep-linking/index.js
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/core/plugins/deep-linking/layout-wrap-actions.js
Normal file
28
src/core/plugins/deep-linking/layout-wrap-actions.js
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
0
src/core/plugins/deep-linking/spec-wrap-actions.js
Normal file
0
src/core/plugins/deep-linking/spec-wrap-actions.js
Normal file
Reference in New Issue
Block a user