-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): update entity docs link (#89)
* chore(*): update entity docs link * chore(*): use EntityType * chore(*): remove computed
- Loading branch information
1 parent
7fe9172
commit e424786
Showing
14 changed files
with
74 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,41 @@ | ||
import { computed } from 'vue' | ||
import { formatVersion } from '@/utils' | ||
import { config } from 'config' | ||
import { config, type GatewayEdition } from 'config' | ||
import { EntityType } from '@/types' | ||
|
||
export const useDocsLink = (entity: string) => { | ||
const version = computed(() => { | ||
if (!config.GATEWAY_VERSION) { | ||
return 'latest' | ||
} | ||
const getVersionInPath = (edition: GatewayEdition) => { | ||
if (!config.GATEWAY_VERSION) { | ||
return 'latest' | ||
} | ||
|
||
return `${formatVersion(config.GATEWAY_VERSION)}.x` | ||
}) | ||
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` | ||
// For OSS, the version has a pattern of <major>.<minor>.x | ||
: `${formatVersion(config.GATEWAY_VERSION)}.x` | ||
} | ||
|
||
export const useDocsLink = (entityType: EntityType) => { | ||
const edition = config.GATEWAY_EDITION ?? 'community' | ||
const versionInPath = getVersionInPath(edition) | ||
const docsBase = `https://docs.konghq.com/gateway/api/admin-${edition === 'enterprise' ? 'ee' : 'oss'}/${versionInPath}/#/` | ||
|
||
const docsBase = computed(() => `https://docs.konghq.com/gateway/${version.value}/admin-api`) | ||
const docsLink = computed(() => { | ||
switch (entity) { | ||
case 'key-set': | ||
return `${docsBase.value}/#key-sets-entity` | ||
default: | ||
return `${docsBase.value}/#${entity}-object` | ||
} | ||
}) | ||
const entityTypeToSpecLinkMap = { | ||
[EntityType.GatewayService]: 'Services', | ||
[EntityType.Route]: 'Routes', | ||
[EntityType.Consumer]: 'Consumers', | ||
[EntityType.ConsumerGroup]: 'consumer_groups', | ||
[EntityType.Plugin]: 'Plugins', | ||
[EntityType.Upstream]: 'Upstreams', | ||
[EntityType.Certificate]: 'Certificates', | ||
[EntityType.CACertificate]: 'CA Certificates', | ||
[EntityType.SNI]: 'SNIs', | ||
[EntityType.Key]: 'Keys', | ||
[EntityType.KeySet]: 'Key-sets', | ||
[EntityType.Target]: 'Targets', | ||
[EntityType.Vault]: 'Vaults', | ||
} | ||
const docsLink = `${docsBase}${entityTypeToSpecLinkMap[entityType] ?? ''}` | ||
|
||
return docsLink | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export enum EntityType { | ||
GatewayService = 1, | ||
Route, | ||
Consumer, | ||
ConsumerGroup, | ||
Plugin, | ||
Upstream, | ||
Certificate, | ||
CACertificate, | ||
SNI, | ||
Key, | ||
KeySet, | ||
Target, | ||
Vault, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './entity' |