diff --git a/backend/.sqlx/query-e58e1182efcb756c465ae98a09828052085b812a22ec8057fb002aab429a0b3f.json b/backend/.sqlx/query-e58e1182efcb756c465ae98a09828052085b812a22ec8057fb002aab429a0b3f.json new file mode 100644 index 0000000000..8c190c6a7f --- /dev/null +++ b/backend/.sqlx/query-e58e1182efcb756c465ae98a09828052085b812a22ec8057fb002aab429a0b3f.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE job_token SET workspace_id = $1\n WHERE workspace_id = $2 AND job_id IN (SELECT id FROM v2_job WHERE workspace_id = $1)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "e58e1182efcb756c465ae98a09828052085b812a22ec8057fb002aab429a0b3f" +} diff --git a/backend/windmill-api-workspaces/src/workspaces_extra.rs b/backend/windmill-api-workspaces/src/workspaces_extra.rs index 2c2edfad49..c7d10abed4 100644 --- a/backend/windmill-api-workspaces/src/workspaces_extra.rs +++ b/backend/windmill-api-workspaces/src/workspaces_extra.rs @@ -791,6 +791,15 @@ pub(crate) async fn change_workspace_id( .execute(&mut *tx) .await?; + sqlx::query!( + "UPDATE job_token SET workspace_id = $1 + WHERE workspace_id = $2 AND job_id IN (SELECT id FROM v2_job WHERE workspace_id = $1)", + &rw.new_id, + &old_id + ) + .execute(&mut *tx) + .await?; + info!("Updating raw_app table"); sqlx::query!( "UPDATE raw_app SET workspace_id = $1 WHERE workspace_id = $2", diff --git a/frontend/src/lib/components/runs/JobDetailFieldConfig.ts b/frontend/src/lib/components/runs/JobDetailFieldConfig.ts index 4e924d7172..4674f8e5ed 100644 --- a/frontend/src/lib/components/runs/JobDetailFieldConfig.ts +++ b/frontend/src/lib/components/runs/JobDetailFieldConfig.ts @@ -161,13 +161,19 @@ export function getTriggerInfo(job: Job): { type: string; icon: any; detail?: st } /** The page of the trigger or app that started the job, when it has one. */ -export function getTriggerHref(job: Job): string | null { +export function getTriggerHref(job: Job, workspaceId: string): string | null { const path = job.trigger_path const kind = job.trigger_kind if (!path || !kind) return null - if (kind === 'app') return `/apps/get/${path}` + const workspace = `workspace=${encodeURIComponent(job.workspace_id || workspaceId)}` + if (kind === 'app') return `/apps/get/${path}?${workspace}` if (kind in TRIGGER_PAGES) { - return pageItemPageHref({ kind: 'trigger', triggerKind: kind as TriggerKind, path }) + const [page, hash] = pageItemPageHref({ + kind: 'trigger', + triggerKind: kind as TriggerKind, + path + }).split('#') + return `${page}?${workspace}#${hash}` } return null } @@ -223,7 +229,7 @@ export const fieldConfigs: Record = { const triggerInfo = getTriggerInfo(job) return triggerInfo ? triggerInfo.type : null }, - getHref: (job) => getTriggerHref(job) + getHref: (job, workspaceId) => getTriggerHref(job, workspaceId) }, token: { @@ -234,8 +240,10 @@ export const fieldConfigs: Record = { const label = job.token_label === 'session' ? 'Session' : job.token_label return `${job.token_prefix}****${label ? ` (${label})` : ''}` }, - getHref: (job) => - job.token_prefix ? `${AUDIT_LOGS_PATH}?token=${encodeURIComponent(job.token_prefix)}` : null + getHref: (job, workspaceId) => + job.token_prefix + ? `${AUDIT_LOGS_PATH}?token=${encodeURIComponent(job.token_prefix)}&workspace=${encodeURIComponent(job.workspace_id || workspaceId)}` + : null }, parent_job: {