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

feat(plugin): support ordering #82

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"stylelint": "stylelint --allow-empty-input 'src/**/*.{css,scss,sass,less,styl,vue}'",
"postinstall": "husky install"
},
"license": "Apache-2.0",
"lint-staged": {
"src/**/*.{ts,js,vue}": "eslint --fix",
"src/**/*.{css,scss,sass,less,styl,vue}": "stylelint --allow-empty-input --fix 'src/**/*.{css,scss,sass,less,styl,vue}'"
Expand Down
4 changes: 4 additions & 0 deletions src/assets/icon-descendent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/composables/useDocsLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { computed } from 'vue'
import { formatVersion } from '@/utils'
import { config } from 'config'

export const useDocsLink = (entity: string) => {
export const useDocsLink = (entity?: string) => {
const version = computed(() => {
if (!config.GATEWAY_VERSION) {
return 'latest'
Expand All @@ -11,15 +11,15 @@ export const useDocsLink = (entity: string) => {
return `${formatVersion(config.GATEWAY_VERSION)}.x`
})

const docsBase = computed(() => `https://docs.konghq.com/gateway/${version.value}/admin-api`)
const docsBase = computed(() => `https://docs.konghq.com/gateway/${version.value}`)
const docsLink = computed(() => {
switch (entity) {
case 'key-set':
return `${docsBase.value}/#key-sets-entity`
return `${docsBase.value}/admin-api/#key-sets-entity`
default:
return `${docsBase.value}/#${entity}-object`
return `${docsBase.value}/admin-api/#${entity}-object`
}
})

return docsLink
return { docsBase, docsLink }
}
20 changes: 18 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"back": "Back",
"edit": "Edit",
"save": "Save",
"create": "Create"
"create": "Create",
"update": "Update",
"cancel": "Cancel"
},
"learn.more": "Learn more"
},
Expand Down Expand Up @@ -123,7 +125,21 @@
"disabled": "Plugin {name} is successfully disabled!",
"list.title": "Plugins",
"create.form.title": "New Plugin",
"edit.form.title": "Edit Plugin"
"edit.form.title": "Edit Plugin",
"ordering.title": "Ordering",
"ordering.disabled": "Consumer-scoped plugins don't support dynamic ordering",
"doc.dynamic": "Dynamic plugin ordering - {docLink}",
"doc.default": "Default plugin execution order - {docLink}",
"empty.ordering.title": "No dynamic ordering applied",
"empty.ordering.cta.text": "Add ordering to override the static priority for Plugin execution",
"empty.ordering.cta.button": "Add ordering",
"ordering.plugin.label": "Plugin {index}",
"ordering.add.plugin": "Add Plugin",
"ordering.before.label": "Before access",
"ordering.before.desc": "Dynamic plugin ordering for 'before.access' phase",
"ordering.after.label": "After access",
"ordering.after.desc": "Dynamic plugin ordering for 'after.access' phase",
"ordering.updated": "Plugin ordering successfully updated"
},
"upstream": {
"description": "An Upstream represents a virtual hostname and can be used to load balance incoming requests over multiple Services.",
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ca-certificates/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defineOptions({
const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const { t } = useI18n()
const docsLink = useDocsLink('ca-certificate')
const { docsLink } = useDocsLink('ca-certificate')

const createRoute = computed(() => {
return { name: 'ca-certificate-create' }
Expand All @@ -59,6 +59,8 @@ const caCertificateListConfig = reactive({
createRoute,
getViewRoute,
getEditRoute,
// CA Certificates only support exact match for both CE and EE
isExactMatch: true,
})

const canCreate = async () => true
Expand Down
4 changes: 3 additions & 1 deletion src/pages/certificates/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defineOptions({
const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const { t } = useI18n()
const docsLink = useDocsLink('certificate')
const { docsLink } = useDocsLink('certificate')

const createRoute = computed(() => {
return { name: 'certificate-create' }
Expand All @@ -59,6 +59,8 @@ const certificateListConfig = reactive({
createRoute,
getViewRoute,
getEditRoute,
// Certificates only support exact match for both CE and EE
isExactMatch: true,
})

const canCreate = async () => true
Expand Down
2 changes: 1 addition & 1 deletion src/pages/consumers/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defineOptions({
const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const { t } = useI18n()
const docsLink = useDocsLink('consumer')
const { docsLink } = useDocsLink('consumer')

const createRoute = computed(() => {
return { name: 'consumer-create' }
Expand Down
2 changes: 1 addition & 1 deletion src/pages/key-sets/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defineOptions({
const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const { t } = useI18n()
const docsLink = useDocsLink('key-set')
const { docsLink } = useDocsLink('key-set')

const filterSchema = computed<FilterSchema>(() => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/keys/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const route = useRoute()
const { t } = useI18n()
const docsLink = useDocsLink('keys')
const { docsLink } = useDocsLink('keys')

const keySetId = computed(() => (route.params?.id ?? '') as string)
const cacheIdentifier = computed(() => `routes-${keySetId.value}`)
Expand Down
38 changes: 37 additions & 1 deletion src/pages/plugins/Detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,26 @@
}"
/>
</PageHeader>
<KTabs
v-if="isOrderingSupported"
:model-value="initialHash"
:tabs="tabs"
@changed="onTabChange"
>
<template #configuration>
<PluginConfigCard
:config="pluginDetailConfig"
:scoped-entity-type="entityType"
:scoped-entity-id="entityId"
@copy:success="onCopySuccess"
/>
</template>
<template #ordering>
<router-view />
</template>
</KTabs>
<PluginConfigCard
v-else
:config="pluginDetailConfig"
:scoped-entity-type="entityType"
:scoped-entity-id="entityId"
Expand All @@ -35,13 +54,30 @@ import { useRoute } from 'vue-router'
import { PluginConfigCard, PluginIcon } from '@kong-ui-public/entities-plugins'
import { useDetailGeneralConfig } from '@/composables/useDetailGeneralConfig'
import { useCopyEventHandlers } from '@/composables/useCopyEventHandlers'
import { useGatewayFeatureSupported } from '@/composables/useGatewayFeatureSupported'
import { useI18n } from '@/composables/useI18n'
import { useTabs } from '@/composables/useTabs'
import { pluginMeta } from '@/pages/plugins/PluginMeta'

defineOptions({
name: 'PluginDetail',
})

// Plugin ordering is supported in Kong Gateway Enterprise 3.0
const isOrderingSupported = useGatewayFeatureSupported({
enterprise: ['3.0'],
})
const { kongponentTabs: tabs, initialHash, onTabChange } = useTabs([
{
title: 'Configuration',
route: { name: 'plugin-detail' },
},
{
title: 'Ordering',
route: { name: 'plugin-ordering' },
},
])

const route = useRoute()
const { t } = useI18n()

Expand All @@ -54,7 +90,7 @@ const entityType = computed(() => {

return `${(route.query?.entity_type as string).split('_')[0]}s`
})
const entityId = computed(() => route.query?.entity_id)
const entityId = computed(() => (route.query?.entity_id ?? '') as string)

const pluginDetailConfig = reactive({
...useDetailGeneralConfig(),
Expand Down
18 changes: 16 additions & 2 deletions src/pages/plugins/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defineOptions({
const { createRedirectRouteQuery } = useListRedirect()
const toaster = useToaster()
const { t } = useI18n()
const docsLink = useDocsLink('plugin')
const { docsLink } = useDocsLink('plugin')
const route = useRoute()
const cacheIdentifier = computed(() => `plugins-${route.params?.id}`)
const entityType = computed(() => route.meta?.scopedIn as EntityType)
Expand Down Expand Up @@ -97,6 +97,20 @@ const getViewRoute = (plugin: Pick<EntityRow, 'id' | 'name'>) => {
}
}

const getConfigureDynamicOrderingRoute = (plugin: Pick<EntityRow, 'id' | 'name'>) => {
return {
name: 'plugin-ordering',
params: {
id: plugin.id,
pluginType: plugin.name,
},
query: {
...scopedQuery.value,
...createRedirectRouteQuery(),
},
}
}

const getEditRoute = (plugin: EntityRow) => ({
name: 'plugin-edit',
params: {
Expand Down Expand Up @@ -130,7 +144,7 @@ const pluginListConfig = reactive({
getViewRoute,
getEditRoute,
getScopedEntityViewRoute,
getConfigureDynamicOrderingRoute: getViewRoute,
getConfigureDynamicOrderingRoute,
filterSchema,
})

Expand Down
Loading
Loading