added table truncate on role description (#34289)

fixes: #32992

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-10-30 13:28:04 +01:00 committed by GitHub
parent 7152a8b0f3
commit fd2338c4fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 8 deletions

View file

@ -74,7 +74,7 @@ export default class RoleMappingTab {
selectRow(name: string, modal = false) { selectRow(name: string, modal = false) {
cy.get(modal ? ".pf-v5-c-modal-box " : "" + this.#namesColumn) cy.get(modal ? ".pf-v5-c-modal-box " : "" + this.#namesColumn)
.contains(name) .contains(name)
.parent() .parents("tr")
.within(() => { .within(() => {
cy.get("input").click(); cy.get("input").click();
}); });

View file

@ -21,7 +21,7 @@ export default class AssociatedRolesPage {
cy.get(this.#addRoleTable) cy.get(this.#addRoleTable)
.contains(roleName) .contains(roleName)
.parent() .parents("tr")
.within(() => { .within(() => {
cy.get("input").click(); cy.get("input").click();
}); });
@ -49,7 +49,7 @@ export default class AssociatedRolesPage {
cy.get(this.#addRoleTable) cy.get(this.#addRoleTable)
.contains(roleName) .contains(roleName)
.parent() .parents("tr")
.within(() => { .within(() => {
cy.get("input").click(); cy.get("input").click();
}); });
@ -67,7 +67,7 @@ export default class AssociatedRolesPage {
cy.get(this.#addRoleTable) cy.get(this.#addRoleTable)
.contains(roleName) .contains(roleName)
.parent() .parents("tr")
.within(() => { .within(() => {
cy.get("input").click(); cy.get("input").click();
}); });

View file

@ -40,7 +40,7 @@ export default class UserRegistration {
selectRow(name: string) { selectRow(name: string) {
cy.get(this.#namesColumn) cy.get(this.#namesColumn)
.contains(name) .contains(name)
.parent() .parents("tr")
.within(() => { .within(() => {
cy.get("input").click(); cy.get("input").click();
}); });

View file

@ -1,3 +1,8 @@
import RoleRepresentation from "@keycloak/keycloak-admin-client/lib/defs/roleRepresentation";
import {
KeycloakDataTable,
ListEmptyState,
} from "@keycloak/keycloak-ui-shared";
import { import {
Button, Button,
Dropdown, Dropdown,
@ -9,14 +14,13 @@ import {
ToolbarItem, ToolbarItem,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { FilterIcon } from "@patternfly/react-icons"; import { FilterIcon } from "@patternfly/react-icons";
import { cellWidth, TableText } from "@patternfly/react-table";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAdminClient } from "../../admin-client"; import { useAdminClient } from "../../admin-client";
import { useAccess } from "../../context/access/Access"; import { useAccess } from "../../context/access/Access";
import { translationFormatter } from "../../utils/translationFormatter"; import { translationFormatter } from "../../utils/translationFormatter";
import useLocaleSort from "../../utils/useLocaleSort"; import useLocaleSort from "../../utils/useLocaleSort";
import { ListEmptyState } from "@keycloak/keycloak-ui-shared";
import { KeycloakDataTable } from "@keycloak/keycloak-ui-shared";
import { ResourcesKey, Row, ServiceRole } from "./RoleMapping"; import { ResourcesKey, Row, ServiceRole } from "./RoleMapping";
import { getAvailableRoles } from "./queries"; import { getAvailableRoles } from "./queries";
import { getAvailableClientRoles } from "./resource"; import { getAvailableClientRoles } from "./resource";
@ -33,6 +37,15 @@ type AddRoleMappingModalProps = {
type FilterType = "roles" | "clients"; type FilterType = "roles" | "clients";
const RoleDescription = ({ role }: { role: RoleRepresentation }) => {
const { t } = useTranslation();
return (
<TableText wrapModifier="truncate">
{translationFormatter(t)(role.description) as string}
</TableText>
);
};
export const AddRoleMappingModal = ({ export const AddRoleMappingModal = ({
id, id,
name, name,
@ -184,11 +197,12 @@ export const AddRoleMappingModal = ({
{ {
name: "name", name: "name",
cellRenderer: ServiceRole, cellRenderer: ServiceRole,
transforms: [cellWidth(20)],
}, },
{ {
name: "role.description", name: "role.description",
displayKey: "description", displayKey: "description",
cellFormatters: [translationFormatter(t)], cellRenderer: RoleDescription,
}, },
]} ]}
emptyState={ emptyState={