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

ctx: Show unselectable items for unreachable Spaces #555

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

adamwg
Copy link
Member

@adamwg adamwg commented Jun 6, 2024

Description of your changes

Avoid the surprise of seeing different Spaces in the console vs. up ctx by listing unreachable items for Spaces that are unreachable or for which we failed to find the ingress. Sort these items to the end of the list so that all the selectable items are at the top.

I have:

  • Read and followed Upbound's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR, as appropriate.

How has this code been tested

Manual testing with organizations that have many unreachable Spaces. Also tested the other menus that may have unselectable items to make sure it all looks good.

Avoid the surprise of seeing different Spaces in the console vs. `up ctx` by
listing unreachable items for Spaces that are unreachable or for which we failed
to find the ingress. Sort these items to the end of the list so that all the
selectable items are at the top.

Signed-off-by: Adam Wolfe Gordon <awg@upbound.io>
Comment on lines 383 to 396
func (s sortedItems) Less(i, j int) bool {
itmI := s[i].(item)
itmJ := s[j].(item)

// Sort unselectable items last.
if itmI.notSelectable && !itmJ.notSelectable {
return false
}
if !itmI.notSelectable && itmJ.notSelectable {
return true
}

return s[i].(item).text < s[j].(item).text
}
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 this is something we always want to commit to? There's a chance we'd want to put a header label, or a separator element, midway through the list and this would conflict?

Wdyt about, when we create the list of items, we have a second list of unreachable items. Then before returning the full list, we append the unreachable ones at the end?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I had the same thought but discovered that this worked for all the current uses of sortedItems. I like the idea of making the ordering explicit in in Items() instead - updated to do that. As these lists get more complex we might think about adding more explicit structure to them so each Items() method doesn't have to do the same append+sort+append dance.

@adamwg adamwg merged commit ad3d217 into main Jun 7, 2024
7 checks passed
@adamwg adamwg deleted the awg/unreachable-spaces branch June 7, 2024 16:22
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.

None yet

2 participants