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

test(site): move users page test to storybook#14579

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 13 commits intomainfrombq/fix-users-page-test
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1282,7 +1282,7 @@ class ApiMethods {
updateUserPassword = async (
userId: TypesGen.User["id"],
updatePassword: TypesGen.UpdateUserPasswordRequest,
): Promise<undefined> => {
): Promise<void> => {
await this.axios.put(`/api/v2/users/${userId}/password`, updatePassword);
};

Expand Down
4 changes: 3 additions & 1 deletionsite/src/api/queries/deployment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
import { API } from "api/api";

export const deploymentConfigQueryKey = ["deployment", "config"];

export const deploymentConfig = () => {
return {
queryKey:["deployment", "config"],
queryKey:deploymentConfigQueryKey,
queryFn: API.getDeploymentConfig,
};
};
Expand Down
42 changes: 22 additions & 20 deletionssite/src/api/queries/groups.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import type { QueryClient, UseQueryOptions } from "react-query";

type GroupSortOrder = "asc" | "desc";

const groupsQueryKey = ["groups"];
exportconst groupsQueryKey = ["groups"];

export const groups = () => {
return {
Expand DownExpand Up@@ -49,27 +49,29 @@ export type GroupsByUserId = Readonly<Map<string, readonly Group[]>>;
export function groupsByUserId() {
return {
...groups(),
select:(allGroups) => {
// Sorting here means that nothing has to be sorted for the individual
// user arrays later
const sorted = sortGroupsByName(allGroups, "asc");
const userIdMapper = new Map<string,Group[]>();

for (const group of sorted) {
for (constuser of group.members) {
let groupsForUser =userIdMapper.get(user.id);
if (groupsForUser === undefined) {
groupsForUser = [];
userIdMapper.set(user.id, groupsForUser);
}

groupsForUser.push(group);
}
select:selectGroupsByUserId,
} satisfies UseQueryOptions<Group[], unknown, GroupsByUserId>;
}

export function selectGroupsByUserId(groups:Group[]): GroupsByUserId {
// Sorting here means that nothing has to be sorted for the individual
// user arrays later
constsorted = sortGroupsByName(groups, "asc");
const userIdMapper =new Map<string, Group[]>();

for (const group of sorted) {
for (constuser of group.members) {
let groupsForUser = userIdMapper.get(user.id);
if (groupsForUser === undefined) {
groupsForUser = [];
userIdMapper.set(user.id, groupsForUser);
}

return userIdMapper as GroupsByUserId;
},
} satisfies UseQueryOptions<Group[], unknown, GroupsByUserId>;
groupsForUser.push(group);
}
}

return userIdMapper as GroupsByUserId;
}

export function groupsForUser(userId: string) {
Expand Down
4 changes: 3 additions & 1 deletionsite/src/api/queries/roles.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,11 @@ const getRoleQueryKey = (organizationId: string, roleName: string) => [
roleName,
];

export const rolesQueryKey = ["roles"];

export const roles = () => {
return {
queryKey:["roles"],
queryKey:rolesQueryKey,
queryFn: API.getRoles,
};
};
Expand Down
4 changes: 3 additions & 1 deletionsite/src/api/queries/users.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -115,11 +115,13 @@ export const updateRoles = (queryClient: QueryClient) => {
};
};

export const authMethodsQueryKey = ["authMethods"];

export const authMethods = () => {
return {
// Even the endpoint being /users/authmethods we don't want to revalidate it
// when users change so its better add a unique query key
queryKey:["authMethods"],
queryKey:authMethodsQueryKey,
queryFn: API.getAuthMethods,
};
};
Expand Down
30 changes: 15 additions & 15 deletionssite/src/components/Filter/filter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -294,21 +294,21 @@ const PresetMenu: FC<PresetMenuProps> = ({
</MenuItem>
))}
{learnMoreLink && (
<>
<Divider css={{ borderColor: theme.palette.divider }} />
<MenuItem
component="a"
href={learnMoreLink}
target="_blank"
css={{ fontSize: 13, fontWeight: 500 }}
onClick={() => {
setIsOpen(false);
}}
>
<OpenInNewOutlined css={{ fontSize: "14px !important" }} />
View advanced filtering
</MenuItem>
</>
<Divider css={{ borderColor: theme.palette.divider }} />
)}
{learnMoreLink && (
<MenuItem
component="a"
href={learnMoreLink}
target="_blank"
css={{ fontSize: 13, fontWeight: 500 }}
onClick={() => {
setIsOpen(false);
}}
>
<OpenInNewOutlined css={{ fontSize: "14px !important" }} />
View advanced filtering
</MenuItem>
)}
{learnMoreLink2 && learnMoreLabel2 && (
<MenuItem
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ const updateUserRole = async (role: SlimRole) => {
}

// Click on the "edit icon" to display the role options
const editButton = within(userRow).getByTitle("Edit user roles");
const editButton = within(userRow).getByLabelText("Edit user roles");
fireEvent.click(editButton);

// Click on the role option
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Interpolation, Theme } from "@emotion/react";
import UserIcon from "@mui/icons-material/PersonOutline";
import Checkbox from "@mui/material/Checkbox";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import type { SlimRole } from "api/typesGenerated";
import {
HelpTooltip,
Expand DownExpand Up@@ -116,13 +117,15 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
return (
<Popover>
<PopoverTrigger>
<IconButton
size="small"
css={styles.editButton}
title="Edit user roles"
>
<EditSquare />
</IconButton>
<Tooltip title="Edit user roles">
<IconButton
aria-label="Edit user roles"
size="small"
css={styles.editButton}
>
<EditSquare />
</IconButton>
</Tooltip>
</PopoverTrigger>

<PopoverContent classes={{ paper }}>
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp