From 0e0d964fc858dcc4551aa792ffeebf4f640197b9 Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Tue, 26 Mar 2024 19:07:21 +0100 Subject: [PATCH] feat: add visible to runner only default value (#3472) --- ...22ea8dcf2d786d0e9fa849754db82c9fa378.json} | 7 +++-- ...c41af92537c0fd5683227767f6a1bd17339f.json} | 5 +-- ...748cb854e23049d0cf73a42229eccc88c4e6.json} | 5 +-- ...122255_add_visible_to_runner_only.down.sql | 1 + ...26122255_add_visible_to_runner_only.up.sql | 3 ++ backend/tests/worker.rs | 2 ++ backend/windmill-api/openapi.yaml | 10 ++++-- backend/windmill-api/src/flows.rs | 14 ++++++--- backend/windmill-api/src/scripts.rs | 9 ++++-- backend/windmill-api/src/workspaces.rs | 3 ++ backend/windmill-common/src/flows.rs | 3 ++ backend/windmill-common/src/scripts.rs | 24 ++++++-------- cli/script.ts | 6 +++- .../src/lib/components/FlowBuilder.svelte | 9 ++++-- frontend/src/lib/components/MoveDrawer.svelte | 3 +- frontend/src/lib/components/RunForm.svelte | 2 +- .../components/RunFormAdvancedPopup.svelte | 2 +- .../src/lib/components/ScriptBuilder.svelte | 31 +++++++++++++++++-- .../flows/content/FlowSettings.svelte | 17 ++++++++++ .../flows/content/ScriptEditorDrawer.svelte | 3 ++ frontend/src/lib/components/flows/types.ts | 7 ++++- frontend/src/lib/components/flows/utils.ts | 7 ++++- .../(logged)/flows/get/[...path]/+page.svelte | 5 ++- .../(root)/(logged)/run/[...run]/+page.svelte | 11 ++++--- .../scripts/get/[...hash]/+page.svelte | 5 ++- 25 files changed, 146 insertions(+), 48 deletions(-) rename backend/.sqlx/{query-260feb784bb0b223bd9276d6a82bd26be90efb17a4323b9673e93ff88513942a.json => query-020d33ed5d47350b456783fd548422ea8dcf2d786d0e9fa849754db82c9fa378.json} (83%) rename backend/.sqlx/{query-c3da506f47dfb42434debf6e005319147c7513193e853c38cfb7c071d61a3d2e.json => query-35e6af0b203e3e4fac9020b037a3c41af92537c0fd5683227767f6a1bd17339f.json} (65%) rename backend/.sqlx/{query-de06474de29c6c2cadb99787f5d627678a5285011d7b1a516d4e240a5810ddba.json => query-f6fd65fbe36502923ab4ccf1a22f748cb854e23049d0cf73a42229eccc88c4e6.json} (71%) create mode 100644 backend/migrations/20240326122255_add_visible_to_runner_only.down.sql create mode 100644 backend/migrations/20240326122255_add_visible_to_runner_only.up.sql diff --git a/backend/.sqlx/query-260feb784bb0b223bd9276d6a82bd26be90efb17a4323b9673e93ff88513942a.json b/backend/.sqlx/query-020d33ed5d47350b456783fd548422ea8dcf2d786d0e9fa849754db82c9fa378.json similarity index 83% rename from backend/.sqlx/query-260feb784bb0b223bd9276d6a82bd26be90efb17a4323b9673e93ff88513942a.json rename to backend/.sqlx/query-020d33ed5d47350b456783fd548422ea8dcf2d786d0e9fa849754db82c9fa378.json index 38795ced69..78bfc65e20 100644 --- a/backend/.sqlx/query-260feb784bb0b223bd9276d6a82bd26be90efb17a4323b9673e93ff88513942a.json +++ b/backend/.sqlx/query-020d33ed5d47350b456783fd548422ea8dcf2d786d0e9fa849754db82c9fa378.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO script (workspace_id, hash, path, parent_hashes, summary, description, content, created_by, schema, is_template, extra_perms, lock, language, kind, tag, draft_only, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, timeout, concurrency_key) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::text::json, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27)", + "query": "INSERT INTO script (workspace_id, hash, path, parent_hashes, summary, description, content, created_by, schema, is_template, extra_perms, lock, language, kind, tag, draft_only, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, delete_after_use, timeout, concurrency_key, visible_to_runner_only) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::text::json, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28)", "describe": { "columns": [], "parameters": { @@ -65,10 +65,11 @@ "Bool", "Bool", "Int4", - "Varchar" + "Varchar", + "Bool" ] }, "nullable": [] }, - "hash": "260feb784bb0b223bd9276d6a82bd26be90efb17a4323b9673e93ff88513942a" + "hash": "020d33ed5d47350b456783fd548422ea8dcf2d786d0e9fa849754db82c9fa378" } diff --git a/backend/.sqlx/query-c3da506f47dfb42434debf6e005319147c7513193e853c38cfb7c071d61a3d2e.json b/backend/.sqlx/query-35e6af0b203e3e4fac9020b037a3c41af92537c0fd5683227767f6a1bd17339f.json similarity index 65% rename from backend/.sqlx/query-c3da506f47dfb42434debf6e005319147c7513193e853c38cfb7c071d61a3d2e.json rename to backend/.sqlx/query-35e6af0b203e3e4fac9020b037a3c41af92537c0fd5683227767f6a1bd17339f.json index b57b852f00..8076362b64 100644 --- a/backend/.sqlx/query-c3da506f47dfb42434debf6e005319147c7513193e853c38cfb7c071d61a3d2e.json +++ b/backend/.sqlx/query-35e6af0b203e3e4fac9020b037a3c41af92537c0fd5683227767f6a1bd17339f.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO flow (workspace_id, path, summary, description, value, edited_by, edited_at, schema, dependency_job, draft_only, tag, dedicated_worker) VALUES ($1, $2, $3, $4, $5, $6, now(), $7::text::json, NULL, $8, $9, $10)", + "query": "INSERT INTO flow (workspace_id, path, summary, description, value, edited_by, edited_at, schema, dependency_job, draft_only, tag, dedicated_worker, visible_to_runner_only) VALUES ($1, $2, $3, $4, $5, $6, now(), $7::text::json, NULL, $8, $9, $10, $11)", "describe": { "columns": [], "parameters": { @@ -14,10 +14,11 @@ "Text", "Bool", "Varchar", + "Bool", "Bool" ] }, "nullable": [] }, - "hash": "c3da506f47dfb42434debf6e005319147c7513193e853c38cfb7c071d61a3d2e" + "hash": "35e6af0b203e3e4fac9020b037a3c41af92537c0fd5683227767f6a1bd17339f" } diff --git a/backend/.sqlx/query-de06474de29c6c2cadb99787f5d627678a5285011d7b1a516d4e240a5810ddba.json b/backend/.sqlx/query-f6fd65fbe36502923ab4ccf1a22f748cb854e23049d0cf73a42229eccc88c4e6.json similarity index 71% rename from backend/.sqlx/query-de06474de29c6c2cadb99787f5d627678a5285011d7b1a516d4e240a5810ddba.json rename to backend/.sqlx/query-f6fd65fbe36502923ab4ccf1a22f748cb854e23049d0cf73a42229eccc88c4e6.json index 27477748b3..72dff20b56 100644 --- a/backend/.sqlx/query-de06474de29c6c2cadb99787f5d627678a5285011d7b1a516d4e240a5810ddba.json +++ b/backend/.sqlx/query-f6fd65fbe36502923ab4ccf1a22f748cb854e23049d0cf73a42229eccc88c4e6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE flow SET path = $1, summary = $2, description = $3, value = $4, edited_by = $5, edited_at = now(), schema = $6::text::json, dependency_job = NULL, draft_only = NULL, tag = $9, dedicated_worker = $10\n WHERE path = $7 AND workspace_id = $8", + "query": "UPDATE flow SET path = $1, summary = $2, description = $3, value = $4, edited_by = $5, edited_at = now(), schema = $6::text::json, dependency_job = NULL, draft_only = NULL, tag = $9, dedicated_worker = $10, visible_to_runner_only = $11\n WHERE path = $7 AND workspace_id = $8", "describe": { "columns": [], "parameters": { @@ -14,10 +14,11 @@ "Text", "Text", "Varchar", + "Bool", "Bool" ] }, "nullable": [] }, - "hash": "de06474de29c6c2cadb99787f5d627678a5285011d7b1a516d4e240a5810ddba" + "hash": "f6fd65fbe36502923ab4ccf1a22f748cb854e23049d0cf73a42229eccc88c4e6" } diff --git a/backend/migrations/20240326122255_add_visible_to_runner_only.down.sql b/backend/migrations/20240326122255_add_visible_to_runner_only.down.sql new file mode 100644 index 0000000000..d2f607c5b8 --- /dev/null +++ b/backend/migrations/20240326122255_add_visible_to_runner_only.down.sql @@ -0,0 +1 @@ +-- Add down migration script here diff --git a/backend/migrations/20240326122255_add_visible_to_runner_only.up.sql b/backend/migrations/20240326122255_add_visible_to_runner_only.up.sql new file mode 100644 index 0000000000..ba529a6cc0 --- /dev/null +++ b/backend/migrations/20240326122255_add_visible_to_runner_only.up.sql @@ -0,0 +1,3 @@ +-- Add up migration script here +ALTER TABLE script ADD COLUMN visible_to_runner_only BOOLEAN; +ALTER TABLE flow ADD COLUMN visible_to_runner_only BOOLEAN; \ No newline at end of file diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index 4296e2f023..3ba82c641e 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -2582,6 +2582,7 @@ async fn test_flow_lock_all(db: Pool) { priority: None, dedicated_worker: None, timeout: None, + visible_to_runner_only: None, }, draft_only: None, deployment_message: None, @@ -3153,6 +3154,7 @@ async fn run_deployed_relative_imports(db: &Pool, script_content: Stri restart_unless_cancelled: None, deployment_message: None, concurrency_key: None, + visible_to_runner_only: None, }, ).await.unwrap(); diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 99a9bcbe2c..1bff45cd48 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -718,7 +718,6 @@ paths: schema: type: string - # pub use_ssl: Option, # #[serde(rename = "accountName")] # pub account_name: String, @@ -1229,7 +1228,6 @@ paths: schema: type: string - /w/{workspace}/workspaces/change_workspace_id: post: summary: change workspace id @@ -8303,6 +8301,8 @@ components: type: integer delete_after_use: type: boolean + visible_to_runner_only: + type: boolean required: - hash - path @@ -8389,6 +8389,8 @@ components: type: string concurrency_key: type: string + visible_to_runner_only: + type: boolean required: - path - summary @@ -9717,6 +9719,8 @@ components: type: boolean timeout: type: number + visible_to_runner_only: + type: boolean required: - path - edited_by @@ -9741,6 +9745,8 @@ components: type: boolean timeout: type: number + visible_to_runner_only: + type: boolean required: - path diff --git a/backend/windmill-api/src/flows.rs b/backend/windmill-api/src/flows.rs index 9cacc42c67..633c596fd4 100644 --- a/backend/windmill-api/src/flows.rs +++ b/backend/windmill-api/src/flows.rs @@ -319,7 +319,7 @@ async fn create_flow( sqlx::query!( "INSERT INTO flow (workspace_id, path, summary, description, value, edited_by, edited_at, \ - schema, dependency_job, draft_only, tag, dedicated_worker) VALUES ($1, $2, $3, $4, $5, $6, now(), $7::text::json, NULL, $8, $9, $10)", + schema, dependency_job, draft_only, tag, dedicated_worker, visible_to_runner_only) VALUES ($1, $2, $3, $4, $5, $6, now(), $7::text::json, NULL, $8, $9, $10, $11)", w_id, nf.path, nf.summary, @@ -329,7 +329,8 @@ async fn create_flow( nf.schema.and_then(|x| serde_json::to_string(&x.0).ok()), nf.draft_only, nf.tag, - nf.dedicated_worker + nf.dedicated_worker, + nf.visible_to_runner_only.unwrap_or(false), ) .execute(&mut tx) .await?; @@ -485,7 +486,7 @@ async fn update_flow( let old_dep_job = not_found_if_none(old_dep_job, "Flow", flow_path)?; sqlx::query!( "UPDATE flow SET path = $1, summary = $2, description = $3, value = $4, edited_by = $5, \ - edited_at = now(), schema = $6::text::json, dependency_job = NULL, draft_only = NULL, tag = $9, dedicated_worker = $10 + edited_at = now(), schema = $6::text::json, dependency_job = NULL, draft_only = NULL, tag = $9, dedicated_worker = $10, visible_to_runner_only = $11 WHERE path = $7 AND workspace_id = $8", nf.path, nf.summary, @@ -496,7 +497,8 @@ async fn update_flow( flow_path, w_id, nf.tag, - nf.dedicated_worker + nf.dedicated_worker, + nf.visible_to_runner_only.unwrap_or(false), ) .execute(&mut tx) .await?; @@ -669,6 +671,8 @@ pub struct FlowWDraft { pub ws_error_handler_muted: Option, #[serde(skip_serializing_if = "Option::is_none")] pub dedicated_worker: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub visible_to_runner_only: Option, } async fn get_flow_by_path_w_draft( @@ -680,7 +684,7 @@ async fn get_flow_by_path_w_draft( let mut tx = user_db.begin(&authed).await?; let flow_o = sqlx::query_as::<_, FlowWDraft>( - "SELECT flow.path, flow.summary, flow,description, flow.schema, flow.value, flow.extra_perms, flow.draft_only, flow.ws_error_handler_muted, flow.dedicated_worker, draft.value as draft, flow.tag + "SELECT flow.path, flow.summary, flow,description, flow.schema, flow.value, flow.extra_perms, flow.draft_only, flow.ws_error_handler_muted, flow.dedicated_worker, draft.value as draft, flow.tag, flow.visible_to_runner_only FROM flow LEFT JOIN draft ON flow.path = draft.path AND draft.workspace_id = $2 AND draft.typ = 'flow' diff --git a/backend/windmill-api/src/scripts.rs b/backend/windmill-api/src/scripts.rs index 8d5367df2f..c96f4c1338 100644 --- a/backend/windmill-api/src/scripts.rs +++ b/backend/windmill-api/src/scripts.rs @@ -88,6 +88,8 @@ pub struct ScriptWDraft { pub timeout: Option, #[serde(skip_serializing_if = "Option::is_none")] pub concurrency_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub visible_to_runner_only: Option, } pub fn global_service() -> Router { @@ -472,8 +474,8 @@ async fn create_script( content, created_by, schema, is_template, extra_perms, lock, language, kind, tag, \ draft_only, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, \ dedicated_worker, ws_error_handler_muted, priority, restart_unless_cancelled, \ - delete_after_use, timeout, concurrency_key) \ - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::text::json, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27)", + delete_after_use, timeout, concurrency_key, visible_to_runner_only) \ + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::text::json, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28)", &w_id, &hash.0, ns.path, @@ -501,6 +503,7 @@ async fn create_script( ns.delete_after_use, ns.timeout, ns.concurrency_key, + ns.visible_to_runner_only, ) .execute(&mut tx) .await?; @@ -720,7 +723,7 @@ async fn get_script_by_path_w_draft( let mut tx = user_db.begin(&authed).await?; let script_o = sqlx::query_as::<_, ScriptWDraft>( - "SELECT hash, script.path, summary, description, content, language, kind, tag, schema, draft_only, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, ws_error_handler_muted, draft.value as draft, dedicated_worker, priority, restart_unless_cancelled, delete_after_use, timeout, concurrency_key FROM script LEFT JOIN draft ON + "SELECT hash, script.path, summary, description, content, language, kind, tag, schema, draft_only, envs, concurrent_limit, concurrency_time_window_s, cache_ttl, ws_error_handler_muted, draft.value as draft, dedicated_worker, priority, restart_unless_cancelled, delete_after_use, timeout, concurrency_key, visible_to_runner_only FROM script LEFT JOIN draft ON script.path = draft.path AND script.workspace_id = draft.workspace_id AND draft.typ = 'script' WHERE script.path = $1 AND script.workspace_id = $2 \ AND script.created_at = (SELECT max(created_at) FROM script WHERE path = $1 AND \ diff --git a/backend/windmill-api/src/workspaces.rs b/backend/windmill-api/src/workspaces.rs index ca32323b50..e6e47c51d0 100644 --- a/backend/windmill-api/src/workspaces.rs +++ b/backend/windmill-api/src/workspaces.rs @@ -2157,6 +2157,8 @@ struct ScriptMetadata { pub delete_after_use: Option, #[serde(skip_serializing_if = "Option::is_none")] pub restart_unless_cancelled: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub visible_to_runner_only: Option, } pub fn is_none_or_false(val: &Option) -> bool { @@ -2432,6 +2434,7 @@ async fn tarball_workspace( timeout: script.timeout, delete_after_use: script.delete_after_use, restart_unless_cancelled: script.restart_unless_cancelled, + visible_to_runner_only: script.visible_to_runner_only, }; let metadata_str = serde_json::to_string_pretty(&metadata).unwrap(); archive diff --git a/backend/windmill-common/src/flows.rs b/backend/windmill-common/src/flows.rs index 6d30fb5cc1..c9b990d280 100644 --- a/backend/windmill-common/src/flows.rs +++ b/backend/windmill-common/src/flows.rs @@ -44,6 +44,8 @@ pub struct Flow { pub ws_error_handler_muted: Option, #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub visible_to_runner_only: Option, } #[derive(Serialize, sqlx::FromRow)] @@ -77,6 +79,7 @@ pub struct NewFlow { pub dedicated_worker: Option, pub timeout: Option, pub deployment_message: Option, + pub visible_to_runner_only: Option, } #[derive(Deserialize, Serialize, Debug, Clone, Default)] diff --git a/backend/windmill-common/src/scripts.rs b/backend/windmill-common/src/scripts.rs index d201a88c7b..05aa5ca032 100644 --- a/backend/windmill-common/src/scripts.rs +++ b/backend/windmill-common/src/scripts.rs @@ -22,8 +22,7 @@ use serde_json::to_string_pretty; use crate::utils::StripPath; -#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Hash, Eq)] -#[derive(sqlx::Type)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Hash, Eq, sqlx::Type)] #[sqlx(type_name = "SCRIPT_LANG", rename_all = "lowercase")] #[serde(rename_all(serialize = "lowercase", deserialize = "lowercase"))] pub enum ScriptLang { @@ -62,13 +61,11 @@ impl ScriptLang { } } -#[derive(PartialEq, Debug, Hash, Clone, Copy)] -#[derive(sqlx::Type)] +#[derive(PartialEq, Debug, Hash, Clone, Copy, sqlx::Type)] #[sqlx(transparent)] pub struct ScriptHash(pub i64); -#[derive(PartialEq)] -#[derive(sqlx::Type)] +#[derive(PartialEq, sqlx::Type)] #[sqlx(transparent, no_pg_array)] pub struct ScriptHashes(pub Vec); @@ -109,8 +106,7 @@ impl Serialize for ScriptHashes { } } -#[derive(Serialize, Deserialize, Debug, Hash)] -#[derive(sqlx::Type)] +#[derive(Serialize, Deserialize, Debug, Hash, sqlx::Type)] #[sqlx(type_name = "SCRIPT_KIND", rename_all = "lowercase")] #[serde(rename_all = "lowercase")] pub enum ScriptKind { @@ -132,8 +128,7 @@ impl Display for ScriptKind { } } -#[derive(Serialize)] -#[derive(sqlx::FromRow)] +#[derive(Serialize, sqlx::FromRow)] pub struct Script { pub workspace_id: String, pub hash: ScriptHash, @@ -178,10 +173,11 @@ pub struct Script { pub restart_unless_cancelled: Option, #[serde(skip_serializing_if = "Option::is_none")] pub concurrency_key: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub visible_to_runner_only: Option, } -#[derive(Serialize)] -#[derive(sqlx::FromRow)] +#[derive(Serialize, sqlx::FromRow)] pub struct ListableScript { pub hash: ScriptHash, pub path: String, @@ -212,8 +208,7 @@ pub struct ScriptHistoryUpdate { pub deployment_msg: Option, } -#[derive(Serialize, Deserialize, Debug)] -#[derive(sqlx::Type)] +#[derive(Serialize, Deserialize, Debug, sqlx::Type)] #[sqlx(transparent)] #[serde(transparent)] pub struct Schema(pub serde_json::Value); @@ -255,6 +250,7 @@ pub struct NewScript { pub deployment_message: Option, #[serde(skip_serializing_if = "Option::is_none")] pub concurrency_key: Option, + pub visible_to_runner_only: Option, } fn lock_deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/cli/script.ts b/cli/script.ts index 51333121e5..381fc63bcc 100644 --- a/cli/script.ts +++ b/cli/script.ts @@ -164,7 +164,9 @@ export async function handleFile( remote.concurrency_time_window_s && typed.concurrent_limit == remote.concurrent_limit && Boolean(typed.restart_unless_cancelled) == - Boolean(remote.restart_unless_cancelled)) + Boolean(remote.restart_unless_cancelled) && + Boolean(typed.visible_to_runner_only) == + Boolean(remote.visible_to_runner_only)) ) { log.info(colors.green(`Script ${remotePath} is up to date`)); return true; @@ -194,6 +196,7 @@ export async function handleFile( concurrent_limit: typed?.concurrent_limit, deployment_message: message, restart_unless_cancelled: typed?.restart_unless_cancelled, + visible_to_runner_only: typed?.visible_to_runner_only, }, }); } else { @@ -221,6 +224,7 @@ export async function handleFile( concurrent_limit: typed?.concurrent_limit, deployment_message: message, restart_unless_cancelled: typed?.restart_unless_cancelled, + visible_to_runner_only: typed?.visible_to_runner_only, }, }); } diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index 9a27d2ba01..6410c62b63 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -157,7 +157,8 @@ schema: flow.schema, tag: flow.tag, draft_only: true, - ws_error_handler_muted: flow.ws_error_handler_muted + ws_error_handler_muted: flow.ws_error_handler_muted, + visible_to_runner_only: flow.visible_to_runner_only } }) } @@ -235,7 +236,8 @@ schema: flow.schema, ws_error_handler_muted: flow.ws_error_handler_muted, tag: flow.tag, - dedicated_worker: flow.dedicated_worker + dedicated_worker: flow.dedicated_worker, + visible_to_runner_only: flow.visible_to_runner_only } }) if (enabled) { @@ -297,7 +299,8 @@ schema: flow.schema, tag: flow.tag, dedicated_worker: flow.dedicated_worker, - ws_error_handler_muted: flow.ws_error_handler_muted + ws_error_handler_muted: flow.ws_error_handler_muted, + visible_to_runner_only: flow.visible_to_runner_only } }) } diff --git a/frontend/src/lib/components/MoveDrawer.svelte b/frontend/src/lib/components/MoveDrawer.svelte index 7b5fdd5d7b..96b9111270 100644 --- a/frontend/src/lib/components/MoveDrawer.svelte +++ b/frontend/src/lib/components/MoveDrawer.svelte @@ -53,7 +53,8 @@ schema: flow.schema, tag: flow.tag, dedicated_worker: flow.dedicated_worker, - ws_error_handler_muted: flow.ws_error_handler_muted + ws_error_handler_muted: flow.ws_error_handler_muted, + visible_to_runner_only: flow.visible_to_runner_only } }) } else if (kind == 'script') { diff --git a/frontend/src/lib/components/RunForm.svelte b/frontend/src/lib/components/RunForm.svelte index a49f9c8b2c..39ee97f0a1 100644 --- a/frontend/src/lib/components/RunForm.svelte +++ b/frontend/src/lib/components/RunForm.svelte @@ -49,7 +49,7 @@ export let viewKeybinding = false export let scheduledForStr: string | undefined - export let invisible_to_owner: false | undefined + export let invisible_to_owner: boolean | undefined export let overrideTag: string | undefined export let args: Record = {} diff --git a/frontend/src/lib/components/RunFormAdvancedPopup.svelte b/frontend/src/lib/components/RunFormAdvancedPopup.svelte index 99f8e36abd..0fbb023bad 100644 --- a/frontend/src/lib/components/RunFormAdvancedPopup.svelte +++ b/frontend/src/lib/components/RunFormAdvancedPopup.svelte @@ -25,7 +25,7 @@ | undefined export let scheduledForStr: string | undefined - export let invisible_to_owner: false | undefined + export let invisible_to_owner: boolean | undefined export let overrideTag: string | undefined loadWorkerGroups() diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 0e8f4bda83..9fd3016e8a 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -241,7 +241,8 @@ restart_unless_cancelled: script.restart_unless_cancelled, delete_after_use: script.delete_after_use, timeout: script.timeout, - concurrency_key: emptyString(script.concurrency_key) ? undefined : script.concurrency_key + concurrency_key: emptyString(script.concurrency_key) ? undefined : script.concurrency_key, + visible_to_runner_only: script.visible_to_runner_only } }) @@ -365,7 +366,8 @@ timeout: script.timeout, concurrency_key: emptyString(script.concurrency_key) ? undefined - : script.concurrency_key + : script.concurrency_key, + visible_to_runner_only: script.visible_to_runner_only } }) } @@ -875,6 +877,31 @@ {/if} +
+ + + When this option is enabled, manual executions of this script are invisible to + users other than the user running it, including the owner(s). This setting can + be overridden when this script is run manually from the advanced menu. + + +
+ { + if (script.visible_to_runner_only) { + script.visible_to_runner_only = undefined + } else { + script.visible_to_runner_only = true + } + }} + options={{ + right: 'Make runs invisible to others' + }} + /> +
+
{#if !isCloudHosted()}
diff --git a/frontend/src/lib/components/flows/content/FlowSettings.svelte b/frontend/src/lib/components/flows/content/FlowSettings.svelte index d6e98a78af..64c4bf5a84 100644 --- a/frontend/src/lib/components/flows/content/FlowSettings.svelte +++ b/frontend/src/lib/components/flows/content/FlowSettings.svelte @@ -161,6 +161,23 @@ + { + if ($flowStore.visible_to_runner_only) { + $flowStore.visible_to_runner_only = undefined + } else { + $flowStore.visible_to_runner_only = true + } + }} + options={{ + right: 'Make runs invisible to others', + rightTooltip: + 'When this option is enabled, manual executions of this script are invisible to users other than the user running it, including the owner(s). This setting can be overridden when this script is run manually from the advanced menu.' + }} + /> +
pathStore: Writable flowStore: Writable< - OpenFlow & { tag?: string; ws_error_handler_muted?: boolean; dedicated_worker?: boolean } + OpenFlow & { + tag?: string + ws_error_handler_muted?: boolean + dedicated_worker?: boolean + visible_to_runner_only?: boolean + } > flowStateStore: Writable testStepStore: Writable> diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts index 158ce70108..19852e8e77 100644 --- a/frontend/src/lib/components/flows/utils.ts +++ b/frontend/src/lib/components/flows/utils.ts @@ -70,7 +70,12 @@ export function evalValue( export function cleanInputs( flow: OpenFlow | any -): OpenFlow & { tag?: string; ws_error_handler_muted?: boolean; dedicated_worker?: boolean } { +): OpenFlow & { + tag?: string + ws_error_handler_muted?: boolean + dedicated_worker?: boolean + visible_to_runner_only?: boolean +} { const newFlow: Flow = JSON.parse(JSON.stringify(flow)) newFlow.value.modules.forEach((mod) => { if (mod.value.type == 'rawscript' || mod.value.type == 'script') { diff --git a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte index 1fb17133a0..b29af0b83a 100644 --- a/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/get/[...path]/+page.svelte @@ -52,7 +52,7 @@ let deploymentInProgress = false let scheduledForStr: string | undefined = undefined - let invisible_to_owner: false | undefined = undefined + let invisible_to_owner: boolean | undefined = undefined let overrideTag: string | undefined = undefined $: cliCommand = `wmill flow run ${flow?.path} -d '${JSON.stringify(args)}'` @@ -81,6 +81,9 @@ let schedule: Schedule | undefined = undefined async function loadFlow(): Promise { flow = await FlowService.getFlowByPath({ workspace: $workspaceStore!, path }) + if (!flow.path.startsWith(`u/${$userStore?.username}`) && flow.path.split('/').length > 2) { + invisible_to_owner = flow.visible_to_runner_only + } can_write = canWrite(flow.path, flow.extra_perms!, $userStore) try { schedule = await loadFlowSchedule(path, $workspaceStore!) diff --git a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte index bdb72e23f9..dbecea6f90 100644 --- a/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/run/[...run]/+page.svelte @@ -571,10 +571,13 @@ Tag: {job.tag}
{/if} - {#if !job.visible_to_owner}only visible to you The option to hide this run from the owner of this script or flow was activatedonly visible to you The option to hide this run from the owner of this script or flow was activated + {/if} diff --git a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte index 74e6023216..86e5d3abe0 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/get/[...hash]/+page.svelte @@ -77,7 +77,7 @@ let runForm: RunForm let scheduledForStr: string | undefined = undefined - let invisible_to_owner: false | undefined = undefined + let invisible_to_owner: boolean | undefined = undefined let overrideTag: string | undefined = undefined $: cliCommand = `wmill script run ${script?.path} -d '${JSON.stringify(args)}'` @@ -172,6 +172,9 @@ if (deploymentInProgress) { intervalId = setInterval(syncer, 500) } + if (!script.path.startsWith(`u/${$userStore?.username}`) && script.path.split('/').length > 2) { + invisible_to_owner = script.visible_to_runner_only + } } onDestroy(() => {