mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-05 08:02:18 +00:00
fix(drafts): deploy only wipes the deployer's draft, not everyone else's
Script / flow / app deploys ran an unconditional DELETE on every draft at the path, so a teammate's deploy silently destroyed any other user's pending draft. After the wipe, the other user's tab kept auto-saving — re-creating the row at a NOW timestamp newer than the deploy — and StaleDraftModal never fired because draft_saved_at had been bumped past the deploy. Filter the DELETE to email = deployer (plus the legacy NULL row), so other users' drafts persist and the stale-draft prompt actually fires on their next reload. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
eb2f90ff78
commit
e3511b040a
@@ -1353,10 +1353,18 @@ async fn create_script_internal<'c>(
|
||||
let p_path_opt = parent_hashes_and_perms.as_ref().map(|x| x.p_path.clone());
|
||||
if let Some(ref p_path) = p_path_opt {
|
||||
if !skip_draft_deletion {
|
||||
// Only wipe the deployer's own draft (plus the legacy
|
||||
// NULL-email workspace draft, if any). Other users' drafts
|
||||
// are independent — they should NOT vanish silently when a
|
||||
// teammate deploys. The home-page badge surfaces them, and
|
||||
// the StaleDraftModal fires on their next reload because
|
||||
// the draft now predates the new deploy.
|
||||
sqlx::query!(
|
||||
"DELETE FROM draft WHERE path = $1 AND workspace_id = $2 AND typ = 'script'",
|
||||
"DELETE FROM draft WHERE path = $1 AND workspace_id = $2 AND typ = 'script' \
|
||||
AND (email = $3 OR email IS NULL)",
|
||||
p_path,
|
||||
&w_id
|
||||
&w_id,
|
||||
&authed.email,
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
@@ -1440,10 +1448,14 @@ async fn create_script_internal<'c>(
|
||||
}
|
||||
}
|
||||
} else if !skip_draft_deletion {
|
||||
// See the matching branch above — only wipe the deployer's own
|
||||
// draft (plus the legacy NULL-email row).
|
||||
sqlx::query!(
|
||||
"DELETE FROM draft WHERE path = $1 AND workspace_id = $2 AND typ = 'script'",
|
||||
"DELETE FROM draft WHERE path = $1 AND workspace_id = $2 AND typ = 'script' \
|
||||
AND (email = $3 OR email IS NULL)",
|
||||
ns.path,
|
||||
&w_id
|
||||
&w_id,
|
||||
&authed.email,
|
||||
)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user