Skip to content

Commit

Permalink
chore: removes EmptyBlock in favour of XEmptyState
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <john.cowen@konghq.com>
  • Loading branch information
johncowen committed Oct 10, 2024
1 parent ff7b2e6 commit 26fb353
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name="empty"
:items="items"
>
<EmptyBlock
<XEmptyState
v-if="props.empty"
:type="props.type"
/>
Expand All @@ -31,7 +31,7 @@
name="empty"
:items="items"
>
<EmptyBlock
<XEmptyState
v-if="props.empty"
:type="props.type"
/>
Expand Down Expand Up @@ -76,7 +76,6 @@
import { useThrottleFn } from '@vueuse/core'
import { computed, useSlots } from 'vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
type PaginationChangeEvent = {
page: number
}
Expand Down
13 changes: 7 additions & 6 deletions src/app/data-planes/views/DataPlaneDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@
v-if="props.data.dataplaneType === 'delegated'"
#empty
>
<EmptyBlock>
This proxy is a delegated gateway therefore {{ t('common.product.name') }} does not have any visibility into inbounds for this gateway
</EmptyBlock>
<XEmptyState>
<p>
This proxy is a delegated gateway therefore {{ t('common.product.name') }} does not have any visibility into inbounds for this gateway.
</p>
</XEmptyState>
</template>
<template #default="{ items: _inbounds }">
<template
Expand Down Expand Up @@ -302,7 +304,7 @@
<span>Outbounds</span>
</template>
<!-- we don't want to show an error here -->
<!-- instead we show a No Data EmptyBlock -->
<!-- instead we show a No Data EmptyState -->
<template v-if="typeof error === 'undefined'">
<LoadingBlock v-if="typeof traffic === 'undefined'" />
<template
Expand Down Expand Up @@ -374,7 +376,7 @@
</template>
</template>
<template v-else>
<EmptyBlock />
<XEmptyState />
</template>
</ConnectionTraffic>
</div>
Expand Down Expand Up @@ -521,7 +523,6 @@ import { computed } from 'vue'
import type { DataplaneOverview, DataplaneInbound } from '../data'
import DefinitionCard from '@/app/common/DefinitionCard.vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
import LoadingBlock from '@/app/common/LoadingBlock.vue'
import StatusBadge from '@/app/common/StatusBadge.vue'
import SummaryView from '@/app/common/SummaryView.vue'
Expand Down
14 changes: 8 additions & 6 deletions src/app/data-planes/views/DataPlaneSummaryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
:find="true"
>
<template #empty>
<EmptyBlock>
<XEmptyState>
<template #title>
{{ t('common.collection.summary.empty_title', { type: 'Data Plane Proxy' }) }}
<h2>
{{ t('common.collection.summary.empty_title', { type: 'Data Plane Proxy' }) }}
</h2>
</template>

<p>{{ t('common.collection.summary.empty_message', { type: 'Data Plane Proxy' }) }}</p>
</EmptyBlock>
<p>
{{ t('common.collection.summary.empty_message', { type: 'Data Plane Proxy' }) }}
</p>
</XEmptyState>
</template>
<template
#default="{ items: proxies }"
Expand Down Expand Up @@ -298,7 +301,6 @@ import { InfoIcon } from '@kong/icons'
import type { DataplaneOverview } from '../data'
import DefinitionCard from '@/app/common/DefinitionCard.vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
import StatusBadge from '@/app/common/StatusBadge.vue'
import TagList from '@/app/common/TagList.vue'
import TextWithCopyButton from '@/app/common/TextWithCopyButton.vue'
Expand Down
11 changes: 5 additions & 6 deletions src/app/gateways/components/ListenerRoutes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@

<div class="content">
<div class="to-rule-list">
<EmptyBlock v-if="toRules.length === 0">
<template #title>
{{ t('builtin-gateways.detail.no_rules', { listener: props.selectedListenerIndex + 1 }) }}
</template>
</EmptyBlock>
<XEmptyState
v-if="toRules.length === 0"
>
{{ t('builtin-gateways.detail.no_rules', { listener: props.selectedListenerIndex + 1 }) }}
</XEmptyState>

<template v-else>
<template
Expand Down Expand Up @@ -254,7 +254,6 @@ import { computed } from 'vue'
import type { MeshGateway } from '../data'
import { matchesTags } from '../utilities'
import { useI18n } from '@/app/application'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
import TagList from '@/app/common/TagList.vue'
import TargetRef from '@/app/common/TargetRef.vue'
import RuleFilter from '@/app/rules/components/RuleFilter.vue'
Expand Down
17 changes: 8 additions & 9 deletions src/app/policies/views/PolicyListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
:items="props.policyTypes ?? []"
>
<template #empty>
<EmptyBlock>
<template #message>
{{ t('policies.routes.items.empty') }}
</template>
</EmptyBlock>
<XEmptyState>
{{ t('policies.routes.items.empty') }}
</XEmptyState>
</template>
<template #item="{ item: type }">
<AppView>
Expand Down Expand Up @@ -110,9 +108,11 @@
<template
#empty
>
<EmptyBlock>
<XEmptyState>
<template #title>
{{ t('policies.x-empty-state.title') }}
<h3>
{{ t('policies.x-empty-state.title') }}
</h3>
</template>
<div
v-html="t('policies.x-empty-state.body', { type: type.name, suffix: route.params.s.length > 0 ? t('common.matchingsearch') : '' })"
Expand All @@ -127,7 +127,7 @@
{{ t('common.documentation') }}
</XAction>
</template>
</EmptyBlock>
</XEmptyState>
</template>
<template
#default
Expand Down Expand Up @@ -279,7 +279,6 @@
import type { PolicyType } from '../data'
import { sources } from '../sources'
import AppCollection from '@/app/application/components/app-collection/AppCollection.vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
import PolicyTypeTag from '@/app/common/PolicyTypeTag.vue'
import SummaryView from '@/app/common/SummaryView.vue'
const props = defineProps<{
Expand Down
13 changes: 8 additions & 5 deletions src/app/policies/views/PolicySummaryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
:find="true"
>
<template #empty>
<EmptyBlock>
<XEmptyState>
<template #title>
{{ t('common.collection.summary.empty_title', { type: props.policyType.name }) }}
<h2>
{{ t('common.collection.summary.empty_title', { type: props.policyType.name }) }}
</h2>
</template>
<p>{{ t('common.collection.summary.empty_message', { type: props.policyType.name }) }}</p>
</EmptyBlock>
<p>
{{ t('common.collection.summary.empty_message', { type: props.policyType.name }) }}
</p>
</XEmptyState>
</template>
<template
#default="{ items: policies }"
Expand Down Expand Up @@ -89,7 +93,6 @@
import PolicySummary from '../components/PolicySummary.vue'
import type { Policy, PolicyType } from '../data'
import ResourceCodeBlock from '@/app/common/code-block/ResourceCodeBlock.vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
const props = defineProps<{
items: Policy[]
Expand Down
80 changes: 0 additions & 80 deletions src/app/services/views/ServiceConfigView.vue

This file was deleted.

37 changes: 37 additions & 0 deletions src/app/x/components/x-empty-state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# XEmptyState

A lot of the time, generally when dealing with collections of data, you should
be using `DataCollection` instead of `XEmptyState`. `DataCollection` will
automatically show an `XEmptyState` when it detects that the collection of data
is empty.

`DataCollections` also have an `#empty` slot which allows you to pass in an
`XEmptyState`.

That being said, there are some cases where you'll need to use an `XEmptyState`
on its own.

`XEmptyState` has a very boring default state:

<Story>
<XEmptyState />
</Story>

But it also has title and default slots to allow you to alter the text. Please
use semantic elements when changing the default state. You should use `p` tags
or `<div v-html="t('markdown')" />` for default/body content and the correct
level of `h*` tag for the title depending on your page and the position/level
of the empty state.

<Story>
<XEmptyState>
<template
#title
>
<h2>A different empty state title</h2>
</template>
<p>
Different empty state content/body
</p>
</XEmptyState>
</Story>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
:key="title"
>
<KEmptyState
class="x-empty-state"
data-testid="empty-block"
>
<template
Expand Down
3 changes: 3 additions & 0 deletions src/app/x/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import XBadge from './components/x-badge/XBadge.vue'
import XBreadcrumbs from './components/x-breadcrumbs/XBreadcrumbs.vue'
import XCopyButton from './components/x-copy-button/XCopyButton.vue'
import XDisclosure from './components/x-disclosure/XDisclosure.vue'
import XEmptyState from './components/x-empty-state/XEmptyState.vue'
import XIcon from './components/x-icon/XIcon.vue'
import XInput from './components/x-input/XInput.vue'
import XPrompt from './components/x-prompt/XPrompt.vue'
Expand All @@ -30,6 +31,7 @@ declare module 'vue' {
XBadge: typeof KBadge
XCopyButton: typeof XCopyButton
XBreadcrumbs: typeof XBreadcrumbs
XEmptyState: typeof XEmptyState
XPrompt: typeof XPrompt
XProvider: typeof XProvider
XSelect: typeof XSelect
Expand Down Expand Up @@ -65,6 +67,7 @@ export const services = (app: Record<string, Token>): ServiceDefinition[] => {
['XBreadcrumbs', XBreadcrumbs],
['XCard', KCard],
['XCopyButton', XCopyButton],
['XEmptyState', XEmptyState],
['XIcon', XIcon],
['XInput', XInput],
['XPrompt', XPrompt],
Expand Down
13 changes: 8 additions & 5 deletions src/app/zone-egresses/views/ZoneEgressSummaryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
:find="true"
>
<template #empty>
<EmptyBlock>
<XEmptyState>
<template #title>
{{ t('common.collection.summary.empty_title', { type: 'ZoneEgress' }) }}
<h2>
{{ t('common.collection.summary.empty_title', { type: 'ZoneEgress' }) }}
</h2>
</template>

<p>{{ t('common.collection.summary.empty_message', { type: 'ZoneEgress' }) }}</p>
</EmptyBlock>
<p>
{{ t('common.collection.summary.empty_message', { type: 'ZoneEgress' }) }}
</p>
</XEmptyState>
</template>
<template
#default="{ items: proxies }"
Expand Down Expand Up @@ -108,7 +112,6 @@
<script lang="ts" setup>
import type { ZoneEgressOverview } from '../data'
import DefinitionCard from '@/app/common/DefinitionCard.vue'
import EmptyBlock from '@/app/common/EmptyBlock.vue'
import StatusBadge from '@/app/common/StatusBadge.vue'
import TextWithCopyButton from '@/app/common/TextWithCopyButton.vue'
Expand Down
Loading

0 comments on commit 26fb353

Please sign in to comment.