chore: Drop application host call, default to regions for info (#7457)

* chore: Drop application host call, default to regions for info
This commit is contained in:
Steven Masley 2023-05-09 09:28:25 -05:00 committed by GitHub
parent 2d62cbc83a
commit fc1bc374cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 24 deletions

1
coderd/apidoc/docs.go generated
View File

@ -149,6 +149,7 @@ const docTemplate = `{
],
"summary": "Get applications host",
"operationId": "get-applications-host",
"deprecated": true,
"responses": {
"200": {
"description": "OK",

View File

@ -121,6 +121,7 @@
"tags": ["Applications"],
"summary": "Get applications host",
"operationId": "get-applications-host",
"deprecated": true,
"responses": {
"200": {
"description": "OK",

View File

@ -27,6 +27,7 @@ import (
// @Tags Applications
// @Success 200 {object} codersdk.AppHostResponse
// @Router /applications/host [get]
// @Deprecated use api/v2/regions and see the primary proxy.
func (api *API) appHost(rw http.ResponseWriter, r *http.Request) {
host := api.AppHostname
if host != "" && api.AccessURL.Port() != "" {

View File

@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"
import { getApplicationsHost, getWorkspaceProxies } from "api/api"
import { getWorkspaceProxies } from "api/api"
import { Region } from "api/typesGenerated"
import { useDashboard } from "components/Dashboard/DashboardProvider"
import {
@ -70,7 +70,6 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
onSuccess: (resp) => {
setAndSaveProxy(proxy.selectedProxy, resp.regions)
},
enabled: experimentEnabled,
})
const setAndSaveProxy = (
@ -93,35 +92,20 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
setProxy(preferred)
}
// ******************************* //
// ** This code can be removed **
// ** when the experimental is **
// ** dropped ** //
const appHostQueryKey = ["get-application-host"]
const {
data: applicationHostResult,
error: appHostError,
isLoading: appHostLoading,
isFetched: appHostFetched,
} = useQuery({
queryKey: appHostQueryKey,
queryFn: getApplicationsHost,
enabled: !experimentEnabled,
})
return (
<ProxyContext.Provider
value={{
proxy: experimentEnabled
? proxy
: {
...getPreferredProxy([]),
preferredWildcardHostname: applicationHostResult?.host || "",
// If the experiment is disabled, then call 'getPreferredProxy' with the regions from
// the api call. The default behavior is to use the `primary` proxy.
...getPreferredProxy(proxiesResp?.regions || []),
},
proxies: experimentEnabled ? proxiesResp?.regions : [],
isLoading: experimentEnabled ? proxiesLoading : appHostLoading,
isFetched: experimentEnabled ? proxiesFetched : appHostFetched,
error: experimentEnabled ? proxiesError : appHostError,
proxies: proxiesResp?.regions,
isLoading: proxiesLoading,
isFetched: proxiesFetched,
error: proxiesError,
// A function that takes the new proxies and selected proxy and updates
// the state with the appropriate urls.
setProxy: setAndSaveProxy,