Skip to content

Commit 42007e2

Browse files
committed
Merge branch 'main' into oauth
2 parents 917dfef + b9933d4 commit 42007e2

Some content is hidden

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

56 files changed

+77
-73
lines changed

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ coderd/database/generate: fmt/sql coderd/database/dump.sql $(wildcard coderd/dat
2020
.PHONY: coderd/database/generate
2121

2222
apitypings/generate: site/src/api/types.ts
23-
go run scripts/apitypings/main.go > site/src/api/types-generated.ts
23+
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
2424
cd site && yarn run format:types
2525
.PHONY: apitypings/generate
2626

@@ -35,7 +35,6 @@ endif
3535
.PHONY: fmt/prettier
3636

3737
fmt/sql: $(wildcard coderd/database/queries/*.sql)
38-
# TODO: this is slightly slow
3938
for fi in coderd/database/queries/*.sql; do \
4039
npx sql-formatter \
4140
--language postgresql \

agent/usershell/usershell_darwin.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package usershell
33
import "os"
44

55
// Get returns the $SHELL environment variable.
6-
// TODO: This should use "dscl" to fetch the proper value. See:
7-
// https://stackoverflow.com/questions/16375519/how-to-get-the-default-shell
86
func Get(username string) (string, error) {
97
return os.Getenv("SHELL"), nil
108
}

cli/workspaceautostart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func workspaceAutostart() *cobra.Command {
2222
Short: "schedule a workspace to automatically start at a regular time",
2323
Long: autostartDescriptionLong,
2424
Example: "coder workspaces autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
25-
Hidden: true, // TODO(cian): un-hide when autostart scheduling implemented
25+
Hidden: true,
2626
}
2727

2828
autostartCmd.AddCommand(workspaceAutostartEnable())

cli/workspaceautostop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func workspaceAutostop() *cobra.Command {
2222
Short: "schedule a workspace to automatically stop at a regular time",
2323
Long: autostopDescriptionLong,
2424
Example: "coder workspaces autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin",
25-
Hidden: true, // TODO(cian): un-hide when autostop scheduling implemented
25+
Hidden: true,
2626
}
2727

2828
autostopCmd.AddCommand(workspaceAutostopEnable())

coderd/rbac/role.go

-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ type Role struct {
2020
Name string `json:"name"`
2121
Site []Permission `json:"site"`
2222
// Org is a map of orgid to permissions. We represent orgid as a string.
23-
// TODO: Maybe switch to uuid, but tokens might need to support a "wildcard" org
24-
// which could be a special uuid (like all 0s?)
2523
Org map[string][]Permission `json:"org"`
2624
User []Permission `json:"user"`
2725
}
@@ -49,7 +47,6 @@ var (
4947
RoleAuditor = Role{
5048
Name: "auditor",
5149
Site: permissions(map[Object][]Action{
52-
// TODO: @emyrk when audit logs are added, add back a read perm
5350
//ResourceAuditLogs: {ActionRead},
5451
// Should be able to read user details to associate with logs.
5552
// Without this the user-id in logs is not very helpful

coderd/turnconn/turnconn_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func TestTURNConn(t *testing.T) {
4444
Logger: logger.Named("client"),
4545
})
4646
require.NoError(t, err)
47+
defer func() {
48+
_ = client.Close()
49+
}()
4750

4851
serverDialer, serverTURN := net.Pipe()
4952
turnServer.Accept(serverTURN, &net.TCPAddr{
@@ -62,6 +65,9 @@ func TestTURNConn(t *testing.T) {
6265
Logger: logger.Named("server"),
6366
})
6467
require.NoError(t, err)
68+
defer func() {
69+
_ = server.Close()
70+
}()
6571
exchange(t, client, server)
6672

6773
_, err = client.Ping()
@@ -71,12 +77,7 @@ func TestTURNConn(t *testing.T) {
7177
func exchange(t *testing.T, client, server *peer.Conn) {
7278
var wg sync.WaitGroup
7379
wg.Add(2)
74-
t.Cleanup(func() {
75-
_ = client.Close()
76-
_ = server.Close()
77-
78-
wg.Wait()
79-
})
80+
t.Cleanup(wg.Wait)
8081
go func() {
8182
defer wg.Done()
8283
for {

peer/channel.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ func (c *Channel) Write(bytes []byte) (n int, err error) {
245245
if c.dc.BufferedAmount()+uint64(len(bytes)) >= maxBufferedAmount {
246246
<-c.sendMore
247247
}
248-
// TODO (@kyle): There's an obvious race-condition here.
249-
// This is an edge-case, as most-frequently data won't
250-
// be pooled so synchronously, but is definitely possible.
248+
// REMARK: There's an obvious race-condition here. This is an edge-case, as
249+
// most-frequently data won't be pooled so synchronously, but is
250+
// definitely possible.
251251
//
252252
// See: https://github.com/pion/sctp/issues/181
253253
time.Sleep(time.Microsecond)

scripts/apitypings/main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"os"
1010
"path/filepath"
11+
"sort"
1112
"strings"
1213

1314
"golang.org/x/xerrors"
@@ -69,9 +70,16 @@ func run() error {
6970
handleValueSpec(s, enums)
7071
})
7172

73+
// sort keys so output is always the same
74+
var keys []string
75+
for k := range enums {
76+
keys = append(keys, k)
77+
}
78+
sort.Strings(keys)
79+
7280
// write each type alias declaration with possible values
73-
for _, v := range enums {
74-
_, _ = fmt.Printf("%s\n", v)
81+
for _, k := range keys {
82+
_, _ = fmt.Printf("%s\n", enums[k])
7583
}
7684

7785
return nil

scripts/yarn_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
#
33
# Run "yarn install" with flags appropriate to the environment
44
# (local development vs build system)

site/.storybook/preview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createMemoryHistory } from "history"
55
import { addDecorator } from "node_modules/@storybook/react"
66
import { unstable_HistoryRouter as HistoryRouter } from "react-router-dom"
77
import { dark, light } from "../src/theme"
8-
import "../src/theme/global-fonts"
8+
import "../src/theme/globalFonts"
99

1010
const providerFn = ({ children, theme }) => (
1111
<ThemeProvider theme={theme}>

site/e2e/util.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ interface WaitForClientSideNavigationOpts {
5757
* @remark This is necessary in a client-side SPA world since playwright
5858
* waitForNavigation waits for load events on the DOM (ex: after a page load
5959
* from the server).
60-
*
61-
* @todo Better logging for this.
6260
*/
6361
export const waitForClientSideNavigation = async (page: Page, opts: WaitForClientSideNavigationOpts): Promise<void> => {
62+
console.info(`--- waitForClientSideNavigation: start`)
63+
6464
await Promise.all([
6565
waitFor(() => {
6666
const conditions: boolean[] = []
@@ -74,9 +74,12 @@ export const waitForClientSideNavigation = async (page: Page, opts: WaitForClien
7474
}
7575

7676
const unmetConditions = conditions.filter((condition) => !condition)
77+
console.info(`--- waitForClientSideNavigation: ${unmetConditions.length} conditions not met`)
7778

7879
return Promise.resolve(unmetConditions.length === 0)
7980
}),
8081
page.waitForLoadState("networkidle"),
8182
])
83+
84+
console.info(`--- waitForClientSideNavigation: done`)
8285
}

site/embed.go

-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ func secureHeaders(next http.Handler) http.Handler {
270270

271271
// Only scripts can manipulate the dom. This prevents someone from
272272
// naming themselves something like '<svg onload="alert(/cross-site-scripting/)" />'.
273-
// TODO: @emyrk we need to make FE changes to enable this. We get 'TrustedHTML' and 'TrustedURL' errors
274-
// that require FE changes to work.
275273
// "require-trusted-types-for" : []string{"'script'"},
276274
}
277275

File renamed without changes.

site/jest.setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { server } from "./src/test_helpers/server"
1+
import { server } from "./src/testHelpers/server"
22

33
// Establish API mocking before all tests through MSW.
44
beforeAll(() =>

site/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"chromatic": "chromatic",
1111
"dev": "webpack-dev-server --config=webpack.dev.ts",
1212
"format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
13-
"format:types": "prettier --write 'src/api/types-generated.ts'",
13+
"format:types": "prettier --write 'src/api/typesGenerated.ts'",
1414
"format:write": "prettier --write '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
1515
"lint": "jest --selectProjects lint",
1616
"lint:fix": "FIX=true yarn lint",

site/src/AppRouter.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { HealthzPage } from "./pages/healthz"
1010
import { SignInPage } from "./pages/login"
1111
import { OrganizationsPage } from "./pages/orgs"
1212
import { PreferencesAccountPage } from "./pages/preferences/account"
13-
import { PreferencesLinkedAccountsPage } from "./pages/preferences/linked-accounts"
13+
import { PreferencesLinkedAccountsPage } from "./pages/preferences/linkedAccounts"
1414
import { PreferencesSecurityPage } from "./pages/preferences/security"
15-
import { PreferencesSSHKeysPage } from "./pages/preferences/ssh-keys"
15+
import { PreferencesSSHKeysPage } from "./pages/preferences/sshKeys"
1616
import { SettingsPage } from "./pages/settings"
1717
import { TemplatesPage } from "./pages/templates"
1818
import { TemplatePage } from "./pages/templates/[organization]/[template]"

site/src/api/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios, { AxiosRequestHeaders } from "axios"
22
import { mutate } from "swr"
3-
import { MockPager, MockUser, MockUser2 } from "../test_helpers/entities"
3+
import { MockPager, MockUser, MockUser2 } from "../testHelpers/entities"
44
import * as Types from "./types"
55

66
const CONTENT_TYPE_JSON: AxiosRequestHeaders = {

site/src/api/types-generated.ts renamed to site/src/api/typesGenerated.ts

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ export interface CreateWorkspaceRequest {
125125
readonly name: string
126126
}
127127

128+
// From codersdk/users.go:81:6.
129+
export interface AuthMethods {
130+
readonly password: boolean
131+
readonly github: boolean
132+
}
133+
128134
// From codersdk/workspaceagents.go:31:6.
129135
export interface GoogleInstanceIdentityToken {
130136
readonly json_web_token: string

site/src/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SWRConfig } from "swr"
66
import { AppRouter } from "./AppRouter"
77
import { GlobalSnackbar } from "./components/Snackbar/GlobalSnackbar"
88
import { light } from "./theme"
9-
import "./theme/global-fonts"
9+
import "./theme/globalFonts"
1010
import { XServiceProvider } from "./xServices/StateContext"
1111

1212
export const App: React.FC = () => {

site/src/components/AdminDropdown/AdminDropdown.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { history, render } from "../../test_helpers"
3+
import { history, render } from "../../testHelpers"
44
import { AdminDropdown, Language } from "./AdminDropdown"
55

66
const renderAndClick = async () => {

site/src/components/CodeBlock/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { CodeBlock } from "./index"
55

66
describe("CodeBlock", () => {

site/src/components/CodeExample/CodeExample.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { CodeExample } from "./CodeExample"
55

66
describe("CodeExample", () => {

site/src/components/EmptyState/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { EmptyState } from "./index"
55

66
describe("EmptyState", () => {

site/src/components/Form/FormTextField.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface FormTextFieldProps<T>
6262
* }}
6363
* />
6464
*/
65-
eventTransform?: (value: string) => unknown
65+
eventTransform?: (value: string) => string
6666
/**
6767
* isPassword uses a PasswordField component when `true`; otherwise a
6868
* TextField component is used.
@@ -145,13 +145,8 @@ export const FormTextField = <T,>({
145145
}
146146

147147
const event = e
148-
if (typeof eventTransform !== "undefined") {
149-
// TODO(Grey): Asserting the type as a string here is not quite
150-
// right in that when an input is of type="number", the value will
151-
// be a number. Type asserting is better than conversion for this
152-
// reason, but perhaps there's a better way to do this without any
153-
// assertions.
154-
event.target.value = eventTransform(e.target.value) as string
148+
if (typeof eventTransform !== "undefined" && typeof event.target.value === "string") {
149+
event.target.value = eventTransform(e.target.value)
155150
}
156151
form.handleChange(event)
157152
}}

site/src/components/Header/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "./../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { Header } from "./index"
55

66
describe("Header", () => {

site/src/components/Icons/index.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SvgIcon from "@material-ui/core/SvgIcon"
22
import React from "react"
3-
import { render } from "./../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import * as Icons from "./index"
55

66
const getAllIcons = (): [string, typeof SvgIcon][] => {

site/src/components/Navbar/NavbarView/NavbarView.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
33
import { NavbarView } from "."
4-
import { render } from "../../../test_helpers"
5-
import { MockUser } from "../../../test_helpers/entities"
4+
import { render } from "../../../testHelpers"
5+
import { MockUser } from "../../../testHelpers/entities"
66

77
describe("NavbarView", () => {
88
const noop = () => {

site/src/components/Navbar/UserDropdown/UserDropdown.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
33
import { Language, UserDropdown, UserDropdownProps } from "."
4-
import { render } from "../../../test_helpers"
5-
import { MockUser } from "../../../test_helpers/entities"
4+
import { render } from "../../../testHelpers"
5+
import { MockUser } from "../../../testHelpers/entities"
66

77
const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => {
88
render(<UserDropdown user={props.user ?? MockUser} onSignOut={props.onSignOut ?? jest.fn()} />)

site/src/components/Page/Footer.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { MockBuildInfo, render } from "../../test_helpers"
3+
import { MockBuildInfo, render } from "../../testHelpers"
44
import { Footer, Language } from "./Footer"
55

66
describe("Footer", () => {

site/src/components/SignIn/CliAuthToken.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { CliAuthToken } from "./CliAuthToken"
55

66
describe("CliAuthToken", () => {

site/src/components/Table/Cells/UserCell.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentMeta, Story } from "@storybook/react"
22
import React from "react"
3-
import { MockUser, MockUserAgent } from "../../../test_helpers"
3+
import { MockUser, MockUserAgent } from "../../../testHelpers"
44
import { UserCell, UserCellProps } from "./UserCell"
55

66
export default {

site/src/components/Table/Cells/UserCell.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fireEvent, render, screen } from "@testing-library/react"
22
import React from "react"
3-
import { MockUser, MockUserAgent, WrapperComponent } from "../../../test_helpers"
3+
import { MockUser, MockUserAgent, WrapperComponent } from "../../../testHelpers"
44
import { UserCell, UserCellProps } from "./UserCell"
55

66
namespace Helpers {

site/src/components/Table/Table.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "./../../test_helpers"
3+
import { render } from "../../testHelpers"
44
import { Column, Table } from "./Table"
55

66
interface TestData {

site/src/components/User/UserAvatar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Avatar from "@material-ui/core/Avatar"
22
import React from "react"
3-
import { firstLetter } from "../../util/first-letter"
3+
import { firstLetter } from "../../util/firstLetter"
44

55
export interface UserAvatarProps {
66
className?: string

site/src/components/UsersTable/UsersTable.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentMeta, Story } from "@storybook/react"
22
import React from "react"
3-
import { MockUser, MockUser2 } from "../../test_helpers"
3+
import { MockUser, MockUser2 } from "../../testHelpers"
44
import { UsersTable, UsersTableProps } from "./UsersTable"
55

66
export default {

0 commit comments

Comments
 (0)