Skip to content

Commit

Permalink
fix: Change routing for legacy pro providers to open source "Create W…
Browse files Browse the repository at this point in the history
…orkspace" page
  • Loading branch information
PRTTMPRPHT authored and pascalbreuninger committed Nov 23, 2024
1 parent 78059e5 commit 919e30a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions desktop/src/lib/modals/useLoginProModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { SubmitHandler, useForm } from "react-hook-form"
import { useNavigate } from "react-router"
import { ConfigureProviderOptionsForm, useSetupProvider } from "@/views/Providers"
import { To } from "react-router-dom"

type TFormValues = {
[FieldName.PRO_HOST]: string
Expand Down Expand Up @@ -145,14 +146,25 @@ export function useLoginProModal() {

const provider = providers?.[state.providerID]

let route: To

// We only redirect to the new experience if the provider supports it.
// Support can be determined via canHealthCheck.
if (provider && canHealthCheck(provider.config)) {
// workaround for layout shift after closing modal, no clue why
setTimeout(() => {
navigate(Routes.toProInstance(proInstanceID))
}, 0)
route = Routes.toProInstance(proInstanceID)
} else {
route = Routes.toWorkspaceCreate({
workspaceID: null,
ide: null,
rawSource: null,
providerID: state.providerID,
})
}

// workaround for layout shift after closing modal, no clue why
setTimeout(() => {
navigate(route)
}, 0)
}, [completeConfigureProvider, navigate, providers, proInstances, resetModal, state.providerID])

const modal = useMemo(() => {
Expand Down

0 comments on commit 919e30a

Please sign in to comment.