diff --git a/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailCategory.java b/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailCategory.java index e84d370bb..42e5aab1f 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailCategory.java +++ b/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailCategory.java @@ -2,11 +2,20 @@ /** * The EmailCategory enumeration. + * + * This enum is for the Slack integration. When team member + * opens the dropdown menu, each email option should be in + * a certain category with a certain category label. + * + * The order of the constants is nontrivial. Besides TRIAL, + * they are listed in order chronologically, based on when + * we would likely send them to the user (i.e. clarify before + * deny, etc.). */ public enum EmailCategory { TRIAL("Trial"), - LICENSE("License"), CLARIFY("Clarify"), + LICENSE("License"), DENY("Deny"); String label; diff --git a/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailSubject.java b/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailSubject.java index 31842dc98..7a8427f18 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailSubject.java +++ b/src/main/java/org/mskcc/cbio/oncokb/domain/enumeration/EmailSubject.java @@ -2,8 +2,16 @@ /** * The EmailSubject enumeration. + * + * This enum is for the Slack integration. When team member + * selects an email option, an input modal will pop up with + * one of the below options as a default subject. See + * + * SlackService.buildModalView() + * + * for more details. */ public enum EmailSubject { - DEFAULT, - COMPANY + DEFAULT // "License for " + userDTO.getLicenseType().getName() + " of OncoKB" + , COMPANY // "OncoKB - " + userDTO.getCompanyName() + " license options" } diff --git a/src/main/java/org/mskcc/cbio/oncokb/service/SlackService.java b/src/main/java/org/mskcc/cbio/oncokb/service/SlackService.java index 7330acd3e..a62af47c1 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/service/SlackService.java +++ b/src/main/java/org/mskcc/cbio/oncokb/service/SlackService.java @@ -273,7 +273,7 @@ private LayoutBlock buildCollapsedBlock(UserDTO userDTO, boolean trialAccountAct sentMails.add(mailOption); } if (!sentMails.isEmpty()) { - sentMails = sentMails.stream().sorted((mo1, mo2) -> mo1.getCategory() == EmailCategory.DENY ? 1 : 0).collect(Collectors.toList()); + sentMails = sentMails.stream().sorted(Comparator.comparing(DropdownEmailOption::getCategory)).collect(Collectors.toList()); sb.append(sentMails.get(0).getCollapsedNote().orElse("")); sentMails.remove(0); for (DropdownEmailOption otherSentMail : sentMails) { @@ -399,9 +399,6 @@ public String getOptionValueArgument(String value) { } public boolean withNote(DropdownEmailOption mailOption, UserDTO userDTO, ActionId actionId) { - if (mailOption.getExpandedNote() == null) - return false; - switch (mailOption) { case GIVE_TRIAL_ACCESS: if ( @@ -442,7 +439,7 @@ private boolean isReviewed(UserDTO userDTO, ActionId actionId) { if (userDTO.isActivated()) return true; for (DropdownEmailOption mailOption : DropdownEmailOption.values()) { - if (mailOption.getExpandedNote() != null && withNote(mailOption, userDTO, actionId)) + if (withNote(mailOption, userDTO, actionId)) return true; } return false; diff --git a/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/ActionId.java b/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/ActionId.java index 25dbc068f..be9d3ff3a 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/ActionId.java +++ b/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/ActionId.java @@ -65,17 +65,6 @@ public static boolean isModalEmailAction(ActionId actionId) { return false; } - public static boolean isConfirmEmailAction(ActionId actionId) { - if (actionId == null) { - return false; - } - for (DropdownEmailOption mailOption : DropdownEmailOption.values()) { - if (actionId.equals(mailOption.getConfirmActionId().orElse(null))) - return true; - } - return false; - } - public static boolean isDropdownAction(ActionId actionId) { if (actionId == null) { return false; diff --git a/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/DropdownEmailOption.java b/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/DropdownEmailOption.java index c543ef6a2..f1ac6002c 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/DropdownEmailOption.java +++ b/src/main/java/org/mskcc/cbio/oncokb/web/rest/slack/DropdownEmailOption.java @@ -10,10 +10,63 @@ import java.util.Optional; /** - * The SlackOption enumeration. This enum is for all the options - * the team can select for a license request in the Slack channel. - * + * The DropdownEmailOption enumeration. This enum is for the email + * options in the Slack dropdown menu that the team can select. * Approval is not included as the logic is complex and unique. + * + * To add a new email option, add the following fields: + * + * REQUIRED: + * - Block blockId (the corresponding BlockId enum constant + * associated with the additional info block after email sent) + * - ActionId actionId (the corresponding ActionId enum constant + * associated with the initial selection from the menu) + * - MailType mailType (the corresponding MailType associated + * with the dropdown option) + * - EmailCategory category (the EmailCategory enum constant, + * which is the group the option goes in) + * - String dropdownKey (the name of the option in the menu) + * - String expandedNote (the string that appears in the + * additional info block after email sent) + * + * OPTIONAL: + * - Optional confirmActionId (the corresponding ActionId + * associated with confirming the dispatch of email in input modal. + * This property is REQUIRED if the email uses an input modal.) + * - List specificLicenses (the specific license(s) + * where the option should show up at all. Used if given email + * will only need to be sent to certain license(s).) + * - boolean notModalEmail (if the email option doesn't prompt an + * input modal. Is 'false' by default.) + * - Optional modalTitle (the title of the input modal + * when option is selected. This property is encouraged if the + * email option uses an input modal.) + * - Optional modalSubject (the default subject of + * the input modal. Defaults to EmailSubject.DEFAULT if not defined.) + * - Optional collapsedNote (the string that appears in the + * collapsed block after email sent. This property is REQUIRED if the + * email option does not grant a token to the user.) + * + * To add a new property to this enum, add a new variable to both the + * Builder and the enum, as well as a builder function in the static + * Builder class and a getter function in the enum. + * + * + * The following template can be used to add a new option: + * + , EMAIL_OPTION(new DropdownEmailOptionBuilder() + .blockId(BlockId) + .actionId(ActionId) + .confirmActionId(ActionId) + .mailType(MailType) + .category(EmailCategory) + .specificLicense(LicenseType) + .dropdownKey("") + .modalTitle("") + .modalSubject(EmailSubject) + .collapsedNote("") + .expandedNote("")) + * */ public enum DropdownEmailOption { GIVE_TRIAL_ACCESS(new DropdownEmailOptionBuilder() @@ -119,6 +172,79 @@ public enum DropdownEmailOption { .expandedNote("The user has been rejected due to alumni email address.")) ; + // blockId/actionId + private BlockId blockId; + private ActionId actionId; + private Optional confirmActionId; + // Email + private MailType mailType; + // Dropdown menu + private EmailCategory category; + private List specificLicenses; + private String dropdownKey; + // View modal + private boolean notModalEmail; + private Optional modalTitle; + private Optional modalSubject; + // Additional info block + private Optional collapsedNote; + private String expandedNote; + + DropdownEmailOption(DropdownEmailOptionBuilder builder) { + this.blockId = builder.blockId; + this.actionId = builder.actionId; + this.confirmActionId = builder.confirmActionId; + this.mailType = builder.mailType; + this.category = builder.category; + this.specificLicenses = builder.specificLicenses; + this.dropdownKey = builder.dropdownKey; + this.notModalEmail = builder.notModalEmail; + this.modalTitle = builder.modalTitle; + this.modalSubject = builder.modalSubject; + this.collapsedNote = builder.collapsedNote; + this.expandedNote = builder.expandedNote; + } + + public BlockId getBlockId() { + return blockId; + } + + public ActionId getActionId() { + return actionId; + } + + public Optional getConfirmActionId() { + return confirmActionId; + } + + public MailType getMailType() { + return mailType; + } + + public EmailCategory getCategory() { return category; } + + public List getSpecificLicenses() { return specificLicenses; } + + public String getDropdownKey() { + return dropdownKey; + } + + public boolean isNotModalEmail() { return notModalEmail; } + + public Optional getModalTitle() { + return modalTitle; + } + + public Optional getModalSubject() { + return modalSubject; + } + + public Optional getCollapsedNote() { + return collapsedNote; + } + + public String getExpandedNote() { return expandedNote;} + private static class DropdownEmailOptionBuilder { // blockId/actionId @@ -199,77 +325,4 @@ public DropdownEmailOptionBuilder expandedNote(String expandedNote) { return this; } } - - // blockId/actionId - private BlockId blockId; - private ActionId actionId; - private Optional confirmActionId; - // Email - private MailType mailType; - // Dropdown menu - private EmailCategory category; - private List specificLicenses; - private String dropdownKey; - // View modal - private boolean notModalEmail; - private Optional modalTitle; - private Optional modalSubject; - // Additional info block - private Optional collapsedNote; - private String expandedNote; - - DropdownEmailOption(DropdownEmailOptionBuilder builder) { - this.blockId = builder.blockId; - this.actionId = builder.actionId; - this.confirmActionId = builder.confirmActionId; - this.mailType = builder.mailType; - this.category = builder.category; - this.specificLicenses = builder.specificLicenses; - this.dropdownKey = builder.dropdownKey; - this.notModalEmail = builder.notModalEmail; - this.modalTitle = builder.modalTitle; - this.modalSubject = builder.modalSubject; - this.collapsedNote = builder.collapsedNote; - this.expandedNote = builder.expandedNote; - } - - public BlockId getBlockId() { - return blockId; - } - - public ActionId getActionId() { - return actionId; - } - - public Optional getConfirmActionId() { - return confirmActionId; - } - - public MailType getMailType() { - return mailType; - } - - public EmailCategory getCategory() { return category; } - - public List getSpecificLicenses() { return specificLicenses; } - - public String getDropdownKey() { - return dropdownKey; - } - - public boolean isNotModalEmail() { return notModalEmail; } - - public Optional getModalTitle() { - return modalTitle; - } - - public Optional getModalSubject() { - return modalSubject; - } - - public Optional getCollapsedNote() { - return collapsedNote; - } - - public String getExpandedNote() { return expandedNote;} }