diff --git a/src/realm-settings/messages.ts b/src/realm-settings/messages.ts index dab5e8dc3f..aa1503a4b7 100644 --- a/src/realm-settings/messages.ts +++ b/src/realm-settings/messages.ts @@ -372,6 +372,7 @@ export default { updateMessageBundleSuccess: "Success! Message bundle updated.", updateMessageBundleError: "Error updating message bundle.", addMessageBundleError: "Error creating message bundle, {{error}}", + allGroups: "All groups", attributeName: "Name", attributeDisplayName: "Display name", attributeGroup: "Attribute group", diff --git a/src/realm-settings/user-profile/AttributesTab.tsx b/src/realm-settings/user-profile/AttributesTab.tsx index c1b133fe51..f7a016d19d 100644 --- a/src/realm-settings/user-profile/AttributesTab.tsx +++ b/src/realm-settings/user-profile/AttributesTab.tsx @@ -4,19 +4,24 @@ import { Button, ButtonVariant, Divider, - Dropdown, - DropdownItem, - KebabToggle, + Select, + SelectOption, + SelectVariant, + Toolbar, + ToolbarContent, ToolbarItem, } from "@patternfly/react-core"; +import { FilterIcon } from "@patternfly/react-icons"; + +import type { UserProfileAttribute } from "@keycloak/keycloak-admin-client/lib/defs/userProfileConfig"; import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner"; import { DraggableTable } from "../../authentication/components/DraggableTable"; -import type { UserProfileAttribute } from "@keycloak/keycloak-admin-client/lib/defs/userProfileConfig"; -import { useHistory } from "react-router-dom"; +import { Link, useHistory } from "react-router-dom"; import { toAddAttribute } from "../routes/AddAttribute"; import { useRealm } from "../../context/realm-context/RealmContext"; import { useUserProfile } from "./UserProfileContext"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; +import useToggle from "../../utils/useToggle"; type movedAttributeType = UserProfileAttribute; @@ -25,12 +30,12 @@ export const AttributesTab = () => { const { realm: realmName } = useRealm(); const { t } = useTranslation("realm-settings"); const history = useHistory(); + const [filter, setFilter] = useState("allGroups"); + const [isFilterTypeDropdownOpen, toggleIsFilterTypeDropdownOpen] = + useToggle(); + const [data, setData] = useState(config?.attributes); const [attributeToDelete, setAttributeToDelete] = useState<{ name: string }>(); - const [kebabOpen, setKebabOpen] = useState({ - status: false, - rowKey: "", - }); const executeMove = async ( attribute: UserProfileAttribute, @@ -81,23 +86,67 @@ export const AttributesTab = () => { }, }); - if (!config) { + if (!config?.attributes) { return ; } return ( <> -
- - - -
+ + + + + + + + + + { executeMove(dragged, newIndex); }} + actions={[ + { + title: t("common:edit"), + onClick: goToCreate, + }, + { + title: t("common:delete"), + onClick: (_key, _idx, component) => { + setAttributeToDelete(component.name); + toggleDeleteDialog(); + }, + }, + ]} columns={[ { name: "name", displayKey: t("attributeName"), + cellRenderer: (row) => ( + {row.name} + ), }, { name: "displayName", @@ -124,68 +189,8 @@ export const AttributesTab = () => { name: "group", displayKey: t("attributeGroup"), }, - { - name: "", - displayKey: "", - cellRenderer: (row) => ( - - setKebabOpen({ - status, - rowKey: row.name!, - }) - } - id={`toggle-${row.name}`} - /> - } - isOpen={kebabOpen.status && kebabOpen.rowKey === row.name} - isPlain - dropdownItems={[ - { - setKebabOpen({ - status: false, - rowKey: row.name!, - }); - }} - > - {t("common:edit")} - , - - {row.name !== "email" && row.name !== "username" - ? [ - { - toggleDeleteDialog(); - setAttributeToDelete({ - name: row.name!, - }); - setKebabOpen({ - status: false, - rowKey: row.name!, - }); - }} - > - {t("common:delete")} - , - ] - : []} - , - ]} - /> - ), - }, ]} - data={config.attributes!} + data={data || config.attributes} /> );