-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Redesigned user profile page #127624
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
thomheymann
merged 57 commits into
elastic:feature/user-profile
from
thomheymann:feature/user-profile-ui
May 24, 2022
Merged
Redesigned user profile page #127624
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
2e3a7b1
Add user profile UI
thomheymann 98eb7c7
add code doc
thomheymann 25eaf0b
More
thomheymann 87ae3f1
Fix nav control for anonymous users
thomheymann e696ce0
Move presentational logic outside form row
thomheymann 10f8f9b
Fix disabled state and update profile api
thomheymann 51825b9
remove presentational logic from form row
thomheymann 6147fb5
wip
thomheymann f46f750
Fix initials
thomheymann 4164504
.
thomheymann d96f416
empty user avatar
thomheymann 1a42bf4
simplify reserved user screen
thomheymann b50a171
.
thomheymann 97fe039
unit tests
thomheymann ea08f16
type fixes
thomheymann d416345
.
thomheymann 55eab66
.
thomheymann 488c489
.
thomheymann 4e7e819
.
thomheymann 31a1c35
.
thomheymann 5ce63e6
.
thomheymann c58ff85
.
thomheymann c4c6d36
.
thomheymann 2bd8875
.
thomheymann c5a4b71
.
thomheymann 833a8c7
.
thomheymann c6ec506
.
thomheymann a265b00
.
thomheymann 167a3d5
.
thomheymann 9043774
.
thomheymann 17101ee
Merge remote-tracking branch 'upstream/feature/user-profile' into fea…
thomheymann 906b4c0
.
thomheymann e433179
.
thomheymann d6851c7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine cf2d7b7
.
thomheymann 2049070
Merge branch 'feature/user-profile-ui' of github.com:thomheymann/kiba…
thomheymann ee80e55
.
thomheymann b9d8a1b
Merge branch 'feature/user-profile' of github.com:elastic/kibana into…
thomheymann b0f7015
.
thomheymann 8afade3
.
thomheymann 29d4ba8
.
thomheymann eb414b9
.
thomheymann 7a08f59
Merge branch 'feature/user-profile' into feature/user-profile-ui
kibanamachine 1ece49a
Merge branch 'feature/user-profile' into feature/user-profile-ui
kibanamachine 3385e40
Merge branch 'feature/user-profile' into pr-127624-user-profiles
azasypkin 02071b1
Merge branch 'feature/user-profile' into pr-127624-user-profiles
azasypkin a1b53ef
Review#1: handle UI inconsistencies, update avatar in the navigation …
azasypkin accd6c0
Fix type errors.
azasypkin cf1c0ce
Merge branch 'feature/user-profile' into pr-127624-user-profiles
azasypkin 462d2c2
Use different validation model for the first and subsequent submits.
azasypkin a34e015
Review#2: move change password form to a modal, support users authent…
azasypkin a887dad
Use proper test subject for the password change Cancel button.
azasypkin 81ed8d3
Review#3: retry profile activation requests.
azasypkin 3522bca
Merge branch 'feature/user-profile' into pr-127624-user-profiles
azasypkin 3e282fe
Review#4: align text color of the non-editable profile fields with th…
azasypkin 73fce79
Merge branch 'feature/user-profile' into pr-127624-user-profiles
azasypkin 0349691
Review#4: improve warning message for the change password form when c…
azasypkin 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { mockAuthenticatedUser } from './authenticated_user.mock'; | ||
| import type { AuthenticatedUserProfile } from './user_profile'; | ||
|
|
||
| export const userProfileMock = { | ||
| create: (userProfile: Partial<AuthenticatedUserProfile> = {}): AuthenticatedUserProfile => { | ||
| const user = mockAuthenticatedUser({ | ||
| username: 'some-username', | ||
| roles: [], | ||
| enabled: true, | ||
| }); | ||
| return { | ||
| uid: 'some-profile-uid', | ||
| enabled: true, | ||
| user: { | ||
| ...user, | ||
| active: true, | ||
| }, | ||
| data: {}, | ||
| ...userProfile, | ||
| }; | ||
| }, | ||
| }; |
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,116 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { VISUALIZATION_COLORS } from '@elastic/eui'; | ||
thomheymann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import type { User } from '..'; | ||
| import type { AuthenticatedUser } from './authenticated_user'; | ||
| import { getUserDisplayName } from './user'; | ||
|
|
||
| /** | ||
| * User information returned in user profile. | ||
| */ | ||
| export interface UserInfo extends User { | ||
| active: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Avatar stored in user profile. | ||
| */ | ||
| export interface UserAvatar { | ||
| initials?: string; | ||
| color?: string; | ||
| imageUrl?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Placeholder for data stored in user profile. | ||
| */ | ||
| export type UserData = Record<string, unknown>; | ||
|
|
||
| /** | ||
| * Describes properties stored in user profile. | ||
| */ | ||
| export interface UserProfile<T extends UserData = UserData> { | ||
| /** | ||
| * Unique ID for of the user profile. | ||
| */ | ||
| uid: string; | ||
|
|
||
| /** | ||
| * Indicates whether user profile is enabled or not. | ||
| */ | ||
| enabled: boolean; | ||
|
|
||
| /** | ||
| * Information about the user that owns profile. | ||
| */ | ||
| user: UserInfo; | ||
|
|
||
| /** | ||
| * User specific data associated with the profile. | ||
| */ | ||
| data: T; | ||
| } | ||
|
|
||
| /** | ||
| * User profile enriched with session information. | ||
| */ | ||
| export interface AuthenticatedUserProfile<T extends UserData = UserData> extends UserProfile<T> { | ||
| /** | ||
| * Information about the currently authenticated user that owns the profile. | ||
| */ | ||
| user: UserProfile['user'] & Pick<AuthenticatedUser, 'authentication_provider'>; | ||
| } | ||
|
|
||
| export const USER_AVATAR_FALLBACK_CODE_POINT = 97; // code point for lowercase "a" | ||
| export const USER_AVATAR_MAX_INITIALS = 2; | ||
|
|
||
| /** | ||
| * Determines the color for the provided user profile. | ||
| * If a color is present on the user profile itself, then that is used. | ||
| * Otherwise, a color is provided from EUI's Visualization Colors based on the display name. | ||
| * | ||
| * @param {UserInfo} user User info | ||
| * @param {UserAvatar} avatar User avatar | ||
| */ | ||
| export function getUserAvatarColor( | ||
| user: Pick<UserInfo, 'username' | 'full_name'>, | ||
| avatar?: UserAvatar | ||
| ) { | ||
| if (avatar && avatar.color) { | ||
| return avatar.color; | ||
| } | ||
|
|
||
| const firstCodePoint = getUserDisplayName(user).codePointAt(0) || USER_AVATAR_FALLBACK_CODE_POINT; | ||
|
|
||
| return VISUALIZATION_COLORS[firstCodePoint % VISUALIZATION_COLORS.length]; | ||
| } | ||
|
|
||
| /** | ||
| * Determines the initials for the provided user profile. | ||
| * If initials are present on the user profile itself, then that is used. | ||
| * Otherwise, the initials are calculated based off the words in the display name, with a max length of 2 characters. | ||
| * | ||
| * @param {UserInfo} user User info | ||
| * @param {UserAvatar} avatar User avatar | ||
| */ | ||
| export function getUserAvatarInitials( | ||
| user: Pick<UserInfo, 'username' | 'full_name'>, | ||
| avatar?: UserAvatar | ||
| ) { | ||
| if (avatar && avatar.initials) { | ||
| return avatar.initials; | ||
| } | ||
|
|
||
| const words = getUserDisplayName(user).split(' '); | ||
| const numInitials = Math.min(USER_AVATAR_MAX_INITIALS, words.length); | ||
|
|
||
| words.splice(numInitials, words.length); | ||
|
|
||
| return words.map((word) => word.substring(0, 1)).join(''); | ||
| } | ||
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.