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", "allowRemoteResourceManagement": "Remote resource management",
"resources": "Resources", "resources": "Resources",
"resource": "Resource", "resource": "Resource",
"emptyResources": "No resources",
"emptyResourcesInstructions": "If you want to create a resource, please click the button below.",
"allTypes": "All types", "allTypes": "All types",
"scope": "Scope", "scope": "Scope",
"owner": "Owner", "owner": "Owner",

View file

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