Added empty state (#3366)

This commit is contained in:
Erik Jan de Wit 2022-09-21 16:27:23 +02:00 committed by GitHub
parent 49ffd816ea
commit 2c1f62fea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -146,6 +146,8 @@
"allowRemoteResourceManagement": "Remote resource management",
"resources": "Resources",
"resource": "Resource",
"emptyResources": "No resources",
"emptyResourcesInstructions": "If you want to create a resource, please click the button below.",
"allTypes": "All types",
"scope": "Scope",
"owner": "Owner",

View file

@ -1,5 +1,5 @@
import { useState } from "react";
import { Link } from "react-router-dom-v5-compat";
import { Link, useNavigate } from "react-router-dom-v5-compat";
import { useTranslation } from "react-i18next";
import {
Alert,
@ -44,6 +44,7 @@ type ExpandableResourceRepresentation = ResourceRepresentation & {
export const AuthorizationResources = ({ clientId }: ResourcesProps) => {
const { t } = useTranslation("clients");
const navigate = useNavigate();
const { adminClient } = useAdminClient();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
@ -294,6 +295,16 @@ export const AuthorizationResources = ({ clientId }: ResourcesProps) => {
instructions={t("common:noSearchResultsInstructions")}
/>
)}
{noData && !searching && (
<ListEmptyState
message={t("emptyResources")}
instructions={t("emptyResourcesInstructions")}
primaryActionText={t("createResource")}
onPrimaryAction={() =>
navigate(toCreateResource({ realm, id: clientId }))
}
/>
)}
</PageSection>
);
};