-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[server] For GitLab projects without an owner avatar, fall back to the namespace avatar, or generate the default GitLab avatar #8824
Conversation
Note: When there is no avatar, it would be nice to use the same default avatar as GitLab (i.e. a big letter with a pastel background). However, I couldn't find how to generate this, so for now I left the avatar URL empty when there is no avatar. |
Looking at this now! 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up, @jankeromnes!
Commented below about two outstanding issues related to UX here.
return anyProject.owner.avatar_url; | ||
} | ||
if (anyProject.namespace?.avatar_url) { | ||
let url = anyProject.namespace.avatar_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Not sure if this is the correct line to comment this but the avatar seems broken now while before it was just a white blank space, see screenshots below. But maybe this is an improvement step towards resolving this issue?
fyi: The one before the last one below is the gitlab-org
group which has an avatar.
BEFORE | AFTER |
---|---|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for catching this @gtsiolis. If you inspect the broken icons, what does the avatar URL look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jankeromnes for all of the ones with a missing avatar, including the gitlab-org
group which has an avatar, I see the following in dev tools:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thanks for fixing this, work like a charm. ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what's special about these groups 🤔 needs more debugging (e.g. maybe you can invite me to one of these, or I can create another Pull Request with more debug logs and ask you to reproduce in there).
Filed follow-up issue: #9112
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be working ok now for all but one of the groups in there, posted a comment in #9112 (comment).
Taking this back to draft as there is some work left to do. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
2e92b16
to
84c3c59
Compare
84c3c59
to
7e5c93e
Compare
4eb07ee
to
25f5c1c
Compare
Ready for another round of reviews! 🚀 I've implemented a default avatar generator similar to GitLab's one (thanks @gtsiolis for linking the relevant code! 🎯) so there should always be an avatar now. I've also implemented more specific types (instead of using |
Taking another look now! 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took another look and left some more comments below. Thanks, @jankeromnes! 🏀
// - https://gitlab.com/gitlab-org/gitlab-foss/-/blob/84b4743475246e91dc78c3f25f9b335c40be84cd/app/assets/stylesheets/startup/startup-general.scss#L420-422 | ||
const text = owner.name[0].toUpperCase(); | ||
const backgroundColor = ["#fcf1ef", "#f4f0ff", "#f1f1ff", "#e9f3fc", "#ecf4ee", "#fdf1dd", "#f0f0f0"][ | ||
owner.id % 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: It so much fun to see the same logic here. Good memories! 🦊
25f5c1c
to
ab4af90
Compare
Briefly taking this back to Draft for some quick debugging. |
17db447
to
55d9ce7
Compare
Phew. Okay now this should be ready to rock'n'roll. 🎸😁 @gtsiolis please take another look when you have some time. 🙏 (For what it's worth, I initially estimated this work as a 0.25 day effort / 1 iteration -- looks like I was about 10x off on both. 😅) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise looks good to me. Adding hold to resolve remaining questions.
/hold
@@ -237,7 +237,11 @@ export default function NewProject() { | |||
|
|||
const accounts = new Map<string, { avatarUrl: string }>(); | |||
reposInAccounts.forEach((r) => { | |||
if (!accounts.has(r.account)) accounts.set(r.account, { avatarUrl: r.accountAvatarUrl }); | |||
if (!accounts.has(r.account)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Much nicer on the eyes
Taking another look at this now! 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @jankeromnes! 🔮
const backgroundColor = ["#fcf1ef", "#f4f0ff", "#f1f1ff", "#e9f3fc", "#ecf4ee", "#fdf1dd", "#f0f0f0"][ | ||
owner.id % 7 | ||
]; | ||
// Uppercase first character of the name, support emojis, default to whitespace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Lovely comment! 💯
…e top-level group avatar, or generate the default GitLab avatar
55d9ce7
to
075997a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works like a charm, @jankeromnes! 🔮
Thanks for also opening the follow up issue in #8824 (comment) to track one potentially minor edge case. 💯
Approving for UX, but you'll still need an approval from someone from the WebApp team.
Waiting on code owner review from gitpod-io/engineering-webapp.
Description
For GitLab projects belonging to a group, it seems that there is no
owner.avatar_url
to be found here:gitpod/components/server/ee/src/gitlab/gitlab-app-support.ts
Line 46 in fc68e47
Example group project from GitLab's API:
As you can see, there is no
"owner"
, but there is an avatar URL on the"namespace"
(although it's relative).When there is no owner avatar URL, this Pull Request falls back to the namespace avatar URL if available.
EDIT: When no avatar is available, it generates a SVG avatar that looks like GitLab's own default group avatar.
Related Issue(s)
Fixes #5330
How to test
/new
-- the GitLab group should have the set avatar visibleRelease Notes
Documentation