Skip to content

Commit

Permalink
feat: Improve Slack schedule error handler and default to it
Browse files Browse the repository at this point in the history
  • Loading branch information
gbouv committed Oct 12, 2023
1 parent d51fc57 commit 2679187
Show file tree
Hide file tree
Showing 9 changed files with 1,667 additions and 701 deletions.
Empty file modified backend/windmill-api-client/bundle.sh
100644 → 100755
Empty file.
1,980 changes: 1,360 additions & 620 deletions backend/windmill-api/openapi-deref.yaml

Large diffs are not rendered by default.

89 changes: 51 additions & 38 deletions backend/windmill-api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,38 @@ paths:
schema:
type: string

/w/{workspace}/workspaces/run_slack_message_test_job:
post:
summary: run a job that sends a message to Slack
operationId: runSlackMessageTestJob
tags:
- workspace
parameters:
- $ref: "#/components/parameters/WorkspaceId"
requestBody:
description: path to hub script to run and its corresponding args
required: true
content:
application/json:
schema:
type: object
properties:
hub_script_path:
type: string
job_args:
type: object

responses:
"200":
description: status
content:
text/json:
schema:
type: object
properties:
job_uuid:
type: string

/w/{workspace}/workspaces/edit_deploy_to:
post:
summary: edit deploy to
Expand Down Expand Up @@ -2056,8 +2088,7 @@ paths:

/w/{workspace}/resources/get_value_interpolated/{path}:
get:
summary:
get resource interpolated (variables and resources are fully unrolled)
summary: get resource interpolated (variables and resources are fully unrolled)
operationId: getResourceValueInterpolated
tags:
- resource
Expand Down Expand Up @@ -2636,8 +2667,7 @@ paths:
schema:
type: string
- name: first_parent_hash
description:
mask to filter scripts whom first direct parent has exact hash
description: mask to filter scripts whom first direct parent has exact hash
in: query
schema:
type: string
Expand Down Expand Up @@ -2805,8 +2835,7 @@ paths:

/workers/custom_tags:
get:
summary:
get all instance custom tags (tags are used to dispatch jobs to
summary: get all instance custom tags (tags are used to dispatch jobs to
different worker groups)
operationId: getCustomTags
tags:
Expand Down Expand Up @@ -2857,8 +2886,7 @@ paths:

/w/{workspace}/scripts/delete/h/{hash}:
post:
summary:
delete script by hash (erase content but keep hash, require admin)
summary: delete script by hash (erase content but keep hash, require admin)
operationId: deleteScriptByHash
tags:
- script
Expand Down Expand Up @@ -3050,16 +3078,14 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description:
schedule the script to execute in the number of seconds starting now
description: schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- name: invisible_to_owner
description:
make the run invisible to the the script owner (default false)
description: make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
Expand Down Expand Up @@ -4005,17 +4031,15 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description:
schedule the script to execute in the number of seconds starting now
description: schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description:
make the run invisible to the the flow owner (default false)
description: make the run invisible to the the flow owner (default false)
in: query
schema:
type: boolean
Expand Down Expand Up @@ -4053,17 +4077,15 @@ paths:
type: string
format: date-time
- name: scheduled_in_secs
description:
schedule the script to execute in the number of seconds starting now
description: schedule the script to execute in the number of seconds starting now
in: query
schema:
type: integer
- $ref: "#/components/parameters/ParentJob"
- $ref: "#/components/parameters/NewJobId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description:
make the run invisible to the the script owner (default false)
description: make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
Expand Down Expand Up @@ -4094,8 +4116,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description:
make the run invisible to the the script owner (default false)
description: make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
Expand Down Expand Up @@ -4128,8 +4149,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/IncludeHeader"
- name: invisible_to_owner
description:
make the run invisible to the the script owner (default false)
description: make the run invisible to the the script owner (default false)
in: query
schema:
type: boolean
Expand Down Expand Up @@ -4344,8 +4364,7 @@ paths:
- job
responses:
"200":
description:
the timestamp of the db that can be used to compute the drift
description: the timestamp of the db that can be used to compute the drift
content:
application/json:
schema:
Expand Down Expand Up @@ -4578,8 +4597,7 @@ paths:

/w/{workspace}/jobs/resume_urls/{id}/{resume_id}:
get:
summary:
get resume urls given a job_id, resume_id and a nonce to resume a flow
summary: get resume urls given a job_id, resume_id and a nonce to resume a flow
operationId: getResumeUrls
tags:
- job
Expand Down Expand Up @@ -5092,8 +5110,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- name: only_member_of
in: query
description:
only list the groups the user is member of (default false)
description: only list the groups the user is member of (default false)
schema:
type: boolean
responses:
Expand Down Expand Up @@ -5281,8 +5298,7 @@ paths:
- $ref: "#/components/parameters/WorkspaceId"
- name: only_member_of
in: query
description:
only list the folders the user is member of (default false)
description: only list the folders the user is member of (default false)
schema:
type: boolean
responses:
Expand Down Expand Up @@ -6000,8 +6016,7 @@ components:
type: integer
PerPage:
name: per_page
description:
number of items to return for a given page (default 30, max 100)
description: number of items to return for a given page (default 30, max 100)
in: query
schema:
type: integer
Expand Down Expand Up @@ -6135,8 +6150,7 @@ components:
type: boolean
ArgsFilter:
name: args
description:
filter on jobs containing those args as a json subset (@> in postgres)
description: filter on jobs containing those args as a json subset (@> in postgres)
in: query
schema:
type: string
Expand All @@ -6148,8 +6162,7 @@ components:
type: string
ResultFilter:
name: result
description:
filter on jobs containing those result as a json subset (@> in postgres)
description: filter on jobs containing those result as a json subset (@> in postgres)
in: query
schema:
type: string
Expand Down
52 changes: 52 additions & 0 deletions backend/windmill-api/src/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use magic_crypt::MagicCryptTrait;
use stripe::CustomerId;
use windmill_audit::{audit_log, ActionKind};
use windmill_common::db::UserDB;
use windmill_common::jobs::JobPayload;
use windmill_common::schedule::Schedule;
use windmill_common::users::username_to_permissioned_as;
use windmill_common::{
Expand All @@ -45,9 +46,11 @@ use windmill_common::{
utils::{paginate, rd_string, require_admin, Pagination},
variables::ExportableListableVariable,
};
use windmill_queue::PushIsolationLevel;

use hyper::{header, StatusCode};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use sqlx::{FromRow, Postgres, Transaction};
use tempfile::TempDir;
use tokio::fs::File;
Expand All @@ -64,6 +67,7 @@ pub fn workspaced_service() -> Router {
.route("/get_settings", get(get_settings))
.route("/get_deploy_to", get(get_deploy_to))
.route("/edit_slack_command", post(edit_slack_command))
.route("/run_slack_message_test_job", post(run_slack_message_test_job))
.route("/edit_webhook", post(edit_webhook))
.route("/edit_auto_invite", post(edit_auto_invite))
.route("/edit_deploy_to", post(edit_deploy_to))
Expand Down Expand Up @@ -149,6 +153,16 @@ struct EditCommandScript {
slack_command_script: Option<String>,
}

#[derive(Deserialize)]
struct RunSlackMessageTestJobRequest {
hub_script_path: String,
job_args: Map<String, Value>
}

#[derive(Serialize)]
struct RunSlackMessageTestJobResponse {
job_uuid: String,
}

#[cfg(feature = "enterprise")]
#[derive(Deserialize)]
Expand Down Expand Up @@ -507,6 +521,44 @@ async fn edit_slack_command(
Ok(format!("Edit command script {}", &w_id))
}

async fn run_slack_message_test_job(
authed: ApiAuthed,
Extension(db): Extension<DB>,
Extension(rsmq): Extension<Option<rsmq_async::MultiplexedRsmq>>,
Path(w_id): Path<String>,
Json(req): Json<RunSlackMessageTestJobRequest>,
) -> JsonResult<RunSlackMessageTestJobResponse> {
let payload = JobPayload::ScriptHub { path: req.hub_script_path };

let tx = PushIsolationLevel::IsolatedRoot(db.clone(), rsmq);
let (uuid, tx) = windmill_queue::push(
&db,
tx,
w_id.as_str(),
payload,
req.job_args,
authed.username.as_str(),
authed.email.as_str(),
username_to_permissioned_as(authed.username.as_str()), // TODO: double check with ruben if this is correct
None,
None,
None,
None,
None,
false,
false,
None,
true,
None,
None,
None
).await?;
tx.commit().await?;

Ok(Json(RunSlackMessageTestJobResponse {
job_uuid: uuid.to_string(),
}))
}

#[cfg(feature = "enterprise")]
async fn edit_deploy_to(
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/components/ArgInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
export let resourceTypes: string[] | undefined
export let disablePortal = false
export let showSchemaExplorer = false
export let simpleTooltip: string | undefined = undefined
let seeEditable: boolean = enum_ != undefined || pattern != undefined
const dispatch = createEventDispatcher()
Expand Down Expand Up @@ -187,7 +188,7 @@
<div class="flex flex-col w-full {minW ? 'min-w-[250px]' : ''}">
<div>
{#if displayHeader}
<FieldHeader prettify={prettifyHeader} {label} {required} {type} {contentEncoding} {format} />
<FieldHeader prettify={prettifyHeader} {label} {required} {type} {contentEncoding} {format} {simpleTooltip} />
{/if}
{#if editableSchema}
<label class="text-secondary">
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/lib/components/FieldHeader.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts">
import { twMerge } from 'tailwind-merge'
import Required from './Required.svelte'
import { capitalize } from '$lib/utils'
import Tooltip from '$lib/components/Tooltip.svelte'
import { capitalize, emptyString } from '$lib/utils'
export let label: string
export let format: string = ''
Expand All @@ -11,6 +12,7 @@
export let displayType: boolean = true
export let labelClass: string = ''
export let prettify = false
export let simpleTooltip: string | undefined
</script>

<div class="inline-flex flex-row items-center truncated">
Expand All @@ -36,4 +38,12 @@
</span>
{/if}
{/if}

{#if !emptyString(simpleTooltip)}
<Tooltip class="ml-2">
<span class="text-xs">
{simpleTooltip}
</span>
</Tooltip>
{/if}
</div>
Loading

0 comments on commit 2679187

Please sign in to comment.