diff --git a/js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties b/js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties index f81428855f..eedb633c71 100644 --- a/js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties +++ b/js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties @@ -3222,7 +3222,8 @@ emptyUserOrganizationsInstructions=There is no organization yet. Please join an joinOrganization=Join organization sendInvitation=Send invitation removeConfirmOrganizationTitle=Remove organization? -organizationRemoveConfirm=Are you sure you want to remove user from the {{count}} selected organizations? +organizationRemoveConfirm_one=Are you sure you want to remove user from the selected organization? +organizationRemoveConfirm_other=Are you sure you want to remove user from the {{count}} selected organizations? organizationRemovedSuccess=User removed from organizations organizationRemoveError=Could not remove user from organizations\: {{error}} organizationName=Organization name @@ -3231,3 +3232,4 @@ join=Join userAddedOrganization_one=Organization added to the user userAddedOrganizationError=Could not add organizations to the user\: {{error}} userAddedOrganization_other={{count}} organizations added to the user +sentInvitation=Sent invitation diff --git a/js/apps/admin-ui/src/organizations/OrganizationModal.tsx b/js/apps/admin-ui/src/organizations/OrganizationModal.tsx index 80e8a79c4e..b018c63156 100644 --- a/js/apps/admin-ui/src/organizations/OrganizationModal.tsx +++ b/js/apps/admin-ui/src/organizations/OrganizationModal.tsx @@ -1,17 +1,23 @@ import OrganizationRepresentation from "@keycloak/keycloak-admin-client/lib/defs/organizationRepresentation"; import UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation"; import { Button, Modal, ModalVariant } from "@patternfly/react-core"; +import { differenceBy } from "lodash-es"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { useAdminClient } from "../admin-client"; import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable"; +import { TableText } from "@patternfly/react-table"; type OrganizationModalProps = { + isJoin?: boolean; + existingOrgs: OrganizationRepresentation[]; onAdd: (orgs: OrganizationRepresentation[]) => Promise; onClose: () => void; }; export const OrganizationModal = ({ + isJoin = true, + existingOrgs, onAdd, onClose, }: OrganizationModalProps) => { @@ -21,13 +27,20 @@ export const OrganizationModal = ({ const [selectedRows, setSelectedRows] = useState([]); const loader = async (first?: number, max?: number, search?: string) => { - return await adminClient.organizations.find({ first, max, search }); + const params = { + first, + search, + max: max! + existingOrgs.length, + }; + + const orgs = await adminClient.organizations.find(params); + return differenceBy(orgs, existingOrgs, "id"); }; return ( - {t("join")} + {isJoin ? t("join") : t("send")} ,