-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): unify all triggers UX and simplify flow settings (#4259)
* feat(frontend): added list of triggers in the flow graph * feat(frontend): added list of triggers in the flow graph * feat(frontend): clean up * feat(frontend): improve UX * feat(frontend): triggers * feat(frontend): triggers * feat(frontend): done * feat(frontend): fix trigger when position when a preprocessor is presetn * Glm/rework flow settings v2 (#4497) * fat(frontend): simplify flow settings menu * improve scroll * changing mute toggle * Add advanced settings badge * Add nord theme colors * Add bage for advanced options * fix minor issue * fix minor issue * Add triggers menu to flow settings * Add quick trigger access * remove triggers in flow settings * fix minor issue * Move triggers settings to flow right panel * polishing * fix unset store * remove save up to for triggers * fix padding * reset default tag color * remove custom select component * revert path change * revert section modif * Revert unused feature --------- Co-authored-by: Guilhem <[email protected]> * Connect top bar cron to schedules settings * Turn copilot into node * fix copilot placement * remove useless import * fix center copilot * fix binding * remove copilot on top of preprocessor * render copilot node on condition * quickfix * remove copilot node * fix minor issues * fix route count update * fix schedule sync * harmonize colors * fix alignment and add edges * recenter node summary * fix schedules sync * Add id title * all * all * all * iteration * all * all * done * fix * more fixes --------- Co-authored-by: Guilhem <[email protected]> Co-authored-by: Guilhem <[email protected]> Co-authored-by: Ruben Fiszel <[email protected]> Co-authored-by: Ruben Fiszel <[email protected]>
- Loading branch information
1 parent
f38b3d1
commit 1ec8d63
Showing
75 changed files
with
2,438 additions
and
1,400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
use axum::Json; | ||
use serde::{Deserialize, Serialize}; | ||
use sqlx::FromRow; | ||
use windmill_common::error::JsonResult; | ||
|
||
use crate::db::DB; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct TriggerPrimarySchedule { | ||
schedule: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct TriggersCount { | ||
primary_schedule: Option<TriggerPrimarySchedule>, | ||
schedule_count: i64, | ||
http_routes_count: i64, | ||
webhook_count: i64, | ||
email_count: i64, | ||
} | ||
pub(crate) async fn get_triggers_count_internal( | ||
db: &DB, | ||
w_id: &str, | ||
path: &str, | ||
is_flow: bool, | ||
) -> JsonResult<TriggersCount> { | ||
let primary_schedule = sqlx::query_scalar!( | ||
"SELECT schedule FROM schedule WHERE path = $1 AND script_path = $1 AND is_flow = $2 AND workspace_id = $3", | ||
path, | ||
is_flow, | ||
w_id | ||
) | ||
.fetch_optional(db) | ||
.await?; | ||
|
||
let schedule_count = sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM schedule WHERE script_path = $1 AND is_flow = $2 AND workspace_id = $3", | ||
path, | ||
is_flow, | ||
w_id | ||
) | ||
.fetch_one(db) | ||
.await? | ||
.unwrap_or(0); | ||
|
||
let http_routes_count = sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM http_trigger WHERE script_path = $1 AND is_flow = $2 AND workspace_id = $3", | ||
path, | ||
is_flow, | ||
w_id | ||
) | ||
.fetch_one(db) | ||
.await? | ||
.unwrap_or(0); | ||
|
||
let webhook_count = (if is_flow { | ||
sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM token WHERE label LIKE 'webhook-%' AND workspace_id = $1 AND scopes @> ARRAY['run:flow/' || $2]::text[]", | ||
w_id, | ||
path, | ||
) | ||
|
||
} else { | ||
sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM token WHERE label LIKE 'webhook-%' AND workspace_id = $1 AND scopes @> ARRAY['run:' || $2]::text[]", | ||
w_id, | ||
path, | ||
) | ||
}).fetch_one(db) | ||
.await? | ||
.unwrap_or(0); | ||
|
||
let email_count = (if is_flow { | ||
sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM token WHERE label LIKE 'email-%' AND workspace_id = $1 AND scopes @> ARRAY['run:flow/' || $2]::text[]", | ||
w_id, | ||
path, | ||
) | ||
|
||
} else { | ||
sqlx::query_scalar!( | ||
"SELECT COUNT(*) FROM token WHERE label LIKE 'email-%' AND workspace_id = $1 AND scopes @> ARRAY['run:script/' || $2]::text[]", | ||
w_id, | ||
path, | ||
) | ||
}).fetch_one(db) | ||
.await? | ||
.unwrap_or(0); | ||
|
||
Ok(Json(TriggersCount { | ||
primary_schedule: primary_schedule.map(|s| TriggerPrimarySchedule { schedule: s }), | ||
schedule_count, | ||
http_routes_count, | ||
webhook_count, | ||
email_count, | ||
})) | ||
} | ||
|
||
#[derive(FromRow, Serialize)] | ||
pub struct TruncatedTokenWithEmail { | ||
pub label: Option<String>, | ||
pub token_prefix: Option<String>, | ||
pub expiration: Option<chrono::DateTime<chrono::Utc>>, | ||
pub created_at: chrono::DateTime<chrono::Utc>, | ||
pub last_used_at: chrono::DateTime<chrono::Utc>, | ||
pub scopes: Option<Vec<String>>, | ||
pub email: Option<String>, | ||
} | ||
|
||
pub async fn list_tokens_internal( | ||
db: &DB, | ||
w_id: &str, | ||
path: &str, | ||
is_flow: bool, | ||
) -> JsonResult<Vec<TruncatedTokenWithEmail>> { | ||
let tokens = if is_flow { | ||
sqlx::query_as!( | ||
TruncatedTokenWithEmail, | ||
"SELECT label, concat(substring(token for 10)) as token_prefix, expiration, created_at, last_used_at, scopes, email FROM token WHERE workspace_id = $1 AND scopes @> ARRAY['run:flow/' || $2]::text[]", | ||
w_id, path).fetch_all(db) | ||
.await? | ||
} else { | ||
sqlx::query_as!( | ||
TruncatedTokenWithEmail, | ||
"SELECT label, concat(substring(token for 10)) as token_prefix, expiration, created_at, last_used_at, scopes, email FROM token WHERE workspace_id = $1 AND scopes @> ARRAY['run:script/' || $2]::text[]", | ||
w_id, path) | ||
.fetch_all(db) | ||
.await? | ||
}; | ||
Ok(Json(tokens)) | ||
} |
Oops, something went wrong.