diff --git a/src/components/SiteResourcesOverview.tsx b/src/components/SiteResourcesOverview.tsx index b547fffbc..080074d87 100644 --- a/src/components/SiteResourcesOverview.tsx +++ b/src/components/SiteResourcesOverview.tsx @@ -12,6 +12,7 @@ import type { ListResourcesResponse } from "@server/routers/resource"; import type ResponseT from "@server/types/Response"; import { useQuery } from "@tanstack/react-query"; import { isAxiosError } from "axios"; +import { Loader2 } from "lucide-react"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { useParams } from "next/navigation"; @@ -176,6 +177,8 @@ type OverviewColumnProps = { emptyLabel: string; isForbidden: boolean; isFetching: boolean; + /** When there are no rows and the first fetch (no SSR initial data) is in flight. */ + isLoading: boolean; rows: OverviewRow[]; canShowMore: boolean; onShowMore: () => void; @@ -189,6 +192,7 @@ function OverviewColumn({ emptyLabel, isForbidden, isFetching, + isLoading, rows, canShowMore, onShowMore @@ -231,10 +235,23 @@ function OverviewColumn({
{header} {rows.length === 0 ? ( -
-

- {emptyLabel} -

+
+ {isLoading ? ( +
+ + {t("loading")} +
+ ) : ( +

+ {emptyLabel} +

+ )}
) : ( <> @@ -390,7 +407,14 @@ export default function SiteResourcesOverview({ initialPrivateForbidden || (privateQuery.isError && isForbidden(privateQuery.error)); + const waitingOnPublicList = + enabled && !publicForbidden && publicQuery.isPending; + const waitingOnPrivateList = + enabled && !privateForbidden && privateQuery.isPending; + const showEmptyPlaceholder = + !waitingOnPublicList && + !waitingOnPrivateList && !publicForbidden && !privateForbidden && publicList.length === 0 && @@ -431,6 +455,17 @@ export default function SiteResourcesOverview({ ); } + const publicEmptyLoading = + enabled && + !publicForbidden && + publicRows.length === 0 && + publicQuery.isPending; + const privateEmptyLoading = + enabled && + !privateForbidden && + privateRows.length === 0 && + privateQuery.isPending; + const publicColumn = ( setPublicPageSize((n) => n + LOAD_MORE_INCREMENT)} @@ -457,6 +493,7 @@ export default function SiteResourcesOverview({ emptyLabel={t("siteResourcesEmptyPrivate")} isForbidden={privateForbidden} isFetching={privateQuery.isFetching} + isLoading={privateEmptyLoading} rows={privateRows} canShowMore={privateList.length < privateTotal} onShowMore={() =>