[AB-343] fixing link buttons not being properly supported in templates

This commit is contained in:
Sheldan
2021-11-23 19:57:16 +01:00
parent 79633d7a8e
commit 15fb9d95a8

View File

@@ -124,17 +124,14 @@ public class TemplateServiceBean implements TemplateService {
throw new AbstractoRunTimeException("Referenced class in button config could not be found: " + buttonConfig.getPayloadType(), e); throw new AbstractoRunTimeException("Referenced class in button config could not be found: " + buttonConfig.getPayloadType(), e);
} }
componentPayloads.put(id, componentConfig); componentPayloads.put(id, componentConfig);
Button createdButton = Button.primary(id, buttonConfig.getLabel()); String idOrUl = buttonConfig.getUrl() == null ? buttonConfig.getId() : buttonConfig.getUrl();
if (buttonConfig.getUrl() != null) { Button createdButton = Button.of(ButtonStyleConfig.getStyle(buttonConfig.getButtonStyle()), idOrUl, buttonConfig.getLabel());
createdButton = createdButton.withUrl(buttonConfig.getUrl());
}
if (buttonConfig.getDisabled() != null) { if (buttonConfig.getDisabled() != null) {
createdButton = createdButton.withDisabled(buttonConfig.getDisabled()); createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
} }
if (buttonConfig.getEmoteMarkdown() != null) { if (buttonConfig.getEmoteMarkdown() != null) {
createdButton = createdButton.withEmoji(Emoji.fromMarkdown(buttonConfig.getEmoteMarkdown())); createdButton = createdButton.withEmoji(Emoji.fromMarkdown(buttonConfig.getEmoteMarkdown()));
} }
createdButton = createdButton.withStyle(ButtonStyleConfig.getStyle(buttonConfig.getButtonStyle()));
if(currentRow == null) { if(currentRow == null) {
currentRow = ActionRow.of(createdButton); currentRow = ActionRow.of(createdButton);
} else if ( } else if (