consents fixes done

This commit is contained in:
jenny-s51 2021-06-09 09:35:35 -04:00
parent 67b6c52c65
commit 0647b88083
2 changed files with 64 additions and 28 deletions

View file

@ -1,7 +1,7 @@
import React, { useState } from "react"; import React from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Label } from "@patternfly/react-core"; import { Chip, ChipGroup } from "@patternfly/react-core";
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState"; import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
import { emptyFormatter } from "../util"; import { emptyFormatter } from "../util";
@ -22,37 +22,27 @@ export const UserConsents = () => {
}; };
const loader = async () => { const loader = async () => {
const consents = await adminClient.users.listConsents({ id }); const getConsents = await adminClient.users.listConsents({ id });
return alphabetize(consents); return alphabetize(getConsents);
}; };
const [labelClicked, setLabelClicked] = useState(false);
// useEffect(() => {
// console.log(labelClicked)
// }, [key])
const [key, setKey] = useState(0);
const clientScopesRenderer = ({ const clientScopesRenderer = ({
grantedClientScopes, grantedClientScopes,
}: UserConsentRepresentation) => { }: UserConsentRepresentation) => {
if (grantedClientScopes!.length <= 5 && labelClicked) {
return <>{grantedClientScopes!.join(", ")}</>;
} else
return ( return (
<> <ChipGroup className="kc-consents-chip-group">
{grantedClientScopes!.slice(1, 6).join(", ")}{" "} {grantedClientScopes!.map((currentChip) => (
<Label <Chip
color="blue" key={currentChip}
style={{ cursor: "pointer" }} isReadOnly
variant="outline" className="kc-consents-chip"
onClick={() => setLabelClicked(true)} id="consents-chip-text"
> >
{grantedClientScopes!.length - 5 + " more"} {currentChip}
</Label> </Chip>
</> ))}
</ChipGroup>
); );
}; };
@ -70,7 +60,6 @@ export const UserConsents = () => {
<> <>
<KeycloakDataTable <KeycloakDataTable
loader={loader} loader={loader}
key={key}
ariaLabelKey="roles:roleList" ariaLabelKey="roles:roleList"
searchPlaceholderKey=" " searchPlaceholderKey=" "
columns={[ columns={[

View file

@ -49,3 +49,50 @@ td.pf-c-table__check > input {
.pf-c-toolbar__content-section { .pf-c-toolbar__content-section {
margin-bottom: calc(var(--pf-global--spacer--lg) * -1); margin-bottom: calc(var(--pf-global--spacer--lg) * -1);
} }
.pf-c-chip.kc-consents-chip::before {
padding: 0px;
border: 0;
}
.pf-c-chip.kc-consents-chip {
padding: 0px;
}
.pf-c-chip-group__list-item {
margin-right: 0px;
}
#consents-chip-text.pf-c-chip-text {
font-size: var(--pf-c-table--cell--FontSize);
}
.kc-consents-chip > .pf-c-chip__text {
font-size: var(--pf-c-table--cell--FontSize);
display: inline-block;
}
.pf-c-chip-group.kc-consents-chip-group
> div.pf-c-chip-group__main
> ul.pf-c-chip-group__list
li:first-child
.pf-c-chip__text::before {
content: "";
}
.pf-c-chip-group.kc-consents-chip-group
> div.pf-c-chip-group__main
> ul.pf-c-chip-group__list
.pf-c-chip__text::before {
content: ", ";
}
.pf-c-chip-group.kc-consents-chip-group
> div.pf-c-chip-group__main
> ul.pf-c-chip-group__list
.pf-m-overflow
.pf-c-chip__text::before {
content: "";
margin-left: var(--pf-global--spacer--sm);
padding-left: 0px;
}