mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 20:16:34 +00:00
[AB-xxx] adding ability to define unique ids for components, a color of the container, disabled state for multiple components and spoiler for container
fixing reminder message not containing a link to the message anymore
This commit is contained in:
@@ -223,6 +223,9 @@ public class RemindServiceBean implements ReminderService {
|
|||||||
.builder()
|
.builder()
|
||||||
.reminderParticipants(participantsDisplays)
|
.reminderParticipants(participantsDisplays)
|
||||||
.reminderDisplay(reminderDisplay)
|
.reminderDisplay(reminderDisplay)
|
||||||
|
.serverId(reminder.getServer().getId())
|
||||||
|
.channelId(reminder.getChannel().getId())
|
||||||
|
.messageId(reminder.getMessageId())
|
||||||
.userDisplay(UserDisplay.fromUser(member.getUser()))
|
.userDisplay(UserDisplay.fromUser(member.getUser()))
|
||||||
.duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate()))
|
.duration(Duration.between(reminder.getReminderDate(), reminder.getTargetDate()))
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class ButtonConfig {
|
|||||||
private String id;
|
private String id;
|
||||||
private String url;
|
private String url;
|
||||||
private Boolean disabled;
|
private Boolean disabled;
|
||||||
|
private Integer uniqueId;
|
||||||
private String emoteMarkdown;
|
private String emoteMarkdown;
|
||||||
private ButtonStyleConfig buttonStyle;
|
private ButtonStyleConfig buttonStyle;
|
||||||
private String buttonPayload;
|
private String buttonPayload;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package dev.sheldan.abstracto.core.templating.model.messagecomponents;
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ContainerColor {
|
||||||
|
private Integer r;
|
||||||
|
private Integer g;
|
||||||
|
private Integer b;
|
||||||
|
|
||||||
|
public Color toColor() {
|
||||||
|
return new Color(r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,10 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@Getter
|
@Getter
|
||||||
public class ContainerConfig implements ComponentConfig {
|
public class ContainerConfig implements ComponentConfig {
|
||||||
private List<ComponentConfig> components;
|
private List<ComponentConfig> components;
|
||||||
|
private ContainerColor color;
|
||||||
|
private Integer uniqueId;
|
||||||
|
private Boolean spoiler;
|
||||||
|
private Boolean disabled;
|
||||||
@Override
|
@Override
|
||||||
public ComponentTypeConfig getType() {
|
public ComponentTypeConfig getType() {
|
||||||
return ComponentTypeConfig.CONTAINER;
|
return ComponentTypeConfig.CONTAINER;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@Getter
|
@Getter
|
||||||
public class MediaGalleryConfig implements ComponentConfig {
|
public class MediaGalleryConfig implements ComponentConfig {
|
||||||
private List<ImageConfig> images;
|
private List<ImageConfig> images;
|
||||||
|
private Integer uniqueId;
|
||||||
@Override
|
@Override
|
||||||
public ComponentTypeConfig getType() {
|
public ComponentTypeConfig getType() {
|
||||||
return ComponentTypeConfig.MEDIA_GALLERY;
|
return ComponentTypeConfig.MEDIA_GALLERY;
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
public class SectionConfig {
|
public class SectionConfig {
|
||||||
protected SectionAccessoryConfig accessory;
|
protected SectionAccessoryConfig accessory;
|
||||||
protected List<SectionComponentConfig> components;
|
protected List<SectionComponentConfig> components;
|
||||||
|
private Boolean disabled;
|
||||||
|
private Integer uniqueId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
public class SeparatorConfig implements ComponentConfig {
|
public class SeparatorConfig implements ComponentConfig {
|
||||||
private Boolean divider;
|
private Boolean divider;
|
||||||
private Spacing spacing;
|
private Spacing spacing;
|
||||||
|
private Integer uniqueId;
|
||||||
@Override
|
@Override
|
||||||
public ComponentTypeConfig getType() {
|
public ComponentTypeConfig getType() {
|
||||||
return ComponentTypeConfig.SEPARATOR;
|
return ComponentTypeConfig.SEPARATOR;
|
||||||
|
|||||||
@@ -351,7 +351,14 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(accessory != null) {
|
if(accessory != null) {
|
||||||
return Section.of(accessory, sectionComponents);
|
Section section = Section.of(accessory, sectionComponents);
|
||||||
|
if(sectionConfig.getDisabled() != null) {
|
||||||
|
section = section.withDisabled(sectionConfig.getDisabled());
|
||||||
|
}
|
||||||
|
if(sectionConfig.getUniqueId() != null) {
|
||||||
|
section = section.withUniqueId(sectionConfig.getUniqueId());
|
||||||
|
}
|
||||||
|
return section;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(componentConfig instanceof TopLevelFileConfig fileConfig) {
|
} else if(componentConfig instanceof TopLevelFileConfig fileConfig) {
|
||||||
@@ -380,11 +387,19 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
}
|
}
|
||||||
galleryItems.add(item);
|
galleryItems.add(item);
|
||||||
});
|
});
|
||||||
return MediaGallery.of(galleryItems);
|
MediaGallery gallery = MediaGallery.of(galleryItems);
|
||||||
|
if(mediaGalleryConfig.getUniqueId() != null) {
|
||||||
|
gallery = gallery.withUniqueId(mediaGalleryConfig.getUniqueId());
|
||||||
|
}
|
||||||
|
return gallery;
|
||||||
}
|
}
|
||||||
} else if(componentConfig instanceof TopLevelSeperatorConfig seperatorConfig) {
|
} else if(componentConfig instanceof TopLevelSeperatorConfig seperatorConfig) {
|
||||||
return Separator.create(seperatorConfig.getDivider(),
|
Separator separator = Separator.create(seperatorConfig.getDivider(),
|
||||||
Spacing.toSpacing(seperatorConfig.getSpacing()));
|
Spacing.toSpacing(seperatorConfig.getSpacing()));
|
||||||
|
if(seperatorConfig.getUniqueId() != null) {
|
||||||
|
separator = separator.withUniqueId(seperatorConfig.getUniqueId());
|
||||||
|
}
|
||||||
|
return separator;
|
||||||
} else if(componentConfig instanceof TopLevelContainerConfig topLevelContainerConfig) {
|
} else if(componentConfig instanceof TopLevelContainerConfig topLevelContainerConfig) {
|
||||||
List<ContainerChildComponent> childComponents = new ArrayList<>();
|
List<ContainerChildComponent> childComponents = new ArrayList<>();
|
||||||
for (ComponentConfig containerComponent : topLevelContainerConfig.getComponents()) {
|
for (ComponentConfig containerComponent : topLevelContainerConfig.getComponents()) {
|
||||||
@@ -393,7 +408,20 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
childComponents.add((ContainerChildComponent) createdComponent);
|
childComponents.add((ContainerChildComponent) createdComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Container.of(childComponents);
|
Container container = Container.of(childComponents);
|
||||||
|
if(topLevelContainerConfig.getColor() != null) {
|
||||||
|
container = container.withAccentColor(topLevelContainerConfig.getColor().toColor());
|
||||||
|
}
|
||||||
|
if(topLevelContainerConfig.getUniqueId() != null) {
|
||||||
|
container = container.withUniqueId(topLevelContainerConfig.getUniqueId());
|
||||||
|
}
|
||||||
|
if(topLevelContainerConfig.getDisabled() != null) {
|
||||||
|
container = container.withDisabled(topLevelContainerConfig.getDisabled());
|
||||||
|
}
|
||||||
|
if(topLevelContainerConfig.getSpoiler() != null) {
|
||||||
|
container = container.withSpoiler(topLevelContainerConfig.getSpoiler());
|
||||||
|
}
|
||||||
|
return container;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -545,6 +573,9 @@ public class TemplateServiceBean implements TemplateService {
|
|||||||
if (buttonConfig.getDisabled() != null) {
|
if (buttonConfig.getDisabled() != null) {
|
||||||
createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
|
createdButton = createdButton.withDisabled(buttonConfig.getDisabled());
|
||||||
}
|
}
|
||||||
|
if(buttonConfig.getUniqueId() != null) {
|
||||||
|
createdButton = createdButton.withUniqueId(buttonConfig.getUniqueId());
|
||||||
|
}
|
||||||
return createdButton;
|
return createdButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user