get doc version from serverVersion

Signed-off-by: andy.lee <andy.lee@suse.com>
This commit is contained in:
andy.lee 2024-11-04 14:16:49 +08:00 committed by Francesco Torchia
parent 541fee0f39
commit ebc14751e7
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393
7 changed files with 30 additions and 21 deletions

View File

@ -1,6 +1,7 @@
<script> <script>
import { Banner } from '@components/Banner'; import { Banner } from '@components/Banner';
import { DOC_LINKS } from '../config/doc-links'; import { DOC } from '../config/doc-links';
import { docLink } from '../utils/feature-flags';
export default { export default {
name: 'HarvesterUpgradeInfo', name: 'HarvesterUpgradeInfo',
@ -20,7 +21,7 @@ export default {
}, },
upgradeLink() { upgradeLink() {
return DOC_LINKS.UPGRADE_URL; return docLink(DOC.UPGRADE_URL, this.$store.getters);
} }
}, },
}; };

View File

@ -10,7 +10,8 @@ import Tip from '@shell/components/Tip';
import { allHash } from '@shell/utils/promise'; import { allHash } from '@shell/utils/promise';
import { NODE } from '@shell/config/types'; import { NODE } from '@shell/config/types';
import { HCI } from '../../types'; import { HCI } from '../../types';
import { DOC_LINKS } from '../../config/doc-links'; import { DOC } from '../../config/doc-links';
import { docLink } from '../../utils/feature-flags';
export default { export default {
name: 'HarvesterEditStorageNetwork', name: 'HarvesterEditStorageNetwork',
@ -87,7 +88,7 @@ export default {
computed: { computed: {
storageNetworkExampleLink() { storageNetworkExampleLink() {
return DOC_LINKS.STORAGE_NETWORK_EXAMPLE; return docLink(DOC.STORAGE_NETWORK_EXAMPLE, this.$store.getters);
}, },
clusterNetworkOptions() { clusterNetworkOptions() {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;

View File

@ -1,12 +1,8 @@
import semver from 'semver'; // suffix of doc link, see utils/feature-flags.js how to get complete doc link
const pkgJson = require('../package.json'); export const DOC = {
CONSOLE_URL: `/host/#remote-console`,
const docVersion = `v${ semver.major(pkgJson.version) }.${ semver.minor(pkgJson.version) }`; RANCHER_INTEGRATION_URL: `/rancher/rancher-integration`,
STORAGE_NETWORK_EXAMPLE: `/advanced/storagenetwork#configuration-example`,
export const DOC_LINKS = { KSMTUNED_MODE: `/host/#ksmtuned-mode`,
CONSOLE_URL: `https://docs.harvesterhci.io/${ docVersion }/host/#remote-console`, UPGRADE_URL: `/upgrade/index`
RANCHER_INTEGRATION_URL: `https://docs.harvesterhci.io/${ docVersion }/rancher/rancher-integration`,
STORAGE_NETWORK_EXAMPLE: `https://docs.harvesterhci.io/${ docVersion }/advanced/storagenetwork#configuration-example`,
KSMTUNED_MODE: `https://docs.harvesterhci.io/${ docVersion }/host/#ksmtuned-mode`,
UPGRADE_URL: `https://docs.harvesterhci.io/${ docVersion }/upgrade/index`
}; };

View File

@ -5,7 +5,8 @@ import UnitInput from '@shell/components/form/UnitInput';
import { RadioGroup } from '@components/Form/Radio'; import { RadioGroup } from '@components/Form/Radio';
import { Checkbox } from '@components/Form/Checkbox'; import { Checkbox } from '@components/Form/Checkbox';
import { HCI } from '../../types'; import { HCI } from '../../types';
import { DOC_LINKS } from '../../config/doc-links'; import { DOC } from '../../config/doc-links';
import { docLink } from '../../utils/feature-flags';
export const ksmtunedMode = [{ export const ksmtunedMode = [{
value: 'standard', value: 'standard',
@ -90,7 +91,7 @@ export default {
}, },
ksmtunedLink() { ksmtunedLink() {
return DOC_LINKS.KSMTUNED_MODE; return docLink(DOC.KSMTUNED_MODE, this.$store.getters);
} }
}, },

View File

@ -8,7 +8,8 @@ import {
import { allHash } from '@shell/utils/promise'; import { allHash } from '@shell/utils/promise';
import metricPoller from '@shell/mixins/metric-poller'; import metricPoller from '@shell/mixins/metric-poller';
import { HCI } from '../types'; import { HCI } from '../types';
import { DOC_LINKS } from '../config/doc-links'; import { DOC } from '../config/doc-links';
import { docLink } from '../utils/feature-flags';
const schema = { const schema = {
id: HCI.HOST, id: HCI.HOST,
@ -166,7 +167,7 @@ export default {
}, },
consoleDocLink() { consoleDocLink() {
return DOC_LINKS.CONSOLE_URL; return docLink(DOC.CONSOLE_URL, this.$store.getters);
} }
}, },
methods: { methods: {

View File

@ -7,7 +7,8 @@ import CommunityLinks from '@shell/components/CommunityLinks';
import { SCHEMA } from '@shell/config/types'; import { SCHEMA } from '@shell/config/types';
import HarvesterSupportBundle from '../../../../dialog/HarvesterSupportBundle'; import HarvesterSupportBundle from '../../../../dialog/HarvesterSupportBundle';
import { HCI } from '../../../../types'; import { HCI } from '../../../../types';
import { DOC_LINKS } from '../../../../config/doc-links'; import { DOC } from '../../../../config/doc-links';
import { docLink } from '../../../../utils/feature-flags';
export default { export default {
components: { components: {
@ -75,7 +76,7 @@ export default {
}, },
rancherIntegrationLink() { rancherIntegrationLink() {
return DOC_LINKS.RANCHER_INTEGRATION_URL; return docLink(DOC.RANCHER_INTEGRATION_URL, this.$store.getters);
}, },
}, },

View File

@ -2,6 +2,14 @@ import semver from 'semver';
import { HCI } from '../types'; import { HCI } from '../types';
import { RELEASE_FEATURES } from '../config/feature-flags'; import { RELEASE_FEATURES } from '../config/feature-flags';
export const docLink = (suffix, getter) => {
const v = serverVersion(getter);
const docVersion = `v${ semver.major(v) }.${ semver.minor(v) }`;
return `https://docs.harvesterhci.io/${ docVersion }${ suffix }`;
};
export function serverVersion(getters) { export function serverVersion(getters) {
// e.g v1.4.0 // e.g v1.4.0
if (process.env.VUE_APP_SERVER_VERSION) { if (process.env.VUE_APP_SERVER_VERSION) {