Skip to content

refactor: simplify user profile to username-only state#1587

Merged
svor merged 1 commit into
mainfrom
CRW-10682_1
Jun 8, 2026
Merged

refactor: simplify user profile to username-only state#1587
svor merged 1 commit into
mainfrom
CRW-10682_1

Conversation

@vinokurig

@vinokurig vinokurig commented May 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

In some circumstances, e.g., a high-load OpenShift cluster, creating or updating a Kubernetes secret may take some time (it is not instant). If reading the user-profile secret occurs during the create or update operation of the secret, an error is thrown. In order to avoid this race condition, request the user from the che-server API instead of reading the user-profile secret directly.

Removed the full user profile API endpoint and state management in favor of a simpler username-only approach. The previous IUserProfile interface contained both email and username, but only username was actively used throughout the application.

Changes:

  • Backend: removed /api/userprofile endpoint and userProfileApi service
  • Frontend: renamed User/Profile store slice to User/Name and removed the redundant gravatar icon
  • API: removed IUserProfile interface from common DTO
  • Simplified API response to return username string directly
  • Updated all imports and selectors to use new username-only state
  • Renamed actionCreators from userProfileActionCreators to usernameActionCreators
  • Updated all tests to reflect new naming and structure

Screenshot/screencast of this PR

What issues does this PR fix or reference?

https://redhat.atlassian.net/browse/CRW-10682

Is it tested? How?

N/A

Release Notes

Docs PR

@che-bot

che-bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1587 (linux/amd64, linux/arm64)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1587", name: che-dashboard}]}}]"

@olexii4 olexii4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is correct — switching away from reading the user-profile secret during concurrent writes makes sense. But there are a couple of things that need to be addressed.

The gravatar-url package generates image URLs by hashing an email address. Passing a username instead of an email will never match any real Gravatar account — every user will get the same generated fallback avatar. So removing email from the profile breaks the avatar in the header. The Avatar component needs to be redesigned with this in mind — either use initials, a generic user icon, or find another way to get the email.

Also, the old code had {isUserAuthenticated && (...)} guards around UserMenu and Avatar. Those are gone now, so both components always render — including during bootstrap when the username is still 'unknown'. That needs to be handled somehow.

My suggestion: instead of merging this PR, let's look at #1569 and fix it there. The original approach of reading the user-profile secret is fine — the only problem is the race condition on high-load clusters. That can be handled by adding a short delay and a few retries before giving up. That way we keep the email, the Gravatar works, and we don't need che-server#1018 to land first.

@vinokurig @akurinnoy what do you think?

@vinokurig

Copy link
Copy Markdown
Contributor Author

@olexii4 Originally we do not have email either, we generate it from the username by adding @che to the username, see.
So in origin it does not work as well.

@olexii4

olexii4 commented May 28, 2026

Copy link
Copy Markdown
Contributor

@olexii4 Originally we do not have email either, we generate it from the username by adding @che to the username, see.
So in origin it does not work as well.

@vinokurig thanks, that settles it. If the email was always <username>@che, the Gravatar has never resolved to a real account — it has always been the retro generated fallback. This PR changes nothing observable for the avatar.

That makes me think we should just remove the Avatar entirely from Tools/index.tsx. There is nothing meaningful behind it:

  • gravatarUrl(email) with a synthetic @che address never matches a real account
  • the component always renders the same generated placeholder
  • keeping it means keeping the gravatar-url dependency and the isUserAuthenticated guard for no practical benefit

Concretely, remove from packages/dashboard-frontend/src/Layout/Header/Tools/index.tsx:

-import gravatarUrl from 'gravatar-url';
...
-  const imageUrl = email ? gravatarUrl(email, { default: 'retro' }) : '';
-  const isUserAuthenticated = !!email;
...
-          {isUserAuthenticated && (
-            <ToolbarItem>
-              <Avatar src={imageUrl} alt="Avatar image" size="md" />
-            </ToolbarItem>
-          )}

@ibuziuk @svor — thoughts on dropping the Avatar altogether?

@svor

svor commented May 29, 2026

Copy link
Copy Markdown
Contributor

IMO it makes sense to remove the avatar since it doesn't provide any functionality or useful information - it's just a default icon. It would also make the UI more consistent with the OpenShift console.

Remove unused user profile backend endpoints and rename User.Profile store to User.Name to reflect that it only manages the username.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vinokurig

Copy link
Copy Markdown
Contributor Author

@olexii4 @svor
removed the gravatar widget:
image

@github-actions

Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1587 (linux/amd64, linux/arm64)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1587", name: che-dashboard}]}}]"

@svor svor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@openshift-ci openshift-ci Bot added the lgtm label Jun 1, 2026

@olexii4 olexii4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci

openshift-ci Bot commented Jun 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4, svor, vinokurig

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vinokurig

Copy link
Copy Markdown
Contributor Author

/retest

@tolusha

tolusha commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm che-ai-assistant — I help with your pull requests.

Available commands:

  • /che-ai-assistant generate-che-doc — Generate a documentation PR based on this PR's changes
  • /che-ai-assistant ok-pr-review — Run a comprehensive PR review (summary, code review, deep review, impact analysis)
  • /che-ai-assistant help — Show this help message

@vinokurig

Copy link
Copy Markdown
Contributor Author

/retest

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.52%. Comparing base (060daf1) to head (fbeb235).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...tend/src/services/backend-client/userProfileApi.ts 66.66% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1587    +/-   ##
========================================
  Coverage   92.52%   92.52%            
========================================
  Files         563      561     -2     
  Lines       56291    56153   -138     
  Branches     4278     4275     -3     
========================================
- Hits        52084    51957   -127     
+ Misses       4157     4146    -11     
  Partials       50       50            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@svor svor merged commit a6fee2f into main Jun 8, 2026
19 checks passed
@svor svor deleted the CRW-10682_1 branch June 8, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants