Skip to content

Commit

Permalink
fix(*): hide teleported create button in empty state for all entities
Browse files Browse the repository at this point in the history
  • Loading branch information
mptap committed Nov 17, 2023
1 parent efa8c39 commit ca89787
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-ca-certificates-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand All @@ -27,8 +28,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -425,10 +427,21 @@ const confirmDelete = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('ca-certificates.errors.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-certificates-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand All @@ -27,8 +28,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -492,10 +494,21 @@ const confirmDelete = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('certificates.errors.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-consumer-credentials-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
disable-row-click
Expand All @@ -18,8 +19,9 @@
>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -453,10 +455,21 @@ const confirmDelete = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('credentials.error.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-consumer-groups-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
:disable-pagination="isConsumerPage"
disable-pagination-page-jump
Expand Down Expand Up @@ -31,8 +32,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -553,10 +555,21 @@ const exitGroups = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('consumer_groups.errors.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-consumers-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
:disable-pagination="isConsumerGroupPage"
disable-pagination-page-jump
Expand Down Expand Up @@ -31,8 +32,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -563,10 +565,21 @@ const removeConsumers = async (): Promise<void> => {
}
}
// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)
/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('consumers.errors.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-gateway-services-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand All @@ -27,8 +28,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -514,11 +516,21 @@ const deleteRow = async (): Promise<void> => {
isDeletePending.value = false
}
}
// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)
/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('errors.general')
// Emit the error for the host app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-key-sets-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand All @@ -27,8 +28,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -428,10 +430,21 @@ const confirmDelete = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('keySets.errors.general')
// Emit the error for the host app
Expand Down
15 changes: 14 additions & 1 deletion packages/entities/entities-keys/src/components/KeyList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-keys-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand All @@ -27,8 +28,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -437,10 +439,21 @@ const confirmDelete = async (): Promise<void> => {
}
}

// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)

/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('keys.errors.general')
// Emit the error for the host app
Expand Down
15 changes: 14 additions & 1 deletion packages/entities/entities-plugins/src/components/PluginList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="kong-ui-entities-plugins-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -29,8 +30,9 @@
</template>
<!-- Create action -->
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside"
:disabled="!useActionOutside || !hasData"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
Expand Down Expand Up @@ -715,10 +717,21 @@ const confirmDelete = async (): Promise<void> => {
}
}
// Remount the table when hasData changes
const key = ref(1)
const hasData = ref(false)
const isLoaded = ref(false)
/**
* Watchers
*/
watch(fetcherState, (state) => {
// if table is populated, show the Create button
if (fetcherState.value.response?.data?.length && !isLoaded.value) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('errors.general')
// Emit the error for the host app
Expand Down
Loading

0 comments on commit ca89787

Please sign in to comment.