Skip to content

Commit

Permalink
feat(plugin-select): enable scrolling to anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
TT1228 committed Dec 26, 2024
1 parent eafcd5d commit 994e0f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const konnectConfig = ref<KonnectPluginSelectConfig>({
control_plane_id: controlPlaneId.value,
plugin,
},
query: {
cancelRoute: JSON.stringify({
name: 'select-plugin',
query: {
anchor: plugin,
},
}),
},
}),
// custom plugins
createCustomRoute: { name: 'create-custom-plugin' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ import type { Tab } from '@kong/kongponents'
import type { AxiosError, AxiosResponse } from 'axios'
import { marked, type MarkedOptions } from 'marked'
import { computed, onBeforeMount, reactive, ref, watch, type PropType } from 'vue'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import composables from '../composables'
import { CREDENTIAL_METADATA, CREDENTIAL_SCHEMAS, PLUGIN_METADATA } from '../definitions/metadata'
import { ArrayInputFieldSchema } from '../definitions/schemas/ArrayInputFieldSchema'
Expand Down Expand Up @@ -276,6 +276,7 @@ const props = defineProps({
})
const router = useRouter()
const route = useRoute()
const { i18n: { t } } = composables.useI18n()
const { customSchemas, typedefs } = composables.useSchemas({ app: props.config.app, credential: props.credential })
const { formatPluginFieldLabel } = composables.usePluginHelpers()
Expand Down Expand Up @@ -1101,7 +1102,10 @@ watch([entityMap, initialized], (newData, oldData) => {
* ---------------
*/
const handleClickCancel = (): void => {
if (props.config.cancelRoute) {
if (route.query.cancelRoute) {
const cancelRoute = JSON.parse(route.query.cancelRoute as string)
router.push(cancelRoute)
} else if (props.config.cancelRoute) {
router.push(props.config.cancelRoute)
} else {
emit('cancel')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</template>

<script setup lang="ts">
import { computed, ref, watch, onBeforeMount, onMounted, type PropType } from 'vue'
import { computed, ref, watch, onBeforeMount, onMounted, type PropType, nextTick } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
PluginGroup,
Expand Down Expand Up @@ -525,6 +525,15 @@ onMounted(async () => {
}
isLoading.value = false
nextTick(() => {
if (route.query.anchor) {
const card = document.getElementById(route.query.anchor as string)
if (card) {
card.scrollIntoView()
}
}
})
})
</script>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="plugin-select-card-wrapper">
<div
:id="plugin.id"
class="plugin-select-card-wrapper"
>
<KTooltip :text="plugin.disabledMessage">
<a
class="plugin-select-card"
Expand Down

0 comments on commit 994e0f6

Please sign in to comment.