Skip to content

Commit

Permalink
fix(*): avoid jump of cta button for all entities
Browse files Browse the repository at this point in the history
  • Loading branch information
mptap committed Nov 20, 2023
1 parent 73e7dbe commit f733ba5
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 111 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="kong-ui-entities-ca-certificates-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -30,11 +29,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-ca-certificate"
icon="plus"
Expand Down Expand Up @@ -427,20 +427,15 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('ca-certificates.errors.general')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="kong-ui-entities-certificates-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -30,11 +29,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-certificate"
icon="plus"
Expand Down Expand Up @@ -494,20 +494,15 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('certificates.errors.general')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="kong-ui-entities-consumer-credentials-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
disable-row-click
Expand All @@ -21,11 +20,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-credential"
icon="plus"
Expand Down Expand Up @@ -456,19 +456,15 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
hasData.value = true
isLoaded.value = true
key.value++
}
if (state.status === FetcherStatus.Error) {
errorMessage.value = t('credentials.error.general')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<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 @@ -34,11 +33,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-consumer-group"
icon="plus"
Expand Down Expand Up @@ -555,21 +555,17 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
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,7 +1,6 @@
<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 @@ -34,11 +33,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-consumer"
icon="plus"
Expand Down Expand Up @@ -565,21 +565,17 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
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,7 +1,6 @@
<template>
<div class="kong-ui-entities-gateway-services-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -30,11 +29,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-gateway-service"
icon="plus"
Expand Down Expand Up @@ -516,21 +516,18 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
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,7 +1,6 @@
<template>
<div class="kong-ui-entities-key-sets-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -30,11 +29,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-key-set"
icon="plus"
Expand Down Expand Up @@ -430,21 +430,17 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
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
12 changes: 4 additions & 8 deletions packages/entities/entities-keys/src/components/KeyList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="kong-ui-entities-keys-list">
<EntityBaseTable
:key="key"
:cache-identifier="cacheIdentifier"
disable-pagination-page-jump
:disable-sorting="disableSorting"
Expand Down Expand Up @@ -30,11 +29,12 @@
<template #toolbar-button>
<!-- Hide Create button if table is empty -->
<Teleport
:disabled="!useActionOutside || !hasData"
:disabled="!useActionOutside"
to="#kong-ui-app-page-header-action-button"
>
<PermissionsWrapper :auth-function="() => canCreate()">
<KButton
v-show="hasData"
appearance="primary"
data-testid="toolbar-add-key"
icon="plus"
Expand Down Expand Up @@ -439,21 +439,17 @@ 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) {
if (state.status !== FetcherStatus.NoResults && state.status !== FetcherStatus.Loading && state.status !== FetcherStatus.Error) {
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
Loading

0 comments on commit f733ba5

Please sign in to comment.