Skip to content

Conversation

ciiay
Copy link
Contributor

@ciiay ciiay commented Aug 11, 2021

Fixes #4233

Signed-off-by: ciiay yicai@redhat.com

Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).

@codecov
Copy link

codecov bot commented Aug 11, 2021

Codecov Report

Merging #6954 (5cf5f63) into master (0dcac9a) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #6954   +/-   ##
=======================================
  Coverage   40.98%   40.98%           
=======================================
  Files         158      158           
  Lines       21305    21305           
=======================================
  Hits         8731     8731           
  Misses      11334    11334           
  Partials     1240     1240           
Impacted Files Coverage Δ
util/settings/settings.go 47.38% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0dcac9a...5cf5f63. Read the comment docs.

Comment on lines 175 to 179
const contentStart = resKey.substr(0, Math.floor(resKey.length / 2));
let contentEnd = resKey.substr(-Math.floor(resKey.length / 2));
// Fix Latin letters being rendered left to right on ellipsis with direction set to rtl
const indexOfFirstLetter = /[a-z]/i.exec(contentEnd).index;
contentEnd = contentEnd.slice(indexOfFirstLetter);
Copy link
Member

Choose a reason for hiding this comment

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

I'm puzzled by this.
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/

Afaict, this regex: /[-0-9a-zA-Z.]{0,253}/ allows more things than kubernetes does.

Does ArgoCD support translations at all?

Copy link
Contributor Author

@ciiay ciiay Aug 11, 2021

Choose a reason for hiding this comment

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

Thanks for the review. Could you elaborate what translation did you mean?

Code in line 178 and line 179 is to avoid contentEnd string which starts with special characters such as /, - and . being placed to the rightmost of contentEnd string when rendered with direction property set to rtl value. For example, if contentEnd is /abcd/argo-cd/test/example, without the fix it would be rendered as ...cd/argo-cd/test/example/.

Copy link
Member

Choose a reason for hiding this comment

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

I'm mostly interested in line 177.

RTL relates to Arabic and Hebrew rendering (namely that logical elements are rendered Right-to-Left). Typically this only happens if you have a "localization" of an application, typically performed by translating the user interface.

For example:
https://www.google.co.il/?hl=he
image

Given that as far as I can tell, it is not possible to view ArgoCD in Arabic or Hebrew, and given that kubernetes resources can't have non ascii (~Latin) characters, a reference to RTL seems out of place.

https://developer.mozilla.org/en-US/docs/Glossary/rtl

Copy link
Member

Choose a reason for hiding this comment

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

Simply put, do you have an example of RTL actually breaking? If so, a picture here would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I added this only because I observed the weird extra /, - and . at the end of the contentEnd string. Here's an example with out the two lines code. Note that the content-end attribute has the value of /CustomResourceDefinition/..., and then the / got moved to the end of the contentEnd of the rendered resource string. Did some research on this issue and it turned out /, - and . are considered Latin characters which will be put in the rightmost when use direction of right-to-left. So I made the change to make the contentEnd string starts with the first English letter instead the original string.

Screen Shot 2021-08-12 at 10 06 59 AM

Screen Shot 2021-08-12 at 10 07 13 AM

…4233-add-tooltips-for-truncated-check-box-label
label::after {
content: attr(content-end);
text-overflow: clip;
direction: rtl;
Copy link
Member

Choose a reason for hiding this comment

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

This direction: rtl is doing a lot of work and needs a comment

@@ -172,9 +172,27 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app
.filter(item => !item.hook)
.map((item, i) => {
const resKey = nodeKey(item);
const contentStart = resKey.substr(0, Math.floor(resKey.length / 2));
let contentEnd = resKey.substr(-Math.floor(resKey.length / 2));
// Fix Latin letters being rendered left to right on ellipsis with direction set to rtl
Copy link
Member

Choose a reason for hiding this comment

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

@ciiay reached out to me and explained that this is tied to the css change.

A comment in both spots explaining that it's relying on the direction change to place the ellipsis where we want it would help.

And then this comment after it can explain "and because we've direction swapped, we now trip on strong LTR characters, so we need to do a bit of extra work for them".

label::after {
content: attr(content-end);
text-overflow: clip;
direction: rtl;
Copy link
Contributor Author

@ciiay ciiay Aug 17, 2021

Choose a reason for hiding this comment

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

Adding a comment here after direction: rtl; as // This is for ellipsis in the middle instead of the end of resource path.

@@ -172,9 +172,27 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app
.filter(item => !item.hook)
.map((item, i) => {
const resKey = nodeKey(item);
const contentStart = resKey.substr(0, Math.floor(resKey.length / 2));
let contentEnd = resKey.substr(-Math.floor(resKey.length / 2));
// Fix Latin letters being rendered left to right on ellipsis with direction set to rtl
Copy link
Contributor Author

@ciiay ciiay Aug 17, 2021

Choose a reason for hiding this comment

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

Updating this comment as // Second part of resource path needs 'direction: rtl;' to make ellipsis in the beginning of the string instead of the end. And because we've direction swapped, we now trip on strong LTR characters, so this extra logic fixes it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I'd write it like this...

I was thinking more like:

// We want the ellipsis to be in the middle of our text, so we use RTL layout to put it there.
// Unfortunately, strong LTR characters get jumbled around, so make sure that the last character isn't strong.

For reference, strong is a technical term:
https://en.wikipedia.org/wiki/Bidirectional_text#Strong_characters

ciiay added 2 commits August 17, 2021 16:10
Signed-off-by: ciiay <yicai@redhat.com>
Signed-off-by: ciiay <yicai@redhat.com>
label::after {
content: attr(content-end);
text-overflow: clip;
direction: rtl; // This is for ellipsis in the middle instead of the end of resource path
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
direction: rtl; // This is for ellipsis in the middle instead of the end of resource path
direction: rtl; // This is to help put the ellipsis in the middle instead of at the end of the resource path

<CheckboxField id={resKey} field={`resources[${i}]`} />
<Tooltip content={<div style={{wordBreak: 'break-all'}}>{resKey}</div>}>
<div className='container'>
<label htmlFor={resKey} style={{display: resKey.length <= 68 ? '' : 'none'}}>
Copy link
Member

Choose a reason for hiding this comment

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

Instead of setting the display property of these elements conditionally, I think it would be simpler to do something like:

isLongLabel = resKey.length > 68;

...

<label htmlFor={resKey} content-start={isLongLabel && contentStart} content-end={isLongLabel && contentEnd} />

Also, I'm can't find documentation about the content-start or content-end properties. Could you explain what they do?

Copy link
Member

Choose a reason for hiding this comment

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

They're custom things which are used by the css.

I'm not sure I'm a huge fan of the names, although I don't offhand have a suggestion for better names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rbreeze Good point on the inline style. I'm removing it. Please confirm updated PR. Thanks for the review.

<CheckboxField id={resKey} field={`resources[${i}]`} />
<Tooltip content={<div style={{wordBreak: 'break-all'}}>{resKey}</div>}>
<div className='container'>
<label htmlFor={resKey} style={{display: resKey.length <= 68 ? '' : 'none'}}>
Copy link
Member

Choose a reason for hiding this comment

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

They're custom things which are used by the css.

I'm not sure I'm a huge fan of the names, although I don't offhand have a suggestion for better names.

ciiay added 3 commits August 18, 2021 13:56
…4233-add-tooltips-for-truncated-check-box-label
Signed-off-by: ciiay <yicai@redhat.com>
Signed-off-by: ciiay <yicai@redhat.com>
Copy link
Member

@rbreeze rbreeze left a comment

Choose a reason for hiding this comment

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

Screen Shot 2021-08-19 at 5 48 34 PM

Is there a way to avoid the character in the middle getting cut off?

Personally I think it seems like a lot of complexity to add for something as small as moving ellipses. I think it's preferable to keep the ellipses to the right (with pure CSS) and simply add a tooltip.

@ciiay
Copy link
Contributor Author

ciiay commented Aug 20, 2021

Screen Shot 2021-08-19 at 5 48 34 PM

Is there a way to avoid the character in the middle getting cut off?

Personally I think it seems like a lot of complexity to add for something as small as moving ellipses. I think it's preferable to keep the ellipses to the right (with pure CSS) and simply add a tooltip.

It's either cutting off letters in the middle or 6 dots for the ellipsis. 3 from first part of content, 3 from the second part of the content.

I agree it's adding too much complexity for moving ellipsis. Since we already added tooltip, there's no problem to see the full path of resource.

@jsoref How do you think?

@jsoref
Copy link
Member

jsoref commented Aug 20, 2021

I like the PR as proposed.

Ellipsis indicate clipped content. It doesn't matter much how that segment is clipped, if someone cares, they'll hover.

But ellipsis of the end results in dozens of identical items and no hint as to which should be hovered. That's the bug that this PR addresses.

There might be a css property to get character oriented clipping instead of pixel oriented…

<CheckboxField id={resKey} field={`resources[${i}]`} />
<Tooltip content={<div style={{wordBreak: 'break-all'}}>{resKey}</div>}>
<div className='container'>
{!isLongLabel && <label htmlFor={resKey}>{resKey}</label>}
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a ternary operator here?

{isLongLabel ? 
  <label htmlFor={resKey} content-start={contentStart} content-end={contentEnd} /> : 
  <label htmlFor={resKey}>{resKey}</label>}

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, ternary operator is better. Thanks for the feedback. Changing to ternary operator.

ciiay added 2 commits August 20, 2021 13:28
…4233-add-tooltips-for-truncated-check-box-label
Signed-off-by: ciiay <yicai@redhat.com>
Copy link
Member

@rbreeze rbreeze left a comment

Choose a reason for hiding this comment

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

LGTM

@rbreeze rbreeze merged commit d12eafa into argoproj:master Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Truncated synchronize check-boxes should have tooltips
3 participants