Skip to content

Commit

Permalink
fix(kconfig): remove kong version from kconfig.js
Browse files Browse the repository at this point in the history
  • Loading branch information
raoxiaoyan committed Nov 16, 2023
1 parent 8f47d3d commit df7d180
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/components/MakeAWish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useI18n } from '@/composables/useI18n'
import { config } from 'config'
import { useInfoStore } from '@/stores/info'
const route = useRoute()
const { t } = useI18n()
const useInfo = useInfoStore()
const mailToUrl = computed(() => `mailto:[email protected]?subject=${t('wish.subject', { title: `${route.meta.title} | Kong Manager OSS@${config.GATEWAY_VERSION}` })}`)
const mailToUrl = computed(() => `mailto:[email protected]?subject=${t('wish.subject', { title: `${route.meta.title} | Kong Manager OSS@${useInfo.kongVersion}` })}`)
</script>

<style scoped lang="scss">
Expand Down
5 changes: 4 additions & 1 deletion src/composables/useDetailGeneralConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { reactive } from 'vue'
import { config } from 'config'
import { useInfoStore } from '@/stores/info'
import type { KongManagerBaseEntityConfig } from '@kong-ui-public/entities-shared'

const useInfo = useInfoStore()

export const useDetailGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: useInfo.kongVersion,
},
apiBaseUrl: config.ADMIN_API_URL,
jsonYamlEnabled: true,
Expand Down
11 changes: 8 additions & 3 deletions src/composables/useDocsLink.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { formatVersion } from '@/utils'
import { config, type GatewayEdition } from 'config'
import { EntityType } from '@/types'
import { computed } from 'vue'
import { useInfoStore } from '@/stores/info'

const useInfo = useInfoStore()
const kongVersion = computed(() => useInfo.kongVersion)

const getVersionInPath = (edition: GatewayEdition) => {
if (!config.GATEWAY_VERSION) {
if (!kongVersion.value) {
return 'latest'
}

return edition === 'enterprise'
// For Enterprise, the version has a pattern of <major>.<minor>.0.x where the 3rd digit
// will always be 0 regardless of the actual patch version
? `${formatVersion(config.GATEWAY_VERSION)}.0.x`
? `${formatVersion(kongVersion.value)}.0.x`
// For OSS, the version has a pattern of <major>.<minor>.x
: `${formatVersion(config.GATEWAY_VERSION)}.x`
: `${formatVersion(kongVersion.value)}.x`
}

export const useDocsLink = (entityType: EntityType) => {
Expand Down
5 changes: 4 additions & 1 deletion src/composables/useFormGeneralConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { reactive } from 'vue'
import { config } from 'config'
import { useInfoStore } from '@/stores/info'
import type { KongManagerBaseFormConfig } from '@kong-ui-public/entities-shared'

const useInfo = useInfoStore()

export const useFormGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: useInfo.kongVersion,
},
apiBaseUrl: config.ADMIN_API_URL,
} as Pick<KongManagerBaseFormConfig, 'app' | 'workspace' | 'gatewayInfo' | 'apiBaseUrl'>)
Expand Down
7 changes: 6 additions & 1 deletion src/composables/useGatewayFeatureSupported.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { computed } from 'vue'
import { useInfoStore } from '@/stores/info'
import { useGatewayFeatureSupported as sharedComposable } from '@kong-ui-public/entities-shared'
import { config } from 'config'

type Arguments = Parameters<typeof sharedComposable>[0]

const useInfo = useInfoStore()
const kongVersion = computed(() => useInfo.kongVersion)

export const useGatewayFeatureSupported = (supportedRange: Arguments['supportedRange']) => {
return sharedComposable({
gatewayInfo: {
edition: config.GATEWAY_EDITION ?? 'community',
version: config.GATEWAY_VERSION ?? '',
version: kongVersion.value ?? '',
},
supportedRange,
})
Expand Down
5 changes: 4 additions & 1 deletion src/composables/useListGeneralConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { reactive } from 'vue'
import { config } from 'config'
import { useInfoStore } from '@/stores/info'
import type { KongManagerBaseTableConfig } from '@kong-ui-public/entities-shared'

const useInfo = useInfoStore()

export const useListGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: useInfo.kongVersion,
},
apiBaseUrl: config.ADMIN_API_URL,
// Kong Gateway OSS only supports exact match and does not support sorting
Expand Down
6 changes: 1 addition & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ export const config = {
return `${window.location.protocol}//${window.location.hostname}:${port}`
},

get GATEWAY_VERSION () {
return getConfig<string | null>('KONG_VERSION', null)
},

get GATEWAY_EDITION () {
return getConfig<GatewayEdition | null>('KONG_EDITION', null)
return getConfig<GatewayEdition | null>('KONG_EDITION', 'community')
},

get ANONYMOUS_REPORTS () {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/overview/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ const infoStore = useInfoStore()
const config = computed(() => ({
...infoStore.infoConfig,
kongVersion: infoStore.kongVersion,
hostname: infoStore.info.hostname,
}))
const version = computed(() => gatewayConfig.GATEWAY_VERSION ? `${formatVersion(gatewayConfig.GATEWAY_VERSION)}.x` : 'latest')
const version = computed(() => config.value.kongVersion ? `${formatVersion(config.value.kongVersion)}.x` : 'latest')
const info = computed(() => {
const guiListeners = config.value.admin_gui_listeners
const nonSslGuiListener = guiListeners?.find?.(listener => !listener.ssl)
Expand All @@ -97,7 +98,7 @@ const info = computed(() => {
},
{
label: t('overview.info.gateway.version'),
value: gatewayConfig.GATEWAY_VERSION,
value: config.value.kongVersion,
},
],
},
Expand Down

0 comments on commit df7d180

Please sign in to comment.