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: allow select tabs for scheduled delivery #11266

Merged

Conversation

Shifan-Gu
Copy link
Contributor

Closes:

Description:

This change allows user to select the tabs of the contents which they want include in the scheduled delivery.

UX:
When include all checkbox is selected, select tabs dropdown would be disabled and scheduled delivery will include all tabs.
Screenshot 2024-08-26 at 14 35 01
When include all checkbox is not selected, then user can select the tabs they want include in the scheduled delivery
Screenshot 2024-08-26 at 14 35 12
Then scheduled delivery will filter content based on the tabs selected.
Screenshot 2024-08-26 at 14 35 29

Reviewer actions

  • I have manually tested the changes in the preview environment
  • I have reviewed the code
  • I understand that "request changes" will block this PR from merging

Copy link

netlify bot commented Aug 26, 2024

👷 Deploy request for peaceful-bassi-cbf284 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2b35ab3

@hamzahc1 hamzahc1 requested review from a team and ZeRego and removed request for a team September 1, 2024 14:10
@hamzahc1
Copy link
Contributor

hamzahc1 commented Sep 1, 2024

@Shifan-Gu do you have the link to the ticket that this PR relates to?

@PriPatel
Copy link
Contributor

PriPatel commented Sep 1, 2024

@hamzahc1 The dev work for this ticket started before I finished speccing the milestone, so there is no spec for this. I can reopen the ticket.

The solution was agreed over a figma file. If I can get a render environment, I'll be able to test this and make sure everything works as expected.

All other changes in the future link to well-specced tickets. this is just an exception!

@owlas owlas requested a deployment to duplicate_feat/select-tabs-in-scheduled-delivery - jaffle_db_pg_13 PR #11336 September 2, 2024 12:18 — with Render Abandoned
@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - headless-browser PR #11336 September 2, 2024 12:18 — with Render Destroyed
@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - lightdash PR #11336 September 2, 2024 12:19 — with Render Destroyed
@ZeRego ZeRego requested a review from PriPatel September 2, 2024 12:53
@ZeRego ZeRego self-assigned this Sep 2, 2024
@ZeRego
Copy link
Contributor

ZeRego commented Sep 2, 2024

@PriPatel
PR env: https://lightdash-pr-11336.onrender.com/login
Reminder that emails are in a sandbox and not sent to your email inbox. Let me know if you need help with this.

Copy link
Contributor

@PriPatel PriPatel left a comment

Choose a reason for hiding this comment

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

Screenshot 2024-09-02 at 14 26 12
  • The checkbox should be selected by default.
  • Change Dashboard Tabs to Tabs
  • !IMPORTANT : If i dont have multiple dashboard tabs, I should not see this option in the form at all. Right now, this is affecting users who don't have multiple tabs and it is confusing
  • This should also affect the delivery if the user has 'image' selected. Right now it only affects .csvs

@Shifan-Gu
Copy link
Contributor Author

Screenshot 2024-09-02 at 14 26 12 * [ ] The checkbox should be selected by default. * [ ] Change `Dashboard Tabs` to `Tabs` * [ ] !IMPORTANT : If i dont have multiple dashboard tabs, I should not see this option in the form at all. Right now, this is affecting users who don't have multiple tabs and it is confusing

Thank you for the comments! @PriPatel, i will update it.

@owlas owlas requested a deployment to duplicate_feat/select-tabs-in-scheduled-delivery - jaffle_db_pg_13 PR #11375 September 3, 2024 15:50 — with Render Abandoned
@owlas owlas deployed to duplicate_feat/select-tabs-in-scheduled-delivery - headless-browser PR #11375 September 3, 2024 15:50 — with Render Active
@ZeRego ZeRego requested a review from PriPatel September 4, 2024 09:37
@owlas owlas deployed to duplicate_feat/select-tabs-in-scheduled-delivery - headless-browser PR #11375 September 6, 2024 17:09 — with Render Active
@ZeRego ZeRego removed their request for review September 16, 2024 11:20
@ZeRego ZeRego removed their assignment Sep 16, 2024
Copy link
Collaborator

@rephus rephus left a comment

Choose a reason for hiding this comment

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

I think we can improve the types on db, replace jsonb with string[].
The rest looks good, once the types are fixed I'll test this on render

packages/backend/src/database/entities/scheduler.ts Outdated Show resolved Hide resolved
}${
selectedTabs
? `?selectedTabs=${encodeURI(
JSON.stringify(selectedTabs),
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't need to do stringify if you use text[] in db

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i removed the stringify call in the model layer, but keep this call because it seems a straightforward way to encode the string array and decode it at the endpoint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, that works, another option is to pass an array using the query parameter multiple times like.

?selectedTabs=tab0&selectedTabs=tab1...

Both ways are accepted

@@ -235,13 240,39 @@ const SchedulerForm: FC<Props> = ({
isThresholdAlert,
itemsMap,
}) => {
const isDashboard = resource && resource.type === 'dashboard';
const isDashboardTabsEnabled = useFeatureFlagEnabled(
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 nice

? getFormValuesFromScheduler({
...savedSchedulerData,
...(isDashboardScheduler(savedSchedulerData) && {
selectedTabs: isDashboardTabsAvailable
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can probably extract all this logic in a variable outside the method call, just for readability.

size="xs"
label="Include all tabs"
labelPosition="right"
checked={allTabsSelected}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be enabled by default, right ?

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, but this is not done by setting a default value for "allTabsSelected", but instead by setting initial the form value "selectedTabs" to include all the tabs, then dynamically derive the value from this form value.

@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - lightdash PR #11375 September 24, 2024 07:02 — with Render Destroyed
@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - lightdash PR #11375 September 24, 2024 07:02 — with Render Destroyed
@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - headless-browser PR #11375 September 24, 2024 07:02 — with Render Destroyed
@owlas owlas temporarily deployed to duplicate_feat/select-tabs-in-scheduled-delivery - headless-browser PR #11375 September 24, 2024 07:03 — with Render Destroyed
Copy link
Collaborator

@rephus rephus left a comment

Choose a reason for hiding this comment

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

The code look ok, but when I was testing, I found some issues.

CSV export

  • not selecting any tab in the csv export, sends an email with nothing in it. Ideally we should prevent the scheduler from being created in the first place... This is a minor bug , which means we could merge this PR without this, and create a separate issue to fix it later.

Screenshot from 2024-09-24 09-20-37

Image export

  • It seems the tab filter is not working, if I try to filter a tab, it always shows me everything. I tested /minimal and hte parameter seems to work, perhaps we are not passing the paramenter correctly inside the headless browser.
    Screenshot from 2024-09-24 09-25-58
    image
  • selecting no tabs simply returns all tabs, I believe this is related with the previous point, where we don't do any filtering. Similar to the CSV UI, we should not allow the scheduler to be created.

I also tested this without tabs, and it works as expected, so it doesn't break dashboards without tabs 👍 that's great.

@@ -317,6 323,10 @@ export class SchedulerModel {
: null,
notification_frequency:
scheduler.notificationFrequency || null,
selected_tabs:
'selectedTabs' in scheduler && scheduler.selectedTabs
? (scheduler.selectedTabs as string[])
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this casting needed here ?

@Shifan-Gu
Copy link
Contributor Author

The code look ok, but when I was testing, I found some issues.

CSV export

  • not selecting any tab in the csv export, sends an email with nothing in it. Ideally we should prevent the scheduler from being created in the first place... This is a minor bug , which means we could merge this PR without this, and create a separate issue to fix it later.

Screenshot from 2024-09-24 09-20-37

Image export

  • It seems the tab filter is not working, if I try to filter a tab, it always shows me everything. I tested /minimal and hte parameter seems to work, perhaps we are not passing the paramenter correctly inside the headless browser.
    Screenshot from 2024-09-24 09-25-58
    image
  • selecting no tabs simply returns all tabs, I believe this is related with the previous point, where we don't do any filtering. Similar to the CSV UI, we should not allow the scheduler to be created.

I also tested this without tabs, and it works as expected, so it doesn't break dashboards without tabs 👍 that's great.

Hi @rephus thanks for the testing work!

I have some issue with my local env to reproduce the issue, so haven't figure out the root cause for the issue. but i have a question for you is that, are you using standalone scheduler deployment to test this change?

Copy link
Collaborator

@rephus rephus left a comment

Choose a reason for hiding this comment

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

Nice work

@rephus rephus merged commit 55587b8 into lightdash:main Sep 26, 2024
6 checks passed
lightdash-bot pushed a commit that referenced this pull request Sep 26, 2024
# [0.1274.0](0.1273.5...0.1274.0) (2024-09-26)

### Features

* allow select tabs for scheduled delivery ([#11266](#11266)) ([55587b8](55587b8))
@lightdash-bot
Copy link
Collaborator

🎉 This PR is included in version 0.1274.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

agha4to pushed a commit to agha4to/lightdash that referenced this pull request Oct 3, 2024
* feat: allow select tabs for scheduled delivery

* support image option

* handle delete tabs

* handle delete tabs

* change selected tabs db type

* fix image export issue
agha4to pushed a commit to agha4to/lightdash that referenced this pull request Oct 3, 2024
# [0.1274.0](lightdash/lightdash@0.1273.5...0.1274.0) (2024-09-26)

### Features

* allow select tabs for scheduled delivery ([lightdash#11266](lightdash#11266)) ([55587b8](lightdash@55587b8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants