Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07e9613

Browse files
committed
Merge remote-tracking branch 'origin/main' into prebuilds-db
2 parents 390a1fd + f01ee96 commit 07e9613

Some content is hidden

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

51 files changed

+961
-876
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9644,7 +9644,7 @@ func (q *FakeQuerier) PaginatedOrganizationMembers(_ context.Context, arg databa
96449644
// All of the members in the organization
96459645
orgMembers := make([]database.OrganizationMember, 0)
96469646
for _, mem := range q.organizationMembers {
9647-
if arg.OrganizationID != uuid.Nil && mem.OrganizationID != arg.OrganizationID {
9647+
if mem.OrganizationID != arg.OrganizationID {
96489648
continue
96499649
}
96509650

@@ -9654,7 +9654,7 @@ func (q *FakeQuerier) PaginatedOrganizationMembers(_ context.Context, arg databa
96549654
selectedMembers := make([]database.PaginatedOrganizationMembersRow, 0)
96559655

96569656
skippedMembers := 0
9657-
for _, organizationMember := range q.organizationMembers {
9657+
for _, organizationMember := range orgMembers {
96589658
if skippedMembers < int(arg.OffsetOpt) {
96599659
skippedMembers++
96609660
continue

codersdk/organizations.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ type OrganizationMemberWithUserData struct {
8282
}
8383

8484
type PaginatedMembersRequest struct {
85-
OrganizationID uuid.UUID `table:"organization id" json:"organization_id" format:"uuid"`
86-
Limit int `json:"limit,omitempty"`
87-
Offset int `json:"offset,omitempty"`
85+
Limit int `json:"limit,omitempty"`
86+
Offset int `json:"offset,omitempty"`
8887
}
8988

9089
type PaginatedMembersResponse struct {
91-
Members []OrganizationMemberWithUserData
92-
Count int `json:"count"`
90+
Members []OrganizationMemberWithUserData `json:"members"`
91+
Count int `json:"count"`
9392
}
9493

9594
type CreateOrganizationRequest struct {

docs/admin/external-auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Inside your Terraform code, you now have access to authentication variables. Ref
5959
Use [`external-auth`](../reference/cli/external-auth.md) in the Coder CLI to access a token within the workspace:
6060

6161
```shell
62-
coder external-auth <USER_DEFINED_ID> access-token
62+
coder external-auth access-token <USER_DEFINED_ID>
6363
```
6464

6565
## Git-provider specific env variables

docs/admin/integrations/prometheus.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ metadata:
8484
namespace: coder
8585
spec:
8686
endpoints:
87-
- port: prometheus-http
87+
- port: prom-http
8888
interval: 10s
8989
scrapeTimeout: 10s
90+
namespaceSelector:
91+
matchNames:
92+
- coder
9093
selector:
9194
matchLabels:
9295
app.kubernetes.io/name: coder

docs/admin/templates/troubleshooting.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,59 @@ See our
170170
to optimize your templates based on this data.
171171

172172
![Workspace build timings UI](../../images/admin/templates/troubleshooting/workspace-build-timings-ui.png)
173+
174+
## Docker Workspaces on Raspberry Pi OS
175+
176+
### Unable to query ContainerMemory
177+
178+
When you query `ContainerMemory` and encounter the error:
179+
180+
```shell
181+
open /sys/fs/cgroup/memory.max: no such file or directory
182+
```
183+
184+
This error mostly affects Raspberry Pi OS, but might also affect older Debian-based systems as well.
185+
186+
<details><summary>Add cgroup_memory and cgroup_enable to cmdline.txt:</summary>
187+
188+
1. Confirm the list of existing cgroup controllers doesn't include `memory`:
189+
190+
```console
191+
$ cat /sys/fs/cgroup/cgroup.controllers
192+
cpuset cpu io pids
193+
194+
$ cat /sys/fs/cgroup/cgroup.subtree_control
195+
cpuset cpu io pids
196+
```
197+
198+
1. Add cgroup entries to `cmdline.txt` in `/boot/firmware` (or `/boot/` on older Pi OS releases):
199+
200+
```text
201+
cgroup_memory=1 cgroup_enable=memory
202+
```
203+
204+
You can use `sed` to add it to the file for you:
205+
206+
```bash
207+
sudo sed -i '$s/$/ cgroup_memory=1 cgroup_enable=memory/' /boot/firmware/cmdline.txt
208+
```
209+
210+
1. Reboot:
211+
212+
```bash
213+
sudo reboot
214+
```
215+
216+
1. Confirm that the list of cgroup controllers now includes `memory`:
217+
218+
```console
219+
$ cat /sys/fs/cgroup/cgroup.controllers
220+
cpuset cpu io memory pids
221+
222+
$ cat /sys/fs/cgroup/cgroup.subtree_control
223+
cpuset cpu io memory pids
224+
```
225+
226+
Read more about cgroup controllers in [The Linux Kernel](https://docs.kernel.org/admin-guide/cgroup-v2.html#controlling-controllers) documentation.
227+
228+
</details>

docs/images/install/coder-setup.png

-199 KB
Binary file not shown.
Loading

docs/install/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ To start the Coder server:
4949
coder server
5050
```
5151

52-
![Coder install](../images/install/coder-setup.png)
52+
![Coder install](../images/screenshots/welcome-create-admin-user.png)
5353

5454
To log in to an existing Coder deployment:
5555

docs/install/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To start the Coder server:
6060
coder server
6161
```
6262

63-
![Coder install](../images/install/coder-setup.png)
63+
![Coder install](../images/screenshots/welcome-create-admin-user.png)
6464

6565
To log in to an existing Coder deployment:
6666

docs/install/offline.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ RUN mkdir -p /opt/terraform
5757
# for supported Terraform versions.
5858
ARG TERRAFORM_VERSION=1.11.0
5959
RUN apk update && \
60-
apk del terraform && \
6160
curl -LOs https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \
6261
&& unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip \
6362
&& mv terraform /opt/terraform \

site/e2e/tests/organizationGroups.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ test("change quota settings", async ({ page }) => {
105105
// Go to settings
106106
await login(page, orgUserAdmin);
107107
await page.goto(`/organizations/${org.name}/groups/${group.name}`);
108-
await page.getByRole("button", { name: "Settings", exact: true }).click();
109-
expectUrl(page).toHavePathName(
108+
109+
await page.getByRole("link", { name: "Settings", exact: true }).click();
110+
await expectUrl(page).toHavePathName(
110111
`/organizations/${org.name}/groups/${group.name}/settings`,
111112
);
112113

@@ -115,11 +116,11 @@ test("change quota settings", async ({ page }) => {
115116
await page.getByRole("button", { name: /save/i }).click();
116117

117118
// We should get sent back to the group page afterwards
118-
expectUrl(page).toHavePathName(
119+
await expectUrl(page).toHavePathName(
119120
`/organizations/${org.name}/groups/${group.name}`,
120121
);
121122

122123
// ...and that setting should persist if we go back
123-
await page.getByRole("button", { name: "Settings", exact: true }).click();
124+
await page.getByRole("link", { name: "Settings", exact: true }).click();
124125
await expect(page.getByLabel("Quota Allowance")).toHaveValue("100");
125126
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect, test } from "@playwright/test";
2+
import { users } from "../../constants";
3+
import { login } from "../../helpers";
4+
import { beforeCoderTest } from "../../hooks";
5+
6+
test.beforeEach(({ page }) => {
7+
beforeCoderTest(page);
8+
});
9+
10+
test("adjust user theme preference", async ({ page }) => {
11+
await login(page, users.member);
12+
13+
await page.goto("/settings/appearance", { waitUntil: "domcontentloaded" });
14+
15+
await page.getByText("Light", { exact: true }).click();
16+
await expect(page.getByLabel("Light")).toBeChecked();
17+
18+
// Make sure the page is actually updated to use the light theme
19+
const [root] = await page.$$("html");
20+
expect(await root.evaluate((it) => it.className)).toContain("light");
21+
22+
await page.goto("/", { waitUntil: "domcontentloaded" });
23+
24+
// Make sure the page is still using the light theme after reloading and
25+
// navigating away from the settings page.
26+
const [homeRoot] = await page.$$("html");
27+
expect(await homeRoot.evaluate((it) => it.className)).toContain("light");
28+
});

site/e2e/tests/workspaces/createWorkspace.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {
55
createTemplate,
66
createWorkspace,
77
echoResponsesWithParameters,
8+
login,
89
openTerminalWindow,
910
requireTerraformProvisioner,
1011
verifyParameters,
1112
} from "../../helpers";
12-
import { login } from "../../helpers";
1313
import { beforeCoderTest } from "../../hooks";
1414
import {
1515
fifthParameter,
@@ -150,9 +150,7 @@ test("create workspace with disable_param search params", async ({ page }) => {
150150
await login(page, users.member);
151151
await page.goto(
152152
`/templates/${templateName}/workspace?disable_params=first_parameter,second_parameter`,
153-
{
154-
waitUntil: "domcontentloaded",
155-
},
153+
{ waitUntil: "domcontentloaded" },
156154
);
157155

158156
await expect(page.getByLabel(/First parameter/i)).toBeDisabled();
@@ -173,9 +171,7 @@ test.skip("create docker workspace", async ({ context, page }) => {
173171
// The workspace agents must be ready before we try to interact with the workspace.
174172
await page.waitForSelector(
175173
`//div[@role="status"][@data-testid="agent-status-ready"]`,
176-
{
177-
state: "visible",
178-
},
174+
{ state: "visible" },
179175
);
180176

181177
// Wait for the terminal button to be visible, and click it.

site/src/api/api.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,24 @@ class ApiMethods {
583583
return response.data;
584584
};
585585

586+
/**
587+
* @param organization Can be the organization's ID or name
588+
* @param options Pagination options
589+
*/
590+
getOrganizationPaginatedMembers = async (
591+
organization: string,
592+
options?: TypesGen.Pagination,
593+
) => {
594+
const url = getURLWithSearchParams(
595+
`/api/v2/organizations/${organization}/paginated-members`,
596+
options,
597+
);
598+
const response =
599+
await this.axios.get<TypesGen.PaginatedMembersResponse>(url);
600+
601+
return response.data;
602+
};
603+
586604
/**
587605
* @param organization Can be the organization's ID or name
588606
*/

site/src/api/queries/organizations.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { API } from "api/api";
22
import type {
33
CreateOrganizationRequest,
44
GroupSyncSettings,
5+
PaginatedMembersRequest,
6+
PaginatedMembersResponse,
57
RoleSyncSettings,
68
UpdateOrganizationRequest,
79
} from "api/typesGenerated";
10+
import type { UsePaginatedQueryOptions } from "hooks/usePaginatedQuery";
811
import {
912
type OrganizationPermissionName,
1013
type OrganizationPermissions,
@@ -59,13 +62,45 @@ export const organizationMembersKey = (id: string) => [
5962
"members",
6063
];
6164

65+
/**
66+
* Creates a query configuration to fetch all members of an organization.
67+
*
68+
* Unlike the paginated version, this function sets the `limit` parameter to 0,
69+
* which instructs the API to return all organization members in a single request
70+
* without pagination.
71+
*
72+
* @param id - The unique identifier of the organization
73+
* @returns A query configuration object for use with React Query
74+
*
75+
* @see paginatedOrganizationMembers - For fetching members with pagination support
76+
*/
6277
export const organizationMembers = (id: string) => {
6378
return {
64-
queryFn: () => API.getOrganizationMembers(id),
79+
queryFn: () => API.getOrganizationPaginatedMembers(id, { limit: 0 }),
6580
queryKey: organizationMembersKey(id),
6681
};
6782
};
6883

84+
export const paginatedOrganizationMembers = (
85+
id: string,
86+
searchParams: URLSearchParams,
87+
): UsePaginatedQueryOptions<
88+
PaginatedMembersResponse,
89+
PaginatedMembersRequest
90+
> => {
91+
return {
92+
searchParams,
93+
queryPayload: ({ limit, offset }) => {
94+
return {
95+
limit: limit,
96+
offset: offset,
97+
};
98+
},
99+
queryKey: ({ payload }) => [...organizationMembersKey(id), payload],
100+
queryFn: ({ payload }) => API.getOrganizationPaginatedMembers(id, payload),
101+
};
102+
};
103+
69104
export const addOrganizationMember = (queryClient: QueryClient, id: string) => {
70105
return {
71106
mutationFn: (userId: string) => {

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Badge/Badge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const badgeVariants = cva(
1212
variants: {
1313
variant: {
1414
default:
15-
"border-transparent bg-surface-secondary text-content-secondary shadow hover:bg-surface-tertiary",
15+
"border-transparent bg-surface-secondary text-content-secondary shadow",
1616
},
1717
size: {
1818
sm: "text-2xs font-regular",

site/src/components/UserAutocomplete/UserAutocomplete.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export const MemberAutocomplete: FC<MemberAutocompleteProps> = ({
6969
}) => {
7070
const [filter, setFilter] = useState<string>();
7171

72-
// Currently this queries all members, as there is no pagination.
7372
const membersQuery = useQuery({
7473
...organizationMembers(organizationId),
7574
enabled: filter !== undefined,
@@ -80,7 +79,7 @@ export const MemberAutocomplete: FC<MemberAutocompleteProps> = ({
8079
error={membersQuery.error}
8180
isFetching={membersQuery.isFetching}
8281
setFilter={setFilter}
83-
users={membersQuery.data}
82+
users={membersQuery.data?.members}
8483
{...props}
8584
/>
8685
);

site/src/modules/management/OrganizationSettingsLayout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const OrganizationSettingsContext = createContext<
2424
OrganizationSettingsValue | undefined
2525
>(undefined);
2626

27-
type OrganizationSettingsValue = Readonly<{
27+
export type OrganizationSettingsValue = Readonly<{
2828
organizations: readonly Organization[];
2929
organizationPermissionsByOrganizationId: Record<
3030
string,
@@ -36,9 +36,10 @@ type OrganizationSettingsValue = Readonly<{
3636

3737
export const useOrganizationSettings = (): OrganizationSettingsValue => {
3838
const context = useContext(OrganizationSettingsContext);
39+
3940
if (!context) {
4041
throw new Error(
41-
"useOrganizationSettings should be used inside of OrganizationSettingsLayout",
42+
"useOrganizationSettings should be used inside of OrganizationSettingsLayout or with the default values in case of testing.",
4243
);
4344
}
4445

0 commit comments

Comments
 (0)