Skip to content

Commit 377525f

Browse files
authored
feat: gateway-services empty states (#1932)
* feat: added new empty states * fix: fixed docs, learn more button * fix: styling issues * fix: docs
1 parent 71ba295 commit 377525f

File tree

3 files changed

+86
-10
lines changed

3 files changed

+86
-10
lines changed

packages/entities/entities-gateway-services/docs/gateway-service-list.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ A synchronous or asynchronous function, that returns a boolean, that evaluates i
166166

167167
Indicates that the user is in the onboarding Serverless control plane and should use explanatory text.
168168

169+
#### `enableV2EmptyStates`
170+
171+
- type: `boolean`
172+
- default: `false`
173+
174+
Enables the new empty state design, this prop can be removed when the khcp-14756-empty-states-m2 FF is removed.
175+
169176
### Events
170177

171178
#### error

packages/entities/entities-gateway-services/src/components/GatewayServiceList.vue

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@clear-search-input="clearFilter"
1717
@click:row="(row: any) => rowClick(row as EntityRow)"
1818
@sort="resetPagination"
19+
@state="handleStateChange"
1920
>
2021
<!-- Filter -->
2122
<template #toolbar-filter>
@@ -30,21 +31,58 @@
3031
:disabled="!useActionOutside"
3132
to="#kong-ui-app-page-header-action-button"
3233
>
33-
<PermissionsWrapper :auth-function="() => canCreate()">
34-
<!-- Hide Create button if table is empty -->
34+
<div class="button-row">
3535
<KButton
36-
appearance="primary"
37-
data-testid="toolbar-add-gateway-service"
38-
:size="useActionOutside ? 'medium' : 'large'"
39-
:to="config.createRoute"
36+
v-if="!showEmptyState && config.app === 'konnect'"
37+
appearance="secondary"
38+
class="open-learning-hub"
39+
data-testid="gateway-services-learn-more-button"
40+
icon
41+
@click="$emit('click:learn-more')"
4042
>
41-
<AddIcon />
42-
{{ t('gateway_services.list.toolbar_actions.new_gateway_service') }}
43+
<BookIcon decorative />
4344
</KButton>
44-
</PermissionsWrapper>
45+
<PermissionsWrapper :auth-function="() => canCreate()">
46+
<!-- Hide Create button if table is empty -->
47+
<KButton
48+
appearance="primary"
49+
data-testid="toolbar-add-gateway-service"
50+
:size="useActionOutside ? 'medium' : 'large'"
51+
:to="config.createRoute"
52+
>
53+
<AddIcon />
54+
{{ t('gateway_services.list.toolbar_actions.new_gateway_service') }}
55+
</KButton>
56+
</PermissionsWrapper>
57+
</div>
4558
</Teleport>
4659
</template>
4760

61+
<template
62+
v-if="enableV2EmptyStates && config.app === 'konnect'"
63+
#empty-state
64+
>
65+
<EntityEmptyState
66+
:action-button-text="t('gateway_services.empty_state_v2.create')"
67+
appearance="secondary"
68+
:can-create="() => canCreate()"
69+
:description="t('gateway_services.empty_state_v2.description')"
70+
:learn-more="config.app === 'konnect'"
71+
:title="t('gateway_services.empty_state_v2.title')"
72+
@click:create="handleCreate"
73+
@click:learn-more="$emit('click:learn-more')"
74+
>
75+
<template #image>
76+
<div class="empty-state-icon-gateway">
77+
<ServicesIcon
78+
:color="KUI_COLOR_TEXT_DECORATIVE_AQUA"
79+
:size="KUI_ICON_SIZE_50"
80+
/>
81+
</div>
82+
</template>
83+
</EntityEmptyState>
84+
</template>
85+
4886
<!-- Column Formatting -->
4987
<template #name="{ rowValue }">
5088
<b>{{ rowValue ?? '-' }}</b>
@@ -160,7 +198,7 @@
160198
import type { PropType } from 'vue'
161199
import { computed, ref, watch, onBeforeMount } from 'vue'
162200
import { useRouter } from 'vue-router'
163-
import { AddIcon } from '@kong/icons'
201+
import { AddIcon, BookIcon, ServicesIcon } from '@kong/icons'
164202
import composables from '../composables'
165203
import endpoints from '../gateway-services-endpoints'
166204
import type { AxiosError } from 'axios'
@@ -184,17 +222,21 @@ import {
184222
EntityFilter,
185223
EntityToggleModal,
186224
EntityTypes,
225+
EntityEmptyState,
187226
FetcherStatus,
188227
PermissionsWrapper,
189228
useAxios,
229+
useTableState,
190230
useFetcher,
191231
useDeleteUrlBuilder,
192232
TableTags,
193233
} from '@kong-ui-public/entities-shared'
234+
import { KUI_ICON_SIZE_50, KUI_COLOR_TEXT_DECORATIVE_AQUA } from '@kong/design-tokens'
194235
import '@kong-ui-public/entities-shared/dist/style.css'
195236
196237
const emit = defineEmits<{
197238
(e: 'error', error: AxiosError): void,
239+
(e: 'click:learn-more'): void,
198240
(e: 'copy:success', payload: CopyEventPayload): void,
199241
(e: 'copy:error', payload: CopyEventPayload): void,
200242
(e: 'delete:success', gatewayService: EntityRow): void,
@@ -253,12 +295,22 @@ const props = defineProps({
253295
type: Boolean,
254296
default: false,
255297
},
298+
/**
299+
* Enables the new empty state design, this prop can be removed when
300+
* the khcp-14756-empty-states-m2 FF is removed.
301+
*/
302+
enableV2EmptyStates: {
303+
type: Boolean,
304+
default: false,
305+
},
256306
})
257307
258308
const { i18n: { t, formatUnixTimeStamp } } = composables.useI18n()
259309
const router = useRouter()
260310
261311
const { axiosInstance } = useAxios(props.config?.axiosRequestConfig)
312+
const { hideTableToolbar: showEmptyState, handleStateChange } = useTableState(() => filterQuery.value)
313+
262314
263315
/**
264316
* Table Headers
@@ -551,6 +603,12 @@ const deleteRow = async (): Promise<void> => {
551603
isDeletePending.value = false
552604
}
553605
}
606+
/**
607+
* Add Gateway Service
608+
*/
609+
const handleCreate = (): void => {
610+
router.push(props.config.createRoute)
611+
}
554612
555613
/**
556614
* Watchers
@@ -579,6 +637,12 @@ onBeforeMount(async () => {
579637
</script>
580638

581639
<style lang="scss" scoped>
640+
.button-row {
641+
align-items: center;
642+
display: flex;
643+
gap: $kui-space-50;
644+
}
645+
582646
.kong-ui-entities-gateway-services-list {
583647
width: 100%;
584648

packages/entities/entities-gateway-services/src/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
"serverless_title": "Configure your first Gateway Service"
4545
}
4646
},
47+
"empty_state_v2": {
48+
"create": "New gateway service",
49+
"title": "Configure your first gateway service",
50+
"description": "Services represent your upstream APIs, allowing for centralized configuration and streamlined management of backend endpoints."
51+
},
4752
"form": {
4853
"sections": {
4954
"general": {

0 commit comments

Comments
 (0)