mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
ui: prevent same string docHelp override (#5014)
Prevent same string docHelp suffix override. List all existing docHelp suffixes in the config file during the build process. Updated apache/cloudstack-documentation#199 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
493d6a08d2
commit
4ecef4bfb4
@ -24,9 +24,11 @@
|
||||
"url": "https://github.com/apache/cloudstack/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"prebuild": "./prebuild.sh",
|
||||
"start": "vue-cli-service lint --no-fix && vue-cli-service serve",
|
||||
"serve": "vue-cli-service lint --no-fix && vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"postbuild": "./postbuild.sh",
|
||||
"lint": "vue-cli-service lint",
|
||||
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
|
||||
"test:unit": "vue-cli-service test:unit"
|
||||
|
||||
36
ui/postbuild.sh
Executable file
36
ui/postbuild.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
DIR=$(dirname $0)
|
||||
configFile="$DIR/public/config.json"
|
||||
tmpFile="$DIR/public/config.json.tmp"
|
||||
echo "Post-build: removing all docHelp suffixes in ${configFile}"
|
||||
|
||||
node > ${tmpFile} <<EOF
|
||||
// Read config
|
||||
var data = require('${configFile}');
|
||||
|
||||
// Clear docHelpMappings
|
||||
data.docHelpMappings = {};
|
||||
|
||||
// Output config
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
|
||||
EOF
|
||||
|
||||
mv ${tmpFile} ${configFile}
|
||||
47
ui/prebuild.sh
Executable file
47
ui/prebuild.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
DIR=$(dirname $0)
|
||||
configFile="$DIR/public/config.json"
|
||||
tmpFile="$DIR/public/config.json.tmp"
|
||||
echo "Pre-build: list all docHelp suffixes in ${configFile}"
|
||||
for m in $(grep "docHelp: '" -R ./src | sed "s/^.*: '//g" | sed "s/',//g" | sort | uniq); do
|
||||
docHelpMappings+="${m},"
|
||||
done;
|
||||
|
||||
node > ${tmpFile} <<EOF
|
||||
// Read config
|
||||
var data = require('${configFile}');
|
||||
|
||||
// Add docHelpMappings
|
||||
var suffixes = '${docHelpMappings}';
|
||||
suffixes = suffixes.split(',');
|
||||
var mappings = {}
|
||||
for (const suffix of suffixes) {
|
||||
if (suffix) {
|
||||
mappings[suffix] = suffix;
|
||||
}
|
||||
}
|
||||
data.docHelpMappings = mappings;
|
||||
|
||||
// Output config
|
||||
console.log(JSON.stringify(data, null, 2));
|
||||
|
||||
EOF
|
||||
|
||||
mv ${tmpFile} ${configFile}
|
||||
6
ui/public/config.json
vendored
6
ui/public/config.json
vendored
@ -6,8 +6,8 @@
|
||||
"logo": "assets/logo.svg",
|
||||
"banner": "assets/banner.svg",
|
||||
"error": {
|
||||
"404": "assets/404.png",
|
||||
"403": "assets/403.png",
|
||||
"404": "assets/404.png",
|
||||
"500": "assets/500.png"
|
||||
},
|
||||
"theme": {
|
||||
@ -46,7 +46,7 @@
|
||||
"jp": "label.japanese.keyboard",
|
||||
"sc": "label.simplified.chinese.keyboard"
|
||||
},
|
||||
"docHelpMappings": {},
|
||||
"plugins": [],
|
||||
"basicZoneEnabled": true
|
||||
"basicZoneEnabled": true,
|
||||
"docHelpMappings": {}
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ export const configUtilPlugin = {
|
||||
if (docHelp && docHelpMappings &&
|
||||
docHelpMappings.constructor === Object && Object.keys(docHelpMappings).length > 0) {
|
||||
for (var key in docHelpMappings) {
|
||||
if (docHelp.includes(key)) {
|
||||
if (docHelp.includes(key) && docHelp !== docHelpMappings[key]) {
|
||||
docHelp = docHelp.replace(key, docHelpMappings[key])
|
||||
break
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user