mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:43:11 +02:00
Improved prompt function add add ctx.* functions (#301)
This commit is contained in:
@@ -147,6 +147,9 @@ pub enum InternalEventPayload {
|
||||
PromptTextRequest(PromptTextRequest),
|
||||
PromptTextResponse(PromptTextResponse),
|
||||
|
||||
WindowInfoRequest(WindowInfoRequest),
|
||||
WindowInfoResponse(WindowInfoResponse),
|
||||
|
||||
GetHttpRequestByIdRequest(GetHttpRequestByIdRequest),
|
||||
GetHttpRequestByIdResponse(GetHttpRequestByIdResponse),
|
||||
|
||||
@@ -521,6 +524,8 @@ pub struct PromptTextRequest {
|
||||
/// Text to add to the confirmation button
|
||||
#[ts(optional)]
|
||||
pub confirm_text: Option<String>,
|
||||
#[ts(optional)]
|
||||
pub password: Option<bool>,
|
||||
/// Text to add to the cancel button
|
||||
#[ts(optional)]
|
||||
pub cancel_text: Option<String>,
|
||||
@@ -536,6 +541,23 @@ pub struct PromptTextResponse {
|
||||
pub value: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
pub struct WindowInfoRequest {
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
pub struct WindowInfoResponse {
|
||||
pub request_id: Option<String>,
|
||||
pub environment_id: Option<String>,
|
||||
pub workspace_id: Option<String>,
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
@@ -710,12 +732,24 @@ pub struct GetTemplateFunctionConfigResponse {
|
||||
pub plugin_ref_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
pub enum TemplateFunctionPreviewType {
|
||||
Live,
|
||||
Click,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "gen_events.ts")]
|
||||
pub struct TemplateFunction {
|
||||
pub name: String,
|
||||
|
||||
#[ts(optional)]
|
||||
pub preview_type: Option<TemplateFunctionPreviewType>,
|
||||
|
||||
#[ts(optional)]
|
||||
pub description: Option<String>,
|
||||
|
||||
@@ -972,6 +1006,9 @@ pub struct FormInputAccordion {
|
||||
pub struct FormInputHStack {
|
||||
#[ts(optional)]
|
||||
pub inputs: Option<Vec<FormInput>>,
|
||||
|
||||
#[ts(optional)]
|
||||
pub hidden: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, TS)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::events::{
|
||||
FormInput, FormInputBase, FormInputText, PluginContext, RenderPurpose, TemplateFunction,
|
||||
TemplateFunctionArg,
|
||||
TemplateFunctionArg, TemplateFunctionPreviewType,
|
||||
};
|
||||
use crate::template_callback::PluginTemplateCallback;
|
||||
use base64::Engine;
|
||||
@@ -17,6 +17,7 @@ use yaak_templates::{FnArg, Parser, Token, Tokens, Val, transform_args};
|
||||
pub(crate) fn template_function_secure() -> TemplateFunction {
|
||||
TemplateFunction {
|
||||
name: "secure".to_string(),
|
||||
preview_type: Some(TemplateFunctionPreviewType::None),
|
||||
description: Some("Securely store encrypted text".to_string()),
|
||||
aliases: None,
|
||||
args: vec![TemplateFunctionArg::FormInput(FormInput::Text(
|
||||
@@ -37,6 +38,7 @@ pub(crate) fn template_function_secure() -> TemplateFunction {
|
||||
pub(crate) fn template_function_keyring() -> TemplateFunction {
|
||||
TemplateFunction {
|
||||
name: "keychain".to_string(),
|
||||
preview_type: Some(TemplateFunctionPreviewType::Live),
|
||||
description: Some("Get a password from the OS keychain or keyring".to_string()),
|
||||
aliases: Some(vec!["keyring".to_string()]),
|
||||
args: vec![
|
||||
|
||||
Reference in New Issue
Block a user