Skip to content

Commit 90da7b9

Browse files
authored
[mail] Add action input labels and descriptions (openhab#18209)
Signed-off-by: Jimmy Tanagra <[email protected]>
1 parent b80efcc commit 90da7b9

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

bundles/org.openhab.binding.mail/src/main/java/org/openhab/binding/mail/internal/action/SendMailActions.java

+24-21
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@ public class SendMailActions implements ThingActions {
5353

5454
@RuleAction(label = "@text/sendMessageActionLabel", description = "@text/sendMessageActionDescription")
5555
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMail(
56-
@ActionInput(name = "recipient") @Nullable String recipient,
57-
@ActionInput(name = "subject") @Nullable String subject,
58-
@ActionInput(name = "text") @Nullable String text) {
56+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
57+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
58+
@ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text) {
5959
return sendMailWithAttachments(recipient, subject, text, List.of());
6060
}
6161

6262
@RuleAction(label = "@text/sendAttachmentMessageActionLabel", description = "@text/sendAttachmentMessageActionDescription")
6363
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachment(
64-
@ActionInput(name = "recipient") @Nullable String recipient,
65-
@ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text,
66-
@ActionInput(name = "url") @Nullable String url) {
64+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
65+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
66+
@ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text,
67+
@ActionInput(name = "url", label = "@text/actionInputUrlLabel", description = "@text/actionInputUrlDescription") @Nullable String url) {
6768
List<String> urlList = new ArrayList<>();
6869
if (url != null) {
6970
urlList.add(url);
@@ -73,9 +74,10 @@ public class SendMailActions implements ThingActions {
7374

7475
@RuleAction(label = "@text/sendAttachmentsMessageActionLabel", description = "@text/sendAttachmentsMessageActionDescription")
7576
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendMailWithAttachments(
76-
@ActionInput(name = "recipient") @Nullable String recipient,
77-
@ActionInput(name = "subject") @Nullable String subject, @ActionInput(name = "text") @Nullable String text,
78-
@ActionInput(name = "urlList", type = "List<String>") @Nullable List<String> urlList) {
77+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
78+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
79+
@ActionInput(name = "text", label = "@text/actionInputTextLabel", description = "@text/actionInputTextDescription") @Nullable String text,
80+
@ActionInput(name = "urlList", type = "List<String>", label = "@text/actionInputUrlListLabel", description = "@text/actionInputUrlListDescription") @Nullable List<String> urlList) {
7981
if (recipient == null) {
8082
logger.warn("Cannot send mail as recipient is missing.");
8183
return false;
@@ -142,18 +144,18 @@ public static boolean sendMailWithAttachments(ThingActions actions, @Nullable St
142144

143145
@RuleAction(label = "@text/sendHTMLMessageActionLabel", description = "@text/sendHTMLMessageActionDescription")
144146
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMail(
145-
@ActionInput(name = "recipient") @Nullable String recipient,
146-
@ActionInput(name = "subject") @Nullable String subject,
147-
@ActionInput(name = "htmlContent") @Nullable String htmlContent) {
147+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
148+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
149+
@ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent) {
148150
return sendHtmlMailWithAttachments(recipient, subject, htmlContent, List.of());
149151
}
150152

151153
@RuleAction(label = "@text/sendHTMLAttachmentMessageActionLabel", description = "@text/sendHTMLAttachmentMessageActionDescription")
152154
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachment(
153-
@ActionInput(name = "recipient") @Nullable String recipient,
154-
@ActionInput(name = "subject") @Nullable String subject,
155-
@ActionInput(name = "htmlContent") @Nullable String htmlContent,
156-
@ActionInput(name = "url") @Nullable String url) {
155+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
156+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
157+
@ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent,
158+
@ActionInput(name = "url", label = "@text/actionInputUrlLabel", description = "@text/actionInputUrlDescription") @Nullable String url) {
157159
List<String> urlList = new ArrayList<>();
158160
if (url != null) {
159161
urlList.add(url);
@@ -163,10 +165,10 @@ public static boolean sendMailWithAttachments(ThingActions actions, @Nullable St
163165

164166
@RuleAction(label = "@text/sendHTMLAttachmentsMessageActionLabel", description = "@text/sendHTMLAttachmentsMessageActionDescription")
165167
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean sendHtmlMailWithAttachments(
166-
@ActionInput(name = "recipient") @Nullable String recipient,
167-
@ActionInput(name = "subject") @Nullable String subject,
168-
@ActionInput(name = "htmlContent") @Nullable String htmlContent,
169-
@ActionInput(name = "urlList", type = "List<String>") @Nullable List<String> urlList) {
168+
@ActionInput(name = "recipient", label = "@text/actionInputRecipientLabel", description = "@text/actionInputRecipientDescription") @Nullable String recipient,
169+
@ActionInput(name = "subject", label = "@text/actionInputSubjectLabel", description = "@text/actionInputSubjectDescription") @Nullable String subject,
170+
@ActionInput(name = "htmlContent", label = "@text/actionInputHtmlContentLabel", description = "@text/actionInputHtmlContentDescription") @Nullable String htmlContent,
171+
@ActionInput(name = "urlList", type = "List<String>", label = "@text/actionInputUrlListLabel", description = "@text/actionInputUrlListDescription") @Nullable List<String> urlList) {
170172
if (recipient == null) {
171173
logger.warn("Cannot send mail as recipient is missing.");
172174
return false;
@@ -245,7 +247,8 @@ public void setThingHandler(@Nullable ThingHandler handler) {
245247

246248
@RuleAction(label = "@text/addHeaderActionLabel", description = "@text/addHeaderActionDescription")
247249
public @ActionOutput(label = "Success", type = "java.lang.Boolean") Boolean addHeader(
248-
@ActionInput(name = "name") @Nullable String name, @ActionInput(name = "value") @Nullable String value) {
250+
@ActionInput(name = "name", label = "@text/actionInputHeaderNameLabel") @Nullable String name,
251+
@ActionInput(name = "value", label = "@text/actionInputHeaderValueLabel") @Nullable String value) {
249252
if (name != null && !name.isEmpty()) {
250253
if (value != null && !value.isEmpty()) {
251254
headers.put(name, value);

bundles/org.openhab.binding.mail/src/main/resources/OH-INF/i18n/mail.properties

+14
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,17 @@ sendHTMLMessageActionLabel = send a HTML mail
7272
sendHTMLMessageActionDescription = Sends a HTML mail.
7373
sendMessageActionLabel = send a text mail
7474
sendMessageActionDescription = Sends a text mail.
75+
actionInputRecipientLabel = Recipient
76+
actionInputRecipientDescription = Recipient email address.
77+
actionInputSubjectLabel = Subject
78+
actionInputSubjectDescription = Subject of the mail.
79+
actionInputTextLabel = Message
80+
actionInputTextDescription = Content of the mail in text format.
81+
actionInputUrlLabel = URL
82+
actionInputUrlDescription = URL of the attachment.
83+
actionInputUrlListLabel = URL List
84+
actionInputUrlListDescription = List of URLs of the attachments.
85+
actionInputHtmlContentLabel = HTML Message
86+
actionInputHtmlContentDescription = Content of the mail in HTML format.
87+
actionInputHeaderNameLabel = Header Name
88+
actionInputHeaderValueLabel = Header Value

0 commit comments

Comments
 (0)