Skip to content

feat: UI/UX for regions #7283

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 54 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
26d3497
chore: Allow regular users to query for all workspaces
Emyrk Apr 24, 2023
3203ad7
Begin work on FE to add workspace proxy options to account settings
Emyrk Apr 24, 2023
a9ad485
Take origin file
Emyrk Apr 25, 2023
bde8870
Remove excess diffs
Emyrk Apr 25, 2023
69ce5f0
fixup! Remove excess diffs
Emyrk Apr 25, 2023
1daa32f
Update proxy page for regions endpoint
Emyrk Apr 25, 2023
b2e3efb
Some basic selector for proxies
Emyrk Apr 25, 2023
f78935f
Make hook for preferred proxy
Emyrk Apr 25, 2023
7a2e78e
Make fmt
Emyrk Apr 25, 2023
9b598e8
Typo
Emyrk Apr 25, 2023
17f9b00
Create workspace proxy context
Emyrk Apr 26, 2023
0683412
Use new context
Emyrk Apr 26, 2023
69c5734
fixup! Use new context
Emyrk Apr 26, 2023
9879476
WorkspaceProxy context syncs with coderd on region responses
Emyrk Apr 26, 2023
7d163fd
Make fmt
Emyrk Apr 26, 2023
e400810
Move dashboard provider
Emyrk Apr 26, 2023
02bcb84
Fix authenticated providers
Emyrk Apr 26, 2023
f9446c2
Fix authenticated renders
Emyrk Apr 26, 2023
9281333
Merge remote-tracking branch 'origin/main' into stevenmasley/regions
Emyrk Apr 26, 2023
8cc227f
Make fmt
Emyrk Apr 26, 2023
63dc985
Use auth render
Emyrk Apr 26, 2023
f4b6921
Fix terminal test render
Emyrk Apr 26, 2023
322fda6
Make fmt
Emyrk Apr 26, 2023
89efc57
Fix local storage load
Emyrk Apr 27, 2023
48a0beb
Fix terminals on the frontend to use proxies
Emyrk Apr 27, 2023
77d943f
Remove CSP hole
Emyrk Apr 27, 2023
75b8fd4
Add comment on origin patterns
Emyrk Apr 27, 2023
3391e84
Add unit test for getURLs
Emyrk Apr 27, 2023
4075b92
remove some TODOs
Emyrk Apr 27, 2023
b79b460
Add another store
Emyrk Apr 27, 2023
e879160
Update site/src/components/TerminalLink/TerminalLink.tsx
Emyrk Apr 27, 2023
27ef4a9
Fix stories
Emyrk Apr 27, 2023
eb38e95
Move providers into requrie auth
Emyrk Apr 27, 2023
1f8cae4
Fix imports
Emyrk Apr 27, 2023
6a22181
Fix 2 stories
Emyrk Apr 27, 2023
51bdaa2
Stories did not have subdomains on
Emyrk Apr 27, 2023
909801c
Merge remote-tracking branch 'origin/main' into stevenmasley/regions
Emyrk Apr 27, 2023
836c5a4
Fmt after merge
Emyrk Apr 27, 2023
0d0ed87
Fix port forward story
Emyrk Apr 27, 2023
6ed5fe4
ProxyPageView -> ProxyView
Emyrk Apr 27, 2023
163bbff
PR comment cleanup
Emyrk Apr 27, 2023
7dee309
Fix moon feature flag panic
Emyrk Apr 27, 2023
b7cfb39
Make fmt
Emyrk Apr 27, 2023
6b19118
Fix typo
Emyrk Apr 27, 2023
3fed785
Rename getUrls
Emyrk Apr 28, 2023
5bb44e8
Rename regions to proxies
Emyrk Apr 28, 2023
c868fc9
Only do 1 api call based on experiment
Emyrk Apr 28, 2023
edbe6e4
Cleanup args to take just the selected proxy
Emyrk Apr 28, 2023
eb6493c
Renames regions -> proxies
Emyrk Apr 28, 2023
017b3db
Fix stories
Emyrk Apr 28, 2023
c59a6ba
Move funciton back to bottom
Emyrk Apr 28, 2023
87e0b6d
Fix onSuccess of proxy provider
Emyrk Apr 28, 2023
fef5b00
Make fmt
Emyrk Apr 28, 2023
d33371d
Simplify some ts
Emyrk Apr 28, 2023
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
Prev Previous commit
Next Next commit
Begin work on FE to add workspace proxy options to account settings
  • Loading branch information
Emyrk committed Apr 25, 2023
commit 3203ad72ba16092933cd29ee49d0f1bb8867a1dc
11 changes: 8 additions & 3 deletions coderd/apidoc/docs.go

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

10 changes: 7 additions & 3 deletions coderd/apidoc/swagger.json

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

1 change: 1 addition & 0 deletions coderd/rbac/object_gen.go

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

12 changes: 7 additions & 5 deletions codersdk/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
type ProxyHealthStatus string

const (
// ProxyReachable means the proxy access url is reachable and returns a healthy
ProxyUnknown ProxyHealthStatus = "unknown"
// ProxyHealthy means the proxy access url is reachable and returns a healthy
// status code.
ProxyReachable ProxyHealthStatus = "reachable"
ProxyHealthy ProxyHealthStatus = "ok"
// ProxyUnreachable means the proxy access url is not responding.
ProxyUnreachable ProxyHealthStatus = "unreachable"
// ProxyUnhealthy means the proxy access url is responding, but there is some
Expand Down Expand Up @@ -48,9 +49,10 @@ type ProxyHealthReport struct {
}

type WorkspaceProxy struct {
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
Name string `json:"name" table:"name,default_sort"`
Icon string `json:"icon" table:"icon"`
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
Name string `json:"name" table:"name,default_sort"`
DisplayName string `json:"display_name" table:"display_name"`
Icon string `json:"icon" table:"icon"`
// Full url including scheme of the proxy api url: https://us.example.com
URL string `json:"url" table:"url"`
// WildcardHostname with the wildcard for subdomain based app hosting: *.us.example.com
Expand Down
12 changes: 8 additions & 4 deletions docs/api/enterprise.md
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
{
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
Expand All @@ -1191,7 +1192,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "unknown"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand All @@ -1215,12 +1216,13 @@ Status Code **200**
| `[array item]` | array | false | | |
| `» created_at` | string(date-time) | false | | |
| `» deleted` | boolean | false | | |
| `» display_name` | string | false | | |
| `» icon` | string | false | | |
| `» id` | string(uuid) | false | | |
| `» name` | string | false | | |
| `» status` | [codersdk.WorkspaceProxyStatus](schemas.md#codersdkworkspaceproxystatus) | false | | Status is the latest status check of the proxy. This will be empty for deleted proxies. This value can be used to determine if a workspace proxy is healthy and ready to use. |
| `»» checked_at` | string(date-time) | false | | |
| `»» report` | [codersdk.ProxyHealthReport](schemas.md#codersdkproxyhealthreport) | false | | Report provides more information about the health of the workspace proxy. |
| `»» report` | [codersdk.ProxyHealthReport](schemas.md#codersdkproxyhealthreport) | false | | Report provides more information about the health of the workspace proxy. This is not provided if the user does not have permission to view workspace proxy metadata. |
| `»»» errors` | array | false | | Errors are problems that prevent the workspace proxy from being healthy |
| `»»» warnings` | array | false | | Warnings do not prevent the workspace proxy from being healthy, but should be addressed. |
| `»» status` | [codersdk.ProxyHealthStatus](schemas.md#codersdkproxyhealthstatus) | false | | |
Expand All @@ -1232,7 +1234,8 @@ Status Code **200**

| Property | Value |
| -------- | -------------- |
| `status` | `reachable` |
| `status` | `unknown` |
| `status` | `ok` |
| `status` | `unreachable` |
| `status` | `unhealthy` |
| `status` | `unregistered` |
Expand Down Expand Up @@ -1277,6 +1280,7 @@ curl -X POST http://coder-server:8080/api/v2/workspaceproxies \
{
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
Expand All @@ -1286,7 +1290,7 @@ curl -X POST http://coder-server:8080/api/v2/workspaceproxies \
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "unknown"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand Down
21 changes: 12 additions & 9 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -3401,7 +3401,7 @@ Parameter represents a set value for the scope.
## codersdk.ProxyHealthStatus

```json
"reachable"
"unknown"
```

### Properties
Expand All @@ -3410,7 +3410,8 @@ Parameter represents a set value for the scope.

| Value |
| -------------- |
| `reachable` |
| `unknown` |
| `ok` |
| `unreachable` |
| `unhealthy` |
| `unregistered` |
Expand Down Expand Up @@ -5272,6 +5273,7 @@ Parameter represents a set value for the scope.
{
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"display_name": "string",
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
Expand All @@ -5281,7 +5283,7 @@ Parameter represents a set value for the scope.
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "unknown"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand All @@ -5295,6 +5297,7 @@ Parameter represents a set value for the scope.
| ------------------- | -------------------------------------------------------------- | -------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `created_at` | string | false | | |
| `deleted` | boolean | false | | |
| `display_name` | string | false | | |
| `icon` | string | false | | |
| `id` | string | false | | |
| `name` | string | false | | |
Expand All @@ -5312,17 +5315,17 @@ Parameter represents a set value for the scope.
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "unknown"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ------------ | -------------------------------------------------------- | -------- | ------------ | ------------------------------------------------------------------------- |
| `checked_at` | string | false | | |
| `report` | [codersdk.ProxyHealthReport](#codersdkproxyhealthreport) | false | | Report provides more information about the health of the workspace proxy. |
| `status` | [codersdk.ProxyHealthStatus](#codersdkproxyhealthstatus) | false | | |
| Name | Type | Required | Restrictions | Description |
| ------------ | -------------------------------------------------------- | -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `checked_at` | string | false | | |
| `report` | [codersdk.ProxyHealthReport](#codersdkproxyhealthreport) | false | | Report provides more information about the health of the workspace proxy. This is not provided if the user does not have permission to view workspace proxy metadata. |
| `status` | [codersdk.ProxyHealthStatus](#codersdkproxyhealthstatus) | false | | |

## codersdk.WorkspaceQuota

Expand Down
1 change: 1 addition & 0 deletions enterprise/coderd/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ func convertProxy(p database.WorkspaceProxy, status proxyhealth.ProxyStatus) cod
return codersdk.WorkspaceProxy{
ID: p.ID,
Name: p.Name,
DisplayName: p.DisplayName,
Icon: p.Icon,
URL: p.Url,
WildcardHostname: p.WildcardHostname,
Expand Down
4 changes: 4 additions & 0 deletions site/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const SSHKeysPage = lazy(
const TokensPage = lazy(
() => import("./pages/UserSettingsPage/TokensPage/TokensPage"),
)
const WorkspaceProxyPage = lazy(
() => import("./pages/UserSettingsPage/WorkspaceProxyPage/WorkspaceProxyPage"),
)
const CreateUserPage = lazy(
() => import("./pages/UsersPage/CreateUserPage/CreateUserPage"),
)
Expand Down Expand Up @@ -259,6 +262,7 @@ export const AppRouter: FC = () => {
<Route index element={<TokensPage />} />
<Route path="new" element={<CreateTokenPage />} />
</Route>
<Route path="workspace-proxies" element={<WorkspaceProxyPage />} />
</Route>

<Route path="/@:username">
Expand Down
10 changes: 10 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,16 @@ export const getFile = async (fileId: string): Promise<ArrayBuffer> => {
return response.data
}


export const getWorkspaceProxies = async (): Promise<TypesGen.WorkspaceProxy[]> => {
const response = await axios.get<TypesGen.WorkspaceProxy[]>(
`/api/v2/workspaceproxies`,
{},
)
return response.data
}


export const getAppearance = async (): Promise<TypesGen.AppearanceConfig> => {
try {
const response = await axios.get(`/api/v2/appearance`)
Expand Down
7 changes: 5 additions & 2 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ export interface WorkspaceOptions {
export interface WorkspaceProxy {
readonly id: string
readonly name: string
readonly display_name: string
readonly icon: string
readonly url: string
readonly wildcard_hostname: string
Expand Down Expand Up @@ -1479,13 +1480,15 @@ export const ProvisionerTypes: ProvisionerType[] = ["echo", "terraform"]

// From codersdk/workspaceproxy.go
export type ProxyHealthStatus =
| "reachable"
| "ok"
| "unhealthy"
| "unknown"
| "unreachable"
| "unregistered"
export const ProxyHealthStatuses: ProxyHealthStatus[] = [
"reachable",
"ok",
"unhealthy",
"unknown",
"unreachable",
"unregistered",
]
Expand Down
8 changes: 8 additions & 0 deletions site/src/components/SettingsLayout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NavLink } from "react-router-dom"
import { combineClasses } from "utils/combineClasses"
import AccountIcon from "@material-ui/icons/Person"
import SecurityIcon from "@material-ui/icons/LockOutlined"
import PublicIcon from '@material-ui/icons/Public';

const SidebarNavItem: FC<
PropsWithChildren<{ href: string; icon: ReactNode }>
Expand Down Expand Up @@ -76,6 +77,13 @@ export const Sidebar: React.FC<{ user: User }> = ({ user }) => {
>
Tokens
</SidebarNavItem>
{/* TODO: @emyrk this should only be shown if the 'moons' experiment is enabled */}
<SidebarNavItem
href="workspace-proxies"
icon={<SidebarNavItemIcon icon={PublicIcon} />}
>
Workspace Proxy
</SidebarNavItem>
</nav>
)
}
Expand Down
55 changes: 55 additions & 0 deletions site/src/i18n/en/proxyPage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"title": "Workspace Proxies",
"description": " Workspace proxies are used to reduce the latency of connections to a workspace. To get the best experience, choose the workspace proxy that is closest located to you.",
"emptyState": "No workspace proxies found",
"tokenActions": {
"addToken": "Add token",
"deleteToken": {
"delete": "Delete Token",
"deleteCaption": "Are you sure you want to permanently delete token <strong><4>{{tokenName}}</4></strong>?",
"deleteSuccess": "Token has been deleted",
"deleteFailure": "Failed to delete token"
}
},
"table": {
"icon": "Proxy",
"url": "URL",
"status": "Status",
"expiresAt": "Expires At",
"createdAt": "Created At"
},
"createToken": {
"title": "Create Token",
"detail": "All tokens are unscoped and therefore have full resource access.",
"nameSection": {
"title": "Name",
"description": "What is this token for?"
},
"lifetimeSection": {
"title": "Expiration",
"description": "The token will expire on {{date}}.",
"emptyDescription": "Please set a token expiration.",
"7": "7 days",
"30": "30 days",
"60": "60 days",
"90": "90 days",
"custom": "Custom",
"noExpiration": "No expiration",
"expiresOn": "Expires on"
},
"fields": {
"name": "Name",
"lifetime": "Lifetime"
},
"footer": {
"retry": "Retry",
"submit": "Create token"
},
"createSuccess": "Token has been created",
"createError": "Failed to create token",
"successModal": {
"title": "Creation successful",
"description": "Make sure you copy the below token before proceeding:"
}
}
}
Loading