-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Truncate branch name in prebuilds tab, and more #6907
Truncate branch name in prebuilds tab, and more #6907
Conversation
Thank you for this contribution. Before we can merge this PR, we need to make sure we have a Contributor License Agreement (CLA) with you on record. @meysholdt And please squash these commit into one @trumbitta |
/werft run 👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.0 |
And you maybe need change |
@iQQBot sure thing, doing it all right now!
|
4103e71
to
ccdf749
Compare
/werft run 👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.1 |
Oof I fat-fingered a merge from main into this branch. Going to delete the commit right now. |
No ok, I'm risking of doing more harm and it should be harmless to leave it since it's all going to go back on main either way 👀 |
hi @trumbitta ! I've send you a CLA to sign via DocuSign. If you have questions, feel free to ping me via moritz@gitpod.io. |
Done! 🖊️ |
Thank you @trumbitta for signing the CLA! |
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.
Hi @trumbitta, many thanks for improving Gitpod's dashboard! ✨ 🙏
No ok, I'm risking of doing more harm and it should be harmless to leave it since it's all going to go back on main either way
No worries here. We want to avoid merge commits on Gitpod's main branch, but since this Pull Request will get "Rebase&Merge"d eventually, this will remove the merge commit automatically.
By the way, if you wanted to remove the merge commit yourself (no need to, but just in case), you could:
- Open this Pull Request in Gitpod: https://gitpod.io/#https://github.com/gitpod-io/gitpod/pull/6907
- Run
git pull --rebase upstream main
(this will rebase your commits and remove the merge commit) - Run
git push -f origin trumbitta/truncate-branch-name-5332
(the force-push is needed in order to change or remove commits from your branch)
I've had a quick look at your changes, and I must say I really like the README.md clarifications, and the use of truncate
classes and title
attributes. 💯 I would love to see them merged.
One minor point that is causing me to delay the approval of this Pull Request is the new shouldCenterVertically
prop, and the slight ambiguity it creates on the CSS classes. Please see my comment inline, and let me know what you think of it (please address it if you agree, but it's also fine to simply reject my comment if you disagree).
{props.children} | ||
</div>; | ||
return ( | ||
<div className={`flex-grow mx-1 ${props.className || ""} ${props.shouldCenterVertically ? "my-auto" : "my-0"}`}> |
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.
Thank you for making the vertical centering optional!
However, I see that you can now set vertical margins via both props.className
(e.g. by including my-auto
and/or my-0
in the classes) or the new props.shouldCenterVertically
boolean. This creates a slight ambiguity, as future developers might accidentally provide conflicting margin classes, and then wonder why their vertical centering doesn't work properly.
How about shifting the responsibility of my-auto
vs my-0
(or no my
class at all) to the users of ItemField
instead? (I.e. remove my-auto
from the className here as you did, but don't introduce a props.shouldCenterVertically
-- simply let all the users of ItemField
provide a my-auto
via the props.className
if needed).
Please let me know what you think of this alternative proposal. 🙂
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.
100% agree!
I don't know if you had the chance to take a look at my commit messages, but the gist of it is I chose to add a prop purposely for limiting the scope of my intervention and "don't go too far my first time around".
I'm totally up for a refactoring involving the 5-6 components where this one is used and removing the new prop, and I'll work on it as soon as I am able.
As a side note, there's also something that makes my spider-senses tingle about having to use both my-auto
and items-center
to center things, but at this moment I just don't know Tailwind nor how it's used in this codebase well enough to propose anything about it.
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.
Refactoring done!
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.
Refactoring done!
Wow, many thanks! 💯 🙏 I'll take another look at your changes today.
As a side note, there's also something that makes my spider-senses tingle about having to use both
my-auto
anditems-center
to center things, but at this moment I just don't know Tailwind nor how it's used in this codebase well enough to propose anything about it.
You're absolutely right, that's an excellent point. 🎯 From my perspective:
- centering things with flex is far superior to centering with margins (flex makes it quite easy, and the produced layout "makes sense" and works well in the majority of situations regardless of screen size, doesn't create awkward overflows, etc.)
- there is still a lot of margin-centering in the code base (or, worse, both margin- and flex-centering combined 🙈) which could be improved by removing all the auto margins and using flex instead
However, in the interest of not derailing this Pull Request too much, maybe let's focus on the my-auto
refactoring here. We can always switch to flex in future Pull Requests. 😁
@@ -193,13 +193,13 @@ export default function () { | |||
</ItemField> | |||
<ItemField className="flex items-center"> | |||
<div className="truncate"> | |||
<div className="text-base text-gray-500 dark:text-gray-50 font-medium mb-1 truncate">{shortCommitMessage(p.info.changeTitle)}</div> | |||
<div className="text-base text-gray-500 dark:text-gray-50 font-medium mb-1 truncate" title={shortCommitMessage(p.info.changeTitle)}>{shortCommitMessage(p.info.changeTitle)}</div> |
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.
Yes 🙏 thank you for that!
<span className="font-medium text-gray-500 dark:text-gray-50">{p.info.branch}</span> | ||
<ItemField className="flex" shouldCenterVertically={false}> | ||
<div className="flex space-x-2 truncate"> | ||
<span className="font-medium text-gray-500 dark:text-gray-50 truncate" title={p.info.branch}>{p.info.branch}</span> |
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.
Also looks good to me!
One small nit: I think it's an anti-pattern to add a truncate
class to both an element and its container. In theory, only one should be required. Maybe you can remove the truncate
class from the container? (Haven't actually tested this -- if it doesn't work, please don't worry about this comment 🙏)
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.
Again, 100% agree.
When I was starting to work on this, I think I found an old commit adding the same thing to another piece of the app (maybe it was just a few lines above these, I can't remember) and I found the double truncate
to be weird... but it turns out it is needed! It doesn't work without.
That's because the CSS ellipsis needs the parent to have certain properties in order to work as expected, and the truncate
class happens to also add those. So at the end of the day it's a hack, a workaround, that I found in the codebase and applied here.
Here's my proposal: I'll create a new TruncatedText
component in components/dashboard/src/components
which will:
- provide the necessary CSS "environment" for
truncate
to work - use
truncate
on itschildren
text - accept a
title
prop
This will result in another refactoring over 38 files 😅 but, hey, I'll do it 💪.
Thoughts?
Also, since this new double truncate
is perfectly in line with what's already around there, maybe I could open another issue / PR and work on it as my next task?
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.
Aha, many thanks for explaining why the double truncate
is needed @trumbitta.
Maybe the underlying reason is that Tailwind's truncate
class is actually a combination of several CSS classes: https://tailwindcss.com/docs/text-overflow
If possible, I think I'd prefer a refactoring that makes our code always use truncate class(es) properly, instead of creating a brand new React component to solve this, but I could be wrong here.
Also, since this new double
truncate
is perfectly in line with what's already around there, maybe I could open another issue / PR and work on it as my next task?
Agreed. 👍 I think you could indeed open an issue about unifying how we truncate text, and we could move this discussion there. Thanks for caring about this!
/werft run 👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.2 |
5e85f26
to
afadeba
Compare
1. Truncate branch name in prebuilds tab 2. Add long form titles to truncated info in prebuilds tab 3. In the prebuilds tab, vertically align the branch name with the other info
afadeba
to
8720b99
Compare
/werft run 👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.3 |
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 looks good to me, and works like a charm. ✨ Many thanks again for improving the dashboard! 💯
I've noticed a few places where the margin-centering could be replaced by flex-centering, but this Pull Request is already a net positive as is, so I'd love to see it merged. 🚀
If you're interested and have time, I'd be more than happy to discuss / help with / review follow-up Pull Requests. 😁
/approve
/lgtm
<span>Branch</span> | ||
</ItemField> | ||
</Item> | ||
{prebuilds.filter(filter).sort(prebuildSorter).map((p, index) => <Item key={`prebuild-${p.info.id}`} className="grid grid-cols-3"> | ||
<ItemField className="flex items-center"> | ||
<ItemField className="flex items-center my-auto"> |
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.
Aha, I think here the my-auto
isn't actually needed (since flex items-center
already does the vertical centering).
<ItemField className="flex items-center my-auto"> | |
<ItemField className="flex items-center"> |
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.
Yeah, I just went for a safe refactoring: "monkey pulls my-auto
out of ItemField
component, monkey adds my-auto
to ItemField
classes everywhere" 😄
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.
That's the best kind of refactoring 😁 🙏
@@ -191,15 +191,15 @@ export default function () { | |||
<p>{p.info.startedByAvatar && <img className="rounded-full w-4 h-4 inline-block align-text-bottom mr-2" src={p.info.startedByAvatar || ''} alt={p.info.startedBy} />}Triggered {formatDate(p.info.startedAt)}</p> | |||
</Link> | |||
</ItemField> | |||
<ItemField className="flex items-center"> | |||
<ItemField className="flex items-center my-auto"> |
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.
Same here:
<ItemField className="flex items-center my-auto"> | |
<ItemField className="flex items-center"> |
@@ -228,21 +228,21 @@ export default function () { | |||
const status = prebuildStatusLabel(prebuild); | |||
|
|||
return <Item key={`branch-${index}-${branch.name}`} className="grid grid-cols-3 group"> | |||
<ItemField className="flex items-center"> | |||
<ItemField className="flex items-center my-auto"> |
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.
Same:
<ItemField className="flex items-center my-auto"> | |
<ItemField className="flex items-center"> |
<div> | ||
<a href={branch.url}><div className="text-base text-gray-600 hover:text-gray-800 dark:text-gray-50 dark:hover:text-gray-200 font-medium mb-1"> | ||
{branch.name} | ||
{branch.isDefault && (<span className="ml-2 self-center rounded-xl py-0.5 px-2 text-sm bg-blue-50 text-blue-40 dark:bg-blue-500 dark:text-blue-100">DEFAULT</span>)} | ||
</div></a> | ||
</div> | ||
</ItemField> | ||
<ItemField className="flex items-center"> | ||
<ItemField className="flex items-center my-auto"> |
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.
Same:
<ItemField className="flex items-center my-auto"> | |
<ItemField className="flex items-center"> |
<div className="truncate"> | ||
<div className="text-base text-gray-500 dark:text-gray-50 font-medium mb-1 truncate">{shortCommitMessage(branch.changeTitle)}</div> | ||
<p>{avatar}Authored {formatDate(branch.changeDate)} · {branch.changeHash?.substring(0, 8)}</p> | ||
</div> | ||
</ItemField> | ||
<ItemField className="flex items-center"> | ||
<ItemField className="flex items-center my-auto"> |
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.
Same:
<ItemField className="flex items-center my-auto"> | |
<ItemField className="flex items-center"> |
LGTM label has been added. Git tree hash: 6991a620a0fc6ea32cc075f2f6f8e679eb42cfb5
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jankeromnes Associated issue: #5332 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Screen.Recording.2021-11-25.at.17.54.17.mov
This does a couple things:
Related Issue(s)
Fixes #5332
How to test
Just start the dashboard and navigate to the prebuild tab of a project. Make sure to have the prebuild of a branch with a long name so that the actual truncation can happen.
Release Notes
Documentation