From 90da7b9d83cba01f52e4a5b14bf86be6fc1602e3 Mon Sep 17 00:00:00 2001 From: jimtng <2554958+jimtng@users.noreply.github.com> Date: Sat, 1 Feb 2025 20:42:39 +1000 Subject: [PATCH] [mail] Add action input labels and descriptions (#18209) Signed-off-by: Jimmy Tanagra --- .../mail/internal/action/SendMailActions.java | 45 ++++++++++--------- .../resources/OH-INF/i18n/mail.properties | 14 ++++++ 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/action/SendMailActions.java b/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/action/SendMailActions.java index b6b1ac372b5..358e7544d0c 100644 --- a/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/action/SendMailActions.java +++ b/bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/action/SendMailActions.java @@ -53,17 +53,18 @@ public class SendMailActions implements ThingActions { @RuleAction(label = "@text/sendMessageActionLabel", description = "@text/sendMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMail( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, - @ActionInput(name = "text") @Nullable String text) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text) { return sendMailWithAttachments(recipient, subject, text, List.of()); } @RuleAction(label = "@text/sendAttachmentMessageActionLabel", description = "@text/sendAttachmentMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachment( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text, - @ActionInput(name = "url") @Nullable String url) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text, + @ActionInput(name = "url", label = "@text/actionInputUrlLabel", description = "@text/actionInputUrlDescription") @Nullable String url) { List urlList = new ArrayList<>(); if (url != null) { urlList.add(url); @@ -73,9 +74,10 @@ public class SendMailActions implements ThingActions { @RuleAction(label = "@text/sendAttachmentsMessageActionLabel", description = "@text/sendAttachmentsMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachments( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text, - @ActionInput(name = "urlList", type = "List") @Nullable List urlList) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text, + @ActionInput(name = "urlList", type = "List", label = "@text/actionInputUrlListLabel", description = "@text/actionInputUrlListDescription") @Nullable List urlList) { if (recipient == null) { logger.warn("Cannot send mail as recipient is missing."); return false; @@ -142,18 +144,18 @@ public class SendMailActions implements ThingActions { @RuleAction(label = "@text/sendHTMLMessageActionLabel", description = "@text/sendHTMLMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMail( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, - @ActionInput(name = "htmlContent") @Nullable String htmlContent) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent) { return sendHtmlMailWithAttachments(recipient, subject, htmlContent, List.of()); } @RuleAction(label = "@text/sendHTMLAttachmentMessageActionLabel", description = "@text/sendHTMLAttachmentMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachment( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, - @ActionInput(name = "htmlContent") @Nullable String htmlContent, - @ActionInput(name = "url") @Nullable String url) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent, + @ActionInput(name = "url", label = "@text/actionInputUrlLabel", description = "@text/actionInputUrlDescription") @Nullable String url) { List urlList = new ArrayList<>(); if (url != null) { urlList.add(url); @@ -163,10 +165,10 @@ public class SendMailActions implements ThingActions { @RuleAction(label = "@text/sendHTMLAttachmentsMessageActionLabel", description = "@text/sendHTMLAttachmentsMessageActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachments( - @ActionInput(name = "recipient") @Nullable String recipient, - @ActionInput(name = "subject") @Nullable String subject, - @ActionInput(name = "htmlContent") @Nullable String htmlContent, - @ActionInput(name = "urlList", type = "List") @Nullable List urlList) { + @ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient, + @ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject, + @ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent, + @ActionInput(name = "urlList", type = "List", label = "@text/actionInputUrlListLabel", description = "@text/actionInputUrlListDescription") @Nullable List urlList) { if (recipient == null) { logger.warn("Cannot send mail as recipient is missing."); return false; @@ -245,7 +247,8 @@ public class SendMailActions implements ThingActions { @RuleAction(label = "@text/addHeaderActionLabel", description = "@text/addHeaderActionDescription") public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean addHeader( - @ActionInput(name = "name") @Nullable String name, @ActionInput(name = "value") @Nullable String value) { + @ActionInput(name = "name", label = "@text/actionInputHeaderNameLabel") @Nullable String name, + @ActionInput(name = "value", label = "@text/actionInputHeaderValueLabel") @Nullable String value) { if (name != null && !name.isEmpty()) { if (value != null && !value.isEmpty()) { headers.put(name, value); diff --git a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties index 1fc84fc970e..164f3ddfd89 100644 --- a/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties +++ b/bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties @@ -72,3 +72,17 @@ sendHTMLMessageActionLabel = send a HTML mail sendHTMLMessageActionDescription = Sends a HTML mail. sendMessageActionLabel = send a text mail sendMessageActionDescription = Sends a text mail. +actionInputRecipientLabel = Recipient +actionInputRecipientDescription = Recipient email address. +actionInputSubjectLabel = Subject +actionInputSubjectDescription = Subject of the mail. +actionInputTextLabel = Message +actionInputTextDescription = Content of the mail in text format. +actionInputUrlLabel = URL +actionInputUrlDescription = URL of the attachment. +actionInputUrlListLabel = URL List +actionInputUrlListDescription = List of URLs of the attachments. +actionInputHtmlContentLabel = HTML Message +actionInputHtmlContentDescription = Content of the mail in HTML format. +actionInputHeaderNameLabel = Header Name +actionInputHeaderValueLabel = Header Value