changed time select order + added success message (#447)
* changed time select order + added success message fixes: #445 * show time instead of the nice from now * made "Remaining count" wrappable
This commit is contained in:
parent
d2891a7bb6
commit
21c0cfcdad
5 changed files with 14 additions and 3 deletions
|
@ -51,6 +51,7 @@ export const CreateInitialAccessToken = () => {
|
||||||
token={token}
|
token={token}
|
||||||
toggleDialog={() => {
|
toggleDialog={() => {
|
||||||
setToken("");
|
setToken("");
|
||||||
|
addAlert(t("tokenSaveSuccess"), AlertVariant.success);
|
||||||
history.push(`/${realm}/clients/initialAccessToken`);
|
history.push(`/${realm}/clients/initialAccessToken`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -78,13 +79,14 @@ export const CreateInitialAccessToken = () => {
|
||||||
>
|
>
|
||||||
<Controller
|
<Controller
|
||||||
name="expiration"
|
name="expiration"
|
||||||
defaultValue=""
|
defaultValue={86400}
|
||||||
control={control}
|
control={control}
|
||||||
render={({ onChange, value }) => (
|
render={({ onChange, value }) => (
|
||||||
<TimeSelector
|
<TimeSelector
|
||||||
data-testid="expiration"
|
data-testid="expiration"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
units={["days", "hours", "minutes", "seconds"]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { useHistory, useRouteMatch } from "react-router-dom";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { AlertVariant, Button, ButtonVariant } from "@patternfly/react-core";
|
import { AlertVariant, Button, ButtonVariant } from "@patternfly/react-core";
|
||||||
|
import { wrappable } from "@patternfly/react-table";
|
||||||
|
|
||||||
import ClientInitialAccessPresentation from "keycloak-admin/lib/defs/clientInitialAccessPresentation";
|
import ClientInitialAccessPresentation from "keycloak-admin/lib/defs/clientInitialAccessPresentation";
|
||||||
import { KeycloakDataTable } from "../../components/table-toolbar/KeycloakDataTable";
|
import { KeycloakDataTable } from "../../components/table-toolbar/KeycloakDataTable";
|
||||||
|
@ -84,7 +85,9 @@ export const InitialAccessTokenList = () => {
|
||||||
name: "expiration",
|
name: "expiration",
|
||||||
displayKey: "clients:expires",
|
displayKey: "clients:expires",
|
||||||
cellRenderer: (row) =>
|
cellRenderer: (row) =>
|
||||||
moment(row.timestamp! * 1000 + row.expiration! * 1000).fromNow(),
|
moment(row.timestamp! * 1000 + row.expiration! * 1000).format(
|
||||||
|
"LLL"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "count",
|
name: "count",
|
||||||
|
@ -93,6 +96,7 @@ export const InitialAccessTokenList = () => {
|
||||||
{
|
{
|
||||||
name: "remainingCount",
|
name: "remainingCount",
|
||||||
displayKey: "clients:remainingCount",
|
displayKey: "clients:remainingCount",
|
||||||
|
transforms: [wrappable],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
emptyState={
|
emptyState={
|
||||||
|
|
|
@ -92,6 +92,7 @@
|
||||||
"expiration": "Expiration",
|
"expiration": "Expiration",
|
||||||
"noTokens": "No initial access tokens",
|
"noTokens": "No initial access tokens",
|
||||||
"noTokensInstructions": "You haven't created any initial access tokens. Create an initial access token by clicking \"Create\".",
|
"noTokensInstructions": "You haven't created any initial access tokens. Create an initial access token by clicking \"Create\".",
|
||||||
|
"tokenSaveSuccess": "New initial access token has been created",
|
||||||
"tokenSaveError": "Could not create initial access token {{error}}",
|
"tokenSaveError": "Could not create initial access token {{error}}",
|
||||||
"initialAccessTokenDetails": "Initial access token details",
|
"initialAccessTokenDetails": "Initial access token details",
|
||||||
"copyInitialAccessToken": "Please copy and paste the initial access token before closing as it can not be retrieved later.",
|
"copyInitialAccessToken": "Please copy and paste the initial access token before closing as it can not be retrieved later.",
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
IActions,
|
IActions,
|
||||||
IActionsResolver,
|
IActionsResolver,
|
||||||
IFormatter,
|
IFormatter,
|
||||||
|
ITransform,
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
|
@ -72,6 +73,7 @@ export type Field<T> = {
|
||||||
name: string;
|
name: string;
|
||||||
displayKey?: string;
|
displayKey?: string;
|
||||||
cellFormatters?: IFormatter[];
|
cellFormatters?: IFormatter[];
|
||||||
|
transforms?: ITransform[];
|
||||||
cellRenderer?: (row: T) => ReactNode;
|
cellRenderer?: (row: T) => ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,9 @@ export const TimeSelector = ({
|
||||||
{ unit: "days", label: t("times.days"), multiplier: 86400 },
|
{ unit: "days", label: t("times.days"), multiplier: 86400 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const times = allTimes.filter((t) => units.includes(t.unit));
|
const times = units.map(
|
||||||
|
(unit) => allTimes.find((time) => time.unit === unit)!
|
||||||
|
);
|
||||||
const defaultMultiplier = allTimes.find((time) => time.unit === units[0])
|
const defaultMultiplier = allTimes.find((time) => time.unit === units[0])
|
||||||
?.multiplier;
|
?.multiplier;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue