Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kconfig): remove kong version from kconfig.js #126

Merged
merged 1 commit into from
Nov 17, 2023
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
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,
raoxiaoyan marked this conversation as resolved.
Show resolved Hide resolved
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
Loading