mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 16:00:38 +00:00
feat(frontend): add support for toasts in frontend scripts (#3147)
* feat(frontend): add support for toast in frontend scripts * feat(frontend): add support for toast in frontend scripts * feat(frontend): fix comment * Update eval.ts * Update eval.ts * Update utils.ts * Update utils.ts --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
@@ -20,7 +20,7 @@ export function computeGlobalContext(world: World | undefined, extraContext: any
|
||||
|
||||
function create_context_function_template(eval_string: string, context, noReturn: boolean) {
|
||||
return `
|
||||
return async function (context, state, goto, setTab, recompute, getAgGrid, setValue, setSelectedIndex, openModal, closeModal, open, close, validate, invalidate, validateAll, clearFiles) {
|
||||
return async function (context, state, goto, setTab, recompute, getAgGrid, setValue, setSelectedIndex, openModal, closeModal, open, close, validate, invalidate, validateAll, clearFiles, showToast) {
|
||||
"use strict";
|
||||
${
|
||||
Object.keys(context).length > 0
|
||||
@@ -56,7 +56,8 @@ function make_context_evaluator(
|
||||
validate,
|
||||
invalidate,
|
||||
validateAll,
|
||||
clearFiles
|
||||
clearFiles,
|
||||
showToast
|
||||
) => Promise<any> {
|
||||
let template = create_context_function_template(eval_string, context, noReturn)
|
||||
let functor = Function(template)
|
||||
@@ -192,6 +193,9 @@ export async function eval_like(
|
||||
},
|
||||
(id) => {
|
||||
controlComponents[id]?.clearFiles?.()
|
||||
},
|
||||
(message, error) => {
|
||||
sendUserToast(message, error)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -199,7 +199,6 @@ declare function recompute(id: string): void;
|
||||
*/
|
||||
declare function getAgGrid(id: string): {api: any, columnApi: any} | undefined;
|
||||
|
||||
|
||||
/** set value of a component
|
||||
* @param id component's id
|
||||
* @param value value to set
|
||||
@@ -245,6 +244,10 @@ declare function validateAll(id: string, key: number): void;
|
||||
*/
|
||||
declare function clearFiles(id: string): void;
|
||||
|
||||
/** Display a toast message
|
||||
* @param message message to display
|
||||
*/
|
||||
declare function showToast(message: string, error: boolean): void;
|
||||
`
|
||||
: ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user