Skip to content

Commit 7b266d9

Browse files
committed
Allow arbitrary queue inputs for v1 engine runs
1 parent 712bd5c commit 7b266d9

File tree

2 files changed

+68
-52
lines changed

2 files changed

+68
-52
lines changed

apps/webapp/app/presenters/v3/TestTaskPresenter.server.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type TestTaskResult =
5555
foundTask: true;
5656
task: TestTask;
5757
disableVersionSelection: boolean;
58+
allowArbitraryQueues: boolean;
5859
}
5960
| {
6061
foundTask: false;
@@ -147,23 +148,24 @@ export class TestTaskPresenter {
147148
})
148149
: undefined;
149150

150-
// last 20 versions should suffice
151-
const latestVersions = (
152-
await this.#prismaClient.backgroundWorker.findMany({
153-
where: {
154-
runtimeEnvironmentId: environment.id,
155-
},
156-
select: {
157-
version: true,
158-
},
159-
orderBy: {
160-
createdAt: "desc",
161-
},
162-
take: 20,
163-
})
164-
).map((v) => v.version);
151+
const backgroundWorkers = await this.#prismaClient.backgroundWorker.findMany({
152+
where: {
153+
runtimeEnvironmentId: environment.id,
154+
},
155+
select: {
156+
version: true,
157+
engine: true,
158+
},
159+
orderBy: {
160+
createdAt: "desc",
161+
},
162+
take: 20, // last 20 versions should suffice
163+
});
164+
165+
const latestVersions = backgroundWorkers.map((v) => v.version);
165166

166167
const disableVersionSelection = environment.type === "DEVELOPMENT";
168+
const allowArbitraryQueues = backgroundWorkers[0]?.engine === "V1";
167169

168170
const latestRuns = await this.#prismaClient.$queryRaw<RawRun[]>`
169171
WITH taskruns AS (
@@ -248,6 +250,7 @@ export class TestTaskPresenter {
248250
latestVersions,
249251
},
250252
disableVersionSelection,
253+
allowArbitraryQueues,
251254
};
252255
case "SCHEDULED":
253256
const possibleTimezones = getTimezones();
@@ -278,6 +281,7 @@ export class TestTaskPresenter {
278281
latestVersions,
279282
},
280283
disableVersionSelection,
284+
allowArbitraryQueues,
281285
};
282286
}
283287
}

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/route.tsx

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export default function Page() {
179179
runs={result.task.runs}
180180
versions={result.task.latestVersions}
181181
disableVersionSelection={result.disableVersionSelection}
182+
allowArbitraryQueues={result.allowArbitraryQueues}
182183
/>
183184
);
184185
}
@@ -212,12 +213,14 @@ function StandardTaskForm({
212213
runs,
213214
versions,
214215
disableVersionSelection,
216+
allowArbitraryQueues,
215217
}: {
216218
task: TestTask["task"];
217219
defaultQueue: TestTask["queue"];
218220
runs: StandardRun[];
219221
versions: string[];
220222
disableVersionSelection: boolean;
223+
allowArbitraryQueues: boolean;
221224
}) {
222225
const environment = useEnvironment();
223226
const { value, replace } = useSearchParams();
@@ -503,43 +506,52 @@ function StandardTaskForm({
503506
</InputGroup>
504507
<InputGroup>
505508
<Label htmlFor={queue.id}>Queue</Label>
506-
<Select
507-
name={queue.name}
508-
id={queue.id}
509-
placeholder="Select queue"
510-
variant="tertiary/small"
511-
dropdownIcon
512-
items={queues}
513-
filter={{ keys: ["label"] }}
514-
value={queueValue}
515-
setValue={setQueueValue}
516-
>
517-
{(matches) =>
518-
matches.map((queueItem) => (
519-
<SelectItem
520-
key={queueItem.value}
521-
value={queueItem.value}
522-
className="max-w-[var(--popover-anchor-width)]"
523-
icon={
524-
queueItem.type === "task" ? (
525-
<TaskIcon className="size-4 shrink-0 text-blue-500" />
526-
) : (
527-
<RectangleStackIcon className="size-4 shrink-0 text-purple-500" />
528-
)
529-
}
530-
>
531-
<div className="flex w-full min-w-0 items-center justify-between">
532-
<span className="truncate">{queueItem.label}</span>
533-
{queueItem.paused && (
534-
<Badge variant="extra-small" className="ml-1 text-warning">
535-
Paused
536-
</Badge>
537-
)}
538-
</div>
539-
</SelectItem>
540-
))
541-
}
542-
</Select>
509+
{allowArbitraryQueues ? (
510+
<Input
511+
{...conform.input(queue, { type: "text" })}
512+
variant="small"
513+
value={queueValue ?? ""}
514+
onChange={(e) => setQueueValue(e.target.value)}
515+
/>
516+
) : (
517+
<Select
518+
name={queue.name}
519+
id={queue.id}
520+
placeholder="Select queue"
521+
variant="tertiary/small"
522+
dropdownIcon
523+
items={queues}
524+
filter={{ keys: ["label"] }}
525+
value={queueValue}
526+
setValue={setQueueValue}
527+
>
528+
{(matches) =>
529+
matches.map((queueItem) => (
530+
<SelectItem
531+
key={queueItem.value}
532+
value={queueItem.value}
533+
className="max-w-[var(--popover-anchor-width)]"
534+
icon={
535+
queueItem.type === "task" ? (
536+
<TaskIcon className="size-4 shrink-0 text-blue-500" />
537+
) : (
538+
<RectangleStackIcon className="size-4 shrink-0 text-purple-500" />
539+
)
540+
}
541+
>
542+
<div className="flex w-full min-w-0 items-center justify-between">
543+
<span className="truncate">{queueItem.label}</span>
544+
{queueItem.paused && (
545+
<Badge variant="extra-small" className="ml-1 text-warning">
546+
Paused
547+
</Badge>
548+
)}
549+
</div>
550+
</SelectItem>
551+
))
552+
}
553+
</Select>
554+
)}
543555
<FormError id={queue.errorId}>{queue.error}</FormError>
544556
</InputGroup>
545557
<InputGroup>

0 commit comments

Comments
 (0)