Skip to content

fix: display workspace avatars correctly when URLs fail to load #14814

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

Merged
merged 13 commits into from
Oct 2, 2024

Conversation

Parkreiner
Copy link
Member

No issue to link – this was an issue that surfaced for certain URL types when kicking the tires on the orgs work

Changes made

  • Updated custom avatar components to favor background color by default
  • Updated AvatarData component to let you manually specify the source of the text used when images fail to load, and updated the orgs breadcrumb segment to use it
  • Added some logic for handling emoji images better

@Parkreiner Parkreiner self-assigned this Sep 26, 2024
cdr-bot[bot]
cdr-bot bot previously approved these changes Sep 26, 2024
Copy link

@cdr-bot cdr-bot bot left a comment

Choose a reason for hiding this comment

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

This PR is no longer a hotfix.

  • ✅ Base is main or release branch
  • ❌ Has hotfix label
  • ✅ Head is from coder/coder
  • ✅ Less than 100 lines

@matifali
Copy link
Member

matifali commented Sep 26, 2024

@Parkreiner, a few changes in the UI tests are showing misalignment.
image

@Parkreiner
Copy link
Member Author

Parkreiner commented Sep 26, 2024

@matifali Yeah, sorry, I should've left a message. I was hoping this would be a hotfix, but after seeing how many stories would be changed, I decided that I'd put this through a full review process, and then went to bed

Definitely not planning to push this through as-is, but appreciate you catching some wonkiness that crept through

@Parkreiner Parkreiner removed the hotfix label Sep 26, 2024
@cdr-bot cdr-bot bot dismissed their stale review September 26, 2024 13:55

This PR is no longer a hotfix.

@Parkreiner
Copy link
Member Author

Parkreiner commented Sep 27, 2024

Edit: never mind. Good to go

Making a quick comment for documentation purposes: Chromatic is currently down, which is blocking part of the CI pipeline. I could try to push the changes through as-is, but since the previous version of this PR broke parts of the UI, I want to err on the side of caution

Will try to re-run processes right before I log off today, but this might have to wait until Monday

@Parkreiner Parkreiner added hotfix and removed hotfix labels Sep 27, 2024
@Parkreiner Parkreiner closed this Sep 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2024
@Parkreiner Parkreiner reopened this Sep 27, 2024
@Parkreiner Parkreiner requested review from a team and bcpeinhardt and removed request for a team September 27, 2024 19:55
Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing about the logic here changed – just got formatted differently

Copy link
Member

Choose a reason for hiding this comment

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

thank you 😄

@Parkreiner Parkreiner removed the request for review from bcpeinhardt October 1, 2024 16:29
@Parkreiner Parkreiner requested a review from aslilac October 1, 2024 16:29
avatar = <Avatar src={src}>{title}</Avatar>;
avatar = (
<Avatar background src={src}>
{typeof title === "string" ? title || "-" : imgFallbackText ?? "-"}
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
{typeof title === "string" ? title || "-" : imgFallbackText ?? "-"}
{(typeof title === "string" ? title : imgFallbackText) || "-"}

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good call

Comment on lines 12 to 22
/**
* Useful for when you need to pass in a ReactNode for the title of the
* component.
*
* MUI will try to take any string titles and turn them into the first
* character, but if you pass in a ReactNode, MUI can't do that, because it
* has no way to reliably grab the text content during renders.
*
* Tried writing some layout effect/JSX parsing logic to do the extraction,
* but it added complexity and render overhead, and wasn't reliable enough
*/
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
/**
* Useful for when you need to pass in a ReactNode for the title of the
* component.
*
* MUI will try to take any string titles and turn them into the first
* character, but if you pass in a ReactNode, MUI can't do that, because it
* has no way to reliably grab the text content during renders.
*
* Tried writing some layout effect/JSX parsing logic to do the extraction,
* but it added complexity and render overhead, and wasn't reliable enough
*/
/**
* Useful for when you need to pass in a `ReactNode` for the title of the
* component, but you still want to use the first character of a bit of text
* as the fallback.
*/

Copy link
Member

Choose a reason for hiding this comment

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

thank you 😄

}

return url.startsWith("/emojis/");
}
Copy link
Member

Choose a reason for hiding this comment

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

hmm. I'm skeptic about adding special handling like this, but I get the motivation.

@Parkreiner Parkreiner enabled auto-merge (squash) October 2, 2024 14:37
@Parkreiner Parkreiner merged commit 680e28b into main Oct 2, 2024
26 of 27 checks passed
@Parkreiner Parkreiner deleted the mes/avatar-fix-2 branch October 2, 2024 14:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants