Skip to content

Commit 4833748

Browse files
committed
hello
1 parent 94fc31c commit 4833748

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

site/e2e/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export const defaultPassword = "SomeSecurePassword!";
2020

2121
// Credentials for users
2222
export const users = {
23-
admin: {
24-
username: "admin",
23+
owner: {
24+
username: "owner",
2525
password: defaultPassword,
26-
email: "admin@coder.com",
26+
email: "owner@coder.com",
2727
},
2828
templateAdmin: {
2929
username: "template-admin",

site/e2e/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export type LoginOptions = {
6767
password: string;
6868
};
6969

70-
export async function login(page: Page, options: LoginOptions = users.admin) {
70+
export async function login(page: Page, options: LoginOptions = users.owner) {
7171
const ctx = page.context();
7272
// biome-ignore lint/suspicious/noExplicitAny: reset the current user
7373
(ctx as any)[Symbol.for("currentUser")] = undefined;

site/e2e/setup/addUsersAndLicense.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ test("setup deployment", async ({ page }) => {
1616
}
1717

1818
// Setup first user
19-
await page.getByLabel(Language.emailLabel).fill(users.admin.email);
20-
await page.getByLabel(Language.passwordLabel).fill(users.admin.password);
19+
await page.getByLabel(Language.emailLabel).fill(users.owner.email);
20+
await page.getByLabel(Language.passwordLabel).fill(users.owner.password);
2121
await page.getByTestId("create").click();
2222

2323
await expectUrl(page).toHavePathName("/workspaces");
2424
await page.getByTestId("button-select-template").isVisible();
2525

2626
for (const user of Object.values(users)) {
2727
// Already created as first user
28-
if (user.username === "admin") {
28+
if (user.username === "owner") {
2929
continue;
3030
}
3131

site/e2e/tests/roles.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ test.describe("roles admin settings access", () => {
8282
]);
8383
});
8484

85-
test("admin can see admin settings", async ({ page }) => {
86-
await login(page, users.admin);
85+
test("owner can see admin settings", async ({ page }) => {
86+
await login(page, users.owner);
8787
await page.goto("/", { waitUntil: "domcontentloaded" });
8888

8989
await hasAccessToAdminSettings(page, [

site/src/modules/management/OrganizationSettingsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const useOrganizationSettings = (): OrganizationSettingsValue => {
4646
};
4747

4848
const OrganizationSettingsLayout: FC = () => {
49-
const { organizations, showOrganizations } = useDashboard();
49+
const { organizations } = useDashboard();
5050
const { organization: orgName } = useParams() as {
5151
organization?: string;
5252
};

site/src/pages/OrganizationSettingsPage/OrganizationRedirect.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ const OrganizationRedirect: FC = () => {
1010
organizationPermissionsByOrganizationId: organizationPermissions,
1111
} = useOrganizationSettings();
1212

13+
const sortedOrganizations = [...organizations].sort(
14+
(a, b) => (b.is_default ? 1 : 0) - (a.is_default ? 1 : 0),
15+
);
16+
1317
// Redirect /organizations => /organizations/some-organization-name
1418
// If they can edit the default org, we should redirect to the default.
1519
// If they cannot edit the default, we should redirect to the first org that
1620
// they can edit.
17-
const editableOrg = [...organizations]
18-
.sort((a, b) => (b.is_default ? 1 : 0) - (a.is_default ? 1 : 0))
19-
.find((org) => canEditOrganization(organizationPermissions[org.id]));
21+
const editableOrg = sortedOrganizations.find((org) =>
22+
canEditOrganization(organizationPermissions[org.id]),
23+
);
2024
if (editableOrg) {
2125
return <Navigate to={`/organizations/${editableOrg.name}`} replace />;
2226
}
2327
// If they cannot edit any org, just redirect to an org they can read.
24-
if (organizations.length > 0) {
25-
return <Navigate to={`/organizations/${organizations[0].name}`} replace />;
28+
if (sortedOrganizations.length > 0) {
29+
return (
30+
<Navigate to={`/organizations/${sortedOrganizations[0].name}`} replace />
31+
);
2632
}
2733
return <EmptyState message="No organizations found" />;
2834
};

0 commit comments

Comments
 (0)