Skip to content

chore: clean up groups page #16259

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
Jan 29, 2025
Merged

chore: clean up groups page #16259

merged 13 commits into from
Jan 29, 2025

Conversation

aslilac
Copy link
Member

@aslilac aslilac commented Jan 24, 2025

Closes coder/internal#284

We somehow wound up with two sets of GroupsPage components despite lots of intentional effort to not do that. Oh boy.

This removes the old set, and adjusts the new set to not depend on useOrganizationSettings, because it needs to be renderable from the DeploymentSettingsPage context as well.

@aslilac aslilac changed the title chore: groups page cleanup chore: clean up groups page Jan 24, 2025
@aslilac aslilac requested a review from jaaydenh January 24, 2025 20:40
@aslilac aslilac marked this pull request as ready for review January 24, 2025 20:44
<SidebarNavItem href="/deployment/groups">Groups</SidebarNavItem>
<SidebarNavItem href="/deployment/groups">
<Stack direction="row" alignItems="center" spacing={0.5}>
Groups {showOrganizations && <ArrowUpRight size={16} />}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some precedent for using ArrowUpRight to convey this type of meaning? Did you get some feedback from christin?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was imagining something a bit more explicit to let users know they are be taken to the default organization

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just trying something new, and keep hearing about how she's already busy enough. If we don't like it we can change it later. 😅

const orgId = await getCurrentOrgId();
const group = await createGroup(orgId);
const numberOfMembers = 3;
const users = await Promise.all(
Array.from({ length: numberOfMembers }, () => createUser(orgId)),
);

await page.goto(`${baseURL}/groups/${group.name}`, {
await page.goto(`${baseURL}/organizations/${orgName}/groups/${group.name}`, {
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the reason to only test the organizations routes. Do you feel it is redundant to test both the deployment and organizations groups functionality?

Copy link
Member Author

Choose a reason for hiding this comment

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

we only run the e2e tests with a premium license, which cannot manage groups from the deployment settings.

<AvatarGroup
max={10}
total={group.members.length}
css={{ justifyContent: "flex-end", gap: 8 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a good opportunity to replace with Tailwind

Copy link
Member Author

Choose a reason for hiding this comment

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

this isn't new code, it's a file rename. there are tons of emotion styles in here and porting them all to tailwind is definitely out of scope for this pr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ya, I know its not in scope, I just try to move things to Tailwind when I am actively changing a line of code for any reason

@@ -211,7 +219,7 @@ export const GroupPage: FC = () => {
try {
await deleteGroupMutation.mutateAsync(groupId);
displaySuccess("Group deleted successfully.");
navigate("/deployment/groups");
navigate("..");
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't know navigate could do this.

Copy link
Member Author

Choose a reason for hiding this comment

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

navigate is actually rad: it does a bunch of stuff to make the urls relative to the route the current component is mounted to (so for example, a layout can use navigate with relative paths even if something in the Outlet is mounted at a deeper route. it's kind of mind melting to imagine at first but it means it almost always just does what you expect.

@aslilac aslilac requested a review from jaaydenh January 28, 2025 18:33
await expect(page).toHaveTitle("Groups - Coder");

const groupRow = page.getByRole("row", { name: DEFAULT_GROUP_NAME });
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, we try to use getByRole as much as possible, just curious why you switched this to getByText?

Copy link
Member Author

Choose a reason for hiding this comment

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

It stopped working 🤷‍♀️ I tried to figure out what was going on but the dom looks basically identical to me. No idea why it broke.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok got it, I having been seeing the same type of things sometimes. Trying to figure out best practices to avoid test flakes.

Comment on lines -64 to +73
// 2025-01-10: useMatch is a workaround for a bug we encountered when you
// pass a render function to NavLink's className prop, and try to access
// NavLinks's isActive state value for the conditional styling. isActive
// wasn't always evaluating to true when it should be, but useMatch worked
const matchResult = useMatch(href);
return (
<NavLink
end={end}
to={href}
className={cn(
"relative text-sm text-content-secondary no-underline font-medium py-2 px-3 hover:bg-surface-secondary rounded-md transition ease-in-out duration-150",
{
"font-semibold text-content-primary": matchResult !== null,
},
)}
className={({ isActive }) =>
cn(
"relative text-sm text-content-secondary no-underline font-medium py-2 px-3 hover:bg-surface-secondary rounded-md transition ease-in-out duration-150",
isActive && "font-semibold text-content-primary",
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

With your changes here, when I navigate to /organizations/coder/ from another route, none of the left side bar menu items are highlighted by default. Members should be active by default. This was the reason for the useMatch workaround

Screenshot 2025-01-28 at 18 39 56

Copy link
Contributor

@jaaydenh jaaydenh left a comment

Choose a reason for hiding this comment

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

LGTM

@aslilac aslilac merged commit f3916a6 into main Jan 29, 2025
32 checks passed
@aslilac aslilac deleted the lilac/groups-page-cleanup branch January 29, 2025 23:13
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2025
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.

polish /deployment/groups route
2 participants