Skip to content

Commit

Permalink
Merge pull request #13 from dataiku/bug/dss12-sc-180121-plugin-migrat…
Browse files Browse the repository at this point in the history
…ion-update-issue-existing-recipes

removing excel_can_ac format key to address migration issue [sc-180121]
  • Loading branch information
liamlynch-data authored Apr 26, 2024
2 parents f01530f + 2615b87 commit a188a26
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## [Version 1.0.1](https://github.com/dataiku/dss-plugin-sendmail/releases/tag/v1.0.1) - Feature release - 2024-04

- Recipe configurations saved in version 1.0.0 with "Attachments format" set to "Nothing selected" will no longer send CSV attachments.
If you send CSV attachments in your integrations, please check existing recipes before upgrading to ensure they explicitly use the CSV option.
- Please read if upgrading from version 1.0.0 of the plugin
- For recipe configurations saved in plugin version 1.0.0 if "Attachments format" was set to "Excel", this may instead be set to "do not send attachments" when they are reopened in subsequent versions of the plugin. To ensure such recipes do not cause problems, it is best to open these recipes after plugin upgrade and if needed resave them, ensuring the "Attachments format" is once again set to "Excel".
- Recipe configurations saved in version 1.0.0 with "Attachments format" set to "Nothing selected" will no longer send CSV attachments. If you send CSV attachments in your integrations, please check existing recipes before upgrading to ensure they explicitly use the CSV option.

- Features added
- Generate HTML tables where colors from conditional formatting are applied for inline datasets
Expand Down
12 changes: 8 additions & 4 deletions custom-recipes/send-mails-from-contacts-dataset/recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,29 @@
"name": "attachment_type",
"label" : "Attachments format",
"type": "SELECT",
"selectChoices" : [
{"value": "send_no_attachments", "label": "Do not send attachments"},
{"value": "excel", "label": "Excel"},
{"value": "csv", "label": "CSV"}
],
"defaultValue" : "send_no_attachments",
"getChoicesFromPython": true,
"description" : "File format for attachments"
},

{
"name": "sep_cond_format",
"label": "Conditional formatting",
"type": "SEPARATOR",
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel_can_ac')"
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel')"
},

{
"name": "apply_coloring_excel",
"label" : "Apply conditional formatting",
"description" : "Color cells by rules, when applicable in the HTML body. Will also be applied when attachment format is Excel.",
"description" : "Color cells by rules, when applicable in the HTML body and Excel attachments. Full support in DSS 12.6.2 and above.",
"defaultValue" : true,
"type": "BOOLEAN",
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel_can_ac')"
"visibilityCondition" : "(model.body_format == 'html') || (model.attachment_type == 'excel')"
}
]
}
8 changes: 6 additions & 2 deletions python-lib/dku_attachment_handling.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dku_email_client import AttachmentFile
from dku_support_detection import supports_dataset_to_html
from dku_support_detection import supports_dataset_to_html, supports_messaging_channels_and_conditional_formatting
import logging
import dataiku


def attachments_template_dict(attachment_datasets, home_project_key, apply_coloring):
Expand Down Expand Up @@ -47,12 +48,15 @@ def build_attachment_files(attachment_datasets, attachment_type, apply_coloring_
return []

logging.info(f"Building attachments, type: {attachment_type}, apply colouring? {apply_coloring_excel}")

# "excel_can_ac" was used to indicate excel in version 1.0.0 of the plugin - but it caused migration problems, so we got rid of it (see SC 80121)
# Still, if the config has "excel_can_ac" and is run from the flow, we want to treat as excel (it means the user saved in v1.0.0 and did not reopen it)
is_excel = attachment_type == "excel" or attachment_type == "excel_can_ac"

format_params = None
if is_excel:
request_fmt = "excel"
if apply_coloring_excel and attachment_type == "excel_can_ac":
if apply_coloring_excel and supports_messaging_channels_and_conditional_formatting(dataiku.api_client()):
format_params = {"applyColoring": True}
else:
request_fmt = "tsv-excel-header"
Expand Down
5 changes: 4 additions & 1 deletion python-lib/dku_support_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ def supports_dataset_to_html(dataset):
# Check for existence to_html() method we added in 12.6.2
return hasattr(dataset.__class__, "to_html") and callable(getattr(dataset.__class__, "to_html"))


def supports_messaging_channels_and_conditional_formatting(dss_client):
# Check for existence of messaging channel API we added in 12.6
# If this is here we also support conditional formatting, as this was done in the same version
return callable(getattr(dss_client, "list_messaging_channels", None))
19 changes: 1 addition & 18 deletions resource/dynamic_form.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from dss_selector_choices import DSSSelectorChoices, SENDER_SUFFIX
from dku_support_detection import supports_messaging_channels_and_conditional_formatting
import dataiku


def supports_messaging_channels_and_conditional_formatting(dss_client):
# Check for existence of messaging channel API we added in 12.6
# If this is here we also support conditional formatting, as this was done in the same version
return callable(getattr(dss_client, "list_messaging_channels", None))


def do(payload, config, plugin_config, inputs):
dss_client = dataiku.api_client()
parameter_name = payload.get("parameterName")
Expand All @@ -32,15 +27,3 @@ def do(payload, config, plugin_config, inputs):
# If there is no choice, put SMTP there but with a key of None, so it will be the default instead of "Nothing selected"
choices.append("Manually define SMTP", None)
return choices.to_dss()

if parameter_name == "attachment_type":
choices = DSSSelectorChoices()
choices.append("Do not send attachments", "send_no_attachments")
if supports_messaging_channels_and_conditional_formatting(dss_client):
# Added excel and give it the key excel_can_ac to indicate to the UI that we can show the
# apply coloring ("apply conditional formatting") option
choices.append("Excel", "excel_can_ac")
else:
choices.append("Excel", "excel")
choices.append("CSV", "csv")
return choices.to_dss()

0 comments on commit a188a26

Please sign in to comment.