diff --git a/apps/admin-ui/src/realm-settings/keys/KeysProvidersTab.tsx b/apps/admin-ui/src/realm-settings/keys/KeysProvidersTab.tsx index 102ef9da30..9808b016e9 100644 --- a/apps/admin-ui/src/realm-settings/keys/KeysProvidersTab.tsx +++ b/apps/admin-ui/src/realm-settings/keys/KeysProvidersTab.tsx @@ -5,9 +5,6 @@ import { AlertVariant, Button, ButtonVariant, - Dropdown, - DropdownItem, - DropdownToggle, InputGroup, PageSection, TextInput, @@ -30,6 +27,7 @@ import { KEY_PROVIDER_TYPE } from "../../util"; import useToggle from "../../utils/useToggle"; import { ProviderType, toKeyProvider } from "../routes/KeyProvider"; import { KeyProviderModal } from "./key-providers/KeyProviderModal"; +import { KeyProvidersPicker } from "./key-providers/KeyProvidersPicker"; import "../realm-settings-section.css"; @@ -65,9 +63,8 @@ export const KeysProvidersTab = ({ const serverInfo = useServerInfo(); const keyProviderComponentTypes = serverInfo.componentTypes?.[KEY_PROVIDER_TYPE] ?? []; - const providerTypes = keyProviderComponentTypes.map((item) => item.id); - const [providerDropdownOpen, setProviderDropdownOpen] = useState(false); + const [providerOpen, toggleProviderOpen] = useToggle(); const [defaultUIDisplayName, setDefaultUIDisplayName] = useState(); @@ -140,6 +137,16 @@ export const KeysProvidersTab = ({ return ( <> + {providerOpen && ( + toggleProviderOpen()} + onConfirm={(provider) => { + handleModalToggle(); + setDefaultUIDisplayName(provider as ProviderType); + toggleProviderOpen(); + }} + /> + )} {isCreateModalOpen && defaultUIDisplayName && ( - setProviderDropdownOpen(val)} - isPrimary - > - {t("addProvider")} - - } - dropdownItems={[ - providerTypes.map((item) => ( - { - handleModalToggle(); - - setProviderDropdownOpen(false); - setDefaultUIDisplayName(item as ProviderType); - }} - data-testid={`option-${item}`} - key={item} - > - {item} - - )), - ]} - /> + onClick={() => toggleProviderOpen()} + > + {t("addProvider")} + diff --git a/apps/admin-ui/src/realm-settings/keys/key-providers/KeyProvidersPicker.tsx b/apps/admin-ui/src/realm-settings/keys/key-providers/KeyProvidersPicker.tsx new file mode 100644 index 0000000000..ca896609d8 --- /dev/null +++ b/apps/admin-ui/src/realm-settings/keys/key-providers/KeyProvidersPicker.tsx @@ -0,0 +1,61 @@ +import { + DataList, + DataListCell, + DataListItem, + DataListItemCells, + DataListItemRow, + Modal, +} from "@patternfly/react-core"; +import { useTranslation } from "react-i18next"; +import { useServerInfo } from "../../../context/server-info/ServerInfoProvider"; +import { KEY_PROVIDER_TYPE } from "../../../util"; + +type KeyProvidersPickerProps = { + onConfirm: (provider: string) => void; + onClose: () => void; +}; + +export const KeyProvidersPicker = ({ + onConfirm, + onClose, +}: KeyProvidersPickerProps) => { + const { t } = useTranslation("realm-settings"); + const serverInfo = useServerInfo(); + const keyProviderComponentTypes = + serverInfo.componentTypes?.[KEY_PROVIDER_TYPE] ?? []; + return ( + + { + onConfirm(id); + }} + aria-label={t("addPredefinedMappers")} + isCompact + > + {keyProviderComponentTypes.map((provider) => ( + + + + {provider.id} + , + + {provider.helpText} + , + ]} + /> + + + ))} + + + ); +};