-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Add custom attributes support to organization invitations #48842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kota65535
wants to merge
2
commits into
keycloak:main
Choose a base branch
from
kota65535:vk/e990-invitation-attri
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...main/java/org/keycloak/representations/idm/OrganizationInvitationExistingUserRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package org.keycloak.representations.idm; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Request body for inviting an existing user to an organization by user ID. | ||
| */ | ||
| public class OrganizationInvitationExistingUserRequest { | ||
|
|
||
| private String id; | ||
| private Map<String, List<String>> attributes; | ||
|
|
||
| public OrganizationInvitationExistingUserRequest() { | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(String id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public Map<String, List<String>> getAttributes() { | ||
| return attributes; | ||
| } | ||
|
|
||
| public void setAttributes(Map<String, List<String>> attributes) { | ||
| this.attributes = attributes; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/src/main/java/org/keycloak/representations/idm/OrganizationInvitationUserRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package org.keycloak.representations.idm; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Request body for inviting a new or existing user to an organization by email. | ||
| */ | ||
| public class OrganizationInvitationUserRequest { | ||
|
|
||
| private String email; | ||
| private String firstName; | ||
| private String lastName; | ||
| private Map<String, List<String>> attributes; | ||
|
|
||
| public OrganizationInvitationUserRequest() { | ||
| } | ||
|
|
||
| public String getEmail() { | ||
| return email; | ||
| } | ||
|
|
||
| public void setEmail(String email) { | ||
| this.email = email; | ||
| } | ||
|
|
||
| public String getFirstName() { | ||
| return firstName; | ||
| } | ||
|
|
||
| public void setFirstName(String firstName) { | ||
| this.firstName = firstName; | ||
| } | ||
|
|
||
| public String getLastName() { | ||
| return lastName; | ||
| } | ||
|
|
||
| public void setLastName(String lastName) { | ||
| this.lastName = lastName; | ||
| } | ||
|
|
||
| public Map<String, List<String>> getAttributes() { | ||
| return attributes; | ||
| } | ||
|
|
||
| public void setAttributes(Map<String, List<String>> attributes) { | ||
| this.attributes = attributes; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
js/apps/admin-ui/src/organizations/InvitationAttributesModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { Button, Form, Modal, ModalVariant } from "@patternfly/react-core"; | ||
| import { FormProvider, useForm } from "react-hook-form"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { KeyValueInput } from "../components/key-value-form/KeyValueInput"; | ||
| import { | ||
| KeyValueType, | ||
| keyValueToArray, | ||
| } from "../components/key-value-form/key-value-convert"; | ||
|
|
||
| type InvitationAttributesModalProps = { | ||
| onSubmit: (attributes: Record<string, string[]>) => Promise<void>; | ||
| onClose: () => void; | ||
| }; | ||
|
|
||
| type InvitationAttributesForm = { | ||
| attributes: KeyValueType[]; | ||
| }; | ||
|
|
||
| export const InvitationAttributesModal = ({ | ||
| onSubmit, | ||
| onClose, | ||
| }: InvitationAttributesModalProps) => { | ||
| const { t } = useTranslation(); | ||
| const form = useForm<InvitationAttributesForm>(); | ||
| const { | ||
| handleSubmit, | ||
| formState: { isSubmitting }, | ||
| } = form; | ||
|
|
||
| const submitForm = async (data: InvitationAttributesForm) => { | ||
| const attributes = keyValueToArray(data.attributes); | ||
| await onSubmit(attributes); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| variant={ModalVariant.small} | ||
| title={t("invitationAttributes")} | ||
| isOpen | ||
| onClose={onClose} | ||
| actions={[ | ||
| <Button | ||
| data-testid="send" | ||
| key="confirm" | ||
| variant="primary" | ||
| onClick={handleSubmit(submitForm)} | ||
| isDisabled={isSubmitting} | ||
| isLoading={isSubmitting} | ||
| > | ||
| {t("send")} | ||
| </Button>, | ||
| <Button | ||
| data-testid="cancel" | ||
| key="cancel" | ||
| variant="link" | ||
| onClick={onClose} | ||
| > | ||
| {t("cancel")} | ||
| </Button>, | ||
| ]} | ||
| > | ||
| <FormProvider {...form}> | ||
| <Form id="invitation-attributes-form"> | ||
| <KeyValueInput name="attributes" /> | ||
| </Form> | ||
| </FormProvider> | ||
| </Modal> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.