diff --git a/server/lib/supafana/web/router.ex b/server/lib/supafana/web/router.ex index 54ccd4b..94c9c8b 100644 --- a/server/lib/supafana/web/router.ex +++ b/server/lib/supafana/web/router.ex @@ -621,6 +621,13 @@ defmodule Supafana.Web.Router do false -> forbid(conn, "Project #{project_ref} does not belong to your Supabase organization") + {:ok, _, _} -> + send_resp( + conn, + 400, + "Project must be restored to provision" + ) + {:ok, service_key} -> case Supafana.Azure.Api.check_deployment(project_ref) do {:ok, %{"properties" => %{"provisioningState" => "Failed"}}} -> @@ -675,7 +682,7 @@ defmodule Supafana.Web.Router do false -> forbid(conn, "Project #{project_ref} does not belong to your Supabase organization") - {:ok, _} -> + _ -> Supafana.Web.Task.schedule( operation: :delete_vm, project_ref: project_ref, diff --git a/server/lib/supafana/web/utils.ex b/server/lib/supafana/web/utils.ex index ea18920..531e70a 100644 --- a/server/lib/supafana/web/utils.ex +++ b/server/lib/supafana/web/utils.ex @@ -36,7 +36,13 @@ defmodule Supafana.Web.Utils do {:ok, service_key} _ -> - false + case Supafana.Supabase.Management.project_health(access_token, project_ref) do + {:ok, health} -> + {:ok, :inactive, health} + + _ -> + false + end end end end diff --git a/storefront/src/ui/SupafanaProject.tsx b/storefront/src/ui/SupafanaProject.tsx index 546fce7..676d24e 100644 --- a/storefront/src/ui/SupafanaProject.tsx +++ b/storefront/src/ui/SupafanaProject.tsx @@ -213,20 +213,33 @@ const SupafanaProject = ({ {(["Failed"].includes(state) || (plan === "Supafana Pro" && ["Deleted"].includes(state))) && (