added empty state for new realms with no sessions (#986)

This commit is contained in:
Erik Jan de Wit 2021-08-11 11:33:51 +02:00 committed by GitHub
parent ba8f927453
commit 15a87b7d2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View file

@ -1,19 +1,21 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import moment from "moment";
import { import {
PageSection, PageSection,
Select, Select,
SelectOption, SelectOption,
SelectVariant, SelectVariant,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import moment from "moment"; import { FilterIcon } from "@patternfly/react-icons";
import type UserSessionRepresentation from "keycloak-admin/lib/defs/userSessionRepresentation";
import type UserSessionRepresentation from "keycloak-admin/lib/defs/userSessionRepresentation";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { ViewHeader } from "../components/view-header/ViewHeader"; import { ViewHeader } from "../components/view-header/ViewHeader";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { useAdminClient } from "../context/auth/AdminClient"; import { useAdminClient } from "../context/auth/AdminClient";
import { FilterIcon } from "@patternfly/react-icons";
import "./SessionsSection.css"; import "./SessionsSection.css";
const Clients = (row: UserSessionRepresentation) => { const Clients = (row: UserSessionRepresentation) => {
@ -88,28 +90,23 @@ export const SessionsSection = () => {
selections={filterType} selections={filterType}
> >
<SelectOption <SelectOption
key={0}
data-testid="all-sessions-option" data-testid="all-sessions-option"
value={t("sessionsType.allSessions")} value={t("sessionsType.allSessions")}
isPlaceholder isPlaceholder
/> />
<SelectOption <SelectOption
key={1}
data-testid="regular-sso-option" data-testid="regular-sso-option"
value={t("sessionsType.regularSSO")} value={t("sessionsType.regularSSO")}
/> />
<SelectOption <SelectOption
key={2}
data-testid="offline-option" data-testid="offline-option"
value={t("sessionsType.offline")} value={t("sessionsType.offline")}
/> />
<SelectOption <SelectOption
key={3}
data-testid="direct-grant-option" data-testid="direct-grant-option"
value={t("sessionsType.directGrant")} value={t("sessionsType.directGrant")}
/> />
<SelectOption <SelectOption
key={4}
data-testid="service-account-option" data-testid="service-account-option"
value={t("sessionsType.serviceAccount")} value={t("sessionsType.serviceAccount")}
/> />
@ -136,6 +133,12 @@ export const SessionsSection = () => {
cellRenderer: Clients, cellRenderer: Clients,
}, },
]} ]}
emptyState={
<ListEmptyState
message={t("emptyTitle")}
instructions={t("emptyInstructions")}
/>
}
/> />
</PageSection> </PageSection>
</> </>

View file

@ -14,5 +14,7 @@ export default {
directGrant: "Direct grant", directGrant: "Direct grant",
serviceAccount: "Service account", serviceAccount: "Service account",
}, },
emptyTitle: "No sessions",
emptyInstructions: "There are no active sessions on this realm",
}, },
}; };