Skip to content

Commit

Permalink
fix(*): customize visible plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiarrowood committed Oct 27, 2023
1 parent f34a631 commit 8bc0c93
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:trigger-label="shouldCollapsedCustomPlugins ? triggerLabels[PLUGIN_GROUPS.CUSTOM_PLUGINS] : pluginHelpText.viewLess"
>
<template
v-if="filteredCustomPlugins.length <= PLUGINS_PER_ROW"
v-if="filteredCustomPlugins.length <= pluginsPerRow"
#trigger
>
&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:ignored-plugins="ignoredPlugins"
:no-route-change="noRouteChange"
:only-available-plugins="onlyAvailablePlugins"
:plugins-per-row="pluginsPerRow"
@loading="(val: boolean) => $emit('loading', val)"
@plugin-clicked="(val: PluginType) => $emit('plugin-clicked', val)"
@plugin-list-updated="(val: PluginCardList) => pluginsList = val"
Expand Down Expand Up @@ -88,6 +89,7 @@
:ignored-plugins="ignoredPlugins"
:no-route-change="noRouteChange"
:only-available-plugins="onlyAvailablePlugins"
:plugins-per-row="pluginsPerRow"
@loading="(val: boolean) => $emit('loading', val)"
@plugin-clicked="(val: PluginType) => $emit('plugin-clicked', val)"
@plugin-list-updated="(val: PluginCardList) => pluginsList = val"
Expand Down Expand Up @@ -174,6 +176,13 @@ const props = defineProps({
type: Object as PropType<DisabledPlugin>,
default: () => ({}),
},
/**
* Number of plugins to always have visible (never will be collapsed)
*/
pluginsPerRow: {
type: Number,
default: 4,
},
})
defineEmits<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<div
v-if="nonCustomPlugins[group]"
:key="idx"
class="row"
>
<KCollapse
v-model="shouldCollapsed[idx]"
Expand All @@ -45,7 +44,7 @@
>
<!-- don't display a trigger if all plugins will already be visible -->
<template
v-if="getGroupPluginCount(group) <= PLUGINS_PER_ROW"
v-if="getGroupPluginCount(group) <= pluginsPerRow"
#trigger
>
&nbsp;
Expand Down Expand Up @@ -95,7 +94,6 @@ import {
type TriggerLabels,
} from '../types'
import { useAxios, useHelpers, useErrors } from '@kong-ui-public/entities-shared'
import { PLUGINS_PER_ROW } from '../constants'
import composables from '../composables'
import endpoints from '../plugins-endpoints'
import PluginCardSkeleton from './PluginCardSkeleton.vue'
Expand Down Expand Up @@ -151,6 +149,13 @@ const props = defineProps({
type: Boolean,
default: false,
},
/**
* Number of plugins to always have visible (never will be collapsed)
*/
pluginsPerRow: {
type: Number,
default: 4,
},
})
const emit = defineEmits<{
Expand Down Expand Up @@ -281,10 +286,10 @@ const getPluginCards = (group: string, type: 'all' | 'visible' | 'hidden') => {
if (type === 'all') {
return plugins
} else if (type === 'visible') {
return plugins.slice(0, PLUGINS_PER_ROW)
return plugins.slice(0, props.pluginsPerRow)
}
return plugins.slice(PLUGINS_PER_ROW)
return plugins.slice(props.pluginsPerRow)
}
const getGroupPluginCount = (group: string) => {
Expand All @@ -299,7 +304,7 @@ const triggerLabels = computed(() => {
const totalCount = getPluginCards(pluginGroup, 'all')?.length || 0
const hiddenCount = getPluginCards(pluginGroup, 'hidden')?.length || 0
if (totalCount > PLUGINS_PER_ROW) {
if (totalCount > props.pluginsPerRow) {
acc[pluginGroup as keyof TriggerLabels] = t('plugins.select.view_more', { count: hiddenCount })
}
Expand Down
1 change: 0 additions & 1 deletion packages/entities/entities-plugins/src/constants.ts

This file was deleted.

0 comments on commit 8bc0c93

Please sign in to comment.