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-select): enable scrolling to anchor #1875

Closed
wants to merge 2 commits into from
Closed
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
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
Loading