Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
"url": "https://github.com/apache/cloudstack/issues"
},
"scripts": {
"prebuild": "./prebuild.sh",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shwstppr could relative paths cause any issue? For ex. break in deb/rpm builds?

Copy link
Copy Markdown
Contributor Author

@shwstppr shwstppr May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhtyd package.json file already have relative paths at line 33. Also, I'm not sure how to get absolute path in this case

"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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shwstppr could relative paths cause any issue? For ex. break in deb/rpm builds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json file already have relative paths at line 33. Also, I'm not sure how to get absolute path in this case

"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"
Expand Down
36 changes: 36 additions & 0 deletions ui/postbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
Comment thread
shwstppr marked this conversation as resolved.
# 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 changes: 47 additions & 0 deletions ui/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
Comment thread
shwstppr marked this conversation as resolved.
# 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 changes: 3 additions & 3 deletions ui/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"jp": "label.japanese.keyboard",
"sc": "label.simplified.chinese.keyboard"
},
"docHelpMappings": {},
"plugins": [],
"basicZoneEnabled": true
"basicZoneEnabled": true,
"docHelpMappings": {}
}
2 changes: 1 addition & 1 deletion ui/src/utils/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down