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

feat(sidebar): active connections toggle COMPASS-8114 #6458

Merged
merged 12 commits into from
Nov 12, 2024

Conversation

kraenhansen
Copy link
Contributor

@kraenhansen kraenhansen commented Nov 7, 2024

Description

Merging this PR will:

  • Add two new icons ("connected plug" and "disconnected plugs") copied from the design.
  • Show a toggle-able IconButton to the right of the NavigationItemsFilter in the ConnectionsNavigation.
  • Add the state of the toggle when filtering connections.
  • Add a test for the Sidebar component.
  • Add two tests for the useFilteredConnections hook.
active-connections-toggle.mov

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

  • I was considering including the IconButton in the NavigationItemsFilter component instead and update the onFilterChange to take an object with the RegExp as well as a boolean.

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@kraenhansen kraenhansen self-assigned this Nov 7, 2024
@github-actions github-actions bot added the feat label Nov 7, 2024
@kraenhansen kraenhansen force-pushed the kh/active-connections-toggle branch from 40b2188 to dc649bf Compare November 7, 2024 10:06
@kraenhansen kraenhansen changed the title feat(sidebar): active connections toggle COMPASS-8381 feat(sidebar): active connections toggle COMPASS-8114 Nov 7, 2024
Use queryByTestId to fix test
Move asserts into a shared expectElementByTestId
Comment on lines 738 to 744
function expectElementByTestId(testId: string, state: 'visible' | 'missing') {
if (state === 'visible') {
expect(screen.queryByTestId(testId)).to.be.visible;
} else if (state === 'missing') {
expect(screen.queryByTestId(testId)).to.be.null;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we want a generalized helper I think it would make a bit more sense so add this as an extra chai assertion instead of a function here, it's more effort but way more consistent with how we assert, which is always done with chai library asserts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did experiment a bit with it. The question is what we'd want that expect to take as an argument.
If it takes the test-id string attribute, I don't know what to call that chai assert property 🙈 expect("some-test-id").to.be.testIdOfElementInDocument?

Thinking more about it, perhaps it's overkill with this helper 🤔 I mostly wanted to find a way to codify the pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted the helper and cleaned up the test instead: 4450dc7 - I think that's better 🤞

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's a good idea, but I'd still have a strong preference to stick to the interface of chai asserts we are accustomed to using if we want to pursue this. And yeah, just a test-id is probably not a great argument for chai here. Maybe for case that you were running in something like expect(elementOrNull).to.be.in.dom that checks that the element is not null and window.document.contains is true can be a new interface for what you're trying to check here. Then you'd be able to combine then with visible check too

@kraenhansen kraenhansen marked this pull request as ready for review November 11, 2024 11:33
Copy link
Contributor

@himanshusinghs himanshusinghs left a comment

Choose a reason for hiding this comment

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

LGTM, left one clarifying question.

@@ -167,6 +169,38 @@ describe('useFilteredConnections', function () {
});
});

context('excluding inactive connections', function () {
it('should match only connected collections items', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should match only connected collections items', function () {
it('should match only connected connection items', function () {

typo I guess?

// Conditionally skip connections that aren't considered active
const inactive =
connection.connectionStatus !== 'connected' &&
connection.connectionStatus !== 'connecting';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if there was a decision taken on this so confirming - are we sure we want to count connecting connections as active?

@kraenhansen
Copy link
Contributor Author

kraenhansen commented Nov 12, 2024

I talked with @bsradcliffe on Slack and he has suggestions to redesigning the flow / experience.
We've agreed to merge this for now as it implements the original design and he'll follow up with another ticket.

@kraenhansen kraenhansen merged commit 81e4156 into main Nov 12, 2024
31 checks passed
@kraenhansen kraenhansen deleted the kh/active-connections-toggle branch November 12, 2024 18:41
@betsybutton
Copy link
Contributor

betsybutton commented Nov 13, 2024

I just filed COMPASS-8503 for the followup work. We should make sure to update the designs before the next GA Compass release or revert this PR; it could be confusing for users to have this UX update come shortly after adding this toggle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants