11import { env } from "~/env.server" ;
22import { parse } from "@conform-to/zod" ;
33import { Form , useLocation , useNavigation , useSubmit } from "@remix-run/react" ;
4- import { ActionFunctionArgs , json } from "@remix-run/server-runtime" ;
4+ import { type ActionFunctionArgs , json } from "@remix-run/server-runtime" ;
55import {
66 conditionallyExportPacket ,
77 IOPacket ,
@@ -25,9 +25,10 @@ import { useProject } from "~/hooks/useProject";
2525import { redirectWithErrorMessage , redirectWithSuccessMessage } from "~/models/message.server" ;
2626import { logger } from "~/services/logger.server" ;
2727import { requireUserId } from "~/services/session.server" ;
28- import { ProjectParamSchema , v3RunsPath } from "~/utils/pathBuilder" ;
28+ import { EnvironmentParamSchema , ProjectParamSchema , v3RunsPath } from "~/utils/pathBuilder" ;
2929import { engine } from "~/v3/runEngine.server" ;
3030import { SpinnerWhite } from "~/components/primitives/Spinner" ;
31+ import { useEnvironment } from "~/hooks/useEnvironment" ;
3132
3233const CompleteWaitpointFormData = z . discriminatedUnion ( "type" , [
3334 z . object ( {
@@ -44,13 +45,13 @@ const CompleteWaitpointFormData = z.discriminatedUnion("type", [
4445 } ) ,
4546] ) ;
4647
47- const Params = ProjectParamSchema . extend ( {
48+ const Params = EnvironmentParamSchema . extend ( {
4849 waitpointFriendlyId : z . string ( ) ,
4950} ) ;
5051
5152export const action = async ( { request, params } : ActionFunctionArgs ) => {
5253 const userId = await requireUserId ( request ) ;
53- const { organizationSlug, projectParam, waitpointFriendlyId } = Params . parse ( params ) ;
54+ const { organizationSlug, projectParam, envParam , waitpointFriendlyId } = Params . parse ( params ) ;
5455
5556 const formData = await request . formData ( ) ;
5657 const submission = parse ( formData , { schema : CompleteWaitpointFormData } ) ;
@@ -181,7 +182,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
181182
182183 const errorMessage = `Something went wrong. Please try again.` ;
183184 return redirectWithErrorMessage (
184- v3RunsPath ( { slug : organizationSlug } , { slug : projectParam } ) ,
185+ v3RunsPath ( { slug : organizationSlug } , { slug : projectParam } , { slug : envParam } ) ,
185186 request ,
186187 errorMessage
187188 ) ;
@@ -191,12 +192,6 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
191192type FormWaitpoint = Pick < Waitpoint , "friendlyId" | "type" | "completedAfter" | "status" > ;
192193
193194export function CompleteWaitpointForm ( { waitpoint } : { waitpoint : FormWaitpoint } ) {
194- const navigation = useNavigation ( ) ;
195- const submit = useSubmit ( ) ;
196- const isLoading = navigation . state !== "idle" ;
197- const organization = useOrganization ( ) ;
198- const project = useProject ( ) ;
199-
200195 return (
201196 < div className = "space-y-3" >
202197 { waitpoint . type === "DATETIME" ? (
@@ -227,6 +222,7 @@ function CompleteDateTimeWaitpointForm({
227222 const isLoading = navigation . state !== "idle" ;
228223 const organization = useOrganization ( ) ;
229224 const project = useProject ( ) ;
225+ const environment = useEnvironment ( ) ;
230226
231227 const timeToComplete = waitpoint . completedAfter . getTime ( ) - Date . now ( ) ;
232228 if ( timeToComplete < 0 ) {
@@ -239,7 +235,7 @@ function CompleteDateTimeWaitpointForm({
239235
240236 return (
241237 < Form
242- action = { `/resources/orgs/${ organization . slug } /projects/${ project . slug } /waitpoints/${ waitpoint . friendlyId } /complete` }
238+ action = { `/resources/orgs/${ organization . slug } /projects/${ project . slug } /env/ ${ environment . slug } / waitpoints/${ waitpoint . friendlyId } /complete` }
243239 method = "post"
244240 className = "grid h-full max-h-full grid-rows-[2.5rem_1fr_3.25rem] overflow-hidden border-t border-grid-bright"
245241 >
@@ -292,8 +288,10 @@ function CompleteManualWaitpointForm({ waitpoint }: { waitpoint: { friendlyId: s
292288 const isLoading = navigation . state !== "idle" ;
293289 const organization = useOrganization ( ) ;
294290 const project = useProject ( ) ;
291+ const environment = useEnvironment ( ) ;
292+
295293 const currentJson = useRef < string > ( "{\n\n}" ) ;
296- const formAction = `/resources/orgs/${ organization . slug } /projects/${ project . slug } /waitpoints/${ waitpoint . friendlyId } /complete` ;
294+ const formAction = `/resources/orgs/${ organization . slug } /projects/${ project . slug } /env/ ${ environment . slug } / waitpoints/${ waitpoint . friendlyId } /complete` ;
297295
298296 const submitForm = useCallback (
299297 ( e : React . FormEvent < HTMLFormElement > ) => {
@@ -382,7 +380,9 @@ export function ForceTimeout({ waitpoint }: { waitpoint: { friendlyId: string }
382380 const isLoading = navigation . state !== "idle" ;
383381 const organization = useOrganization ( ) ;
384382 const project = useProject ( ) ;
385- const formAction = `/resources/orgs/${ organization . slug } /projects/${ project . slug } /waitpoints/${ waitpoint . friendlyId } /complete` ;
383+ const environment = useEnvironment ( ) ;
384+
385+ const formAction = `/resources/orgs/${ organization . slug } /projects/${ project . slug } /env/${ environment . slug } /waitpoints/${ waitpoint . friendlyId } /complete` ;
386386
387387 return (
388388 < Form action = { formAction } method = "post" >
0 commit comments