mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-28 08:02:43 +00:00
cleanup
This commit is contained in:
@@ -3476,6 +3476,10 @@ paths:
|
||||
text:
|
||||
type: string
|
||||
description: The message text to be sent in the Teams card
|
||||
card_block:
|
||||
type: object
|
||||
description: The card block to be sent in the Teams card
|
||||
|
||||
responses:
|
||||
'200':
|
||||
description: Activity processed successfully
|
||||
|
||||
@@ -43,9 +43,11 @@
|
||||
export let customScriptTemplate: string
|
||||
export let customHandlerKind: 'flow' | 'script' = 'script'
|
||||
|
||||
let initialSlackChannel: string | undefined = undefined
|
||||
let initialTeamsChannel: string | undefined = undefined
|
||||
|
||||
let customHandlerSchema: Schema | undefined
|
||||
let slackHandlerSchema: Schema | undefined
|
||||
let teamsHandlerSchema: Schema | undefined
|
||||
let isFetching: boolean = false
|
||||
|
||||
let teams_channels: ListAvailableTeamsChannelsResponse = []
|
||||
@@ -201,10 +203,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
let lastHandlerSelected: 'slack' | 'teams' | 'custom' | undefined = undefined
|
||||
|
||||
$: {
|
||||
if (lastHandlerSelected !== handlerSelected) {
|
||||
lastHandlerSelected = handlerSelected;
|
||||
updateHandlerExtraArgs();
|
||||
}
|
||||
}
|
||||
|
||||
function updateHandlerExtraArgs() {
|
||||
if (handlerSelected === 'slack' && initialSlackChannel) {
|
||||
handlerExtraArgs['channel'] = initialSlackChannel;
|
||||
} else if (handlerSelected === 'teams' && initialTeamsChannel) {
|
||||
handlerExtraArgs['channel'] = initialTeamsChannel;
|
||||
} else {
|
||||
handlerExtraArgs['channel'] = undefined;
|
||||
}
|
||||
connectionTestJob = undefined;
|
||||
}
|
||||
|
||||
$: {
|
||||
if ($workspaceStore) {
|
||||
loadSlackResources()
|
||||
loadTeamsResources()
|
||||
if (handlerSelected === 'slack') {
|
||||
initialSlackChannel = handlerExtraArgs['channel']
|
||||
} else if (handlerSelected === 'teams') {
|
||||
initialTeamsChannel = handlerExtraArgs['channel']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,6 +256,7 @@
|
||||
|
||||
$: handlerPath &&
|
||||
isSlackHandler(handlerPath) &&
|
||||
!isTeamsHandler(handlerPath) &&
|
||||
loadHandlerScriptArgs(handlerPath, [
|
||||
'path',
|
||||
'workspace_id',
|
||||
@@ -245,31 +273,10 @@
|
||||
'email',
|
||||
'slack'
|
||||
]).then((schema) => (slackHandlerSchema = schema))
|
||||
|
||||
$: handlerPath &&
|
||||
isTeamsHandler(handlerPath) &&
|
||||
loadHandlerScriptArgs(handlerPath, [
|
||||
'path',
|
||||
'workspace_id',
|
||||
'job_id',
|
||||
'is_flow',
|
||||
'schedule_path',
|
||||
'error',
|
||||
'error_started_at',
|
||||
'failed_times',
|
||||
'started_at',
|
||||
'success_times',
|
||||
'success_result',
|
||||
'success_started_at',
|
||||
'email',
|
||||
'teams'
|
||||
]).then((schema) => (teamsHandlerSchema = schema))
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<Tabs bind:selected={handlerSelected} on:change={() => {
|
||||
//TODO
|
||||
}} class="mt-2 mb-4">
|
||||
<Tabs bind:selected={handlerSelected} class="mt-2 mb-4">
|
||||
<Tab value="slack" disabled={!isEditable}>Slack</Tab>
|
||||
<Tab value="teams" disabled={!isEditable}>Teams</Tab>
|
||||
<Tab value="custom" disabled={!isEditable}>
|
||||
@@ -439,7 +446,7 @@
|
||||
</div>
|
||||
<p class="text-sm">Teams Channel</p>
|
||||
<div class="flex-grow">
|
||||
<select class="w-full" bind:value={handlerExtraArgs['teams_channel']}>
|
||||
<select class="w-full" bind:value={handlerExtraArgs['channel']}>
|
||||
{#if teams_channels.length === 0}
|
||||
<option value="" disabled selected>Bot not connected to any channel</option>
|
||||
{:else}
|
||||
@@ -481,10 +488,10 @@
|
||||
</Alert>
|
||||
{:else}
|
||||
<Button
|
||||
disabled={emptyString(handlerExtraArgs['teams_channel'])}
|
||||
disabled={emptyString(handlerExtraArgs['channel'])}
|
||||
btnClasses="w-32 text-center"
|
||||
color="dark"
|
||||
on:click={() => sendTeamsMessage(handlerExtraArgs['teams_channel'])}
|
||||
on:click={() => sendTeamsMessage(handlerExtraArgs['channel'])}
|
||||
size="xs">Send test message</Button
|
||||
>
|
||||
{#if connectionTestJob !== undefined}
|
||||
|
||||
@@ -570,6 +570,8 @@
|
||||
if (errorHandlerScriptPath) {
|
||||
if (errorHandlerScriptPath !== undefined && isSlackHandler(errorHandlerScriptPath)) {
|
||||
errorHandlerExtraArgs['slack'] = '$res:f/slack_bot/bot_token'
|
||||
} else {
|
||||
errorHandlerExtraArgs['slack'] = undefined
|
||||
}
|
||||
await WorkspaceService.editErrorHandler({
|
||||
workspace: $workspaceStore!,
|
||||
|
||||
@@ -710,11 +710,11 @@ class Windmill:
|
||||
return self.get(f"/w/{self.workspace}/users/username_to_email/{username}").text
|
||||
|
||||
|
||||
def send_teams_message(self, conversation_id: str, text: str, success: bool = True):
|
||||
def send_teams_message(self, conversation_id: str, text: str, success: bool = True, card_block: dict = None):
|
||||
"""
|
||||
Send a message to a Microsoft Teams conversation with conversation_id, where success is used to style the message
|
||||
"""
|
||||
return self.post(f"/teams/activities", json={"conversation_id": conversation_id, "text": text, "success": success})
|
||||
return self.post(f"/teams/activities", json={"conversation_id": conversation_id, "text": text, "success": success, "card_block": card_block})
|
||||
|
||||
|
||||
def init_global_client(f):
|
||||
@@ -1076,8 +1076,8 @@ def request_interactive_slack_approval(
|
||||
)
|
||||
|
||||
@init_global_client
|
||||
def send_teams_message(conversation_id: str, text: str, success: bool):
|
||||
return _client.send_teams_message(conversation_id, text, success)
|
||||
def send_teams_message(conversation_id: str, text: str, success: bool, card_block: dict = None):
|
||||
return _client.send_teams_message(conversation_id, text, success, card_block)
|
||||
|
||||
@init_global_client
|
||||
def cancel_running() -> dict:
|
||||
|
||||
Reference in New Issue
Block a user