Skip to content
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

Merged

Conversation

trumbitta
Copy link
Contributor

Description

Screen.Recording.2021-11-25.at.17.54.17.mov

This does a couple things:

  • Fixes Truncate branch name on the prebuilds page #5332 by truncating the branch name in the prebuilds tab
  • Adds a title to both the branch name and the commit (which was already truncated) so that the user is still able to read the complete info even when truncated. See the attached short video.
  • Aligns the branch name vertically to the rest of the info. Something that was bugging me to no end because I'm both border-line OCD and 45% UX designer 🤪. It's done with retrocompatibility in mind, to avoid a refactor. I'm willing to do the refactor if you want me to, tho.
  • Updates the README with some info from the awesome @iQQBot , and a screenshot.

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

Tweaks to the UI of the Prebuilds tab in the dashboard
Some improvements to the README of the dashboard, aimed at contributors

Documentation

@iQQBot
Copy link
Contributor

iQQBot commented Nov 25, 2021

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

@iQQBot
Copy link
Contributor

iQQBot commented Nov 25, 2021

/werft run

👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.0

@gtsiolis gtsiolis added the do-not-merge/cla-pending CLA has not been signed label Nov 25, 2021
@iQQBot
Copy link
Contributor

iQQBot commented Nov 25, 2021

And you maybe need change README.png to another name eg how-to-get-cookie.png, because README.png seem not pass pre-commit check

@trumbitta
Copy link
Contributor Author

trumbitta commented Nov 25, 2021

@iQQBot sure thing, doing it all right now!

  • Do you need me to do something about the CLA or should I wait for input by @meysholdt ?
  • I chose the name README.png to keep it well sorted near the README.md :-/ is there a way for me to run the pre-commit hook before submitting the update, so that I can find the best name?
    [UPDATE]: I tried pre-commit run --all-files which I found in werft logs, but it fails with an error about --user not possible in a virtualenv, so I think I'll just keep the name you suggested 😺
  • Are you sure you want me to squash all of the commits into one? What if I squash together the 3 commits that update the prebuilds tab, then keep the one for the ItemField component and the one for the README apart? 3 commits total after I rebase them. (I'll do it like this without waiting for your reply, since I can always squash them all into one if you say "no, squash them all" 😄 )

@gtsiolis
Copy link
Contributor

gtsiolis commented Nov 26, 2021

/werft run

👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.1

@trumbitta
Copy link
Contributor Author

Oof I fat-fingered a merge from main into this branch. Going to delete the commit right now.

@trumbitta
Copy link
Contributor Author

trumbitta commented Nov 26, 2021

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

👀

@meysholdt
Copy link
Member

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.

@trumbitta
Copy link
Contributor Author

trumbitta commented Nov 26, 2021

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! 🖊️

@meysholdt meysholdt added cla: accepted ✔️ and removed do-not-merge/cla-pending CLA has not been signed labels Nov 26, 2021
@meysholdt
Copy link
Member

Thank you @trumbitta for signing the CLA!

Copy link
Contributor

@jankeromnes jankeromnes left a 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"}`}>
Copy link
Contributor

@jankeromnes jankeromnes Nov 27, 2021

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. 🙂

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring done!

Copy link
Contributor

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 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.

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>
Copy link
Contributor

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>
Copy link
Contributor

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 🙏)

Copy link
Contributor Author

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 its children 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?

Copy link
Contributor

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!

@iQQBot
Copy link
Contributor

iQQBot commented Nov 27, 2021

/werft run

👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.2

@trumbitta trumbitta force-pushed the trumbitta/truncate-branch-name-5332 branch from 5e85f26 to afadeba Compare November 28, 2021 21:15
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
@trumbitta trumbitta force-pushed the trumbitta/truncate-branch-name-5332 branch from afadeba to 8720b99 Compare November 28, 2021 22:53
@roboquat roboquat added size/L and removed size/M labels Nov 28, 2021
@jankeromnes
Copy link
Contributor

jankeromnes commented Nov 29, 2021

/werft run

👍 started the job as gitpod-build-trumbitta-truncate-branch-name-5332-fork.3

Copy link
Contributor

@jankeromnes jankeromnes left a 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">
Copy link
Contributor

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).

Suggested change
<ItemField className="flex items-center my-auto">
<ItemField className="flex items-center">

Copy link
Contributor Author

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" 😄

Copy link
Contributor

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">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
<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">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same:

Suggested change
<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">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same:

Suggested change
<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">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same:

Suggested change
<ItemField className="flex items-center my-auto">
<ItemField className="flex items-center">

@roboquat
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6991a620a0fc6ea32cc075f2f6f8e679eb42cfb5

@roboquat
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@roboquat roboquat merged commit e2c1988 into gitpod-io:main Nov 29, 2021
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cla: accepted ✔️ community-contribution deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Truncate branch name on the prebuilds page
6 participants