-
Notifications
You must be signed in to change notification settings - Fork 407
feat(clerk-js,types): Surface enterprise accounts in UserProfile
#4518
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
Merged
LauraBeatris
merged 21 commits into
main
from
laura/orgs-293-display-enterprise-accounts-from-userenterprise_accounts
Nov 13, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
eced539
Add `EnterpriseAccount` resource to backend layer
LauraBeatris a3ca6c9
Add `EnterpriseAccount` to types layer
LauraBeatris 107dc77
Add `EnterpriseAccountResource` to clerk-js
LauraBeatris 0fe99f8
Populate `enterprise_accounts` on `User` resource
LauraBeatris 7b6c6de
Verify if there are enterprise accounts to display
LauraBeatris c83c34b
Update UI description with new enterprise provider union
LauraBeatris b18329d
Display enterprise accounts from `User` resource
LauraBeatris 9ae6104
Disallow user profile changes for multiple enterprise connection types
LauraBeatris 7f5056d
Introduce UI tests
LauraBeatris f6e67ee
Fix icon for SAML providers
LauraBeatris 0b2e26f
Update changeset
LauraBeatris b037709
Update `firstName` and `lastName` to be nullable
LauraBeatris efa346e
Update tests to rely on `enterprise_accounts`
LauraBeatris 38750b2
Add deprecation JSDocs
LauraBeatris 75c913b
Treat provider as strategy
LauraBeatris 63c8e3c
Add test for inactive connection
LauraBeatris 6f33bb6
Add generic descriptor for SSO connections
LauraBeatris 2c3ec62
Include generic `providerInitialIcon` descriptor
LauraBeatris 3e3cee6
Preserve `ProviderInitialIcon` descriptors
LauraBeatris d4cdd22
Rely on FAPI for connection name and logo
LauraBeatris e71267b
Use CDN for provider logo
LauraBeatris 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
There are no files selected for viewing
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,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/types': minor | ||
| --- | ||
|
|
||
| Surface enterprise accounts in `UserProfile`, allowing to display more protocols besides SAML |
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,98 @@ | ||
| import type { | ||
| EnterpriseAccountConnectionJSON, | ||
| EnterpriseAccountConnectionResource, | ||
| EnterpriseAccountJSON, | ||
| EnterpriseAccountResource, | ||
| VerificationResource, | ||
| } from '@clerk/types'; | ||
|
|
||
| import { unixEpochToDate } from '../../utils/date'; | ||
| import { BaseResource } from './Base'; | ||
| import { Verification } from './Verification'; | ||
|
|
||
| export class EnterpriseAccount extends BaseResource implements EnterpriseAccountResource { | ||
| id!: string; | ||
| protocol!: EnterpriseAccountResource['protocol']; | ||
| provider!: EnterpriseAccountResource['provider']; | ||
| providerUserId: string | null = null; | ||
| active!: boolean; | ||
| emailAddress = ''; | ||
| firstName: string | null = ''; | ||
| lastName: string | null = ''; | ||
| publicMetadata = {}; | ||
| verification: VerificationResource | null = null; | ||
| enterpriseConnection: EnterpriseAccountConnectionResource | null = null; | ||
|
|
||
| public constructor(data: Partial<EnterpriseAccountJSON>, pathRoot: string); | ||
| public constructor(data: EnterpriseAccountJSON, pathRoot: string) { | ||
| super(); | ||
| this.pathRoot = pathRoot; | ||
| this.fromJSON(data); | ||
| } | ||
|
|
||
| protected fromJSON(data: EnterpriseAccountJSON | null): this { | ||
| if (!data) { | ||
| return this; | ||
| } | ||
|
|
||
| this.id = data.id; | ||
| this.provider = data.provider; | ||
| this.protocol = data.protocol; | ||
| this.providerUserId = data.provider_user_id; | ||
| this.active = data.active; | ||
| this.emailAddress = data.email_address; | ||
| this.firstName = data.first_name; | ||
| this.lastName = data.last_name; | ||
| this.publicMetadata = data.public_metadata; | ||
|
|
||
| if (data.verification) { | ||
| this.verification = new Verification(data.verification); | ||
| } | ||
|
|
||
| if (data.enterprise_connection) { | ||
| this.enterpriseConnection = new EnterpriseAccountConnection(data.enterprise_connection); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| export class EnterpriseAccountConnection extends BaseResource implements EnterpriseAccountConnectionResource { | ||
| id!: string; | ||
| active!: boolean; | ||
| allowIdpInitiated!: boolean; | ||
| allowSubdomains!: boolean; | ||
| disableAdditionalIdentifications!: boolean; | ||
| domain!: string; | ||
| logoPublicUrl: string | null = ''; | ||
| name!: string; | ||
| protocol!: EnterpriseAccountResource['protocol']; | ||
| provider!: EnterpriseAccountResource['provider']; | ||
| syncUserAttributes!: boolean; | ||
| createdAt!: Date; | ||
| updatedAt!: Date; | ||
|
|
||
| constructor(data: EnterpriseAccountConnectionJSON | null) { | ||
| super(); | ||
| this.fromJSON(data); | ||
| } | ||
|
|
||
| protected fromJSON(data: EnterpriseAccountConnectionJSON | null): this { | ||
| if (data) { | ||
| this.id = data.id; | ||
| this.name = data.name; | ||
| this.domain = data.domain; | ||
| this.active = data.active; | ||
| this.provider = data.provider; | ||
| this.logoPublicUrl = data.logo_public_url; | ||
| this.syncUserAttributes = data.sync_user_attributes; | ||
| this.allowSubdomains = data.allow_subdomains; | ||
| this.allowIdpInitiated = data.allow_idp_initiated; | ||
| this.disableAdditionalIdentifications = data.disable_additional_identifications; | ||
| this.createdAt = unixEpochToDate(data.created_at); | ||
| this.updatedAt = unixEpochToDate(data.updated_at); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } |
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
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
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
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.