Skip to content

[pull] main from coder:main #198

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 4 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ result

# dlv debug binaries for go tests
__debug_bin*

**/.claude/settings.local.json
2 changes: 1 addition & 1 deletion docs/contributing/frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const WithQuota: Story = {
parameters: {
queries: [
{
key: getWorkspaceQuotaQueryKey(MockUser.username),
key: getWorkspaceQuotaQueryKey(MockUserOwner.username),
data: {
credits_consumed: 2,
budget: 40,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ require (

require (
github.com/anthropics/anthropic-sdk-go v0.2.0-beta.3
github.com/coder/preview v0.0.1
github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245
github.com/fsnotify/fsnotify v1.9.0
github.com/kylecarbs/aisdk-go v0.0.8
github.com/mark3labs/mcp-go v0.25.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,8 @@ github.com/coder/pq v1.10.5-0.20240813183442-0c420cb5a048 h1:3jzYUlGH7ZELIH4XggX
github.com/coder/pq v1.10.5-0.20240813183442-0c420cb5a048/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
github.com/coder/preview v0.0.1 h1:2X5McKdMOZJILTIDf7qRplXKupT+91qTJBN67XUh5cA=
github.com/coder/preview v0.0.1/go.mod h1:eInDmOdSDF8cxCvapIvYkGRzmzvcvGAFL1HYqcA4g+E=
github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245 h1:RGoANNubwwPZF8puiYAk2qbzhVgipBMNu8WIrY1VIbI=
github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245/go.mod h1:5VnO9yw7vq19hBgBqqBksE2BH53UTmNYH1QltkYLXJI=
github.com/coder/quartz v0.1.2 h1:PVhc9sJimTdKd3VbygXtS4826EOCpB1fXoRlLnCrE+s=
github.com/coder/quartz v0.1.2/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
Expand Down
10 changes: 8 additions & 2 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion site/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const badgeVariants = cva(
warning:
"border border-solid border-border-warning bg-surface-orange text-content-warning shadow",
destructive:
"border border-solid border-border-destructive bg-surface-red text-content-highlight-red shadow",
"border border-solid border-border-destructive bg-surface-red text-highlight-red shadow",
},
size: {
xs: "text-2xs font-regular h-5 [&_svg]:hidden rounded px-1.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { userEvent, within } from "@storybook/test";
import {
MockOrganization,
MockOrganization2,
MockUser,
MockUserOwner,
} from "testHelpers/entities";
import { OrganizationAutocomplete } from "./OrganizationAutocomplete";

Expand All @@ -22,7 +22,7 @@ type Story = StoryObj<typeof OrganizationAutocomplete>;
export const ManyOrgs: Story = {
parameters: {
showOrganizations: true,
user: MockUser,
user: MockUserOwner,
features: ["multiple_organizations"],
permissions: { viewDeploymentConfig: true },
queries: [
Expand All @@ -42,7 +42,7 @@ export const ManyOrgs: Story = {
export const OneOrg: Story = {
parameters: {
showOrganizations: true,
user: MockUser,
user: MockUserOwner,
features: ["multiple_organizations"],
permissions: { viewDeploymentConfig: true },
queries: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react";
import { MockUser } from "testHelpers/entities";
import { MockUserOwner } from "testHelpers/entities";
import { UserAutocomplete } from "./UserAutocomplete";

const meta: Meta<typeof UserAutocomplete> = {
Expand All @@ -12,13 +12,13 @@ type Story = StoryObj<typeof UserAutocomplete>;

export const WithLabel: Story = {
args: {
value: MockUser,
value: MockUserOwner,
label: "User",
},
};

export const NoLabel: Story = {
args: {
value: MockUser,
value: MockUserOwner,
},
};
6 changes: 3 additions & 3 deletions site/src/contexts/auth/RequireAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAuthenticated } from "hooks";
import { http, HttpResponse } from "msw";
import type { FC, PropsWithChildren } from "react";
import { QueryClientProvider } from "react-query";
import { MockPermissions, MockUser } from "testHelpers/entities";
import { MockPermissions, MockUserOwner } from "testHelpers/entities";
import {
createTestQueryClient,
renderWithAuth,
Expand Down Expand Up @@ -82,7 +82,7 @@ describe("useAuthenticated", () => {

expect(() => {
renderHook(() => useAuthenticated(), {
wrapper: createAuthWrapper({ user: MockUser }),
wrapper: createAuthWrapper({ user: MockUserOwner }),
});
}).toThrow("Permissions are not available.");

Expand All @@ -93,7 +93,7 @@ describe("useAuthenticated", () => {
expect(() => {
renderHook(() => useAuthenticated(), {
wrapper: createAuthWrapper({
user: MockUser,
user: MockUserOwner,
permissions: MockPermissions,
}),
});
Expand Down
6 changes: 3 additions & 3 deletions site/src/hooks/useEmbeddedMetadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
MockBuildInfo,
MockEntitlements,
MockExperiments,
MockUser,
MockUserAppearanceSettings,
MockUserOwner,
} from "testHelpers/entities";
import {
DEFAULT_METADATA_KEY,
Expand Down Expand Up @@ -38,7 +38,7 @@ const mockDataForTags = {
"build-info": MockBuildInfo,
entitlements: MockEntitlements,
experiments: MockExperiments,
user: MockUser,
user: MockUserOwner,
userAppearance: MockUserAppearanceSettings,
regions: MockRegions,
} as const satisfies Record<MetadataKey, MetadataValue>;
Expand Down Expand Up @@ -97,7 +97,7 @@ const populatedMetadata: RuntimeHtmlMetadata = {
},
user: {
available: true,
value: MockUser,
value: MockUserOwner,
},
userAppearance: {
available: true,
Expand Down
6 changes: 1 addition & 5 deletions site/src/hooks/usePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const usePagination = ({
const [searchParams, setSearchParams] = searchParamsResult;
const page = searchParams.get("page") ? Number(searchParams.get("page")) : 1;
const limit = DEFAULT_RECORDS_PER_PAGE;
const offset = calcOffset(page, limit);
const offset = page <= 0 ? 0 : (page - 1) * limit;

const goToPage = (page: number) => {
searchParams.set("page", page.toString());
Expand All @@ -23,7 +23,3 @@ export const usePagination = ({
offset,
};
};

export const calcOffset = (page: number, limit: number) => {
return page <= 0 ? 0 : (page - 1) * limit;
};
12 changes: 6 additions & 6 deletions site/src/modules/dashboard/Navbar/MobileMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
MockPrimaryWorkspaceProxy,
MockProxyLatencies,
MockSupportLinks,
MockUser,
MockUser2,
MockUserMember,
MockUserOwner,
MockWorkspaceProxies,
} from "testHelpers/entities";
import { MobileMenu } from "./MobileMenu";
Expand Down Expand Up @@ -36,7 +36,7 @@ const meta: Meta<typeof MobileMenu> = {
proxyLatencies: MockProxyLatencies,
proxies: MockWorkspaceProxies,
},
user: MockUser,
user: MockUserOwner,
supportLinks: MockSupportLinks,
onSignOut: fn(),
isDefaultOpen: true,
Expand All @@ -63,7 +63,7 @@ export const Admin: Story = {

export const Auditor: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: true,
canViewDeployment: false,
canViewHealth: false,
Expand All @@ -74,7 +74,7 @@ export const Auditor: Story = {

export const OrgAdmin: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: true,
canViewDeployment: false,
canViewHealth: false,
Expand All @@ -85,7 +85,7 @@ export const OrgAdmin: Story = {

export const Member: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: false,
canViewDeployment: false,
canViewHealth: false,
Expand Down
10 changes: 5 additions & 5 deletions site/src/modules/dashboard/Navbar/NavbarView.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";
import { userEvent, within } from "@storybook/test";
import { chromaticWithTablet } from "testHelpers/chromatic";
import { MockUser, MockUser2 } from "testHelpers/entities";
import { MockUserMember, MockUserOwner } from "testHelpers/entities";
import { withDashboardProvider } from "testHelpers/storybook";
import { NavbarView } from "./NavbarView";

Expand All @@ -10,7 +10,7 @@ const meta: Meta<typeof NavbarView> = {
parameters: { chromatic: chromaticWithTablet, layout: "fullscreen" },
component: NavbarView,
args: {
user: MockUser,
user: MockUserOwner,
canViewAuditLog: true,
canViewDeployment: true,
canViewHealth: true,
Expand All @@ -33,7 +33,7 @@ export const ForAdmin: Story = {

export const ForAuditor: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: true,
canViewDeployment: false,
canViewHealth: false,
Expand All @@ -49,7 +49,7 @@ export const ForAuditor: Story = {

export const ForOrgAdmin: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: true,
canViewDeployment: false,
canViewHealth: false,
Expand All @@ -65,7 +65,7 @@ export const ForOrgAdmin: Story = {

export const ForMember: Story = {
args: {
user: MockUser2,
user: MockUserMember,
canViewAuditLog: false,
canViewDeployment: false,
canViewHealth: false,
Expand Down
10 changes: 5 additions & 5 deletions site/src/modules/dashboard/Navbar/NavbarView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import type { ProxyContextValue } from "contexts/ProxyContext";
import { MockPrimaryWorkspaceProxy, MockUser } from "testHelpers/entities";
import { MockPrimaryWorkspaceProxy, MockUserOwner } from "testHelpers/entities";
import { renderWithAuth } from "testHelpers/renderHelpers";
import { NavbarView } from "./NavbarView";

Expand All @@ -26,7 +26,7 @@ describe("NavbarView", () => {
renderWithAuth(
<NavbarView
proxyContextValue={proxyContextValue}
user={MockUser}
user={MockUserOwner}
onSignOut={noop}
canViewDeployment
canViewOrganizations
Expand All @@ -43,7 +43,7 @@ describe("NavbarView", () => {
renderWithAuth(
<NavbarView
proxyContextValue={proxyContextValue}
user={MockUser}
user={MockUserOwner}
onSignOut={noop}
canViewDeployment
canViewOrganizations
Expand All @@ -60,7 +60,7 @@ describe("NavbarView", () => {
renderWithAuth(
<NavbarView
proxyContextValue={proxyContextValue}
user={MockUser}
user={MockUserOwner}
onSignOut={noop}
canViewDeployment
canViewOrganizations
Expand All @@ -78,7 +78,7 @@ describe("NavbarView", () => {
renderWithAuth(
<NavbarView
proxyContextValue={proxyContextValue}
user={MockUser}
user={MockUserOwner}
onSignOut={noop}
canViewDeployment
canViewOrganizations
Expand Down
4 changes: 2 additions & 2 deletions site/src/modules/dashboard/Navbar/ProxyMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
MockAuthMethodsAll,
MockPermissions,
MockProxyLatencies,
MockUser,
MockUserOwner,
MockWorkspaceProxies,
} from "testHelpers/entities";
import { withDesktopViewport } from "testHelpers/storybook";
Expand Down Expand Up @@ -41,7 +41,7 @@ const meta: Meta<typeof ProxyMenu> = {
],
parameters: {
queries: [
{ key: ["me"], data: MockUser },
{ key: ["me"], data: MockUserOwner },
{ key: ["authMethods"], data: MockAuthMethodsAll },
{ key: ["hasFirstUser"], data: true },
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Meta, StoryObj } from "@storybook/react";
import { expect, screen, userEvent, waitFor, within } from "@storybook/test";
import { MockBuildInfo, MockUser } from "testHelpers/entities";
import { MockBuildInfo, MockUserOwner } from "testHelpers/entities";
import { withDashboardProvider } from "testHelpers/storybook";
import { UserDropdown } from "./UserDropdown";

const meta: Meta<typeof UserDropdown> = {
title: "modules/dashboard/UserDropdown",
component: UserDropdown,
args: {
user: MockUser,
user: MockUserOwner,
buildInfo: MockBuildInfo,
supportLinks: [
{ icon: "docs", name: "Documentation", target: "" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { screen } from "@testing-library/react";
import { Popover } from "components/deprecated/Popover/Popover";
import { MockUser } from "testHelpers/entities";
import { MockUserOwner } from "testHelpers/entities";
import { render, waitForLoaderToBeRemoved } from "testHelpers/renderHelpers";
import { Language, UserDropdownContent } from "./UserDropdownContent";

describe("UserDropdownContent", () => {
it("has the correct link for the account item", async () => {
render(
<Popover>
<UserDropdownContent user={MockUser} onSignOut={jest.fn()} />
<UserDropdownContent user={MockUserOwner} onSignOut={jest.fn()} />
</Popover>,
);
await waitForLoaderToBeRemoved();
Expand All @@ -25,7 +25,7 @@ describe("UserDropdownContent", () => {
const onSignOut = jest.fn();
render(
<Popover>
<UserDropdownContent user={MockUser} onSignOut={onSignOut} />
<UserDropdownContent user={MockUserOwner} onSignOut={onSignOut} />
</Popover>,
);
await waitForLoaderToBeRemoved();
Expand Down
Loading
Loading