mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
ui: allow docHelp override using config.json (#4745)
config.json can have a property named 'docHelpMappings' which can be used to override docHelp suffixes.
In config.json admin can add mappings as follows:
"docHelpMappings": {
"virtual_machine.html": "some.html",
"some_string": "override_string"
}
UI will use these mappings and will make appropriate replacements in the documentation links for different sections and forms.
Addresses #4731
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
dc5b9ec7c8
commit
251368361e
1
ui/public/config.json
vendored
1
ui/public/config.json
vendored
@ -46,5 +46,6 @@
|
|||||||
"jp": "label.japanese.keyboard",
|
"jp": "label.japanese.keyboard",
|
||||||
"sc": "label.simplified.chinese.keyboard"
|
"sc": "label.simplified.chinese.keyboard"
|
||||||
},
|
},
|
||||||
|
"docHelpMappings": {},
|
||||||
"plugins": []
|
"plugins": []
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
execAction (action) {
|
execAction (action) {
|
||||||
action.resource = this.resource
|
action.resource = this.resource
|
||||||
|
if (action.docHelp) {
|
||||||
|
action.docHelp = this.$applyDocHelpMappings(action.docHelp)
|
||||||
|
}
|
||||||
this.$emit('exec-action', action)
|
this.$emit('exec-action', action)
|
||||||
},
|
},
|
||||||
handleShowBadge () {
|
handleShowBadge () {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ function generateRouterMap (section) {
|
|||||||
name: section.name,
|
name: section.name,
|
||||||
path: '/' + section.name,
|
path: '/' + section.name,
|
||||||
hidden: section.hidden,
|
hidden: section.hidden,
|
||||||
meta: { title: section.title, icon: section.icon, docHelp: section.docHelp, searchFilters: section.searchFilters },
|
meta: { title: section.title, icon: section.icon, docHelp: Vue.prototype.$applyDocHelpMappings(section.docHelp), searchFilters: section.searchFilters },
|
||||||
component: RouteView
|
component: RouteView
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ function generateRouterMap (section) {
|
|||||||
title: child.title,
|
title: child.title,
|
||||||
name: child.name,
|
name: child.name,
|
||||||
icon: child.icon,
|
icon: child.icon,
|
||||||
docHelp: child.docHelp,
|
docHelp: Vue.prototype.$applyDocHelpMappings(child.docHelp),
|
||||||
permission: child.permission,
|
permission: child.permission,
|
||||||
resourceType: child.resourceType,
|
resourceType: child.resourceType,
|
||||||
filters: child.filters,
|
filters: child.filters,
|
||||||
@ -85,7 +85,7 @@ function generateRouterMap (section) {
|
|||||||
title: child.title,
|
title: child.title,
|
||||||
name: child.name,
|
name: child.name,
|
||||||
icon: child.icon,
|
icon: child.icon,
|
||||||
docHelp: child.docHelp,
|
docHelp: Vue.prototype.$applyDocHelpMappings(child.docHelp),
|
||||||
permission: child.permission,
|
permission: child.permission,
|
||||||
resourceType: child.resourceType,
|
resourceType: child.resourceType,
|
||||||
params: child.params ? child.params : {},
|
params: child.params ? child.params : {},
|
||||||
@ -140,7 +140,7 @@ function generateRouterMap (section) {
|
|||||||
title: section.title,
|
title: section.title,
|
||||||
name: section.name,
|
name: section.name,
|
||||||
icon: section.icon,
|
icon: section.icon,
|
||||||
docHelp: section.docHelp,
|
docHelp: Vue.prototype.$applyDocHelpMappings(section.docHelp),
|
||||||
hidden: section.hidden,
|
hidden: section.hidden,
|
||||||
permission: section.permission,
|
permission: section.permission,
|
||||||
resourceType: section.resourceType,
|
resourceType: section.resourceType,
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import './core/lazy_use'
|
|||||||
import './core/ext'
|
import './core/ext'
|
||||||
import './permission' // permission control
|
import './permission' // permission control
|
||||||
import './utils/filter' // global filter
|
import './utils/filter' // global filter
|
||||||
import { pollJobPlugin, notifierPlugin, toLocaleDatePlugin } from './utils/plugins'
|
import { pollJobPlugin, notifierPlugin, toLocaleDatePlugin, configUtilPlugin } from './utils/plugins'
|
||||||
import { VueAxios } from './utils/request'
|
import { VueAxios } from './utils/request'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
@ -49,3 +49,5 @@ fetch('config.json').then(response => response.json()).then(config => {
|
|||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Vue.use(configUtilPlugin)
|
||||||
|
|||||||
@ -167,3 +167,21 @@ export const toLocaleDatePlugin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const configUtilPlugin = {
|
||||||
|
install (Vue) {
|
||||||
|
Vue.prototype.$applyDocHelpMappings = function (docHelp) {
|
||||||
|
var docHelpMappings = this.$config.docHelpMappings
|
||||||
|
if (docHelp && docHelpMappings &&
|
||||||
|
docHelpMappings.constructor === Object && Object.keys(docHelpMappings).length > 0) {
|
||||||
|
for (var key in docHelpMappings) {
|
||||||
|
if (docHelp.includes(key)) {
|
||||||
|
docHelp = docHelp.replace(key, docHelpMappings[key])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return docHelp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -21,10 +21,11 @@ import mockRouter from '../mock/mockRouter'
|
|||||||
|
|
||||||
import localVue from '../setup'
|
import localVue from '../setup'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import { pollJobPlugin, notifierPlugin } from '@/utils/plugins'
|
import { pollJobPlugin, notifierPlugin, configUtilPlugin } from '@/utils/plugins'
|
||||||
|
|
||||||
localVue.use(pollJobPlugin)
|
localVue.use(pollJobPlugin)
|
||||||
localVue.use(notifierPlugin)
|
localVue.use(notifierPlugin)
|
||||||
|
localVue.use(configUtilPlugin)
|
||||||
|
|
||||||
function createMockRouter (newRoutes = []) {
|
function createMockRouter (newRoutes = []) {
|
||||||
let routes = []
|
let routes = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user