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

chore: add more stories and use new groups query for user settings page#14481

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
aslilac merged 2 commits intomainfromfollow-up-for-user-groups
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
1 change: 1 addition & 0 deletionssite/src/@types/storybook.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ declare module "@storybook/react" {
interface Parameters {
features?: FeatureName[];
experiments?: Experiments;
showOrganizations?: boolean;
queries?: { key: QueryKey; data: unknown }[];
webSocket?: WebSocketEvent[];
user?: User;
Expand Down
11 changes: 9 additions & 2 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1603,8 +1603,15 @@ class ApiMethods {
return response.data;
};

getGroups = async (): Promise<TypesGen.Group[]> => {
const response = await this.axios.get("/api/v2/groups");
getGroups = async (
options: { userId?: string } = {},
): Promise<TypesGen.Group[]> => {
const params: Record<string, string> = {};
if (options.userId !== undefined) {
params.has_member = options.userId;
}

const response = await this.axios.get("/api/v2/groups", { params });
return response.data;
};

Expand Down
12 changes: 3 additions & 9 deletionssite/src/api/queries/groups.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,15 +74,9 @@ export function groupsByUserId() {

export function groupsForUser(userId: string) {
return {
...groups(),
select: (allGroups) => {
const groupsForUser = allGroups.filter((group) =>
group.members.some((member) => member.id === userId),
);

return sortGroupsByName(groupsForUser, "asc");
},
} as const satisfies UseQueryOptions<Group[], unknown, readonly Group[]>;
queryKey: groupsQueryKey,
queryFn: () => API.getGroups({ userId }),
} as const satisfies UseQueryOptions<Group[]>;
}

export const groupPermissionsKey = (groupId: string) => [
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import {
MockUser,
mockApiError,
} from "testHelpers/entities";
import { withDashboardProvider } from "testHelpers/storybook";
import { AccountUserGroups } from "./AccountUserGroups";

const MockGroup2 = {
Expand All@@ -24,13 +25,20 @@ const meta: Meta<typeof AccountUserGroups> = {
groups: [MockGroup1, MockGroup2],
loading: false,
},
decorators: [withDashboardProvider],
};

export default meta;
type Story = StoryObj<typeof AccountUserGroups>;

export const Example: Story = {};

export const ExampleWithOrganizations: Story = {
parameters: {
showOrganizations: true,
},
};

export const NoGroups: Story = {
args: {
groups: [],
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import type { Group } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { AvatarCard } from "components/AvatarCard/AvatarCard";
import { Loader } from "components/Loader/Loader";
import { useDashboard } from "modules/dashboard/useDashboard";
import type { FC } from "react";
import { Section } from "../Section";

Expand All@@ -20,6 +21,7 @@ export const AccountUserGroups: FC<AccountGroupsProps> = ({
loading,
}) => {
const theme = useTheme();
const { showOrganizations } = useDashboard();

return (
<Section
Expand DownExpand Up@@ -55,7 +57,16 @@ export const AccountUserGroups: FC<AccountGroupsProps> = ({
imgUrl={group.avatar_url}
altText={group.display_name || group.name}
header={group.display_name || group.name}
subtitle={group.organization_display_name}
subtitle={
showOrganizations ? (
group.organization_display_name
) : (
<>
{group.total_member_count} member
{group.total_member_count !== 1 && "s"}
</>
)
}
/>
</Grid>
))}
Expand Down
8 changes: 6 additions & 2 deletionssite/src/testHelpers/storybook.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,11 @@ export const withDashboardProvider = (
Story: FC,
{ parameters }: StoryContext,
) => {
const { features = [], experiments = [] } = parameters;
const {
features = [],
experiments = [],
showOrganizations = false,
} = parameters;

const entitlements: Entitlements = {
...MockEntitlements,
Expand All@@ -42,7 +46,7 @@ export const withDashboardProvider = (
experiments,
appearance: MockAppearanceConfig,
organizations: [MockDefaultOrganization],
showOrganizations: false,
showOrganizations,
}}
>
<Story />
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp