Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alerts): enable tab selection for dashboard alerts/reports #29096

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

fisjac
Copy link
Contributor

@fisjac fisjac commented Jun 5, 2024

SUMMARY

Implements a new feature enabling a tab to be selected as a view for an alert/report. When a dashboard is selected as the content for a report, an antd TreeSelect component is rendered to load and select tab options. When selected, the tab selection is added to the report payload as an anchor.

On execution, the feature takes advantage of existing logic for the report.extra.dashboard.anchor_tab attribute of the ReportSchedule SQLA model. When extra metadata are attached to the report schedule, a permalink is generated with the metadata included, and this permalink is then used to generate screenshots of the selected dashboard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

https://www.loom.com/share/e075b22bd5574e30bcf3bbec5984884f?sid=aeefd476-bf0a-4289-b13f-6b5fe2854156

TESTING INSTRUCTIONS

Create a tab or tabs within an existing dashboard
Navigate to the alerts and reports listview from the settings menu
Create a new report
Under the content section select the dashboard
A selection field for tabs should appear with the tabs available within the select options
select a tab and save the report with the other required fields
at the selected interval, a report should be sent out with the selected tab in focus

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: ALERT_REPORTS, ALERT_REPORT_TABS
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions bot added api Related to the REST API dependencies:npm labels Jun 5, 2024
@dosubot dosubot bot added alert-reports Namespace | Anything related to the Alert & Reports feature dashboard Namespace | Anything related to the Dashboard labels Jun 5, 2024
@fisjac fisjac marked this pull request as draft June 5, 2024 16:45
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 63.04348% with 17 lines in your changes missing coverage. Please review.

Project coverage is 70.39%. Comparing base (76d897e) to head (0001f9f).
Report is 477 commits behind head on master.

Files Patch % Lines
...-frontend/src/features/alerts/AlertReportModal.tsx 61.36% 14 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #29096      +/-   ##
==========================================
+ Coverage   60.48%   70.39%   +9.91%     
==========================================
  Files        1931     1969      +38     
  Lines       76236    78935    +2699     
  Branches     8568     9014     +446     
==========================================
+ Hits        46114    55570    +9456     
+ Misses      28017    21150    -6867     
- Partials     2105     2215     +110     
Flag Coverage Δ
hive 49.10% <50.00%> (-0.07%) ⬇️
javascript 58.10% <61.36%> (+0.39%) ⬆️
mysql 76.91% <100.00%> (?)
postgres 77.00% <100.00%> (?)
presto 53.66% <50.00%> (-0.15%) ⬇️
python 83.69% <100.00%> (+20.20%) ⬆️
sqlite 76.48% <100.00%> (?)
unit 59.89% <50.00%> (+2.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@john-bodley john-bodley added review:checkpoint Last PR reviewed during the daily review standup review:draft and removed review:checkpoint Last PR reviewed during the daily review standup labels Jun 5, 2024
@geido geido requested review from kgabryje and geido June 10, 2024 16:18
@fisjac fisjac force-pushed the ar-tabs/tree-select branch 2 times, most recently from 0361493 to 0cbe1ac Compare June 25, 2024 17:04
@github-actions github-actions bot removed the api Related to the REST API label Jun 25, 2024
@github-actions github-actions bot added the api Related to the REST API label Jun 25, 2024
@github-actions github-actions bot removed the api Related to the REST API label Jun 25, 2024
superset-frontend/src/features/alerts/AlertReportModal.tsx Outdated Show resolved Hide resolved
superset-frontend/src/features/alerts/AlertReportModal.tsx Outdated Show resolved Hide resolved
if dashboard_state := self._report_schedule.extra.get("dashboard"):
if (
dashboard_state := self._report_schedule.extra.get("dashboard")
) and feature_flag_manager.is_feature_enabled("ALERT_REPORT_TABS"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be an and?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the logic here is saying that if there is dashboard metadata and the feature flag is enabled, open in a stateful permalink, else open in the normal url without permalinks.

Copy link
Member

@geido geido Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I am saying is that now this is only applied if the ALERT_REPORT_TABS is enabled but shouldn't it be applied anyway if there is an extra parameter? Is there a reason to tie this to the ALERT_REPORT_TABS FF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rationale for hiding that functionality behind the ALERT_REPORT_TABS FF was that if a report was saved with an extra parameter, then the FF was turned off, there would no longer be an interface for viewing/updating the currently selected tab. It seemed more intuitive to have the behavior default to ignoring the extra parameter altogether while the FF was disabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are confident that extra is only used for this use case, then it's good.

@yousoph
Copy link
Member

yousoph commented Jul 17, 2024

/testenv up FLAG_ALERT_REPORTS = True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://35.94.63.93:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@yousoph
Copy link
Member

yousoph commented Jul 18, 2024

/testenv up FEATURE_ALERT_REPORTS = True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://34.221.90.242:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@yousoph
Copy link
Member

yousoph commented Jul 18, 2024

/testenv up FEATURE_ALERT_REPORTS=True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://35.94.142.6:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@fisjac fisjac force-pushed the ar-tabs/tree-select branch 2 times, most recently from 8b6f683 to db7c487 Compare July 19, 2024 17:07
@yousoph
Copy link
Member

yousoph commented Jul 22, 2024

/testenv up FEATURE_ALERT_REPORTS=True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://34.214.205.147:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

const { tab_tree: tabTree, all_tabs: allTabs } = response.json.result;
setTabOptions(tabTree);
if (currentAlert?.extra?.dashboard?.anchor) {
if (!(currentAlert?.extra?.dashboard?.anchor in allTabs)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are already checking above if this exists. Maybe it would help readability to move it inside a const.

const anchor = currentAlert?.extra?.dashboard?.anchor
if (anchor && !anchor in allTabs)...

superset-frontend/src/features/alerts/AlertReportModal.tsx Outdated Show resolved Hide resolved
superset-frontend/src/features/alerts/AlertReportModal.tsx Outdated Show resolved Hide resolved
if dashboard_state := self._report_schedule.extra.get("dashboard"):
if (
dashboard_state := self._report_schedule.extra.get("dashboard")
) and feature_flag_manager.is_feature_enabled("ALERT_REPORT_TABS"):
Copy link
Member

@geido geido Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I am saying is that now this is only applied if the ALERT_REPORT_TABS is enabled but shouldn't it be applied anyway if there is an extra parameter? Is there a reason to tie this to the ALERT_REPORT_TABS FF?

superset-frontend/src/features/alerts/AlertReportModal.tsx Outdated Show resolved Hide resolved
@kasiazjc
Copy link
Contributor

Functionality wise - looks good! Thanks @fisjac

@@ -593,6 +605,22 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
setNotificationAddState('active');
};

const updateAnchorState = (value: any) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use more specific type?

Copy link
Contributor Author

@fisjac fisjac Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I'd like for this to be typed as string | undefined, but I'm running into issues from antd's typing for the onSelect prop which is typed as 'RawValueType | LabelValueType' and throws an error on compile when typed as such. I've used any as a workaround.

@yousoph
Copy link
Member

yousoph commented Jul 24, 2024

/testenv up FEATURE_ALERT_REPORTS=True FEATURE_ALERT_REPORT_TABS = True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://54.213.240.222:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@yousoph
Copy link
Member

yousoph commented Jul 24, 2024

/testenv up FEATURE_ALERT_REPORTS=True FEATURE_ALERT_REPORT_TABS=True

Copy link
Contributor

@yousoph Ephemeral environment spinning up at http://54.213.76.60:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rusackas
Copy link
Member

Any reason not to merge this? Itchy trigger finger kicking in ;)

@kasiazjc
Copy link
Contributor

Any reason not to merge this? Itchy trigger finger kicking in ;)

there are only reasons to merge it 🤠

@rusackas rusackas merged commit d21d759 into apache:master Jul 30, 2024
38 checks passed
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:tab Related to the usage of tabs in the Dashboard dashboard Namespace | Anything related to the Dashboard size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants