Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit092c129

Browse files
authored
chore: perform several small frontend permissions refactors (#16735)
1 parent54745b1 commit092c129

File tree

57 files changed

+158
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+158
-174
lines changed

‎enterprise/coderd/groups.go‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
167167
})
168168
return
169169
}
170-
// TODO: It would be nice to enforce this at the schema level
171-
// but unfortunately our org_members table does not have an ID.
172170
_,err:=database.ExpectOne(api.Database.OrganizationMembers(ctx, database.OrganizationMembersParams{
173171
OrganizationID:group.OrganizationID,
174172
UserID:uuid.MustParse(id),

‎site/e2e/constants.ts‎

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

2121
// Credentials for users
2222
exportconstusers={
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",
@@ -41,7 +41,7 @@ export const users = {
4141
username:"auditor",
4242
password:defaultPassword,
4343
email:"auditor@coder.com",
44-
roles:["Template Admin","Auditor"],
44+
roles:["Auditor"],
4545
},
4646
member:{
4747
username:"member",

‎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-
exportasyncfunctionlogin(page:Page,options:LoginOptions=users.admin){
70+
exportasyncfunctionlogin(page:Page,options:LoginOptions=users.owner){
7171
constctx=page.context();
7272
// biome-ignore lint/suspicious/noExplicitAny: reset the current user
7373
(ctxasany)[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-
awaitpage.getByLabel(Language.emailLabel).fill(users.admin.email);
20-
awaitpage.getByLabel(Language.passwordLabel).fill(users.admin.password);
19+
awaitpage.getByLabel(Language.emailLabel).fill(users.owner.email);
20+
awaitpage.getByLabel(Language.passwordLabel).fill(users.owner.password);
2121
awaitpage.getByTestId("create").click();
2222

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

2626
for(constuserofObject.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/auditLogs.spec.ts‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,63 @@ test.describe.configure({ mode: "parallel" });
1313

1414
test.beforeEach(async({ page})=>{
1515
beforeCoderTest(page);
16-
awaitlogin(page,users.auditor);
1716
});
1817

19-
asyncfunctionresetSearch(page:Page){
18+
asyncfunctionresetSearch(page:Page,username:string){
2019
constclearButton=page.getByLabel("Clear search");
2120
if(awaitclearButton.isVisible()){
2221
awaitclearButton.click();
2322
}
2423

2524
// Filter by the auditor test user to prevent race conditions
26-
constuser=currentUser(page);
2725
awaitexpect(page.getByText("All users")).toBeVisible();
28-
awaitpage.getByPlaceholder("Search...").fill(`username:${user.username}`);
26+
awaitpage.getByPlaceholder("Search...").fill(`username:${username}`);
2927
awaitexpect(page.getByText("All users")).not.toBeVisible();
3028
}
3129

3230
test("logins are logged",async({ page})=>{
3331
requiresLicense();
3432

3533
// Go to the audit history
34+
awaitlogin(page,users.auditor);
3635
awaitpage.goto("/audit");
36+
constusername=users.auditor.username;
3737

3838
constuser=currentUser(page);
39-
constloginMessage=`${user.username} logged in`;
39+
constloginMessage=`${username} logged in`;
4040
// Make sure those things we did all actually show up
41-
awaitresetSearch(page);
41+
awaitresetSearch(page,username);
4242
awaitexpect(page.getByText(loginMessage).first()).toBeVisible();
4343
});
4444

4545
test("creating templates and workspaces is logged",async({ page})=>{
4646
requiresLicense();
4747

4848
// Do some stuff that should show up in the audit logs
49+
awaitlogin(page,users.templateAdmin);
50+
constusername=users.templateAdmin.username;
4951
consttemplateName=awaitcreateTemplate(page);
5052
constworkspaceName=awaitcreateWorkspace(page,templateName);
5153

5254
// Go to the audit history
55+
awaitlogin(page,users.auditor);
5356
awaitpage.goto("/audit");
5457

55-
constuser=currentUser(page);
56-
5758
// Make sure those things we did all actually show up
58-
awaitresetSearch(page);
59+
awaitresetSearch(page,username);
5960
awaitexpect(
60-
page.getByText(`${user.username} created template${templateName}`),
61+
page.getByText(`${username} created template${templateName}`),
6162
).toBeVisible();
6263
awaitexpect(
63-
page.getByText(`${user.username} created workspace${workspaceName}`),
64+
page.getByText(`${username} created workspace${workspaceName}`),
6465
).toBeVisible();
6566
awaitexpect(
66-
page.getByText(`${user.username} started workspace${workspaceName}`),
67+
page.getByText(`${username} started workspace${workspaceName}`),
6768
).toBeVisible();
6869

6970
// Make sure we can inspect the details of the log item
7071
constcreatedWorkspace=page.locator(".MuiTableRow-root",{
71-
hasText:`${user.username} created workspace${workspaceName}`,
72+
hasText:`${username} created workspace${workspaceName}`,
7273
});
7374
awaitcreatedWorkspace.getByLabel("open-dropdown").click();
7475
awaitexpect(
@@ -83,18 +84,19 @@ test("inspecting and filtering audit logs", async ({ page }) => {
8384
requiresLicense();
8485

8586
// Do some stuff that should show up in the audit logs
87+
awaitlogin(page,users.templateAdmin);
88+
constusername=users.templateAdmin.username;
8689
consttemplateName=awaitcreateTemplate(page);
8790
constworkspaceName=awaitcreateWorkspace(page,templateName);
8891

8992
// Go to the audit history
93+
awaitlogin(page,users.auditor);
9094
awaitpage.goto("/audit");
91-
92-
constuser=currentUser(page);
93-
constloginMessage=`${user.username} logged in`;
94-
conststartedWorkspaceMessage=`${user.username} started workspace${workspaceName}`;
95+
constloginMessage=`${username} logged in`;
96+
conststartedWorkspaceMessage=`${username} started workspace${workspaceName}`;
9597

9698
// Filter by resource type
97-
awaitresetSearch(page);
99+
awaitresetSearch(page,username);
98100
awaitpage.getByText("All resource types").click();
99101
constworkspaceBuildsOption=page.getByText("Workspace Build");
100102
awaitworkspaceBuildsOption.scrollIntoViewIfNeeded({timeout:5000});
@@ -107,7 +109,7 @@ test("inspecting and filtering audit logs", async ({ page }) => {
107109
awaitexpect(page.getByText("All resource types")).toBeVisible();
108110

109111
// Filter by action type
110-
awaitresetSearch(page);
112+
awaitresetSearch(page,username);
111113
awaitpage.getByText("All actions").click();
112114
awaitpage.getByText("Login",{exact:true}).click();
113115
// Logins should be visible

‎site/e2e/tests/deployment/general.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test("experiments", async ({ page }) => {
1616
constavailableExperiments=awaitAPI.getAvailableExperiments();
1717

1818
// Verify if the site lists the same experiments
19-
awaitpage.goto("/deployment/general",{waitUntil:"networkidle"});
19+
awaitpage.goto("/deployment/overview",{waitUntil:"domcontentloaded"});
2020

2121
constexperimentsLocator=page.locator(
2222
"div.options-table tr.option-experiments ul.option-array",

‎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-
awaitlogin(page,users.admin);
85+
test("owner can see admin settings",async({ page})=>{
86+
awaitlogin(page,users.owner);
8787
awaitpage.goto("/",{waitUntil:"domcontentloaded"});
8888

8989
awaithasAccessToAdminSettings(page,[

‎site/src/@types/storybook.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
SerpentOption,
77
User,
88
}from"api/typesGenerated";
9-
importtype{Permissions}from"contexts/auth/permissions";
9+
importtype{Permissions}from"modules/permissions";
1010
importtype{QueryKey}from"react-query";
1111

1212
declare module"@storybook/react"{

‎site/src/api/queries/organizations.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
typeOrganizationPermissionName,
1010
typeOrganizationPermissions,
1111
organizationPermissionChecks,
12-
}from"modules/management/organizationPermissions";
12+
}from"modules/permissions/organizations";
1313
importtype{QueryClient}from"react-query";
1414
import{meKey}from"./users";
1515

‎site/src/contexts/auth/AuthProvider.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
importtype{UpdateUserProfileRequest,User}from"api/typesGenerated";
1111
import{displaySuccess}from"components/GlobalSnackbar/utils";
1212
import{useEmbeddedMetadata}from"hooks/useEmbeddedMetadata";
13+
import{typePermissions,permissionChecks}from"modules/permissions";
1314
import{
1415
typeFC,
1516
typePropsWithChildren,
@@ -18,7 +19,6 @@ import {
1819
useContext,
1920
}from"react";
2021
import{useMutation,useQuery,useQueryClient}from"react-query";
21-
import{typePermissions,permissionChecks}from"./permissions";
2222

2323
exporttypeAuthContextValue={
2424
isLoading:boolean;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp