mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 08:01:25 +00:00
add visible_to_owner
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- Add down migration script here
|
||||
ALTER TABLE queue DROP COLUMN visible_to_owner;
|
||||
ALTER TABLE completed_job DROP COLUMN visible_to_owner;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Add up migration script here
|
||||
ALTER TABLE queue ADD COLUMN visible_to_owner BOOLEAN DEFAULT true;
|
||||
ALTER TABLE completed_job ADD COLUMN visible_to_owner BOOLEAN DEFAULT true;
|
||||
@@ -831,6 +831,7 @@ impl RunJob {
|
||||
/* is_flow_step */ false,
|
||||
/* running */ false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.expect("push has to succeed");
|
||||
|
||||
@@ -2175,7 +2175,11 @@ paths:
|
||||
schema:
|
||||
type: integer
|
||||
- $ref: "#/components/parameters/ParentJob"
|
||||
|
||||
- name: invisible_to_owner
|
||||
description: make the run invisible to the the script owner (default false)
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
requestBody:
|
||||
description: script args
|
||||
required: true
|
||||
@@ -2653,6 +2657,11 @@ paths:
|
||||
type: integer
|
||||
- $ref: "#/components/parameters/ParentJob"
|
||||
- $ref: "#/components/parameters/IncludeHeader"
|
||||
- name: invisible_to_owner
|
||||
description: make the run invisible to the the flow owner (default false)
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
|
||||
requestBody:
|
||||
description: flow args
|
||||
@@ -2693,7 +2702,11 @@ paths:
|
||||
type: integer
|
||||
- $ref: "#/components/parameters/ParentJob"
|
||||
- $ref: "#/components/parameters/IncludeHeader"
|
||||
|
||||
- name: invisible_to_owner
|
||||
description: make the run invisible to the the script owner (default false)
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
requestBody:
|
||||
description: Partially filled args
|
||||
required: true
|
||||
@@ -2720,7 +2733,11 @@ paths:
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- $ref: "#/components/parameters/IncludeHeader"
|
||||
|
||||
- name: invisible_to_owner
|
||||
description: make the run invisible to the the script owner (default false)
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
requestBody:
|
||||
description: preview
|
||||
required: true
|
||||
@@ -2747,6 +2764,11 @@ paths:
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
- $ref: "#/components/parameters/IncludeHeader"
|
||||
- name: invisible_to_owner
|
||||
description: make the run invisible to the the script owner (default false)
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
|
||||
requestBody:
|
||||
description: preview
|
||||
@@ -4215,6 +4237,8 @@ components:
|
||||
type: boolean
|
||||
email:
|
||||
type: string
|
||||
visible_to_owner:
|
||||
type: boolean
|
||||
required:
|
||||
- id
|
||||
- created_by
|
||||
@@ -4228,6 +4252,7 @@ components:
|
||||
- is_flow_step
|
||||
- is_skipped
|
||||
- email
|
||||
- visible_to_owner
|
||||
|
||||
Job:
|
||||
allOf:
|
||||
|
||||
@@ -535,6 +535,7 @@ async fn execute_component(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ async fn create_flow(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
sqlx::query!(
|
||||
@@ -302,6 +303,7 @@ async fn update_flow(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
sqlx::query!(
|
||||
|
||||
@@ -239,6 +239,7 @@ pub struct CompletedJob {
|
||||
pub language: Option<ScriptLang>,
|
||||
pub is_skipped: bool,
|
||||
pub email: String,
|
||||
pub visible_to_owner: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
@@ -247,6 +248,7 @@ pub struct RunJobQuery {
|
||||
scheduled_in_secs: Option<i64>,
|
||||
parent_job: Option<Uuid>,
|
||||
include_header: Option<String>,
|
||||
invisible_to_owner: Option<bool>,
|
||||
}
|
||||
|
||||
impl RunJobQuery {
|
||||
@@ -402,6 +404,7 @@ async fn list_jobs(
|
||||
"language",
|
||||
"false as is_skipped",
|
||||
"email",
|
||||
"visible_to_owner",
|
||||
],
|
||||
);
|
||||
let sqlc = list_completed_jobs_query(
|
||||
@@ -435,6 +438,7 @@ async fn list_jobs(
|
||||
"language",
|
||||
"is_skipped",
|
||||
"email",
|
||||
"visible_to_owner",
|
||||
],
|
||||
);
|
||||
let sql = format!(
|
||||
@@ -811,6 +815,7 @@ struct UnifiedJob {
|
||||
language: Option<ScriptLang>,
|
||||
is_skipped: bool,
|
||||
email: String,
|
||||
visible_to_owner: bool,
|
||||
}
|
||||
|
||||
impl From<UnifiedJob> for Job {
|
||||
@@ -844,6 +849,7 @@ impl From<UnifiedJob> for Job {
|
||||
language: uj.language,
|
||||
is_skipped: uj.is_skipped,
|
||||
email: uj.email,
|
||||
visible_to_owner: uj.visible_to_owner,
|
||||
}),
|
||||
"QueuedJob" => Job::QueuedJob(QueuedJob {
|
||||
workspace_id: uj.workspace_id,
|
||||
@@ -874,6 +880,7 @@ impl From<UnifiedJob> for Job {
|
||||
same_worker: false,
|
||||
pre_run_error: None,
|
||||
email: uj.email,
|
||||
visible_to_owner: uj.visible_to_owner,
|
||||
}),
|
||||
t => panic!("job type {} not valid", t),
|
||||
}
|
||||
@@ -971,6 +978,7 @@ pub async fn run_flow_by_path(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
!run_query.invisible_to_owner.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1005,6 +1013,7 @@ pub async fn run_job_by_path(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
!run_query.invisible_to_owner.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1072,6 +1081,7 @@ pub async fn run_wait_result_job_by_path(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
!run_query.invisible_to_owner.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1107,6 +1117,7 @@ pub async fn run_wait_result_job_by_hash(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
!run_query.invisible_to_owner.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1160,6 +1171,7 @@ async fn run_preview_job(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1192,6 +1204,7 @@ async fn run_preview_flow_job(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1226,6 +1239,7 @@ pub async fn run_job_by_hash(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
!run_query.invisible_to_owner.unwrap_or(false),
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
@@ -1398,6 +1412,7 @@ async fn list_completed_jobs(
|
||||
"language",
|
||||
"is_skipped",
|
||||
"email",
|
||||
"visible_to_owner",
|
||||
],
|
||||
)
|
||||
.sql()?;
|
||||
|
||||
@@ -806,6 +806,7 @@ async fn slack_command(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
|
||||
@@ -343,6 +343,7 @@ async fn create_script(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
tx
|
||||
|
||||
@@ -254,6 +254,7 @@ pub async fn push<'c>(
|
||||
is_flow_step: bool,
|
||||
mut same_worker: bool,
|
||||
pre_run_error: Option<&windmill_common::error::Error>,
|
||||
visible_to_owner: bool,
|
||||
) -> Result<(Uuid, Transaction<'c, Postgres>), Error> {
|
||||
let scheduled_for = scheduled_for_o.unwrap_or_else(chrono::Utc::now);
|
||||
let args_json = serde_json::Value::Object(args);
|
||||
@@ -476,8 +477,8 @@ pub async fn push<'c>(
|
||||
"INSERT INTO queue
|
||||
(workspace_id, id, running, parent_job, created_by, permissioned_as, scheduled_for,
|
||||
script_hash, script_path, raw_code, raw_lock, args, job_kind, schedule_path, raw_flow, \
|
||||
flow_status, is_flow_step, language, started_at, same_worker, pre_run_error, email)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, CASE WHEN $3 THEN now() END, $19, $20, $21) \
|
||||
flow_status, is_flow_step, language, started_at, same_worker, pre_run_error, email, visible_to_owner)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, CASE WHEN $3 THEN now() END, $19, $20, $21, $22) \
|
||||
RETURNING id",
|
||||
workspace_id,
|
||||
job_id,
|
||||
@@ -499,7 +500,8 @@ pub async fn push<'c>(
|
||||
language: ScriptLang,
|
||||
same_worker,
|
||||
pre_run_error.map(|e| e.to_string()),
|
||||
email
|
||||
email,
|
||||
visible_to_owner
|
||||
)
|
||||
.fetch_one(&mut tx)
|
||||
.await
|
||||
@@ -595,6 +597,7 @@ pub struct QueuedJob {
|
||||
pub same_worker: bool,
|
||||
pub pre_run_error: Option<String>,
|
||||
pub email: String,
|
||||
pub visible_to_owner: bool,
|
||||
}
|
||||
|
||||
impl QueuedJob {
|
||||
|
||||
@@ -116,6 +116,7 @@ pub async fn push_scheduled_job<'c>(
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
sqlx::query!(
|
||||
|
||||
@@ -127,9 +127,11 @@ pub async fn add_completed_job(
|
||||
, is_flow_step
|
||||
, is_skipped
|
||||
, language
|
||||
, email )
|
||||
, email
|
||||
, visible_to_owner
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, COALESCE($26, EXTRACT(milliseconds FROM (now() - $6))), $7, $8, $9,\
|
||||
$10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $27)
|
||||
$10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $27, $28)
|
||||
ON CONFLICT (id) DO UPDATE SET success = $7, result = $11, logs = concat(cj.logs, $12)",
|
||||
queued_job.workspace_id,
|
||||
queued_job.id,
|
||||
@@ -157,7 +159,8 @@ pub async fn add_completed_job(
|
||||
skipped,
|
||||
queued_job.language: ScriptLang,
|
||||
duration: Option<i64>,
|
||||
queued_job.email
|
||||
queued_job.email,
|
||||
queued_job.visible_to_owner
|
||||
)
|
||||
.execute(&mut tx)
|
||||
.await
|
||||
|
||||
@@ -2215,7 +2215,7 @@ async fn handle_child(
|
||||
r#"
|
||||
UPDATE queue
|
||||
SET canceled = true
|
||||
, canceled_by = 'timeout',
|
||||
, canceled_by = 'timeout'
|
||||
, canceled_reason = $1
|
||||
WHERE id = $2
|
||||
r"#,
|
||||
|
||||
@@ -1241,6 +1241,7 @@ async fn push_next_flow_job(
|
||||
true,
|
||||
continue_on_same_worker,
|
||||
err,
|
||||
flow_job.visible_to_owner,
|
||||
)
|
||||
.await?;
|
||||
tx = inner_tx;
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
}
|
||||
|
||||
let ownerFilter: string | undefined = undefined
|
||||
$: if ($workspaceStore) {
|
||||
ownerFilter = undefined
|
||||
}
|
||||
$: prefilteredItems = ownerFilter ? items?.filter((x) => x.path.startsWith(ownerFilter!)) : items
|
||||
|
||||
$: owners = Array.from(
|
||||
|
||||
@@ -129,6 +129,10 @@
|
||||
|
||||
let ownerFilter: string | undefined = undefined
|
||||
|
||||
$: if ($workspaceStore) {
|
||||
ownerFilter = undefined
|
||||
}
|
||||
|
||||
$: {
|
||||
if (($userStore || $superadmin) && $workspaceStore) {
|
||||
loadScripts()
|
||||
|
||||
@@ -89,6 +89,11 @@
|
||||
|
||||
let filter = ''
|
||||
let ownerFilter: string | undefined = undefined
|
||||
|
||||
$: if ($workspaceStore) {
|
||||
ownerFilter = undefined
|
||||
}
|
||||
|
||||
let typeFilter: string | undefined = undefined
|
||||
|
||||
$: preFilteredItemsOwners =
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
|
||||
let ownerFilter: string | undefined = undefined
|
||||
|
||||
$: if ($workspaceStore) {
|
||||
ownerFilter = undefined
|
||||
}
|
||||
|
||||
$: preFilteredItems =
|
||||
ownerFilter == undefined
|
||||
? variables
|
||||
|
||||
Reference in New Issue
Block a user