Skip to content

Commit

Permalink
fix(kconfig): remove kong version from kconfig.js (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
raoxiaoyan authored Nov 17, 2023
1 parent 2c03503 commit b2a5055
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 infoStore = useInfoStore()
const mailToUrl = computed(() => `mailto:wish@konghq.com?subject=${t('wish.subject', { title: `${route.meta.title} | Kong Manager OSS@${config.GATEWAY_VERSION}` })}`)
const mailToUrl = computed(() => `mailto:wish@konghq.com?subject=${t('wish.subject', { title: `${route.meta.title} | Kong Manager OSS@${infoStore.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 infoStore = useInfoStore()

export const useDetailGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: infoStore.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 infoStore = useInfoStore()
const kongVersion = computed(() => infoStore.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 infoStore = useInfoStore()

export const useFormGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: infoStore.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 infoStore = useInfoStore()
const kongVersion = computed(() => infoStore.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 infoStore = useInfoStore()

export const useListGeneralConfig = () => {
return reactive({
app: 'kongManager' as const,
workspace: '',
gatewayInfo: {
edition: config.GATEWAY_EDITION,
version: config.GATEWAY_VERSION,
version: infoStore.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 b2a5055

Please sign in to comment.