Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/app/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const jobDetailPage = (viewer: { email: string }, jobId: string) => shell
<dialog id="manual-run-dialog" aria-labelledby="manual-run-title" class="m-auto w-[min(34rem,calc(100%-2rem))] rounded-2xl border border-stone-200 bg-white p-0 text-slate-950 shadow-2xl backdrop:bg-slate-950/60 dark:border-slate-700 dark:bg-slate-900 dark:text-white"><form id="manual-run-form"><div class="p-6"><h2 id="manual-run-title" class="text-lg font-semibold">Run job manually</h2><p class="mt-2 text-sm text-slate-500 dark:text-slate-400">Add an optional prompt for this run.</p><label class="label mt-6" for="manual-run-prompt">Prompt</label><textarea id="manual-run-prompt" name="prompt" class="field min-h-32 resize-y" placeholder="Leave blank to skip prompt"></textarea><p id="manual-run-error" class="mt-3 hidden rounded-lg bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/40 dark:text-red-300" role="alert"></p><div class="mt-6 flex justify-end gap-3"><button id="cancel-manual-run" type="button" class="min-h-11 px-4 text-sm font-semibold">Cancel</button><button id="submit-manual-run" type="submit" class="min-h-11 rounded-xl bg-slate-950 px-4 text-sm font-semibold text-white disabled:cursor-wait disabled:opacity-60 dark:bg-white dark:text-slate-950">Run now</button></div></div></form></dialog></main>`, `${uiHelpers}
const id=$('#job-detail').dataset.id,root=$('#job-detail');
const manualRunDialog=$('#manual-run-dialog'),manualRunForm=$('#manual-run-form');
const nativeJobFetch=window.fetch.bind(window);window.fetch=async(input,init)=>{const response=await nativeJobFetch(input,init);if(!init?.method&&String(input).includes('/api/v1/jobs/'))response.clone().json().then(j=>setTimeout(()=>{const details=root.querySelector('dl');if(details&&!details.querySelector('[data-name-template]'))details.insertAdjacentHTML('beforeend','<dt class="font-semibold text-slate-950 dark:text-white">Name template</dt><dd data-name-template class="min-w-0 break-words font-mono">'+esc(j.runNameTemplate||'Default run name')+'</dd>')},0)).catch(()=>{});return response};
function openManualRun(){manualRunForm.reset();$('#manual-run-error').classList.add('hidden');manualRunDialog.showModal();$('#manual-run-prompt').focus()}
$('#cancel-manual-run').onclick=()=>manualRunDialog.close();manualRunDialog.onclick=e=>{if(e.target===manualRunDialog)manualRunDialog.close()};
manualRunForm.onsubmit=async e=>{e.preventDefault();const button=$('#submit-manual-run'),error=$('#manual-run-error');button.disabled=true;error.classList.add('hidden');try{const x=await request('/api/v1/jobs/'+encodeURIComponent(id)+'/invocations',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({prompt:manualRunForm.elements.prompt.value})});location.href='/job-runs/'+encodeURIComponent(x.runId)}catch(e){error.textContent=e.message;error.classList.remove('hidden');button.disabled=false}};
Expand Down
2 changes: 2 additions & 0 deletions packages/app/test/ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ describe("pages", () => {
expect(detail).toContain("esc(j.name)");
expect(detail).toContain('<summary class="w-fit cursor-pointer');
expect(detail).toContain('>Details</summary>');
expect(detail).toContain('Name template');
expect(detail).toContain('j.runNameTemplate||\'Default run name\'');
expect(detail).toContain('w-full break-words text-3xl');
expect(detail).toContain("esc(j.runningCount)+'/'+esc(j.concurrencyLimit)+' Running");
expect(detail).toContain('data-run-started=');
Expand Down