mirror of https://github.com/coder/coder.git
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:
parent
2d62cbc83a
commit
fc1bc374cb
|
@ -149,6 +149,7 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "Get applications host",
|
||||
"operationId": "get-applications-host",
|
||||
"deprecated": true,
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
"tags": ["Applications"],
|
||||
"summary": "Get applications host",
|
||||
"operationId": "get-applications-host",
|
||||
"deprecated": true,
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
|
|
|
@ -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() != "" {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue