Add config switch for deep linking
This commit is contained in:
@@ -30,6 +30,7 @@ const CONFIGS = [
|
|||||||
"parameterMacro",
|
"parameterMacro",
|
||||||
"displayOperationId",
|
"displayOperationId",
|
||||||
"displayRequestDuration",
|
"displayRequestDuration",
|
||||||
|
"deepLinking",
|
||||||
]
|
]
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
@@ -61,6 +62,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
custom: {},
|
custom: {},
|
||||||
displayOperationId: false,
|
displayOperationId: false,
|
||||||
displayRequestDuration: false,
|
displayRequestDuration: false,
|
||||||
|
deepLinking: true,
|
||||||
|
|
||||||
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
// Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance.
|
||||||
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
// Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest.
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import { setHash } from "./helpers"
|
import { setHash } from "./helpers"
|
||||||
|
|
||||||
export const show = (ori, system) => (...args) => {
|
export const show = (ori, { getConfigs }) => (...args) => {
|
||||||
ori(...args)
|
ori(...args)
|
||||||
|
|
||||||
|
const isDeepLinkingEnabled = getConfigs().deepLinking
|
||||||
|
if(!isDeepLinkingEnabled || isDeepLinkingEnabled === "false") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let [thing, shown] = args
|
let [thing, shown] = args
|
||||||
let [type] = thing
|
let [type] = thing
|
||||||
|
|||||||
@@ -4,9 +4,14 @@ const SCROLL_OFFSET = -5
|
|||||||
let hasHashBeenParsed = false
|
let hasHashBeenParsed = false
|
||||||
|
|
||||||
|
|
||||||
export const updateResolved = (ori, { layoutActions }) => (...args) => {
|
export const updateResolved = (ori, { layoutActions, getConfigs }) => (...args) => {
|
||||||
ori(...args)
|
ori(...args)
|
||||||
|
|
||||||
|
const isDeepLinkingEnabled = getConfigs().deepLinking
|
||||||
|
if(!isDeepLinkingEnabled || isDeepLinkingEnabled === "false") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(window.location.hash && !hasHashBeenParsed ) {
|
if(window.location.hash && !hasHashBeenParsed ) {
|
||||||
let hash = window.location.hash.slice(1) // # is first character
|
let hash = window.location.hash.slice(1) // # is first character
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user