mirror of https://github.com/halo-dev/halo
feat: add empty state for some widgets (#7522)
#### What type of PR is this? /area ui /kind improvement /milestone 2.21.x #### What this PR does / why we need it: Add empty state for some dashboard widgets #### Does this PR introduce a user-facing change? ```release-note None ```pull/7516/head^2
parent
392d851353
commit
8dfae708ff
|
@ -2,12 +2,17 @@
|
||||||
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
|
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
|
||||||
import type { ListedComment } from "@halo-dev/api-client";
|
import type { ListedComment } from "@halo-dev/api-client";
|
||||||
import { consoleApiClient } from "@halo-dev/api-client";
|
import { consoleApiClient } from "@halo-dev/api-client";
|
||||||
import { VEntityContainer } from "@halo-dev/components";
|
import {
|
||||||
|
VButton,
|
||||||
|
VEmpty,
|
||||||
|
VEntityContainer,
|
||||||
|
VLoading,
|
||||||
|
} from "@halo-dev/components";
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from "@tanstack/vue-query";
|
||||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||||
import CommentItem from "./CommentItem.vue";
|
import CommentItem from "./CommentItem.vue";
|
||||||
|
|
||||||
const { data } = useQuery<ListedComment[]>({
|
const { data, isLoading, isFetching, refetch } = useQuery<ListedComment[]>({
|
||||||
queryKey: ["widget-pending-comments"],
|
queryKey: ["widget-pending-comments"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await consoleApiClient.content.comment.listComments({
|
const { data } = await consoleApiClient.content.comment.listComments({
|
||||||
|
@ -29,6 +34,17 @@ const { data } = useQuery<ListedComment[]>({
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
<VLoading v-if="isLoading" />
|
||||||
|
<VEmpty
|
||||||
|
v-else-if="!data?.length"
|
||||||
|
:title="$t('core.dashboard.widgets.presets.pending_comments.empty.title')"
|
||||||
|
>
|
||||||
|
<template #actions>
|
||||||
|
<VButton :loading="isFetching" @click="refetch">
|
||||||
|
{{ $t("core.common.buttons.refresh") }}
|
||||||
|
</VButton>
|
||||||
|
</template>
|
||||||
|
</VEmpty>
|
||||||
<OverlayScrollbarsComponent
|
<OverlayScrollbarsComponent
|
||||||
element="div"
|
element="div"
|
||||||
:options="{ scrollbars: { autoHide: 'scroll' } }"
|
:options="{ scrollbars: { autoHide: 'scroll' } }"
|
||||||
|
|
|
@ -3,12 +3,17 @@ import { postLabels } from "@/constants/labels";
|
||||||
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
|
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
|
||||||
import type { ListedPost } from "@halo-dev/api-client";
|
import type { ListedPost } from "@halo-dev/api-client";
|
||||||
import { consoleApiClient } from "@halo-dev/api-client";
|
import { consoleApiClient } from "@halo-dev/api-client";
|
||||||
import { VEntityContainer } from "@halo-dev/components";
|
import {
|
||||||
|
VButton,
|
||||||
|
VEmpty,
|
||||||
|
VEntityContainer,
|
||||||
|
VLoading,
|
||||||
|
} from "@halo-dev/components";
|
||||||
import { useQuery } from "@tanstack/vue-query";
|
import { useQuery } from "@tanstack/vue-query";
|
||||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||||
import PostListItem from "./components/PostListItem.vue";
|
import PostListItem from "./components/PostListItem.vue";
|
||||||
|
|
||||||
const { data } = useQuery<ListedPost[]>({
|
const { data, isLoading, isFetching, refetch } = useQuery<ListedPost[]>({
|
||||||
queryKey: ["widget-recent-posts"],
|
queryKey: ["widget-recent-posts"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await consoleApiClient.content.post.listPosts({
|
const { data } = await consoleApiClient.content.post.listPosts({
|
||||||
|
@ -25,7 +30,19 @@ const { data } = useQuery<ListedPost[]>({
|
||||||
:body-class="['!overflow-auto']"
|
:body-class="['!overflow-auto']"
|
||||||
:title="$t('core.dashboard.widgets.presets.recent_published.title')"
|
:title="$t('core.dashboard.widgets.presets.recent_published.title')"
|
||||||
>
|
>
|
||||||
|
<VLoading v-if="isLoading" />
|
||||||
|
<VEmpty
|
||||||
|
v-else-if="!data?.length"
|
||||||
|
:title="$t('core.dashboard.widgets.presets.recent_published.empty.title')"
|
||||||
|
>
|
||||||
|
<template #actions>
|
||||||
|
<VButton :loading="isFetching" @click="refetch">
|
||||||
|
{{ $t("core.common.buttons.refresh") }}
|
||||||
|
</VButton>
|
||||||
|
</template>
|
||||||
|
</VEmpty>
|
||||||
<OverlayScrollbarsComponent
|
<OverlayScrollbarsComponent
|
||||||
|
v-else
|
||||||
element="div"
|
element="div"
|
||||||
:options="{ scrollbars: { autoHide: 'scroll' } }"
|
:options="{ scrollbars: { autoHide: 'scroll' } }"
|
||||||
class="h-full w-full"
|
class="h-full w-full"
|
||||||
|
|
|
@ -31,6 +31,8 @@ core:
|
||||||
presets:
|
presets:
|
||||||
recent_published:
|
recent_published:
|
||||||
publishTime: Publish Time {publishTime}
|
publishTime: Publish Time {publishTime}
|
||||||
|
empty:
|
||||||
|
title: No published posts
|
||||||
notification:
|
notification:
|
||||||
title: Notifications
|
title: Notifications
|
||||||
empty:
|
empty:
|
||||||
|
@ -42,6 +44,8 @@ core:
|
||||||
label: Enabled Items
|
label: Enabled Items
|
||||||
pending_comments:
|
pending_comments:
|
||||||
title: Pending Comments
|
title: Pending Comments
|
||||||
|
empty:
|
||||||
|
title: No pending comments
|
||||||
stack:
|
stack:
|
||||||
title: Widget Stack
|
title: Widget Stack
|
||||||
operations:
|
operations:
|
||||||
|
|
|
@ -70,6 +70,8 @@ core:
|
||||||
title: Recent Posts
|
title: Recent Posts
|
||||||
visits: "{visits} Visits"
|
visits: "{visits} Visits"
|
||||||
comments: "{comments} Comments"
|
comments: "{comments} Comments"
|
||||||
|
empty:
|
||||||
|
title: No published posts
|
||||||
notification:
|
notification:
|
||||||
title: Notifications
|
title: Notifications
|
||||||
empty:
|
empty:
|
||||||
|
@ -110,6 +112,8 @@ core:
|
||||||
title: Comments
|
title: Comments
|
||||||
pending_comments:
|
pending_comments:
|
||||||
title: Pending Comments
|
title: Pending Comments
|
||||||
|
empty:
|
||||||
|
title: No pending comments
|
||||||
views_stats:
|
views_stats:
|
||||||
title: Visits
|
title: Visits
|
||||||
stack:
|
stack:
|
||||||
|
|
|
@ -64,6 +64,8 @@ core:
|
||||||
title: 最近文章
|
title: 最近文章
|
||||||
visits: 访问量 {visits}
|
visits: 访问量 {visits}
|
||||||
comments: 评论 {comments}
|
comments: 评论 {comments}
|
||||||
|
empty:
|
||||||
|
title: 暂无已发布文章
|
||||||
notification:
|
notification:
|
||||||
title: 通知
|
title: 通知
|
||||||
empty:
|
empty:
|
||||||
|
@ -104,6 +106,8 @@ core:
|
||||||
title: 浏览量
|
title: 浏览量
|
||||||
pending_comments:
|
pending_comments:
|
||||||
title: 新评论
|
title: 新评论
|
||||||
|
empty:
|
||||||
|
title: 暂无待审核评论
|
||||||
stack:
|
stack:
|
||||||
title: 堆叠部件
|
title: 堆叠部件
|
||||||
operations:
|
operations:
|
||||||
|
|
|
@ -64,6 +64,8 @@ core:
|
||||||
title: 最近文章
|
title: 最近文章
|
||||||
visits: 訪問量 {visits}
|
visits: 訪問量 {visits}
|
||||||
comments: 留言 {comments}
|
comments: 留言 {comments}
|
||||||
|
empty:
|
||||||
|
title: 沒有已發布文章
|
||||||
notification:
|
notification:
|
||||||
title: 通知
|
title: 通知
|
||||||
empty:
|
empty:
|
||||||
|
@ -104,6 +106,8 @@ core:
|
||||||
title: 瀏覽量
|
title: 瀏覽量
|
||||||
pending_comments:
|
pending_comments:
|
||||||
title: 新評論
|
title: 新評論
|
||||||
|
empty:
|
||||||
|
title: 沒有待審核評論
|
||||||
stack:
|
stack:
|
||||||
title: 堆疊部件
|
title: 堆疊部件
|
||||||
operations:
|
operations:
|
||||||
|
|
Loading…
Reference in New Issue