Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

feat(sdk-package, embed-js): Subscription supports for SDK/EAJS (#66249)

Mahatthana (Kelvin) Nomsawadi61b0f5f50305
diff --git a/.github/workflows/embedding-sdk-component-tests.yml b/.github/workflows/embedding-sdk-component-tests.yml
index 05180a10a3a..44b117b7288 100644
--- a/.github/workflows/embedding-sdk-component-tests.yml
+++ b/.github/workflows/embedding-sdk-component-tests.yml
@@ -28,6 +28,19 @@ jobs:
steps:
- uses: actions/checkout@v4
+ - name: Prepare Docker containers
+ uses: ./.github/actions/e2e-prepare-containers
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ maildev: true
+ openldap: false
+ webhook: false
+ snowplow: false
+ postgres: false
+ mysql: false
+ mongo: false
+
- name: Retrieve uberjar artifact for ee
uses: ./.github/actions/fetch-artifact
with:
@@ -156,6 +169,19 @@ jobs:
with:
ref: ${{ needs.decide-target-ref.outputs.target-ref }}
+ - name: Prepare Docker containers
+ uses: ./.github/actions/e2e-prepare-containers
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ maildev: true
+ openldap: false
+ webhook: false
+ snowplow: false
+ postgres: false
+ mysql: false
+ mongo: false
+
- name: Get the actual commit SHA from the checked out branch
id: get-commit-sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png
index 9bb46c0b7f3..322270907f1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png
index 57778a27a87..2153c848cf7 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png
index be30b1dbbc5..02795a677e3 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png
index 928d1d0dfa5..e4c0ed8e05b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png
index 1fe3d9c1b9f..aced89a189b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png
index 38269ec9003..e273bbee9fe 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Results.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Results.png
index af31c0e6e5d..e1d49191154 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Results.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Results.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Narrow_With_Many_Tabs.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Narrow_With_Many_Tabs.png
index 6e62afdf400..f0b5c00bfa1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Narrow_With_Many_Tabs.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Narrow_With_Many_Tabs.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png
index fcc0bd653eb..61eae389bec 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png
index 75740511faf..0c8878f5b21 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png
index 16e08b1214c..1306b8dafff 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png
index 1d9ada5901c..e0343f0f99d 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png
index 110a6a16862..e9c9b3ebbaf 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png
index 03578cf7783..2176ecded2f 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png
index d6094643d6b..ad6d5ad23e8 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png
index b4becdf2f79..f529d8fec5b 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png
index fb5aa293163..7b35304e969 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png
index 6267198f36b..b504c654d7e 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png
index f61b8cec768..07b75b8dcee 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png
index e9201f6f78b..3070acbc631 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png
index eb7a5567842..abc613d6b32 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png
index 9dca88c1716..0b961c8ee25 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png
index 3ab943fec67..e51bd7a3ded 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png
index 985b171421a..9fdf22230a0 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png
index 76be519e4cf..2f87882b2b6 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png
index be26ae8f7a3..8db2054853d 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png
index 05df61de6eb..9c1aac937eb 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png
index 8b578bb0bb9..4bf397c84c4 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png
index c859ffd0f80..acca9e6cfa9 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png
index f8dfcdf87c8..54f71d54dd0 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png
index 0ebb2bc599e..32016f8f47f 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png
index cf7756bf9e9..f85897304b0 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png
index 4392ce74c9e..1a6108a2d1f 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png
index c5c6312d5e1..9bd45172dd5 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png
index 5d017beba62..c86d8ac34f4 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png
index 4392ce74c9e..1a6108a2d1f 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png
index 9128da5e2fa..7ad5a3a7c52 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png
index 5a2937b244c..1da6fd8bdc1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png
index 5a2937b244c..1da6fd8bdc1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png
index 684513d2c37..6a00cf40c36 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png
index 442694b95d6..cf13f1ce89d 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png
index fc965c39cd0..ae2249e7ef0 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png
index 3bedba47260..3db057423d1 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png
index 60516d07497..43deb7fcc12 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png
index 8b81da8a14d..8ea3d441b40 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png
index 8b075d99316..1ef346c16cd 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png
index 09ca1eaee72..f5fe6d50c6c 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png
index 2c86d80ae93..c3818d60636 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png
index ba42def0737..d04e507eff8 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png
index 23a9c364a27..41871efcec7 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png
index eaa8cd7fa70..28048216111 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png
index 6839eefbe9b..d04e507eff8 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png
index fec163ba24e..56842a425dc 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png
index 87587f692bd..1b2c0cd8299 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png
index f3872ec1269..323376b2170 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png
index 51199d7dab8..bc53dc5ac10 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png differ
diff --git a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts
index 5160b619b5c..205e082e7fc 100644
--- a/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts
+++ b/e2e/support/helpers/e2e-embedding-iframe-sdk-helpers.ts
@@ -187,21 +187,19 @@ const convertPropertiesToEmbedTagAttributes = (
* @param {EnabledAuthMethods[]} enabledAuthMethods - The authentication methods to enable.
*/
export function prepareSdkIframeEmbedTest({
- withTokenFeatures = true,
+ withToken = "bleeding-edge",
enabledAuthMethods = ["jwt"],
signOut = false,
}: {
- withTokenFeatures?: boolean;
+ withToken?: false | "starter" | "bleeding-edge";
enabledAuthMethods?: EnabledAuthMethods[];
signOut?: boolean;
} = {}) {
restore();
cy.signInAsAdmin();
- if (withTokenFeatures) {
- activateToken("bleeding-edge");
- } else {
- activateToken("starter");
+ if (withToken) {
+ activateToken(withToken);
}
cy.request("PUT", "/api/setting/enable-embedding-simple", {
diff --git a/e2e/test-component/scenarios/embedding-sdk/subscriptions.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/subscriptions.cy.spec.tsx
new file mode 100644
index 00000000000..a4277385c73
--- /dev/null
+++ b/e2e/test-component/scenarios/embedding-sdk/subscriptions.cy.spec.tsx
@@ -0,0 +1,129 @@
+const { H } = cy;
+import {
+ EditableDashboard,
+ InteractiveDashboard,
+ StaticDashboard,
+} from "@metabase/embedding-sdk-react";
+
+import {
+ ORDERS_DASHBOARD_DASHCARD_ID,
+ ORDERS_QUESTION_ID,
+} from "e2e/support/cypress_sample_instance_data";
+import { createDashboard, getTextCardDetails } from "e2e/support/helpers";
+import { getSdkRoot } from "e2e/support/helpers/e2e-embedding-sdk-helpers";
+import { mountSdkContent } from "e2e/support/helpers/embedding-sdk-component-testing";
+import { signInAsAdminAndEnableEmbeddingSdk } from "e2e/support/helpers/embedding-sdk-testing";
+import { mockAuthProviderAndJwtSignIn } from "e2e/support/helpers/embedding-sdk-testing/embedding-sdk-helpers";
+
+describe("scenarios > embedding-sdk > subscriptions", () => {
+ beforeEach(() => {
+ signInAsAdminAndEnableEmbeddingSdk();
+
+ const textCard = getTextCardDetails({ col: 16, text: "Test text card" });
+ const questionCard = {
+ id: ORDERS_DASHBOARD_DASHCARD_ID,
+ card_id: ORDERS_QUESTION_ID,
+ row: 0,
+ col: 0,
+ size_x: 16,
+ size_y: 8,
+ visualization_settings: {
+ "card.title": "Test question card",
+ },
+ };
+
+ createDashboard({
+ name: "Embedding SDK Test Dashboard",
+ dashcards: [questionCard, textCard],
+ }).then(({ body: dashboard }) => {
+ cy.wrap(dashboard.id).as("dashboardId");
+ cy.wrap(dashboard.entity_id).as("dashboardEntityId");
+ });
+
+ cy.signOut();
+
+ mockAuthProviderAndJwtSignIn();
+
+ cy.signInAsAdmin();
+ H.setupSMTP();
+
+ cy.intercept("POST", "/api/pulse").as("createPulse");
+ });
+
+ describe("adding a subscription", () => {
+ it("should work in StaticDashboard", () => {
+ cy.get("@dashboardId").then((dashboardId) => {
+ cy.signOut();
+ mockAuthProviderAndJwtSignIn();
+
+ mountSdkContent(
+ <StaticDashboard dashboardId={dashboardId} withSubscriptions />,
+ );
+ });
+
+ getSdkRoot().within(() => {
+ cy.findByText("Embedding SDK Test Dashboard").should("be.visible");
+ cy.icon("subscription").click();
+ cy.findByText("Email this dashboard").should("be.visible");
+
+ cy.findByRole("button", { name: "Done" }).click();
+ cy.wait("@createPulse");
+
+ cy.findByText("Subscriptions").should("be.visible");
+
+ // check that there are 2 subscriptions
+ cy.findByText("Emailed hourly").should("be.visible");
+ });
+ });
+
+ it("should work in InteractiveDashboard", () => {
+ cy.get("@dashboardId").then((dashboardId) => {
+ cy.signOut();
+ mockAuthProviderAndJwtSignIn();
+
+ mountSdkContent(
+ <InteractiveDashboard dashboardId={dashboardId} withSubscriptions />,
+ );
+ });
+
+ getSdkRoot().within(() => {
+ cy.findByText("Embedding SDK Test Dashboard").should("be.visible");
+ cy.icon("subscription").click();
+ cy.findByText("Email this dashboard").should("be.visible");
+
+ cy.findByRole("button", { name: "Done" }).click();
+ cy.wait("@createPulse");
+
+ cy.findByText("Subscriptions").should("be.visible");
+
+ // check that there are 2 subscriptions
+ cy.findByText("Emailed hourly").should("be.visible");
+ });
+ });
+
+ it("should work in EditableDashboard", () => {
+ cy.get("@dashboardId").then((dashboardId) => {
+ cy.signOut();
+ mockAuthProviderAndJwtSignIn();
+
+ mountSdkContent(
+ <EditableDashboard dashboardId={dashboardId} withSubscriptions />,
+ );
+ });
+
+ getSdkRoot().within(() => {
+ cy.findByText("Embedding SDK Test Dashboard").should("be.visible");
+ cy.icon("subscription").click();
+ cy.findByText("Email this dashboard").should("be.visible");
+
+ cy.findByRole("button", { name: "Done" }).click();
+ cy.wait("@createPulse");
+
+ cy.findByText("Subscriptions").should("be.visible");
+
+ // check that there are 2 subscriptions
+ cy.findByText("Emailed hourly").should("be.visible");
+ });
+ });
+ });
+});
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
index 46497bfab9f..7882c18848a 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
@@ -16,6 +16,82 @@ const QUESTION_NAME = "Orders, Count";
const suiteTitle =
"scenarios > embedding > sdk iframe embed setup > select embed options";
+describe("OSS", { tags: "@OSS" }, () => {
+ describe(suiteTitle, () => {
+ beforeEach(() => {
+ H.restore();
+ H.resetSnowplow();
+ cy.signInAsAdmin();
+ H.enableTracking();
+ H.updateSetting("enable-embedding-simple", true);
+
+ cy.intercept("GET", "/api/dashboard/**").as("dashboard");
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+
+ mockEmbedJsToDevServer();
+ });
+
+ it("should show upsell for Allow subscriptions option", () => {
+ navigateToEmbedOptionsStep({
+ experience: "dashboard",
+ resourceName: DASHBOARD_NAME,
+ });
+
+ assertUpsellForOption("Existing Metabase session");
+ assertUpsellForOption("Single sign-on (SSO)");
+ assertUpsellForOption("Allow people to drill through on data points");
+ assertUpsellForOption("Allow downloads");
+ assertUpsellForOption("Allow subscriptions");
+ });
+ });
+});
+
+describe("EE without license", () => {
+ describe(suiteTitle, () => {
+ beforeEach(() => {
+ H.restore();
+ H.resetSnowplow();
+ cy.signInAsAdmin();
+ H.activateToken("starter");
+ H.enableTracking();
+ H.updateSetting("enable-embedding-simple", true);
+
+ cy.intercept("GET", "/api/dashboard/**").as("dashboard");
+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");
+
+ mockEmbedJsToDevServer();
+ });
+
+ it("should show upsell for Allow subscriptions option", () => {
+ navigateToEmbedOptionsStep({
+ experience: "dashboard",
+ resourceName: DASHBOARD_NAME,
+ });
+
+ assertUpsellForOption("Existing Metabase session");
+ assertUpsellForOption("Single sign-on (SSO)");
+ assertUpsellForOption("Allow people to drill through on data points");
+ assertUpsellForOption("Allow downloads");
+ assertUpsellForOption("Allow subscriptions");
+ });
+ });
+});
+
+function assertUpsellForOption(label: string) {
+ getEmbedSidebar()
+ .findByLabelText(label)
+ .closest("[data-testid=tooltip-warning]")
+ .icon("gem")
+ .realHover();
+
+ H.hovercard().should("contain.text", "Get more powerful embedding");
+ H.hovercard().should(
+ "contain.text",
+ "Upgrade to get access to embeds with single sign-on, drill through, advanced theming, the SDK for React, and more.",
+ );
+ H.hovercard().should("contain.text", "Upgrade to Metabase Pro");
+}
+
describe(suiteTitle, () => {
beforeEach(() => {
H.restore();
@@ -126,7 +202,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- "settings=custom,experience=dashboard,auth=user-session,drills=false,withDownloads=false,withTitle=true,isSaveEnabled=false,theme=default",
+ "settings=custom,experience=dashboard,auth=user-session,drills=false,withDownloads=false,withSubscriptions=false,withTitle=true,isSaveEnabled=false,theme=default",
});
codeBlock().should("contain", 'drills="false"');
@@ -137,6 +213,7 @@ describe(suiteTitle, () => {
experience: "dashboard",
resourceName: DASHBOARD_NAME,
});
+ cy.findByLabelText("Existing Metabase session").click();
getEmbedSidebar()
.findByLabelText("Allow downloads")
@@ -162,10 +239,121 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- 'settings=custom,experience=dashboard,guestEmbedEnabled=false,auth=guest-embed,drills=false,withDownloads=true,withTitle=true,params={"disabled":0,"locked":0,"enabled":0},theme=default',
+ "settings=custom,experience=dashboard,auth=user-session,drills=true,withDownloads=true,withSubscriptions=false,withTitle=true,isSaveEnabled=false,theme=default",
});
- codeBlock().should("contain", 'with-downloads="true"');
+ codeBlock().should("contain", 'with-subscriptions="false"');
+ });
+
+ it("cannot select subscriptions for dashboard when email is not set up", () => {
+ navigateToEmbedOptionsStep({
+ experience: "dashboard",
+ resourceName: DASHBOARD_NAME,
+ });
+
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .should("not.be.checked")
+ .and("be.disabled");
+
+ cy.log("Email warning should only be shown on non-guest embedding");
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .closest("[data-testid=tooltip-warning]")
+ .icon("info")
+ .realHover();
+ H.tooltip().should(
+ "contain.text",
+ "Not available if Guest Mode is selected",
+ );
+
+ H.getSimpleEmbedIframeContent()
+ .findByRole("button", { name: "Subscriptions" })
+ .should("not.exist");
+
+ cy.log("snippet should show subscriptions as false");
+ getEmbedSidebar().findByText("Get code").click();
+
+ H.expectUnstructuredSnowplowEvent({
+ event: "embed_wizard_options_completed",
+ event_detail: "settings=default",
+ });
+
+ cy.log("test non-guest embeds");
+ getEmbedSidebar().within(() => {
+ cy.button("Back").click();
+ cy.findByLabelText("Existing Metabase session").click();
+ cy.findByLabelText("Allow subscriptions")
+ .closest("[data-testid=tooltip-warning]")
+ .icon("info")
+ .realHover();
+ });
+ H.hovercard().should(
+ "contain.text",
+ "To allow subscriptions, set up email in admin settings",
+ );
+ });
+
+ it("toggles subscriptions for dashboard when email is set up", () => {
+ H.setupSMTP();
+
+ navigateToEmbedOptionsStep({
+ experience: "dashboard",
+ resourceName: DASHBOARD_NAME,
+ });
+ cy.findByLabelText("Existing Metabase session").click();
+
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .should("not.be.checked");
+
+ H.getSimpleEmbedIframeContent()
+ .findByRole("button", { name: "Subscriptions" })
+ .should("not.exist");
+
+ cy.log("turn on subscriptions");
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .click()
+ .should("be.checked");
+
+ cy.log(
+ "assert that unchecking subscriptions will close the subscription sidebar",
+ );
+ H.getSimpleEmbedIframeContent().within(() => {
+ cy.findByRole("button", { name: "Subscriptions" })
+ .should("be.visible")
+ .click();
+
+ cy.findByRole("heading", { name: "Email this dashboard" }).should(
+ "be.visible",
+ );
+ });
+
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .click()
+ .should("not.be.checked");
+ H.getSimpleEmbedIframeContent()
+ .findByRole("heading", { name: "Email this dashboard" })
+ .should("not.exist");
+
+ cy.log("toggle subscriptions back on");
+ getEmbedSidebar()
+ .findByLabelText("Allow subscriptions")
+ .click()
+ .should("be.checked");
+
+ cy.log("snippet should be updated");
+ getEmbedSidebar().findByText("Get code").click();
+
+ H.expectUnstructuredSnowplowEvent({
+ event: "embed_wizard_options_completed",
+ event_detail:
+ "settings=custom,experience=dashboard,auth=user-session,drills=true,withDownloads=false,withSubscriptions=true,withTitle=true,isSaveEnabled=false,theme=default",
+ });
+
+ codeBlock().should("contain", 'with-subscriptions="true"');
});
it("toggles dashboard title for dashboards", () => {
@@ -198,7 +386,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- 'settings=custom,experience=dashboard,guestEmbedEnabled=false,auth=guest-embed,drills=false,withDownloads=false,withTitle=false,params={"disabled":0,"locked":0,"enabled":0},theme=default',
+ 'settings=custom,experience=dashboard,guestEmbedEnabled=false,auth=guest-embed,drills=false,withDownloads=false,withSubscriptions=false,withTitle=false,params={"disabled":0,"locked":0,"enabled":0},theme=default',
});
codeBlock().should("contain", 'with-title="false"');
@@ -472,7 +660,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- 'settings=custom,experience=dashboard,guestEmbedEnabled=false,auth=guest-embed,drills=false,withDownloads=false,withTitle=true,params={"disabled":0,"locked":0,"enabled":0},theme=custom',
+ 'settings=custom,experience=dashboard,guestEmbedEnabled=false,auth=guest-embed,drills=false,withDownloads=false,withSubscriptions=false,withTitle=true,params={"disabled":0,"locked":0,"enabled":0},theme=custom',
});
codeBlock().should("contain", '"theme": {');
@@ -505,6 +693,14 @@ describe(suiteTitle, () => {
});
it("derives colors for dark theme palette", () => {
+ /**
+ * There's a problem on CI where the hovercard on allow subscriptions is open
+ * when email is not set up and that is counted in H.popover() making H.popover().within() failed.
+ *
+ * Setting up the email should prevent such a hovercard from showing up.
+ */
+ H.setupSMTP();
+
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
@@ -520,12 +716,14 @@ describe(suiteTitle, () => {
cy.log("change primary text color");
cy.findByTestId("text-primary-color-picker").findByRole("button").click();
+
H.popover().within(() => {
cy.findByDisplayValue("#303D46").clear().type("#F1F1F1");
});
cy.log("change background color");
cy.findByTestId("background-color-picker").findByRole("button").click();
+
H.popover().within(() => {
cy.findByDisplayValue("#FFFFFF").clear().type("#121212");
});
@@ -541,7 +739,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- "settings=custom,experience=dashboard,auth=user-session,drills=true,withDownloads=false,withTitle=true,isSaveEnabled=false,theme=custom",
+ "settings=custom,experience=dashboard,auth=user-session,drills=true,withDownloads=false,withSubscriptions=false,withTitle=true,isSaveEnabled=false,theme=custom",
});
// derived-colors-for-embed-flow.unit.spec.ts contains the tests for other derived colors.
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
index 2e2d0804a75..ef0fed22889 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/custom-elements-api.cy.spec.ts
@@ -14,7 +14,7 @@ describe("scenarios > embedding > sdk iframe embedding > custom elements api", (
beforeEach(() => {
cy.signInAsAdmin();
H.prepareSdkIframeEmbedTest({
- withTokenFeatures: true,
+ withToken: "bleeding-edge",
});
});
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
index 896f698c723..897383a603c 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/embed-options.cy.spec.ts
@@ -6,6 +6,139 @@ import {
const { H } = cy;
+describe("OSS", { tags: "@OSS" }, () => {
+ describe("scenarios > embedding > Embedded Analytics JS (EAJS)", () => {
+ beforeEach(() => {
+ H.prepareSdkIframeEmbedTest({
+ withToken: false,
+ enabledAuthMethods: ["api-key"],
+ });
+ H.setupSMTP();
+ cy.signOut();
+ });
+
+ describe("dashboards", () => {
+ it("should not render a subscription button even with `with-subscriptions=true`", () => {
+ cy.get<string>("@apiKey").then((apiKey) => {
+ const frame = H.loadSdkIframeEmbedTestPage({
+ elements: [
+ {
+ component: "metabase-dashboard",
+ attributes: {
+ dashboardId: ORDERS_DASHBOARD_ID,
+ withSubscriptions: true,
+ },
+ },
+ ],
+ metabaseConfig: { apiKey },
+ });
+
+ frame.within(() => {
+ cy.findByRole("button", { name: "Subscriptions" }).should(
+ "not.exist",
+ );
+ });
+ });
+ });
+ });
+ });
+});
+
+describe("EE without license", () => {
+ describe("scenarios > embedding > Embedded Analytics JS (EAJS)", () => {
+ beforeEach(() => {
+ H.prepareSdkIframeEmbedTest({
+ withToken: "starter",
+ enabledAuthMethods: ["api-key"],
+ });
+ H.setupSMTP();
+ cy.signOut();
+ });
+
+ describe("dashboards", () => {
+ it("should not render a subscription button even with `with-subscriptions=true`", () => {
+ cy.get<string>("@apiKey").then((apiKey) => {
+ const frame = H.loadSdkIframeEmbedTestPage({
+ elements: [
+ {
+ component: "metabase-dashboard",
+ attributes: {
+ dashboardId: ORDERS_DASHBOARD_ID,
+ withSubscriptions: true,
+ },
+ },
+ ],
+ metabaseConfig: { apiKey },
+ });
+
+ frame.within(() => {
+ cy.findByRole("button", { name: "Subscriptions" }).should(
+ "not.exist",
+ );
+ });
+ });
+ });
+ });
+ });
+});
+
+describe("EE", () => {
+ describe("scenarios > embedding > Embedded Analytics JS (EAJS)", () => {
+ beforeEach(() => {
+ H.prepareSdkIframeEmbedTest({ withToken: "bleeding-edge" });
+ H.setupSMTP();
+ cy.signOut();
+ });
+
+ describe("dashboards", () => {
+ it("should render a subscription button with `with-subscriptions=true`", () => {
+ const frame = H.loadSdkIframeEmbedTestPage({
+ elements: [
+ {
+ component: "metabase-dashboard",
+ attributes: {
+ dashboardId: ORDERS_DASHBOARD_ID,
+ withSubscriptions: true,
+ },
+ },
+ ],
+ });
+
+ frame.within(() => {
+ cy.findByRole("button", { name: "Subscriptions" })
+ .should("be.visible")
+ .click();
+ dashboardSidebar().within(() => {
+ cy.log("set up the first subscription");
+ cy.findByRole("button", { name: "Done" }).click();
+
+ cy.log("set up the second subscription");
+ cy.button("Set up a new schedule").click();
+ cy.findByText("Hourly").click();
+ });
+
+ H.popover().findByRole("option", { name: "Daily" }).click();
+ cy.findByRole("button", { name: "Done" }).click();
+
+ dashboardSidebar().within(() => {
+ // Header
+ cy.findByText("Subscriptions").should("be.visible");
+
+ // Subscription list
+ cy.findAllByText("Bobby Tables").should("have.length", 2);
+ cy.findByText("Emailed hourly").should("be.visible");
+ cy.findByText("Emailed daily at 8:00 AM").should("be.visible");
+ });
+ });
+ });
+ });
+ });
+});
+
+function dashboardSidebar() {
+ return cy.findByRole("complementary");
+}
+
describe("scenarios > embedding > sdk iframe embed options passthrough", () => {
beforeEach(() => {
H.prepareSdkIframeEmbedTest({ signOut: true });
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts
index 8d8c0ce6d2d..cc446f8b089 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/missing-tokens.cy.spec.ts
@@ -3,7 +3,7 @@ const { H } = cy;
describe("scenarios > embedding > sdk iframe embedding > without token features", () => {
beforeEach(() => {
H.prepareSdkIframeEmbedTest({
- withTokenFeatures: false,
+ withToken: "starter",
// JWT requires a valid license to use, so we expect customers to use API keys when testing.
enabledAuthMethods: ["api-key"],
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
index 24811b311d0..e79f1b25ffe 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/view-and-curate-content.cy.spec.ts
@@ -11,7 +11,7 @@ const setupEmbed = (elementHtml: string) => {
describe("scenarios > embedding > sdk iframe embedding > view and curate content", () => {
beforeEach(() => {
cy.signInAsAdmin();
- H.prepareSdkIframeEmbedTest({ withTokenFeatures: true });
+ H.prepareSdkIframeEmbedTest({ withToken: "bleeding-edge" });
});
describe("<metabase-browser> (read-only mode)", () => {
diff --git a/enterprise/frontend/src/embedding-sdk-ee/auth/auth.ts b/enterprise/frontend/src/embedding-sdk-ee/auth/auth.ts
index 46f96c639d4..206c90e0048 100644
--- a/enterprise/frontend/src/embedding-sdk-ee/auth/auth.ts
+++ b/enterprise/frontend/src/embedding-sdk-ee/auth/auth.ts
@@ -23,7 +23,10 @@ import type {
import type { MetabaseAuthConfig } from "embedding-sdk-bundle/types/auth-config";
import { getBuildInfo } from "embedding-sdk-shared/lib/get-build-info";
import { requestSessionTokenFromEmbedJs } from "metabase/embedding/embedding-iframe-sdk/utils";
-import { EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG } from "metabase/embedding-sdk/config";
+import {
+ EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG,
+ isEmbeddingEajs,
+} from "metabase/embedding-sdk/config";
import { samlTokenStorage } from "metabase/embedding-sdk/lib/saml-token-storage";
import type { MetabaseEmbeddingSessionToken } from "metabase/embedding-sdk/types/refresh-token";
import api from "metabase/lib/api";
@@ -121,7 +124,7 @@ const refreshTokenImpl = async (
): Promise<MetabaseEmbeddingSessionToken | null> => {
const state = getState() as SdkStoreState;
- if (EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG.isSimpleEmbedding) {
+ if (isEmbeddingEajs()) {
return requestSessionTokenFromEmbedJs();
}
diff --git a/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.tsx b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.tsx
new file mode 100644
index 00000000000..d92d493ad88
--- /dev/null
+++ b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.tsx
@@ -0,0 +1,32 @@
+import { t } from "ttag";
+
+import type { DashboardSubscriptionsButtonProps } from "embedding-sdk-bundle/components/public/subscriptions";
+import { ToolbarButton } from "metabase/common/components/ToolbarButton";
+import { useHasEmailSetup } from "metabase/common/hooks";
+import { toggleSharing } from "metabase/dashboard/actions";
+import { useDispatch } from "metabase/lib/redux";
+
+/**
+ * @internal Do not import this component directly, use either SDK or EAJS EE plugins instead.
+ */
+export const DashboardSubscriptionsButton = (
+ props: DashboardSubscriptionsButtonProps,
+) => {
+ const dispatch = useDispatch();
+ const handleClick = () => dispatch(toggleSharing());
+
+ // We decided not to show the subscriptions button if email is not set up
+ const hasEmailSetup = useHasEmailSetup();
+ if (!hasEmailSetup) {
+ return null;
+ }
+
+ return (
+ <ToolbarButton
+ icon="subscription"
+ tooltipLabel={t`Subscriptions`}
+ onClick={handleClick}
+ {...props}
+ />
+ );
+};
diff --git a/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.unit.spec.tsx
new file mode 100644
index 00000000000..7b650f45c64
--- /dev/null
+++ b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton.unit.spec.tsx
@@ -0,0 +1,45 @@
+import { screen, waitFor } from "@testing-library/react";
+
+import {
+ findRequests,
+ setupNotificationChannelsEndpoints,
+} from "__support__/server-mocks";
+import { renderWithProviders } from "__support__/ui";
+
+import { DashboardSubscriptionsButton } from "./DashboardSubscriptionsButton";
+
+interface SetupOpts {
+ emailConfigured?: boolean;
+}
+const setup = (opts: SetupOpts = {}) => {
+ setupNotificationChannelsEndpoints({
+ email: {
+ configured: opts.emailConfigured,
+ },
+ });
+ renderWithProviders(<DashboardSubscriptionsButton />);
+};
+
+describe("DashboardSubscriptionsButton", () => {
+ it("should render the subscriptions button when email is configured", async () => {
+ setup({ emailConfigured: true });
+
+ expect(
+ await screen.findByRole("button", { name: "Subscriptions" }),
+ ).toBeInTheDocument();
+ const gets = await findRequests("GET");
+ expect(gets).toHaveLength(1);
+ });
+
+ it("should not render the subscriptions button when email is not configured", async () => {
+ setup({ emailConfigured: false });
+ // Ensure the API finishes loading, otherwise, the assertion below will always pass because the API hasn't returned yet
+ await waitFor(async () => {
+ const gets = await findRequests("GET");
+ expect(gets).toHaveLength(1);
+ });
+ expect(
+ screen.queryByRole("button", { name: "Subscriptions" }),
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/enterprise/frontend/src/embedding-sdk-ee/subscriptions/index.ts b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/index.ts
new file mode 100644
index 00000000000..93acb59a4f2
--- /dev/null
+++ b/enterprise/frontend/src/embedding-sdk-ee/subscriptions/index.ts
@@ -0,0 +1,11 @@
+import { PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK } from "embedding-sdk-bundle/components/public/subscriptions";
+import { hasPremiumFeature } from "metabase-enterprise/settings";
+
+import { DashboardSubscriptionsButton } from "./DashboardSubscriptionsButton";
+
+export function initializePlugin() {
+ if (hasPremiumFeature("embedding_sdk")) {
+ PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK.DashboardSubscriptionsButton =
+ DashboardSubscriptionsButton;
+ }
+}
diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk/index.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk/index.ts
index 296a66fb5bb..0cc13879820 100644
--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk/index.ts
+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk/index.ts
@@ -1,6 +1,12 @@
import { PLUGIN_EMBEDDING_IFRAME_SDK } from "metabase/plugins";
import { hasPremiumFeature } from "metabase-enterprise/settings";
-if (hasPremiumFeature("embedding_simple")) {
- PLUGIN_EMBEDDING_IFRAME_SDK.hasValidLicense = () => true;
+import { DashboardSubscriptionsButton } from "../../embedding-sdk-ee/subscriptions/DashboardSubscriptionsButton";
+
+export function initializePlugin() {
+ if (hasPremiumFeature("embedding_simple")) {
+ PLUGIN_EMBEDDING_IFRAME_SDK.isEnabled = () => true;
+ PLUGIN_EMBEDDING_IFRAME_SDK.DashboardSubscriptionsButton =
+ DashboardSubscriptionsButton;
+ }
}
diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/index.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/index.ts
index b7739aacc5e..6f3b329a0d5 100644
--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/index.ts
+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/index.ts
@@ -8,6 +8,6 @@ export function initializePlugin() {
// Feature gate the embed setup for gradual rollouts.
// In the future, we may drop this to enable users to try out new iframe embedding.
if (hasPremiumFeature("embedding_simple")) {
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled = () => true;
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => true;
}
}
diff --git a/enterprise/frontend/src/metabase-enterprise/plugins.js b/enterprise/frontend/src/metabase-enterprise/plugins.js
index 428844b0e12..a3b54afe513 100644
--- a/enterprise/frontend/src/metabase-enterprise/plugins.js
+++ b/enterprise/frontend/src/metabase-enterprise/plugins.js
@@ -27,6 +27,7 @@ import { initializePlugin as initializeDependencies } from "./dependencies";
import { initializePlugin as initializeDocuments } from "./documents";
import { initializePlugin as initializeEmbedding } from "./embedding";
import { initializePlugin as initializeEmbeddingSdk } from "./embedding-sdk";
+import { initializePlugin as initializeEmbeddingIframeSdk } from "./embedding_iframe_sdk";
import { initializePlugin as initializeEmbeddingIframeSdkSetup } from "./embedding_iframe_sdk_setup";
import { initializePlugin as initializeFeatureLevelPermissions } from "./feature_level_permissions";
import { initializePlugin as initializeGroupManagers } from "./group_managers";
@@ -55,44 +56,45 @@ import { initializePlugin as initializeWhitelabel } from "./whitelabel";
* Must be called after token features are available.
*/
export function initializePlugins() {
- initializeTools?.();
- initializeSandboxes?.();
- initializeAuth?.();
- initializeCaching?.();
- initializeCollections?.();
- initializeContentTranslation?.();
- initializeContentVerification?.();
- initializeDatabaseRouting?.();
- initializeDataStudio?.();
- initializeRemoteSync?.();
- initializeWhitelabel?.();
- initializeEmbedding?.();
- initializeEmbeddingSdk?.();
- initializeEmbeddingIframeSdkSetup?.();
- initializeSnippets?.();
- initializeSmtpOverride?.();
- initializeSharing?.();
- initializeModeration?.();
- initializeAdvancedPermissions?.();
- initializeAiSqlFixer?.();
- initializeAiEntityAnalysis?.();
- initializeAuditApp?.();
- initializeModelPersistence?.();
- initializeFeatureLevelPermissions?.();
- initializeApplicationPermissions?.();
- initializeGroupManagers?.();
- initializeUploadManagement?.();
- initializeResourceDownloads?.();
- initializeUserProvisioning?.();
- initializeCleanUp?.();
- initializeMetabot?.();
- initializeDatabaseReplication?.();
- initializeTableEditing?.();
- initializeDependencies?.();
- initializeDocuments?.();
- initializeSemanticSearch?.();
- initializeTransforms?.();
- initializeTransformsPython?.();
- initializePublicSharing?.();
- initializeSupport?.();
+ initializeTools();
+ initializeSandboxes();
+ initializeAuth();
+ initializeCaching();
+ initializeCollections();
+ initializeContentTranslation();
+ initializeContentVerification();
+ initializeDatabaseRouting();
+ initializeDataStudio();
+ initializeRemoteSync();
+ initializeWhitelabel();
+ initializeEmbedding();
+ initializeEmbeddingSdk();
+ initializeEmbeddingIframeSdk();
+ initializeEmbeddingIframeSdkSetup();
+ initializeSnippets();
+ initializeSmtpOverride();
+ initializeSharing();
+ initializeModeration();
+ initializeAdvancedPermissions();
+ initializeAiSqlFixer();
+ initializeAiEntityAnalysis();
+ initializeAuditApp();
+ initializeModelPersistence();
+ initializeFeatureLevelPermissions();
+ initializeApplicationPermissions();
+ initializeGroupManagers();
+ initializeUploadManagement();
+ initializeResourceDownloads();
+ initializeUserProvisioning();
+ initializeCleanUp();
+ initializeMetabot();
+ initializeDatabaseReplication();
+ initializeTableEditing();
+ initializeDependencies();
+ initializeDocuments();
+ initializeSemanticSearch();
+ initializeTransforms();
+ initializeTransformsPython();
+ initializePublicSharing();
+ initializeSupport();
}
diff --git a/enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-plugins.js b/enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-plugins.js
index 8c97e17544d..fdd46a0854c 100644
--- a/enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-plugins.js
+++ b/enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-plugins.js
@@ -1,6 +1,7 @@
import { initializePlugins } from "sdk-ee-plugins";
// Plugins that are only applicable to the new iframe embedding.
-import "./embedding_iframe_sdk";
+import { initializePlugin as initializeEmbeddingIframeSdkPlugin } from "./embedding_iframe_sdk";
+initializeEmbeddingIframeSdkPlugin();
initializePlugins();
diff --git a/enterprise/frontend/src/metabase-enterprise/sdk-plugins.ts b/enterprise/frontend/src/metabase-enterprise/sdk-plugins.ts
index 16c22d12ab9..b4449b27182 100644
--- a/enterprise/frontend/src/metabase-enterprise/sdk-plugins.ts
+++ b/enterprise/frontend/src/metabase-enterprise/sdk-plugins.ts
@@ -5,6 +5,8 @@ PLUGIN_IS_EE_BUILD.isEEBuild = () => true;
import "./shared";
+import { initializePlugin as initializeSubscriptions } from "../embedding-sdk-ee/subscriptions";
+
// CORE APP PLUGINS THAT USE hasPremiumFeature (import initialization functions):
import { initializePlugin as initializeContentTranslation } from "./content_translation";
import { initializePlugin as initializeEmbedding } from "./embedding";
@@ -24,6 +26,7 @@ export function initializePlugins() {
initializeWhitelabelPlugin?.();
initializeWhitelabelOverridePlugin?.();
initializeContentTranslation?.();
+ initializeSubscriptions();
}
// "SDK EE-plugins", that are specific to the embedding sdk.
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.schema.ts b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.schema.ts
index 553363c3b70..d3e99665d87 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.schema.ts
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.schema.ts
@@ -50,6 +50,7 @@ const propsSchema: Yup.SchemaOf<EditableDashboardProps> = Yup.object({
style: Yup.mixed().optional(),
withCardTitle: Yup.mixed().optional(),
withDownloads: Yup.mixed().optional(),
+ withSubscriptions: Yup.mixed().optional(),
withTitle: Yup.mixed().optional(),
onVisualizationChange: Yup.mixed().optional(),
}).noUnknown();
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.stories.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.stories.tsx
index 5a926b75412..39fca4861f1 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.stories.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.stories.tsx
@@ -65,6 +65,15 @@ const meta = {
defaultValue: { summary: "false" },
},
},
+ withSubscriptions: {
+ control: { type: "boolean" },
+ description:
+ "Whether to allow users to subscribe themselves to the dashboard",
+ table: {
+ type: { summary: "boolean" },
+ defaultValue: { summary: "false" },
+ },
+ },
// Parameters
initialParameters: {
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.tsx
index 1cb5e0cd71a..58313a01fb6 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.tsx
@@ -25,13 +25,14 @@ export type EditableDashboardProps = SdkDashboardProps &
export const EditableDashboardInner = (props: EditableDashboardProps) => {
const dashboardActions: SdkDashboardInnerProps["dashboardActions"] = ({
isEditing,
- downloadsEnabled,
}) =>
isEditing
? DASHBOARD_EDITING_ACTIONS
- : downloadsEnabled.pdf
- ? [DASHBOARD_ACTION.EDIT_DASHBOARD, DASHBOARD_ACTION.DOWNLOAD_PDF]
- : [DASHBOARD_ACTION.EDIT_DASHBOARD];
+ : [
+ DASHBOARD_ACTION.EDIT_DASHBOARD,
+ DASHBOARD_ACTION.DASHBOARD_SUBSCRIPTIONS,
+ DASHBOARD_ACTION.DOWNLOAD_PDF,
+ ];
const getClickActionMode: SdkDashboardInnerProps["getClickActionMode"] = ({
question,
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/enterprise.unit.spec.tsx
similarity index 77%
rename from frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx
rename to frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/enterprise.unit.spec.tsx
index 77832919526..ffe41d78e38 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/enterprise.unit.spec.tsx
@@ -10,6 +10,7 @@ import { screen, waitFor, within } from "__support__/ui";
import { ROOT_COLLECTION } from "metabase/entities/collections";
import { createMockCollection } from "metabase-types/api/mocks";
+import { addEnterpriseSubscriptionsTests } from "../shared-tests/subscriptions.spec";
import {
type SetupSdkDashboardOptions,
setupSdkDashboard,
@@ -17,18 +18,21 @@ import {
import { EditableDashboard } from "./EditableDashboard";
-const setup = async (
+const setupEnterprise = async (
options: Omit<SetupSdkDashboardOptions, "component"> = {},
) => {
return setupSdkDashboard({
...options,
+ enterprisePlugins: ["sdk_subscriptions", "embedding"],
component: EditableDashboard,
});
};
describe("EditableDashboard", () => {
+ addEnterpriseSubscriptionsTests(setupEnterprise);
+
it("should support dashboard editing", async () => {
- await setup();
+ await setupEnterprise();
await waitFor(() => {
expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
@@ -50,7 +54,7 @@ describe("EditableDashboard", () => {
});
it("should show the edit and download button if downloads are enabled", async () => {
- await setup({
+ await setupEnterprise({
props: { withDownloads: true },
});
@@ -74,7 +78,7 @@ describe("EditableDashboard", () => {
});
it("should not show download button if downloads are disabled", async () => {
- await setup({
+ await setupEnterprise({
props: { withDownloads: false },
});
@@ -97,40 +101,8 @@ describe("EditableDashboard", () => {
).not.toBeInTheDocument();
});
- it("should allow to create a new question in addition to adding existing questions", async () => {
- await setup({ hasEmbeddingEnterprisePlugin: true });
- setupSimpleDataPickerEndpoints();
-
- expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
-
- await userEvent.click(
- within(screen.getByTestId("dashboard-header")).getByLabelText(
- "Edit dashboard",
- ),
- );
- await userEvent.click(
- screen.getByRole("button", { name: "Add questions" }),
- );
- await userEvent.click(screen.getByRole("button", { name: "New Question" }));
-
- // We should render the simple data picker at this point
- expect(screen.queryByTestId("dashboard-header")).not.toBeInTheDocument();
- expect(
- await screen.findByRole("button", { name: "Pick your starting data" }),
- ).toBeInTheDocument();
-
- // Default `entityTypes` should be `["model", "table"]`
- // EmbeddingDataPicker makes a call to `/api/search` with limit=0 to decide if SimpleDataPicker should be used
- // then SimpleDataPicker makes a call to `/api/search` to fetch the data
- const dataPickerDataCalls = fetchMock.callHistory.calls("path:/api/search");
- expect(dataPickerDataCalls).toHaveLength(2);
- const dataPickerDataCallUrl = dataPickerDataCalls[1].url;
- expect(dataPickerDataCallUrl).toContain("models=dataset");
- expect(dataPickerDataCallUrl).toContain("models=table");
- });
-
it("should allow to go back to the dashboard after seeing the query builder", async () => {
- await setup({ dashboardName: "Test dashboard" });
+ await setupEnterprise({ dashboardName: "Test dashboard" });
setupSimpleDataPickerEndpoints();
expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
@@ -160,7 +132,7 @@ describe("EditableDashboard", () => {
});
it("should allow to pass `dataPickerProps.entityTypes` to the query builder", async () => {
- await setup({
+ await setupEnterprise({
dataPickerProps: {
entityTypes: ["model"],
},
@@ -196,14 +168,14 @@ describe("EditableDashboard", () => {
});
it("should show 'Add a chart' button on empty dashboards", async () => {
- await setup({ dashcards: [] });
+ await setupEnterprise({ dashcards: [] });
expect(screen.getByText("This dashboard is empty")).toBeInTheDocument();
expect(screen.getByText("Add a chart")).toBeInTheDocument();
});
it("should allow editing the dashboard title", async () => {
- await setup();
+ await setupEnterprise();
expect(screen.getByTestId("dashboard-name-heading")).toBeEnabled();
});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/premium.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/premium.unit.spec.tsx
new file mode 100644
index 00000000000..0d79dd70024
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/EditableDashboard/premium.unit.spec.tsx
@@ -0,0 +1,78 @@
+import userEvent from "@testing-library/user-event";
+import fetchMock from "fetch-mock";
+
+import {
+ setupCollectionItemsEndpoint,
+ setupEmbeddingDataPickerDecisionEndpoints,
+ setupSearchEndpoints,
+} from "__support__/server-mocks";
+import { screen, within } from "__support__/ui";
+import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { createMockCollection } from "metabase-types/api/mocks";
+
+import { addPremiumSubscriptionsTests } from "../shared-tests/subscriptions.spec";
+import {
+ type SetupSdkDashboardOptions,
+ setupSdkDashboard,
+} from "../tests/setup";
+
+import { EditableDashboard } from "./EditableDashboard";
+
+const setupPremium = async (
+ options: Omit<SetupSdkDashboardOptions, "component"> = {},
+) => {
+ return setupSdkDashboard({
+ ...options,
+ tokenFeatures: {
+ embedding_sdk: true,
+ },
+ enterprisePlugins: ["sdk_subscriptions", "embedding"],
+ component: EditableDashboard,
+ });
+};
+
+describe("EditableDashboard", () => {
+ addPremiumSubscriptionsTests(setupPremium);
+
+ it("should allow to create a new question in addition to adding existing questions", async () => {
+ await setupPremium();
+ setupSimpleDataPickerEndpoints();
+
+ expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
+
+ await userEvent.click(
+ within(screen.getByTestId("dashboard-header")).getByLabelText(
+ "Edit dashboard",
+ ),
+ );
+ await userEvent.click(
+ screen.getByRole("button", { name: "Add questions" }),
+ );
+ await userEvent.click(screen.getByRole("button", { name: "New Question" }));
+
+ // We should render the simple data picker at this point
+ expect(screen.queryByTestId("dashboard-header")).not.toBeInTheDocument();
+ expect(
+ await screen.findByRole("button", { name: "Pick your starting data" }),
+ ).toBeInTheDocument();
+
+ // Default `entityTypes` should be `["model", "table"]`
+ // EmbeddingDataPicker makes a call to `/api/search` with limit=0 to decide if SimpleDataPicker should be used
+ // then SimpleDataPicker makes a call to `/api/search` to fetch the data
+ const dataPickerDataCalls = fetchMock.callHistory.calls("path:/api/search");
+ expect(dataPickerDataCalls).toHaveLength(2);
+ const dataPickerDataCallUrl = dataPickerDataCalls[1].url;
+ expect(dataPickerDataCallUrl).toContain("models=dataset");
+ expect(dataPickerDataCallUrl).toContain("models=table");
+ });
+});
+
+function setupSimpleDataPickerEndpoints() {
+ // These endpoints are used in the simple data picker
+ setupCollectionItemsEndpoint({
+ collection: createMockCollection(ROOT_COLLECTION),
+ collectionItems: [],
+ });
+ setupEmbeddingDataPickerDecisionEndpoints("flat");
+ setupSearchEndpoints([]);
+}
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.schema.ts b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.schema.ts
index efbadcaf1da..b2e3335cea8 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.schema.ts
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.schema.ts
@@ -52,6 +52,7 @@ const propsSchema: Yup.SchemaOf<InteractiveDashboardProps> = Yup.object({
style: Yup.mixed().optional(),
withCardTitle: Yup.mixed().optional(),
withDownloads: Yup.mixed().optional(),
+ withSubscriptions: Yup.mixed().optional(),
withTitle: Yup.mixed().optional(),
onVisualizationChange: Yup.mixed().optional(),
}).noUnknown();
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.stories.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.stories.tsx
index c698317aae7..838b04a6fe6 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.stories.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.stories.tsx
@@ -49,6 +49,15 @@ export default {
defaultValue: { summary: "false" },
},
},
+ withSubscriptions: {
+ control: { type: "boolean" },
+ description:
+ "Whether to allow users to subscribe themselves to the dashboard",
+ table: {
+ type: { summary: "boolean" },
+ defaultValue: { summary: "false" },
+ },
+ },
// Parameters
initialParameters: {
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.tsx
index c767b1d07c0..f537d34c053 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.tsx
@@ -44,9 +44,10 @@ const InteractiveDashboardInner = (props: InteractiveDashboardProps) => {
<SdkDashboard
{...props}
getClickActionMode={getClickActionMode}
- dashboardActions={({ downloadsEnabled }) => {
- return downloadsEnabled.pdf ? [DASHBOARD_ACTION.DOWNLOAD_PDF] : [];
- }}
+ dashboardActions={[
+ DASHBOARD_ACTION.DASHBOARD_SUBSCRIPTIONS,
+ DASHBOARD_ACTION.DOWNLOAD_PDF,
+ ]}
dashcardMenu={({ dashcard, result, downloadsEnabled }) =>
downloadsEnabled?.results &&
isQuestionCard(dashcard.card) &&
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.unit.spec.tsx
deleted file mode 100644
index 243b2e7e88c..00000000000
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/InteractiveDashboard.unit.spec.tsx
+++ /dev/null
@@ -1,147 +0,0 @@
-import userEvent from "@testing-library/user-event";
-
-import { screen, waitFor, within } from "__support__/ui";
-
-import {
- type SetupSdkDashboardOptions,
- setupSdkDashboard,
-} from "../tests/setup";
-
-import { InteractiveDashboard } from "./InteractiveDashboard";
-
-const setup = async (
- options: Omit<SetupSdkDashboardOptions, "component"> = {},
-) => {
- return setupSdkDashboard({
- ...options,
- component: InteractiveDashboard,
- });
-};
-
-console.warn = () => {};
-
-describe("InteractiveDashboard", () => {
- it("should call onVisualizationChange when a card is opened", async () => {
- const onVisualizationChange = jest.fn();
-
- await setup({
- dashboardName: "Test dashboard",
- props: {
- onVisualizationChange,
- },
- });
-
- await userEvent.click(screen.getByText("Here is a card title"));
-
- expect(
- await screen.findByLabelText("Back to Test dashboard"),
- ).toBeInTheDocument();
- expect(screen.getByText("Filter")).toBeInTheDocument();
- expect(screen.getByText("Group")).toBeInTheDocument();
- expect(screen.getByTestId("query-visualization-root")).toBeInTheDocument();
-
- expect(onVisualizationChange).toHaveBeenCalledTimes(1);
- expect(onVisualizationChange).toHaveBeenCalledWith("table");
-
- await userEvent.click(screen.getByText("Table"));
- await userEvent.click(screen.getByText("Bar"));
-
- expect(onVisualizationChange).toHaveBeenCalledTimes(2);
- expect(onVisualizationChange).toHaveBeenCalledWith("bar");
- });
-
- it("should allow users to click the dashcard title", async () => {
- await setup({
- dashboardName: "Test dashboard",
- });
-
- expect(screen.getByTestId("legend-label")).toHaveAttribute(
- "data-is-clickable",
- "true",
- );
-
- await userEvent.click(screen.getByTestId("legend-label"));
-
- expect(
- await screen.findByLabelText("Back to Test dashboard"),
- ).toBeInTheDocument();
- expect(screen.getByText("Filter")).toBeInTheDocument();
- expect(screen.getByText("Group")).toBeInTheDocument();
- expect(screen.getByTestId("query-visualization-root")).toBeInTheDocument();
- });
-
- it("should only show the download button in the dashcard when downloads are enabled", async () => {
- await setup({
- props: {
- withDownloads: true,
- },
- });
-
- const ellipsisIcon = screen.queryByLabelText("ellipsis icon");
- expect(ellipsisIcon).toBeInTheDocument();
- await userEvent.click(ellipsisIcon!);
- await waitFor(() => {
- expect(screen.getByLabelText("Download results")).toBeInTheDocument();
- });
- });
-
- it("should show no button in the dashcard when downloads are disabled", async () => {
- await setup({
- props: {
- withDownloads: false,
- },
- });
-
- expect(screen.queryByLabelText("Download results")).not.toBeInTheDocument();
- expect(screen.queryByLabelText("ellipsis icon")).not.toBeInTheDocument();
- });
-
- it("should only show the download button if downloads are enabled", async () => {
- await setup({
- props: { withDownloads: true },
- });
-
- await waitFor(() => {
- expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
- });
-
- const dashboardHeader = within(screen.getByTestId("dashboard-header"));
-
- expect(
- dashboardHeader.getAllByTestId("dashboard-header-row-button"),
- ).toHaveLength(1);
-
- expect(
- dashboardHeader.getByLabelText("Download as PDF"),
- ).toBeInTheDocument();
- });
-
- it("should not show buttons if downloads are disabled", async () => {
- await setup({
- props: { withDownloads: false },
- });
-
- await waitFor(() => {
- expect(screen.getByTestId("dashboard-header")).toBeInTheDocument();
- });
-
- const dashboardHeader = within(screen.getByTestId("dashboard-header"));
-
- expect(
- dashboardHeader.queryByTestId("dashboard-header-row-button"),
- ).not.toBeInTheDocument();
- });
-
- it("should not show 'Add a chart' button on empty dashboards", async () => {
- await setup({ dashcards: [] });
-
- expect(screen.getByText("This dashboard is empty")).toBeInTheDocument();
- expect(screen.queryByText("Add a chart")).not.toBeInTheDocument();
- });
-
- it("should not allow editing the dashboard title", async () => {
- await setup();
-
- expect(screen.getByTestId("dashboard-name-heading")).toBeDisabled();
- });
-});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/enterprise.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/enterprise.unit.spec.tsx
new file mode 100644
index 00000000000..46906453e9f
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/enterprise.unit.spec.tsx
@@ -0,0 +1,22 @@
+import { addEnterpriseSubscriptionsTests } from "../../shared-tests/subscriptions.spec";
+import {
+ type SetupSdkDashboardOptions,
+ setupSdkDashboard,
+} from "../../tests/setup";
+import { InteractiveDashboard } from "../InteractiveDashboard";
+
+const setupEnterprise = async (
+ options: Omit<SetupSdkDashboardOptions, "component"> = {},
+) => {
+ return setupSdkDashboard({
+ ...options,
+ enterprisePlugins: ["sdk_subscriptions"],
+ component: InteractiveDashboard,
+ });
+};
+
+console.warn = () => {};
+
+describe("InteractiveDashboard", () => {
+ addEnterpriseSubscriptionsTests(setupEnterprise);
+});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/premium.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/premium.unit.spec.tsx
new file mode 100644
index 00000000000..a9ac431cf2f
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/InteractiveDashboard/tests/premium.unit.spec.tsx
@@ -0,0 +1,25 @@
+import { addPremiumSubscriptionsTests } from "../../shared-tests/subscriptions.spec";
+import {
+ type SetupSdkDashboardOptions,
+ setupSdkDashboard,
+} from "../../tests/setup";
+import { InteractiveDashboard } from "../InteractiveDashboard";
+
+const setupPremium = async (
+ options: Omit<SetupSdkDashboardOptions, "component"> = {},
+) => {
+ return setupSdkDashboard({
+ ...options,
+ tokenFeatures: {
+ embedding_sdk: true,
+ },
+ enterprisePlugins: ["sdk_subscriptions"],
+ component: InteractiveDashboard,
+ });
+};
+
+console.warn = () => {};
+
+describe("InteractiveDashboard", () => {
+ addPremiumSubscriptionsTests(setupPremium);
+});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/SdkDashboard.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/SdkDashboard.tsx
index 2d0a5eabad6..1098ec43383 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/SdkDashboard.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/SdkDashboard.tsx
@@ -28,11 +28,15 @@ import {
import { useSdkDispatch, useSdkSelector } from "embedding-sdk-bundle/store";
import { getIsGuestEmbed } from "embedding-sdk-bundle/store/selectors";
import type { MetabaseQuestion } from "embedding-sdk-bundle/types";
-import type { DashboardEventHandlersProps } from "embedding-sdk-bundle/types/dashboard";
+import type {
+ DashboardEventHandlersProps,
+ SdkDashboardId,
+} from "embedding-sdk-bundle/types/dashboard";
import type { MetabasePluginsConfig } from "embedding-sdk-bundle/types/plugins";
import { useConfirmation } from "metabase/common/hooks";
import { useLocale } from "metabase/common/hooks/use-locale";
import {
+ closeSidebarIfSubscriptionsSidebarOpen,
setEditingDashboard,
toggleSidebar,
updateDashboardAndCards,
@@ -46,6 +50,7 @@ import {
useDashboardContext,
} from "metabase/dashboard/context";
import { getDashboardComplete, getIsDirty } from "metabase/dashboard/selectors";
+import type { ParameterValues } from "metabase/embedding-sdk/types/dashboard";
import { isStaticEmbeddingEntityLoadingError } from "metabase/lib/errors/is-static-embedding-entity-loading-error";
import { useSelector } from "metabase/lib/redux";
import { PLUGIN_CONTENT_TRANSLATION } from "metabase/plugins";
@@ -96,6 +101,26 @@ export type SdkDashboardProps = PropsWithChildren<
* Props of a question component when drilled from the dashboard to a question level.
*/
drillThroughQuestionProps?: DrillThroughQuestionProps;
+
+ /**
+ * The ID of the dashboard.
+ * <br/>
+ * This is either:
+ * <br/>
+ * - the numerical ID when accessing a dashboard link, i.e. `http://localhost:3000/dashboard/1-my-dashboard` where the ID is `1`
+ * <br/>
+ * - the string ID found in the `entity_id` key of the dashboard object when using the API directly or using the SDK Collection Browser to return data
+ */
+ dashboardId: SdkDashboardId;
+
+ /**
+ * Query parameters for the dashboard. For a single option, use a `string` value, and use a list of strings for multiple options.
+ * <br/>
+ * - Combining {@link SdkDashboardProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to filter data on the frontend is a [security risk](https://www.metabase.com/docs/latest/embedding/sdk/authentication.html#security-warning-each-end-user-must-have-their-own-metabase-account).
+ * <br/>
+ * - Combining {@link SdkDashboardProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to declutter the user interface is fine.
+ */
+ initialParameters?: ParameterValues;
} & SdkDashboardDisplayProps &
DashboardEventHandlersProps &
EditableDashboardOwnProps
@@ -133,6 +158,7 @@ const SdkDashboardInner = ({
withTitle = true,
withCardTitle = true,
withDownloads = false,
+ withSubscriptions = false,
hiddenParameters = [],
drillThroughQuestionHeight,
plugins,
@@ -182,6 +208,7 @@ const SdkDashboardInner = ({
const { displayOptions } = useSdkDashboardParams({
withDownloads,
+ withSubscriptions,
withTitle,
withCardTitle,
hiddenParameters,
@@ -246,6 +273,12 @@ const SdkDashboardInner = ({
}
}, [dispatch, dashboardId]);
+ useEffect(() => {
+ if (!withSubscriptions) {
+ dispatch(closeSidebarIfSubscriptionsSidebarOpen());
+ }
+ }, [dispatch, withSubscriptions]);
+
const { modalContent, show } = useConfirmation();
const isDashboardDirty = useSelector(getIsDirty);
@@ -334,6 +367,7 @@ const SdkDashboardInner = ({
}
}}
downloadsEnabled={displayOptions.downloadsEnabled}
+ withSubscriptions={displayOptions.withSubscriptions}
background={displayOptions.background}
bordered={displayOptions.bordered}
hideParameters={displayOptions.hideParameters}
@@ -421,6 +455,7 @@ export const SdkDashboard = withPublicComponentWrapper(SdkDashboardInner, {
| "ParametersList"
| "FullscreenButton"
| "ExportAsPdfButton"
+ | "SubscriptionsButton"
| "InfoButton"
| "RefreshPeriod"
>;
@@ -432,6 +467,7 @@ SdkDashboard.Tabs = Dashboard.Tabs;
SdkDashboard.ParametersList = Dashboard.ParametersList;
SdkDashboard.FullscreenButton = Dashboard.FullscreenButton;
SdkDashboard.ExportAsPdfButton = Dashboard.ExportAsPdfButton;
+SdkDashboard.SubscriptionsButton = Dashboard.SubscriptionsButton;
SdkDashboard.InfoButton = Dashboard.InfoButton;
SdkDashboard.RefreshPeriod = Dashboard.RefreshPeriod;
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.schema.ts b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.schema.ts
index 3b5558a5c44..1ee14baea2c 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.schema.ts
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.schema.ts
@@ -31,6 +31,7 @@ const propsSchema: Yup.SchemaOf<StaticDashboardProps> = Yup.object({
style: Yup.mixed().optional(),
withCardTitle: Yup.mixed().optional(),
withDownloads: Yup.mixed().optional(),
+ withSubscriptions: Yup.mixed().optional(),
withTitle: Yup.mixed().optional(),
onVisualizationChange: Yup.mixed().optional(),
}).noUnknown();
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.stories.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.stories.tsx
index 92496d2449d..5486092a899 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.stories.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.stories.tsx
@@ -47,6 +47,15 @@ export default {
defaultValue: { summary: "false" },
},
},
+ withSubscriptions: {
+ control: { type: "boolean" },
+ description:
+ "Whether to allow users to subscribe themselves to the dashboard",
+ table: {
+ type: { summary: "boolean" },
+ defaultValue: { summary: "false" },
+ },
+ },
// Parameters
initialParameters: {
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.tsx
index 9eb41050589..589422986fa 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.tsx
@@ -43,9 +43,10 @@ const StaticDashboardInner = (props: StaticDashboardProps) => {
<SdkDashboard
{...(normalizedProps as SdkDashboardProps)}
getClickActionMode={getClickActionMode}
- dashboardActions={({ downloadsEnabled }) =>
- downloadsEnabled.pdf ? [DASHBOARD_ACTION.DOWNLOAD_PDF] : []
- }
+ dashboardActions={[
+ DASHBOARD_ACTION.DASHBOARD_SUBSCRIPTIONS,
+ DASHBOARD_ACTION.DOWNLOAD_PDF,
+ ]}
navigateToNewCardFromDashboard={null}
dashcardMenu={({ dashcard, result }) =>
withDownloads &&
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/enterprise.unit.spec.tsx
similarity index 85%
rename from frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.unit.spec.tsx
rename to frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/enterprise.unit.spec.tsx
index 5b9297f82f9..b73f2296032 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/StaticDashboard.unit.spec.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/enterprise.unit.spec.tsx
@@ -4,30 +4,33 @@ import type { ComponentType } from "react";
import { screen, waitFor, within } from "__support__/ui";
import type { SdkDashboardProps } from "embedding-sdk-bundle/components/public/dashboard/SdkDashboard";
+import { addEnterpriseSubscriptionsTests } from "../../shared-tests/subscriptions.spec";
import {
type SetupSdkDashboardOptions,
setupSdkDashboard,
-} from "../tests/setup";
-
-import { StaticDashboard } from "./StaticDashboard";
+} from "../../tests/setup";
+import { StaticDashboard } from "../StaticDashboard";
jest.mock("metabase/common/hooks/use-locale", () => ({
useLocale: jest.fn(),
}));
-const setup = async (
+const setupEnterprise = async (
options: Omit<SetupSdkDashboardOptions, "component"> = {},
) => {
return setupSdkDashboard({
...options,
+ enterprisePlugins: ["sdk_subscriptions"],
component: StaticDashboard as ComponentType<SdkDashboardProps>,
});
};
console.warn = () => {};
describe("StaticDashboard", () => {
+ addEnterpriseSubscriptionsTests(setupEnterprise);
+
it("should not allow users to click the dashcard title", async () => {
- await setup();
+ await setupEnterprise();
expect(screen.getByTestId("legend-label")).toHaveAttribute(
"data-is-clickable",
@@ -42,7 +45,7 @@ describe("StaticDashboard", () => {
});
it("should only show the download button in the dashcard when downloads are enabled", async () => {
- await setup({
+ await setupEnterprise({
props: {
withDownloads: true,
},
@@ -57,7 +60,7 @@ describe("StaticDashboard", () => {
});
it("should show no button in the dashcard when downloads are disabled", async () => {
- await setup({
+ await setupEnterprise({
props: {
withDownloads: false,
},
@@ -68,7 +71,7 @@ describe("StaticDashboard", () => {
});
it("should only show the download button if downloads are enabled", async () => {
- await setup({
+ await setupEnterprise({
props: { withDownloads: true },
});
@@ -88,7 +91,7 @@ describe("StaticDashboard", () => {
});
it("should not show buttons if downloads are disabled", async () => {
- await setup({
+ await setupEnterprise({
props: { withDownloads: false },
});
@@ -104,14 +107,14 @@ describe("StaticDashboard", () => {
});
it("should not show 'Add a chart' button on empty dashboards", async () => {
- await setup({ dashcards: [] });
+ await setupEnterprise({ dashcards: [] });
expect(screen.getByText("This dashboard is empty")).toBeInTheDocument();
expect(screen.queryByText("Add a chart")).not.toBeInTheDocument();
});
it("should not allow editing the dashboard title", async () => {
- await setup();
+ await setupEnterprise();
expect(screen.getByTestId("dashboard-name-heading")).toBeDisabled();
});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/premium.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/premium.unit.spec.tsx
new file mode 100644
index 00000000000..52044ba9f6e
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/StaticDashboard/tests/premium.unit.spec.tsx
@@ -0,0 +1,32 @@
+import type { ComponentType } from "react";
+
+import type { SdkDashboardProps } from "embedding-sdk-bundle/components/public/dashboard/SdkDashboard";
+
+import { addPremiumSubscriptionsTests } from "../../shared-tests/subscriptions.spec";
+import {
+ type SetupSdkDashboardOptions,
+ setupSdkDashboard,
+} from "../../tests/setup";
+import { StaticDashboard } from "../StaticDashboard";
+
+jest.mock("metabase/common/hooks/use-locale", () => ({
+ useLocale: jest.fn(),
+}));
+
+const setupPremium = async (
+ options: Omit<SetupSdkDashboardOptions, "component"> = {},
+) => {
+ return setupSdkDashboard({
+ ...options,
+ tokenFeatures: {
+ embedding_sdk: true,
+ },
+ enterprisePlugins: ["sdk_subscriptions"],
+ component: StaticDashboard as ComponentType<SdkDashboardProps>,
+ });
+};
+console.warn = () => {};
+
+describe("StaticDashboard", () => {
+ addPremiumSubscriptionsTests(setupPremium);
+});
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/shared-tests/subscriptions.spec.ts b/frontend/src/embedding-sdk-bundle/components/public/dashboard/shared-tests/subscriptions.spec.ts
new file mode 100644
index 00000000000..d958a089ce9
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/shared-tests/subscriptions.spec.ts
@@ -0,0 +1,148 @@
+import { screen, within } from "__support__/ui";
+import type { Dashboard } from "metabase-types/api";
+
+import type { SetupSdkDashboardOptions } from "../tests/setup";
+
+type SetupOpts = Omit<SetupSdkDashboardOptions, "component">;
+
+export function addEnterpriseSubscriptionsTests(
+ setup: (options?: SetupOpts) => Promise<{ dashboard: Dashboard }>,
+) {
+ describe(`Subscriptions Button (enterprise)`, () => {
+ it.each([
+ { isSlackConfigured: false, isEmailConfigured: false },
+ { isSlackConfigured: false, isEmailConfigured: true },
+ { isSlackConfigured: true, isEmailConfigured: false },
+ { isSlackConfigured: true, isEmailConfigured: true },
+ ])(
+ "should not show subscriptions button without `embedding_sdk` token feature (isSlackConfigured: $isSlackConfigured, isEmailConfigured: $isEmailConfigured)",
+ async ({ isSlackConfigured, isEmailConfigured }) => {
+ await setup({
+ props: { withSubscriptions: true },
+ isEmailConfigured,
+ isSlackConfigured,
+ });
+
+ expect(
+ await screen.findByTestId("dashboard-header"),
+ ).toBeInTheDocument();
+
+ const dashboardHeader = within(screen.getByTestId("dashboard-header"));
+
+ expect(
+ dashboardHeader.queryByLabelText("Subscriptions"),
+ ).not.toBeInTheDocument();
+ },
+ );
+ });
+}
+
+export function addPremiumSubscriptionsTests(
+ setup: (options?: SetupOpts) => Promise<{ dashboard: Dashboard }>,
+) {
+ describe("Subscriptions Button (premium)", () => {
+ it.each([
+ {
+ isSlackConfigured: false,
+ },
+ {
+ isSlackConfigured: true,
+ },
+ ])(
+ "should show subscriptions button if subscriptions are enabled and email is set up (isSlackConfigured: $isSlackConfigured)",
+ async ({ isSlackConfigured }) => {
+ await setup({
+ props: { withSubscriptions: true },
+ isEmailConfigured: true,
+ isSlackConfigured,
+ });
+
+ expect(
+ await screen.findByTestId("dashboard-header"),
+ ).toBeInTheDocument();
+
+ const dashboardHeader = within(screen.getByTestId("dashboard-header"));
+
+ expect(
+ await dashboardHeader.findByLabelText("Subscriptions"),
+ ).toBeInTheDocument();
+ },
+ );
+
+ it.each([
+ {
+ isEmailConfigured: false,
+ isSlackConfigured: false,
+ },
+ {
+ isEmailConfigured: false,
+ isSlackConfigured: true,
+ },
+ {
+ isEmailConfigured: true,
+ isSlackConfigured: false,
+ },
+ {
+ isEmailConfigured: true,
+ isSlackConfigured: true,
+ },
+ ])(
+ "should not show subscriptions button if subscriptions are disabled (isEmailConfigured: $isEmailConfigured, isSlackConfigured: $isSlackConfigured)",
+ async ({ isEmailConfigured, isSlackConfigured }) => {
+ await setup({
+ props: { withSubscriptions: false },
+ isEmailConfigured,
+ isSlackConfigured,
+ });
+
+ expect(
+ await screen.findByTestId("dashboard-header"),
+ ).toBeInTheDocument();
+
+ const dashboardHeader = within(screen.getByTestId("dashboard-header"));
+
+ expect(
+ dashboardHeader.queryByLabelText("Subscriptions"),
+ ).not.toBeInTheDocument();
+ },
+ );
+
+ it.each([
+ {
+ isSlackConfigured: false,
+ withSubscriptions: false,
+ },
+ {
+ isSlackConfigured: false,
+ withSubscriptions: true,
+ },
+ {
+ isSlackConfigured: true,
+ withSubscriptions: false,
+ },
+ {
+ isSlackConfigured: true,
+ withSubscriptions: true,
+ },
+ ])(
+ "should not show subscriptions button if email is not configured (isSlackConfigured: $isSlackConfigured, withSubscriptions: $withSubscriptions)",
+ async ({ isSlackConfigured, withSubscriptions }) => {
+ await setup({
+ props: { withSubscriptions },
+ isEmailConfigured: false,
+ isSlackConfigured,
+ });
+
+ expect(
+ await screen.findByTestId("dashboard-header"),
+ ).toBeInTheDocument();
+
+ const dashboardHeader = within(screen.getByTestId("dashboard-header"));
+
+ expect(
+ dashboardHeader.queryByLabelText("Subscriptions"),
+ ).not.toBeInTheDocument();
+ },
+ );
+ });
+}
diff --git a/frontend/src/embedding-sdk-bundle/components/public/dashboard/tests/setup.tsx b/frontend/src/embedding-sdk-bundle/components/public/dashboard/tests/setup.tsx
index f57b0ea03af..22b5336ff23 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/dashboard/tests/setup.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/dashboard/tests/setup.tsx
@@ -2,6 +2,7 @@ import type { ComponentType } from "react";
import { indexBy } from "underscore";
import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
+import type { ENTERPRISE_PLUGIN_NAME } from "__support__/enterprise-typed";
import {
setupAlertsEndpoints,
setupBookmarksEndpoints,
@@ -24,7 +25,7 @@ import { setupSdkState } from "embedding-sdk-bundle/test/server-mocks/sdk-init";
import type { MetabaseProviderProps } from "embedding-sdk-bundle/types/metabase-provider";
import { useLocale } from "metabase/common/hooks/use-locale";
import { Box } from "metabase/ui";
-import type { DashboardCard } from "metabase-types/api";
+import type { DashboardCard, TokenFeatures } from "metabase-types/api";
import {
createMockCard,
createMockCardQueryMetadata,
@@ -110,7 +111,7 @@ export const DEFAULT_DASHCARDS: DashboardCard[] = [
textDashcard2,
];
-export interface SetupSdkDashboardOptions {
+export interface SetupSdkDashboardOptions extends NotificationChannelSetup {
props?: Omit<Partial<SdkDashboardProps>, "token">;
providerProps?: Partial<MetabaseProviderProps>;
isLocaleLoading?: boolean;
@@ -118,7 +119,13 @@ export interface SetupSdkDashboardOptions {
dashboardName?: string;
dataPickerProps?: EditableDashboardProps["dataPickerProps"];
dashcards?: DashboardCard[];
- hasEmbeddingEnterprisePlugin?: boolean;
+ enterprisePlugins?: ENTERPRISE_PLUGIN_NAME[];
+ tokenFeatures?: Partial<TokenFeatures>;
+}
+
+interface NotificationChannelSetup {
+ isEmailConfigured?: boolean;
+ isSlackConfigured?: boolean;
}
jest.mock("metabase/common/hooks/use-locale", () => ({
@@ -133,7 +140,10 @@ export const setupSdkDashboard = async ({
dashboardName = "Dashboard",
dataPickerProps,
dashcards = DEFAULT_DASHCARDS,
- hasEmbeddingEnterprisePlugin = false,
+ enterprisePlugins = [],
+ tokenFeatures = {},
+ isEmailConfigured = false,
+ isSlackConfigured = false,
}: SetupSdkDashboardOptions) => {
const useLocaleMock = useLocale as jest.Mock;
useLocaleMock.mockReturnValue({ isLocaleLoading });
@@ -177,7 +187,10 @@ export const setupSdkDashboard = async ({
setupAlertsEndpoints(tableCard, []);
- setupNotificationChannelsEndpoints({});
+ setupNotificationChannelsEndpoints({
+ email: { configured: isEmailConfigured },
+ slack: { configured: isSlackConfigured },
+ } as any);
setupDatabasesEndpoints([createMockDatabase()]);
@@ -199,10 +212,11 @@ export const setupSdkDashboard = async ({
},
dashcards: indexBy(dashcards, "id"),
}),
+ tokenFeatures,
});
- if (hasEmbeddingEnterprisePlugin) {
- setupEnterpriseOnlyPlugin("embedding");
+ if (enterprisePlugins.length > 0) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithSDKProviders(
diff --git a/frontend/src/embedding-sdk-bundle/components/public/subscriptions/index.tsx b/frontend/src/embedding-sdk-bundle/components/public/subscriptions/index.tsx
new file mode 100644
index 00000000000..1e0eca0e601
--- /dev/null
+++ b/frontend/src/embedding-sdk-bundle/components/public/subscriptions/index.tsx
@@ -0,0 +1,27 @@
+import type { ButtonHTMLAttributes } from "react";
+
+import type { ActionIconProps } from "metabase/ui";
+
+export type DashboardSubscriptionsButtonProps = ActionIconProps &
+ ButtonHTMLAttributes<HTMLButtonElement>;
+
+function getDefaultPluginDashboardSubscriptionsSdk() {
+ return {
+ DashboardSubscriptionsButton: (
+ _props: DashboardSubscriptionsButtonProps,
+ ): JSX.Element | null => null,
+ };
+}
+
+export const PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK =
+ getDefaultPluginDashboardSubscriptionsSdk();
+
+/**
+ * @internal Do not call directly. Use the main reinitialize function from metabase/plugins instead.
+ */
+export function reinitialize() {
+ Object.assign(
+ PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK,
+ getDefaultPluginDashboardSubscriptionsSdk(),
+ );
+}
diff --git a/frontend/src/embedding-sdk-bundle/hooks/private/use-sdk-dashboard-params.ts b/frontend/src/embedding-sdk-bundle/hooks/private/use-sdk-dashboard-params.ts
index 2856ab608ff..3ce7eef633a 100644
--- a/frontend/src/embedding-sdk-bundle/hooks/private/use-sdk-dashboard-params.ts
+++ b/frontend/src/embedding-sdk-bundle/hooks/private/use-sdk-dashboard-params.ts
@@ -41,24 +41,34 @@ export type SdkDashboardDisplayProps = SdkDashboardEntityInternalProps & {
*/
withDownloads?: boolean;
+ /**
+ * Whether to show the subscriptions button.
+ */
+ withSubscriptions?: boolean;
+
/**
* A list of [parameters to hide](https://www.metabase.com/docs/latest/embedding/public-links.html#appearance-parameters).
* <br/>
- * - Combining {@link SdkDashboardDisplayProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to filter data on the frontend is a [security risk](https://www.metabase.com/docs/latest/embedding/sdk/authentication.html#security-warning-each-end-user-must-have-their-own-metabase-account).
+ * - Combining {@link SdkDashboardProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to filter data on the frontend is a [security risk](https://www.metabase.com/docs/latest/embedding/sdk/authentication.html#security-warning-each-end-user-must-have-their-own-metabase-account).
* <br/>
- * - Combining {@link SdkDashboardDisplayProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to declutter the user interface is fine.
+ * - Combining {@link SdkDashboardProps.initialParameters | initialParameters} and {@link SdkDashboardDisplayProps.hiddenParameters | hiddenParameters} to declutter the user interface is fine.
**/
hiddenParameters?: string[];
} & CommonStylingProps;
export const useSdkDashboardParams = ({
withDownloads,
+ withSubscriptions,
withTitle,
withCardTitle,
hiddenParameters,
}: Pick<
SdkDashboardDisplayProps,
- "withDownloads" | "withTitle" | "withCardTitle" | "hiddenParameters"
+ | "withDownloads"
+ | "withSubscriptions"
+ | "withTitle"
+ | "withCardTitle"
+ | "hiddenParameters"
>) => {
// temporary name until we change `hideDownloadButton` to `downloads`
const hideDownloadButton = !withDownloads;
@@ -71,6 +81,7 @@ export const useSdkDashboardParams = ({
cardTitled: withCardTitle,
hideDownloadButton,
downloadsEnabled: { pdf: withDownloads, results: withDownloads },
+ withSubscriptions,
hideParameters: hiddenParameters?.join(",") ?? null,
},
isNotNull,
diff --git a/frontend/src/embedding-sdk-bundle/lib/usage-problem.ts b/frontend/src/embedding-sdk-bundle/lib/usage-problem.ts
index c45ea865ec5..d2b8cb01c0e 100644
--- a/frontend/src/embedding-sdk-bundle/lib/usage-problem.ts
+++ b/frontend/src/embedding-sdk-bundle/lib/usage-problem.ts
@@ -5,7 +5,7 @@ import type {
SdkUsageProblem,
SdkUsageProblemKey,
} from "embedding-sdk-bundle/types/usage-problem";
-import { EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG } from "metabase/embedding-sdk/config";
+import { isEmbeddingEajs } from "metabase/embedding-sdk/config";
import type { MetabaseEmbeddingSessionToken } from "metabase/embedding-sdk/types/refresh-token";
import { getIsLocalhost } from "./get-is-localhost";
@@ -156,7 +156,7 @@ const toWarning = (type: SdkUsageProblemKey): SdkUsageProblem => ({
});
const getTitle = () => {
- if (EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG.isSimpleEmbedding) {
+ if (isEmbeddingEajs()) {
// eslint-disable-next-line no-literal-metabase-strings -- only shown in development or config error.
return "This embed is powered by the Metabase Embedded Analytics JS";
}
diff --git a/frontend/src/embedding-sdk-bundle/store/index.ts b/frontend/src/embedding-sdk-bundle/store/index.ts
index 0e527df0b48..4392605a84c 100644
--- a/frontend/src/embedding-sdk-bundle/store/index.ts
+++ b/frontend/src/embedding-sdk-bundle/store/index.ts
@@ -6,6 +6,7 @@ import {
useDispatch,
useStore,
} from "metabase/lib/redux";
+import * as pulse from "metabase/notifications/pulse/reducers";
import { PLUGIN_REDUCERS } from "metabase/plugins";
import * as qb from "metabase/query_builder/reducers";
import { commonReducers } from "metabase/reducers-common";
@@ -18,6 +19,7 @@ import type { SdkDispatch, SdkStore } from "./types";
export const sdkReducers = {
...commonReducers,
+ pulse: combineReducers(pulse),
qb: combineReducers(qb),
visualizer,
sdk,
diff --git a/frontend/src/embedding-sdk-bundle/test/server-mocks/sdk-init.ts b/frontend/src/embedding-sdk-bundle/test/server-mocks/sdk-init.ts
index ced01360bdd..41fdb1417fc 100644
--- a/frontend/src/embedding-sdk-bundle/test/server-mocks/sdk-init.ts
+++ b/frontend/src/embedding-sdk-bundle/test/server-mocks/sdk-init.ts
@@ -37,13 +37,13 @@ export const setupSdkState = ({
}: {
currentUser?: User;
settingValues?: EnterpriseSettings;
- tokenFeatures?: TokenFeatures;
+ tokenFeatures?: Partial<TokenFeatures>;
settingDefinitions?: SettingDefinition[];
sdkState?: SdkState;
} & Partial<SdkStoreState> = {}) => {
const settingValuesWithToken = {
...settingValues,
- "token-features": tokenFeatures,
+ "token-features": createMockTokenFeatures(tokenFeatures),
};
setupCurrentUserEndpoint(currentUser);
diff --git a/frontend/src/metabase-types/api/mocks/user.ts b/frontend/src/metabase-types/api/mocks/user.ts
index d51337786cc..fbd07ed7d56 100644
--- a/frontend/src/metabase-types/api/mocks/user.ts
+++ b/frontend/src/metabase-types/api/mocks/user.ts
@@ -1,29 +1,33 @@
import type { User, UserInfo, UserListResult } from "metabase-types/api";
-export const createMockUser = (opts?: Partial<User>): User => ({
- id: 1,
- first_name: "Testy",
- last_name: "Tableton",
- common_name: `Testy Tableton`,
- custom_homepage: null,
- email: "[email protected]",
- locale: null,
- attributes: null,
- login_attributes: null,
- is_active: true,
- is_qbnewb: false,
- is_superuser: false,
- is_installer: false,
- has_invited_second_user: false,
- has_question_and_dashboard: false,
- personal_collection_id: 1,
- date_joined: new Date().toISOString(),
- first_login: new Date().toISOString(),
- last_login: new Date().toISOString(),
- updated_at: new Date().toISOString(),
- sso_source: null,
- ...opts,
-});
+export const createMockUser = (opts?: Partial<User>): User => {
+ const firstName = opts?.first_name ?? "Testy";
+ const lastName = opts?.last_name ?? "Tableton";
+ return {
+ id: 1,
+ first_name: firstName,
+ last_name: lastName,
+ common_name: [firstName, lastName].filter(Boolean).join(" "),
+ custom_homepage: null,
+ email: "[email protected]",
+ locale: null,
+ attributes: null,
+ login_attributes: null,
+ is_active: true,
+ is_qbnewb: false,
+ is_superuser: false,
+ is_installer: false,
+ has_invited_second_user: false,
+ has_question_and_dashboard: false,
+ personal_collection_id: 1,
+ date_joined: new Date().toISOString(),
+ first_login: new Date().toISOString(),
+ last_login: new Date().toISOString(),
+ updated_at: new Date().toISOString(),
+ sso_source: null,
+ ...opts,
+ };
+};
export const createMockUserListResult = (
opts?: Partial<UserListResult>,
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
index 4340bb71265..173dcb9c011 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
@@ -31,7 +31,7 @@ export function SharedCombinedEmbeddingSettings({
showContentTranslationSettings,
}: Props) {
const isSimpleEmbedFeatureAvailable =
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled();
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled();
const isGuestEmbedsEnabled = useSetting("enable-embedding-static");
const upgradeUrl = useSelector((state) =>
diff --git a/frontend/src/metabase/api/email.ts b/frontend/src/metabase/api/email.ts
index 08f1ca9aca7..236d241084b 100644
--- a/frontend/src/metabase/api/email.ts
+++ b/frontend/src/metabase/api/email.ts
@@ -1,7 +1,11 @@
import type { EmailSMTPSettings } from "metabase-types/api";
import { Api } from "./api";
-import { invalidateTags, tag } from "./tags";
+import {
+ invalidateTags,
+ provideSubscriptionChannelListTags,
+ tag,
+} from "./tags";
export const settingsApi = Api.injectEndpoints({
endpoints: (builder) => ({
@@ -18,7 +22,10 @@ export const settingsApi = Api.injectEndpoints({
body: emailSettings,
}),
invalidatesTags: (_, error) =>
- invalidateTags(error, [tag("session-properties")]),
+ invalidateTags(error, [
+ tag("session-properties"),
+ ...provideSubscriptionChannelListTags(),
+ ]),
}),
deleteEmailSMTPSettings: builder.mutation<void, void>({
query: () => ({
@@ -26,7 +33,10 @@ export const settingsApi = Api.injectEndpoints({
url: `/api/email`,
}),
invalidatesTags: (_, error) =>
- invalidateTags(error, [tag("session-properties")]),
+ invalidateTags(error, [
+ tag("session-properties"),
+ ...provideSubscriptionChannelListTags(),
+ ]),
}),
}),
});
diff --git a/frontend/src/metabase/common/components/ToolbarButton/ToolbarButton.tsx b/frontend/src/metabase/common/components/ToolbarButton/ToolbarButton.tsx
index b279a12cce8..7e05954cd00 100644
--- a/frontend/src/metabase/common/components/ToolbarButton/ToolbarButton.tsx
+++ b/frontend/src/metabase/common/components/ToolbarButton/ToolbarButton.tsx
@@ -6,13 +6,22 @@ import { ActionIcon, Box, Icon, Tooltip } from "metabase/ui";
export type ToolbarButtonProps = {
icon?: IconName;
- "aria-label": string;
- tooltipLabel?: TooltipProps["label"];
tooltipPosition?: TooltipProps["position"];
visibleOnSmallScreen?: boolean;
isActive?: boolean;
hasBackground?: boolean;
} & ActionIconProps &
+ (
+ | {
+ "aria-label": string;
+ tooltipLabel?: TooltipProps["label"];
+ }
+ | {
+ // Allow `aria-label` to be optional if `tooltipLabel` is provided as a string, so we don't need to provide the same string twice.
+ "aria-label"?: string;
+ tooltipLabel: string;
+ }
+ ) &
ButtonHTMLAttributes<HTMLButtonElement>;
export const ToolbarButton = forwardRef(function ToolbarButton(
@@ -49,7 +58,10 @@ export const ToolbarButton = forwardRef(function ToolbarButton(
}}
size="2rem"
variant="viewHeader"
- aria-label={ariaLabel}
+ aria-label={
+ ariaLabel ??
+ (typeof tooltipLabel === "string" ? tooltipLabel : undefined)
+ }
onClick={handleButtonClick}
bg={hasBackground ? undefined : "transparent"}
disabled={disabled}
diff --git a/frontend/src/metabase/dashboard/actions/sharing.ts b/frontend/src/metabase/dashboard/actions/sharing.ts
index 2ac3314b056..95469d994dd 100644
--- a/frontend/src/metabase/dashboard/actions/sharing.ts
+++ b/frontend/src/metabase/dashboard/actions/sharing.ts
@@ -1,5 +1,7 @@
import { SIDEBAR_NAME } from "metabase/dashboard/constants";
-import type { Dispatch } from "metabase-types/store";
+import type { Dispatch, GetState } from "metabase-types/store";
+
+import { getIsSharing } from "../selectors";
import { closeSidebar, setSidebar } from "./ui";
@@ -14,3 +16,18 @@ export const setSharing = (isSharing: boolean) => (dispatch: Dispatch) => {
dispatch(closeSidebar());
}
};
+
+export const closeSidebarIfSubscriptionsSidebarOpen =
+ () => (dispatch: Dispatch, getState: GetState) => {
+ const state = getState();
+ const isSharing = getIsSharing(state);
+ if (isSharing) {
+ dispatch(closeSidebar());
+ }
+ };
+
+export const toggleSharing = () => (dispatch: Dispatch, getState: GetState) => {
+ const state = getState();
+ const isSharing = getIsSharing(state);
+ dispatch(setSharing(!isSharing));
+};
diff --git a/frontend/src/metabase/dashboard/components/Dashboard/Dashboard.tsx b/frontend/src/metabase/dashboard/components/Dashboard/Dashboard.tsx
index 905bc2a6f7e..4772650a1e0 100644
--- a/frontend/src/metabase/dashboard/components/Dashboard/Dashboard.tsx
+++ b/frontend/src/metabase/dashboard/components/Dashboard/Dashboard.tsx
@@ -2,6 +2,7 @@ import cx from "classnames";
import { useMemo } from "react";
import { t } from "ttag";
+import { PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK } from "embedding-sdk-bundle/components/public/subscriptions";
import { DashboardArchivedEntityBanner } from "metabase/archive/components/ArchivedEntityBanner/DashboardArchivedEntityBanner";
import DashboardS from "metabase/css/dashboard.module.css";
import { DashboardHeader } from "metabase/dashboard/components/DashboardHeader";
@@ -145,6 +146,7 @@ type DashboardComponentType = typeof DashboardDefaultView & {
ParametersList: typeof ParametersList;
FullscreenButton: typeof FullscreenToggle;
ExportAsPdfButton: typeof ExportAsPdfButton;
+ SubscriptionsButton: typeof PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK.DashboardSubscriptionsButton;
InfoButton: typeof DashboardInfoButton;
RefreshPeriod: typeof RefreshWidget;
};
@@ -157,6 +159,8 @@ DashboardComponent.Tabs = DashboardTabs;
DashboardComponent.ParametersList = ParametersList;
DashboardComponent.FullscreenButton = FullscreenToggle;
DashboardComponent.ExportAsPdfButton = ExportAsPdfButton;
+DashboardComponent.SubscriptionsButton =
+ PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK.DashboardSubscriptionsButton;
DashboardComponent.InfoButton = DashboardInfoButton;
DashboardComponent.RefreshPeriod = RefreshWidget;
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.tsx
index fb9b933f17d..62b174c3f58 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.tsx
@@ -40,6 +40,7 @@ export const DashboardHeaderButtonRow = ({
isFullscreen,
onFullscreenChange,
downloadsEnabled,
+ withSubscriptions,
dashboardActions,
} = useDashboardContext();
@@ -78,6 +79,7 @@ export const DashboardHeaderButtonRow = ({
isFullscreen,
onFullscreenChange,
downloadsEnabled,
+ withSubscriptions,
...buttonComponentProps,
})
) {
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.unit.spec.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.unit.spec.tsx
index f1f734a600c..3145e113a3b 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/DashboardHeaderButtonRow.unit.spec.tsx
@@ -100,6 +100,10 @@ const DASHBOARD_EXPECTED_DATA_MAP: Record<
icon: "download",
tooltip: "Download as PDF",
},
+ DASHBOARD_SUBSCRIPTIONS: {
+ icon: "subscription",
+ tooltip: "Subscriptions",
+ },
};
const setup = ({
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/action-buttons.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/action-buttons.tsx
index 6d0a791081b..894a3445f12 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/action-buttons.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/action-buttons.tsx
@@ -19,6 +19,7 @@ import {
FullscreenToggle,
} from "../buttons";
import { AddLinkOrEmbedButton } from "../buttons/AddLinkOrEmbedButton";
+import { DashboardSubscriptionsButton } from "../buttons/DashboardSubscriptionsButton";
import { DASHBOARD_ACTION } from "./dashboard-action-keys";
import type { DashboardActionButton, DashboardActionKey } from "./types";
@@ -116,7 +117,7 @@ export const dashboardActionButtons: Record<
enabled: ({ isAnalyticsDashboard = false }) => isAnalyticsDashboard,
},
- // UTILITY
+ // UTILITY
[DASHBOARD_ACTION.DASHBOARD_HEADER_ACTION_DIVIDER]: {
component: () => (
<Center h="1.25rem" px="sm">
@@ -129,4 +130,9 @@ export const dashboardActionButtons: Record<
component: () => <ExportAsPdfButton />,
enabled: ({ downloadsEnabled }) => Boolean(downloadsEnabled.pdf),
},
+ // Modular embedding
+ [DASHBOARD_ACTION.DASHBOARD_SUBSCRIPTIONS]: {
+ enabled: ({ withSubscriptions }) => withSubscriptions,
+ component: () => <DashboardSubscriptionsButton />,
+ },
};
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/dashboard-action-keys.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/dashboard-action-keys.tsx
index 80c537f2811..3dd277a9d67 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/dashboard-action-keys.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/dashboard-action-keys.tsx
@@ -17,4 +17,10 @@ export const DASHBOARD_ACTION = {
DASHBOARD_ACTION_MENU: "DASHBOARD_ACTION_MENU",
FULLSCREEN_ANALYTICS_DASHBOARD: "FULLSCREEN_ANALYTICS_DASHBOARD",
DOWNLOAD_PDF: "DOWNLOAD_PDF",
+ // Modular embeddings (SDK, EAJS)
+ DASHBOARD_SUBSCRIPTIONS: "DASHBOARD_SUBSCRIPTIONS",
} as const;
+
+type DashboardActionKey = keyof typeof DASHBOARD_ACTION;
+export type DashboardActionValue =
+ (typeof DASHBOARD_ACTION)[DashboardActionKey];
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/types.ts b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/types.ts
index 1715083b318..e5f2b6ee888 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/types.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/DashboardHeaderButtonRow/types.ts
@@ -34,7 +34,10 @@ export type DashboardActionButton = {
props: HeaderButtonProps &
Pick<
DashboardContextReturned,
- "downloadsEnabled" | "isFullscreen" | "onFullscreenChange"
+ | "downloadsEnabled"
+ | "isFullscreen"
+ | "onFullscreenChange"
+ | "withSubscriptions"
>,
) => boolean;
};
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/DashboardSubscriptionsButton.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/DashboardSubscriptionsButton.tsx
new file mode 100644
index 00000000000..2725f5d68a6
--- /dev/null
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/DashboardSubscriptionsButton.tsx
@@ -0,0 +1,16 @@
+import { PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK } from "embedding-sdk-bundle/components/public/subscriptions";
+import { isEmbeddingEajs, isEmbeddingSdk } from "metabase/embedding-sdk/config";
+import { PLUGIN_EMBEDDING_IFRAME_SDK } from "metabase/plugins";
+
+export function DashboardSubscriptionsButton() {
+ if (isEmbeddingEajs()) {
+ return <PLUGIN_EMBEDDING_IFRAME_SDK.DashboardSubscriptionsButton />;
+ }
+
+ // This flag isn't exclusive it could mean we're on either SDK or EAJS
+ if (isEmbeddingSdk()) {
+ return <PLUGIN_DASHBOARD_SUBSCRIPTIONS_SDK.DashboardSubscriptionsButton />;
+ }
+
+ return null;
+}
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/ExportAsPdfButton.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/ExportAsPdfButton.tsx
index ccb23f6320e..c1c484c17c2 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/ExportAsPdfButton.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/buttons/ExportAsPdfButton.tsx
@@ -1,6 +1,8 @@
+import type { ButtonHTMLAttributes } from "react";
import { match } from "ts-pattern";
import { t } from "ttag";
+import { ToolbarButton } from "metabase/common/components/ToolbarButton";
import { useHasTokenFeature } from "metabase/common/hooks";
import {
type DashboardAccessedVia,
@@ -10,10 +12,12 @@ import { DASHBOARD_PDF_EXPORT_ROOT_ID } from "metabase/dashboard/constants";
import { useDashboardContext } from "metabase/dashboard/context/context";
import { isJWT } from "metabase/lib/utils";
import { isUuid } from "metabase/lib/uuid";
-import { ActionIcon, type ActionIconProps, Icon, Tooltip } from "metabase/ui";
+import type { ActionIconProps } from "metabase/ui";
import { saveDashboardPdf } from "metabase/visualizations/lib/save-dashboard-pdf";
-export const ExportAsPdfButton = (props: ActionIconProps) => {
+export const ExportAsPdfButton = (
+ props: ActionIconProps & ButtonHTMLAttributes<HTMLButtonElement>,
+) => {
const { dashboard } = useDashboardContext();
const isWhitelabeled = useHasTokenFeature("whitelabel");
const includeBranding = !isWhitelabeled;
@@ -38,15 +42,12 @@ export const ExportAsPdfButton = (props: ActionIconProps) => {
};
return (
- <Tooltip label={t`Download as PDF`}>
- <ActionIcon
- onClick={saveAsPDF}
- aria-label={t`Download as PDF`}
- data-testid="export-as-pdf-button"
- {...props}
- >
- <Icon name="download" />
- </ActionIcon>
- </Tooltip>
+ <ToolbarButton
+ icon="download"
+ onClick={saveAsPDF}
+ tooltipLabel={t`Download as PDF`}
+ data-testid="export-as-pdf-button"
+ {...props}
+ />
);
};
diff --git a/frontend/src/metabase/dashboard/constants.ts b/frontend/src/metabase/dashboard/constants.ts
index a0d6f9ed887..886ca12b595 100644
--- a/frontend/src/metabase/dashboard/constants.ts
+++ b/frontend/src/metabase/dashboard/constants.ts
@@ -68,6 +68,8 @@ export const DEFAULT_DASHBOARD_DISPLAY_OPTIONS: EmbedDisplayParams = {
font: null,
theme: "light",
downloadsEnabled: { pdf: true, results: true },
+ // TODO: (Kelvin 2025-11-17) this will be removed when I work on EMB-1025
+ withSubscriptions: true,
withFooter: true,
getClickActionMode: undefined,
};
diff --git a/frontend/src/metabase/dashboard/context/context.tsx b/frontend/src/metabase/dashboard/context/context.tsx
index 67cc766c93b..059e0a21748 100644
--- a/frontend/src/metabase/dashboard/context/context.tsx
+++ b/frontend/src/metabase/dashboard/context/context.tsx
@@ -63,13 +63,12 @@ export type DashboardContextOwnProps = {
dashcardMenu?: DashboardCardMenu | null;
dashboardActions?:
| DashboardActionButtonList
- | (({
- isEditing,
- downloadsEnabled,
- }: Pick<
- DashboardContextReturned,
- "isEditing" | "downloadsEnabled"
- >) => DashboardActionButtonList);
+ | ((
+ props: Pick<
+ DashboardContextReturned,
+ "isEditing" | "downloadsEnabled" | "withSubscriptions"
+ >,
+ ) => DashboardActionButtonList);
isDashcardVisible?: (dc: DashboardCard) => boolean;
isGuestEmbed?: boolean;
/**
@@ -138,6 +137,12 @@ const DashboardContextProviderInner = forwardRef(
font = null,
hideParameters: hide_parameters = null,
downloadsEnabled = { pdf: true, results: true },
+ /**
+ * TODO: (Kelvin 2025-11-17) See if we could communicate better how these default values are derived from. E.g. some are passed via the SDK props
+ * which already have default values and we're setting another default values here again. One thing we could do is to have a constant file that
+ * multiple places could refer to.
+ */
+ withSubscriptions = false,
autoScrollToDashcardId = undefined,
reportAutoScrolledToDashcard = noop,
cardTitled = true,
@@ -365,7 +370,11 @@ const DashboardContextProviderInner = forwardRef(
const dashboardActions =
typeof initDashboardActions === "function"
- ? initDashboardActions({ isEditing, downloadsEnabled })
+ ? initDashboardActions({
+ isEditing,
+ downloadsEnabled,
+ withSubscriptions,
+ })
: (initDashboardActions ?? null);
// Determine if the dashboard is editable.
@@ -417,6 +426,7 @@ const DashboardContextProviderInner = forwardRef(
font,
hideParameters,
downloadsEnabled,
+ withSubscriptions,
autoScrollToDashcardId,
reportAutoScrolledToDashcard,
cardTitled,
diff --git a/frontend/src/metabase/dashboard/types/embed-display-options.ts b/frontend/src/metabase/dashboard/types/embed-display-options.ts
index eac6afb335f..34854f7c25a 100644
--- a/frontend/src/metabase/dashboard/types/embed-display-options.ts
+++ b/frontend/src/metabase/dashboard/types/embed-display-options.ts
@@ -30,4 +30,6 @@ export type EmbedDisplayParams = {
getClickActionMode: ClickActionModeGetter | undefined;
downloadsEnabled: EmbedResourceDownloadOptions;
withFooter: boolean;
+ // TODO: (Kelvin 2025-11-17) move this to a new type in EMB-1025
+ withSubscriptions: boolean;
};
diff --git a/frontend/src/metabase/embedding-sdk/config.ts b/frontend/src/metabase/embedding-sdk/config.ts
index 5c3e65e68b2..cef9f4b51fb 100644
--- a/frontend/src/metabase/embedding-sdk/config.ts
+++ b/frontend/src/metabase/embedding-sdk/config.ts
@@ -45,3 +45,9 @@ export const EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG = {
* such as sdk-based iframe embedding.
**/
export const isEmbeddingSdk = () => EMBEDDING_SDK_CONFIG.isEmbeddingSdk;
+
+/**
+ * Whether we are in the Embedded Analytics JS
+ */
+export const isEmbeddingEajs = () =>
+ EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG.isSimpleEmbedding;
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts
index 7b3ed101b8a..87a2895defe 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/analytics.ts
@@ -32,6 +32,7 @@ const EMBED_SETTINGS_TO_TRACK: SdkIframeEmbedSettingKey[] = [
"drills",
"withTitle",
"withDownloads",
+ "withSubscriptions",
"isSaveEnabled",
"readOnly",
"layout",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupProvider.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupProvider.tsx
index 3d75880a216..d9bc8d2042d 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupProvider.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupProvider.tsx
@@ -37,7 +37,7 @@ export const SdkIframeEmbedSetupProvider = ({
onClose,
}: SdkIframeEmbedSetupProviderProps) => {
const isSimpleEmbedFeatureAvailable =
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled();
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled();
const isSimpleEmbeddingEnabled = useSetting("enable-embedding-simple");
const isSimpleEmbeddingTermsAccepted = !useSetting("show-simple-embed-terms");
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx
index 40526cc85f7..3a4f53bc779 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx
@@ -1,8 +1,9 @@
import { type ReactNode, useCallback, useMemo } from "react";
+import { Link } from "react-router";
import { P, match } from "ts-pattern";
-import { t } from "ttag";
+import { c, t } from "ttag";
-import { useSetting } from "metabase/common/hooks";
+import { useHasEmailSetup, useSetting } from "metabase/common/hooks";
import {
UPSELL_CAMPAIGN_AUTH,
UPSELL_CAMPAIGN_BEHAVIOR,
@@ -170,6 +171,7 @@ const AuthenticationSection = () => {
const BehaviorSection = () => {
const { settings, updateSettings } = useSdkIframeEmbedSetupContext();
+ const hasEmailSetup = useHasEmailSetup();
const behaviorSection = useMemo(() => {
return match(settings)
@@ -266,6 +268,54 @@ const BehaviorSection = () => {
/>
)}
</WithNotAvailableWithoutSimpleEmbeddingFeatureWarning>
+
+ <WithNotAvailableForGuestEmbedsWarning
+ campaign={UPSELL_CAMPAIGN_BEHAVIOR}
+ >
+ {({ disabled: disabledInGuestEmbedding }) => {
+ return (
+ <Flex align="center" gap="xs">
+ <Checkbox
+ disabled={!hasEmailSetup || disabledInGuestEmbedding}
+ label={t`Allow subscriptions`}
+ checked={settings.withSubscriptions}
+ onChange={(e) =>
+ updateSettings({ withSubscriptions: e.target.checked })
+ }
+ />
+ {!hasEmailSetup && !disabledInGuestEmbedding && (
+ <HoverCard>
+ <HoverCard.Target>
+ <Icon
+ name="info"
+ size={14}
+ c="var(--mb-color-text-secondary)"
+ />
+ </HoverCard.Target>
+ <HoverCard.Dropdown p="sm">
+ <Text>{c(
+ "{0} is a link to email settings page with text 'admin settings'",
+ ).jt`To allow subscriptions, set up email in ${(
+ <Link
+ key="admin-settings-link"
+ to="/admin/settings/email"
+ >
+ <Text
+ display="inline"
+ c="var(--mb-color-text-brand)"
+ fw="bold"
+ >{c(
+ "is a link in a sentence 'To allow subscriptions, set up email in admin settings'",
+ ).t`admin settings`}</Text>
+ </Link>
+ )}`}</Text>
+ </HoverCard.Dropdown>
+ </HoverCard>
+ )}
+ </Flex>
+ );
+ }}
+ </WithNotAvailableForGuestEmbedsWarning>
</Stack>
),
)
@@ -281,7 +331,7 @@ const BehaviorSection = () => {
),
)
.otherwise(() => null);
- }, [settings, updateSettings]);
+ }, [hasEmailSetup, settings, updateSettings]);
if (behaviorSection === null) {
return null;
@@ -407,11 +457,7 @@ const WithGuestEmbedsDisabledWarning = ({
return (
<TooltipWarning
- warning={
- <Text lh="md" p="md">
- {t`Disabled in the admin settings`}
- </Text>
- }
+ tooltip={t`Disabled in the admin settings`}
disabled={disabled}
>
{children}
@@ -460,11 +506,7 @@ const WithNotAvailableForGuestEmbedsWarning = ({
{({ disabled: disabledForOss, hoverCard: disabledForOssHoverCard }) => (
<TooltipWarning
enableTooltip={!disabledForOss}
- warning={
- <Text lh="md" p="md">
- {t`Not available if Guest Mode is selected`}
- </Text>
- }
+ tooltip={t`Not available if Guest Mode is selected`}
disabled={!!settings.isGuest}
>
{({
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
index a12f9a476d5..9ede2a12453 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
@@ -7,11 +7,11 @@ import { setup, waitForUpdateSetting } from "./test-setup";
describe("Embed flow > embedding hub step completion tracking", () => {
beforeEach(() => {
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled = jest.fn(() => true);
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = jest.fn(() => true);
});
afterEach(() => {
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled = () => false;
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => false;
});
afterEach(() => {
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
index eb90eeda024..d8981bd6c2e 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
@@ -33,11 +33,11 @@ describe("Embed flow > initial setup", () => {
describe("Embed flow > forward and backward navigation", () => {
beforeEach(() => {
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled = jest.fn(() => true);
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = jest.fn(() => true);
});
afterEach(() => {
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled = () => false;
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => false;
});
it("navigates forward through the embed flow", async () => {
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
index ea89bc56ed8..2306ed079a6 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
@@ -3,6 +3,7 @@ import {
findRequests,
setupDashboardEndpoints,
setupDashboardQueryMetadataEndpoint,
+ setupNotificationChannelsEndpoints,
setupRecentViewsAndSelectionsEndpoints,
setupSearchEndpoints,
setupUpdateSettingEndpoint,
@@ -60,6 +61,7 @@ export const setup = (options?: {
);
setupUpdateSettingsEndpoint();
setupUpdateSettingEndpoint();
+ setupNotificationChannelsEndpoints({});
renderWithProviders(
<SdkIframeEmbedSetupModal
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/TooltipWarning.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/TooltipWarning.tsx
index 9bbf310ea6b..9e1308569f5 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/TooltipWarning.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/TooltipWarning.tsx
@@ -1,18 +1,12 @@
import type { ReactNode } from "react";
+import { P, match } from "ts-pattern";
import CS from "metabase/css/core/index.css";
-import { Box, Flex, HoverCard, Icon } from "metabase/ui";
+import { Flex, HoverCard, Icon, Tooltip } from "metabase/ui";
export type TooltipWarningMode = "default" | "custom";
-export const TooltipWarning = ({
- children,
- mode = "default",
- enableTooltip = true,
- icon,
- warning,
- disabled,
-}: {
+type TooltipWarningProps = {
mode?: TooltipWarningMode;
children: (data: {
disabled: boolean;
@@ -20,34 +14,57 @@ export const TooltipWarning = ({
}) => ReactNode;
enableTooltip?: boolean;
icon?: ReactNode;
- warning: ReactNode;
disabled: boolean;
-}) => {
+} & (
+ | {
+ tooltip: string;
+ hovercard?: never;
+ }
+ | {
+ tooltip?: never;
+ hovercard: ReactNode;
+ }
+);
+
+export const TooltipWarning = ({
+ children,
+ mode = "default",
+ enableTooltip = true,
+ icon,
+ tooltip,
+ hovercard,
+ disabled,
+}: TooltipWarningProps) => {
if (!enableTooltip) {
return children({ disabled: false, hoverCard: null });
}
- const iconElement = (
- <Box>
- {icon ?? (
- <Icon
- name={"info"}
- size={14}
- c="text-medium"
- cursor="pointer"
- style={{ flexShrink: 0 }}
- />
- )}
- </Box>
+ const iconElement = icon ?? (
+ <Icon
+ name={"info"}
+ size={14}
+ c="var(--mb-color-text-secondary)"
+ cursor="pointer"
+ style={{ flexShrink: 0 }}
+ />
);
- const hoverCard = disabled ? (
- <HoverCard position="bottom">
- <HoverCard.Target>
- <Box className={CS.cursorPointer}>{iconElement}</Box>
- </HoverCard.Target>
- <HoverCard.Dropdown>{warning}</HoverCard.Dropdown>
- </HoverCard>
- ) : null;
+ const hoverCard = disabled
+ ? match({ tooltip, hovercard })
+ .with({ tooltip: P.not(P.nullish) }, ({ tooltip }) => (
+ <Tooltip label={tooltip}>{iconElement}</Tooltip>
+ ))
+ .with({ hovercard: P.not(P.nullish) }, ({ hovercard }) => (
+ <HoverCard position="bottom">
+ <HoverCard.Target>
+ <Flex align="center" className={CS.cursorPointer}>
+ {iconElement}
+ </Flex>
+ </HoverCard.Target>
+ <HoverCard.Dropdown>{hovercard}</HoverCard.Dropdown>
+ </HoverCard>
+ ))
+ .otherwise(() => null)
+ : null;
const isCustomMode = mode === "custom";
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx
index cf52bb9eba0..846a1d493cb 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/warnings/WithSimpleEmbeddingFeatureUpsellTooltip.tsx
@@ -35,7 +35,7 @@ export const WithSimpleEmbeddingFeatureUpsellTooltip = ({
mode={mode}
enableTooltip={enableTooltip}
icon={<UpsellGem />}
- warning={
+ hovercard={
<UpsellCard
title={t`Get more powerful embedding`}
buttonLink={upgradeUrl}
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
index 921749c2f55..395b3e75594 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
@@ -86,7 +86,7 @@ export const getCommonEmbedSettings = ({
isGuestEmbedsEnabled: boolean;
}) => {
const isSimpleEmbedFeatureAvailable =
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled();
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled();
if (isSimpleEmbedFeatureAvailable) {
return isGuestEmbedsEnabled && state?.isGuest
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.unit.spec.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.unit.spec.ts
index 0b5bfbb243c..93177f36939 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.unit.spec.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.unit.spec.ts
@@ -5,14 +5,14 @@ import { getCommonEmbedSettings } from "./get-common-embed-settings";
jest.mock("metabase/plugins", () => ({
PLUGIN_EMBEDDING_IFRAME_SDK_SETUP: {
- isFeatureEnabled: jest.fn(),
+ isEnabled: jest.fn(),
},
}));
-const mockIsFeatureEnabled = (enabled: boolean) => {
- (
- PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isFeatureEnabled as jest.Mock
- ).mockReturnValue(enabled);
+const mockIsPluginEnabled = (enabled: boolean) => {
+ (PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled as jest.Mock).mockReturnValue(
+ enabled,
+ );
};
describe("getCommonEmbedSettings", () => {
@@ -22,7 +22,7 @@ describe("getCommonEmbedSettings", () => {
describe("when simple embed feature is available (Enterprise)", () => {
beforeEach(() => {
- mockIsFeatureEnabled(true);
+ mockIsPluginEnabled(true);
});
describe("with guest embeds enabled and state.isGuest is true", () => {
@@ -210,7 +210,7 @@ describe("getCommonEmbedSettings", () => {
describe("when simple embed feature is not available (OSS)", () => {
beforeEach(() => {
- mockIsFeatureEnabled(false);
+ mockIsPluginEnabled(false);
});
it.each<{
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
index 0d031cb1ce6..2069fdc0819 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
@@ -47,6 +47,7 @@ export const getDefaultSdkIframeEmbedSettings = ({
dashboardId: resourceId,
drills: true,
withDownloads: false,
+ withSubscriptions: false,
withTitle: true,
}),
)
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
index 37b144ee2c2..aa43b3d4771 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
@@ -62,7 +62,7 @@ export const SdkIframeEmbedRoute = () => {
return null;
}
- const hasEmbedTokenFeature = PLUGIN_EMBEDDING_IFRAME_SDK.hasValidLicense();
+ const hasEmbedTokenFeature = PLUGIN_EMBEDDING_IFRAME_SDK.isEnabled();
const { isGuest, locale } = embedSettings;
const isProduction = !embedSettings._isLocalhost;
@@ -194,6 +194,7 @@ const SdkIframeEmbedView = ({
token={settings.token}
withTitle={settings.withTitle}
withDownloads={settings.withDownloads}
+ withSubscriptions={settings.withSubscriptions}
initialParameters={settings.initialParameters}
hiddenParameters={settings.hiddenParameters}
drillThroughQuestionHeight="100%"
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts
index cf60ba907a2..26f7d1893a2 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts
@@ -31,6 +31,7 @@ export const ALLOWED_EMBED_SETTING_KEYS_MAP = {
"dashboardId",
"withTitle",
"withDownloads",
+ "withSubscriptions",
"initialParameters",
"hiddenParameters",
"drills",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
index 0bc88bd1062..614fbe52fec 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
@@ -489,6 +489,7 @@ const MetabaseDashboardElement = createCustomElement("metabase-dashboard", [
"token",
"with-title",
"with-downloads",
+ "with-subscriptions",
"drills",
"initial-parameters",
"hidden-parameters",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
index f2b387d0926..33af74f29c8 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
@@ -75,6 +75,7 @@ export type DashboardEmbedOptions = StrictUnion<
drills?: boolean;
withTitle?: boolean;
withDownloads?: boolean;
+ withSubscriptions?: boolean;
// parameters
initialParameters?: ParameterValues;
diff --git a/frontend/src/metabase/notifications/AddEditSidebar/AddEditEmailSidebar.tsx b/frontend/src/metabase/notifications/AddEditSidebar/AddEditEmailSidebar.tsx
index 5785779d3a4..385fe31bf98 100644
--- a/frontend/src/metabase/notifications/AddEditSidebar/AddEditEmailSidebar.tsx
+++ b/frontend/src/metabase/notifications/AddEditSidebar/AddEditEmailSidebar.tsx
@@ -1,7 +1,9 @@
import cx from "classnames";
+import { useEffect } from "react";
import { t } from "ttag";
import _ from "underscore";
+import { getCurrentUser } from "metabase/admin/datamodel/selectors";
import SchedulePicker, {
type ScheduleChangeProp,
} from "metabase/common/components/SchedulePicker";
@@ -9,6 +11,7 @@ import SendTestPulse from "metabase/common/components/SendTestPulse";
import Toggle from "metabase/common/components/Toggle";
import CS from "metabase/css/core/index.css";
import { Sidebar } from "metabase/dashboard/components/Sidebar";
+import { isEmbeddingSdk } from "metabase/embedding-sdk/config";
import { dashboardPulseIsValid } from "metabase/lib/pulse";
import { useSelector } from "metabase/lib/redux";
import EmailAttachmentPicker from "metabase/notifications/EmailAttachmentPicker";
@@ -80,6 +83,13 @@ export const AddEditEmailSidebar = ({
}: AddEditEmailSidebarProps) => {
const isValid = dashboardPulseIsValid(pulse, formInput.channels);
const userCanAccessSettings = useSelector(canAccessSettings);
+ const currentUser = useSelector(getCurrentUser);
+
+ useEffect(() => {
+ if (isEmbeddingSdk()) {
+ onChannelPropertyChange("recipients", [currentUser]);
+ }
+ }, [currentUser, onChannelPropertyChange]);
return (
<Sidebar
@@ -91,26 +101,28 @@ export const AddEditEmailSidebar = ({
<Icon name="mail" className={CS.mr1} size={21} />
<Heading>{t`Email this dashboard`}</Heading>
</div>
- <CaveatMessage />
+ {isEmbeddingSdk() ? null : <CaveatMessage />}
<div
className={cx(CS.my2, CS.px4, CS.fullHeight, CS.flex, CS.flexColumn)}
>
- <div>
- <div className={cx(CS.textBold, CS.mb1)}>{t`To:`}</div>
- <RecipientPicker
- autoFocus={false}
- recipients={channel.recipients}
- users={users}
- onRecipientsChange={(recipients) =>
- onChannelPropertyChange("recipients", recipients)
- }
- invalidRecipientText={(domains) =>
- userCanAccessSettings
- ? t`You're only allowed to email subscriptions to addresses ending in ${domains}`
- : t`You're only allowed to email subscriptions to allowed domains`
- }
- />
- </div>
+ {isEmbeddingSdk() ? null : (
+ <div>
+ <div className={cx(CS.textBold, CS.mb1)}>{t`To:`}</div>
+ <RecipientPicker
+ autoFocus={false}
+ recipients={channel.recipients}
+ users={users}
+ onRecipientsChange={(recipients) =>
+ onChannelPropertyChange("recipients", recipients)
+ }
+ invalidRecipientText={(domains) =>
+ userCanAccessSettings
+ ? t`You're only allowed to email subscriptions to addresses ending in ${domains}`
+ : t`You're only allowed to email subscriptions to allowed domains`
+ }
+ />
+ </div>
+ )}
<SchedulePicker
schedule={_.pick(
channel,
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/DashboardSubscriptionsSidebar.jsx b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/DashboardSubscriptionsSidebar.jsx
index a3c775aa5bc..ed9ca5480b9 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/DashboardSubscriptionsSidebar.jsx
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/DashboardSubscriptionsSidebar.jsx
@@ -1,12 +1,13 @@
/* eslint "react/prop-types": "error" */
import PropTypes from "prop-types";
-import { Component } from "react";
+import { Component, useMemo } from "react";
import _ from "underscore";
import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
import { Sidebar } from "metabase/dashboard/components/Sidebar";
import { useDashboardContext } from "metabase/dashboard/context";
+import { isEmbeddingSdk } from "metabase/embedding-sdk/config";
import Pulses from "metabase/entities/pulses";
import {
NEW_PULSE_TEMPLATE,
@@ -45,7 +46,7 @@ const EDITING_MODES = {
ADD_EMAIL: "add-edit-email",
ADD_SLACK: "add-edit-slack",
NEW_PULSE: "new-pulse",
- LIST_PULSES: "list-pulses",
+ LIST_PULSES_OR_NEW_PULSE: "list-pulses-or-new-pulse",
};
const CHANNEL_TYPES = {
@@ -106,7 +107,7 @@ const mapDispatchToProps = {
class DashboardSubscriptionsSidebarInner extends Component {
state = {
- editingMode: EDITING_MODES.LIST_PULSES,
+ editingMode: EDITING_MODES.LIST_PULSES_OR_NEW_PULSE,
// use this to know where to go "back" to
returnMode: [],
isSaving: false,
@@ -128,6 +129,8 @@ class DashboardSubscriptionsSidebarInner extends Component {
onCancel: PropTypes.func.isRequired,
setPulseArchived: PropTypes.func.isRequired,
params: PropTypes.object,
+ // From Pulses.loadList HOC
+ loading: PropTypes.bool,
};
componentDidMount() {
@@ -136,7 +139,31 @@ class DashboardSubscriptionsSidebarInner extends Component {
}
componentDidUpdate(prevProps) {
- const { isAdmin } = this.props;
+ const { editingMode } = this.state;
+ const { isAdmin, pulses, loading: isSubscriptionListLoading } = this.props;
+
+ /**
+ * (EMB-976): In SDK/EAJS context we need to avoid showing the NEW_PULSE view (the view that lets users select
+ * between Email and Slack options) because we only allow email subscriptions there.
+ *
+ * And it's guaranteed that email would already be set up in SDK/EAJS context.
+ * Otherwise, we won't show the subscription button to open this sidebar
+ * in the first place.
+ */
+ if (
+ isEmbeddingSdk() &&
+ shouldDisplayNewPulse(editingMode, pulses) &&
+ /**
+ * Ensure we don't prematurely switch to ADD_EMAIL while the pulse list is loading.
+ * When loading completes, shouldDisplayNewPulse() will correctly return false if the list is empty.
+ */
+ !isSubscriptionListLoading
+ ) {
+ this.setState({
+ editingMode: EDITING_MODES.ADD_EMAIL,
+ });
+ this.setPulseWithChannel(CHANNEL_TYPES.EMAIL);
+ }
if (!isAdmin) {
this.forwardNonAdmins({ prevProps });
@@ -144,7 +171,12 @@ class DashboardSubscriptionsSidebarInner extends Component {
}
fetchUsers = async () => {
- this.setState({ users: (await UserApi.list()).data });
+ if (isEmbeddingSdk()) {
+ // We don't need the the list of users in SDK/EAJS context because we will hard code the recipient to the logged in user.
+ this.setState({ users: [] });
+ } else {
+ this.setState({ users: (await UserApi.list()).data });
+ }
};
forwardNonAdmins = ({ prevProps }) => {
@@ -157,7 +189,7 @@ class DashboardSubscriptionsSidebarInner extends Component {
if (newPulses?.length > 0 && prevPulses?.length === 0) {
this.setState(() => {
return {
- editingMode: EDITING_MODES.LIST_PULSES,
+ editingMode: EDITING_MODES.LIST_PULSES_OR_NEW_PULSE,
returnMode: [],
};
});
@@ -165,9 +197,10 @@ class DashboardSubscriptionsSidebarInner extends Component {
return;
}
- const isEditingModeForwardable =
- editingMode === EDITING_MODES.NEW_PULSE ||
- (editingMode === EDITING_MODES.LIST_PULSES && newPulses?.length === 0);
+ const isEditingModeForwardable = shouldDisplayNewPulse(
+ editingMode,
+ newPulses,
+ );
if (isEditingModeForwardable) {
const emailConfigured = formInput?.channels?.email?.configured || false;
@@ -270,7 +303,10 @@ class DashboardSubscriptionsSidebarInner extends Component {
this.setState({ isSaving: true });
await this.props.updateEditingPulse(cleanedPulse);
await this.props.saveEditingPulse();
- this.setState({ editingMode: EDITING_MODES.LIST_PULSES, returnMode: [] });
+ this.setState({
+ editingMode: EDITING_MODES.LIST_PULSES_OR_NEW_PULSE,
+ returnMode: [],
+ });
} finally {
this.setState({ isSaving: false });
}
@@ -288,18 +324,32 @@ class DashboardSubscriptionsSidebarInner extends Component {
editPulse = (pulse, channelType) => {
this.setPulse(pulse);
this.setState(({ editingMode, returnMode }) => {
+ const editingModeMap = {
+ [CHANNEL_TYPES.EMAIL]: EDITING_MODES.ADD_EMAIL,
+ [CHANNEL_TYPES.SLACK]: EDITING_MODES.ADD_SLACK,
+ };
return {
- editingMode: "add-edit-" + channelType,
+ editingMode: editingModeMap[channelType],
returnMode: returnMode.concat([
- editingMode || EDITING_MODES.LIST_PULSES,
+ editingMode || EDITING_MODES.LIST_PULSES_OR_NEW_PULSE,
]),
};
});
};
handleArchive = async () => {
- await this.props.setPulseArchived(this.props.pulse, true);
- this.setState({ editingMode: EDITING_MODES.LIST_PULSES, returnMode: [] });
+ const { pulse, pulses, setPulseArchived, onCancel } = this.props;
+
+ await setPulseArchived(pulse, true);
+
+ if (isEmbeddingSdk() && pulses.length === 1) {
+ onCancel();
+ } else {
+ this.setState({
+ editingMode: EDITING_MODES.LIST_PULSES_OR_NEW_PULSE,
+ returnMode: [],
+ });
+ }
};
// Because you can navigate down the sidebar, we need to wrap
@@ -333,7 +383,10 @@ class DashboardSubscriptionsSidebarInner extends Component {
);
}
- if (editingMode === EDITING_MODES.LIST_PULSES && pulses.length > 0) {
+ if (
+ editingMode === EDITING_MODES.LIST_PULSES_OR_NEW_PULSE &&
+ pulses.length > 0
+ ) {
return (
<PulsesListSidebar
pulses={pulses}
@@ -364,21 +417,16 @@ class DashboardSubscriptionsSidebarInner extends Component {
const channelSpec = formInput.channels.email;
return (
- <AddEditEmailSidebar
+ <AddEditEmailSidebarWithHooks
+ index={index}
pulse={pulse}
formInput={formInput}
channel={channel}
channelSpec={channelSpec}
handleSave={this.handleSave}
onCancel={this.onCancel}
- onChannelPropertyChange={_.partial(
- this.onChannelPropertyChange,
- index,
- )}
- onChannelScheduleChange={_.partial(
- this.onChannelScheduleChange,
- index,
- )}
+ onChannelPropertyChange={this.onChannelPropertyChange}
+ onChannelScheduleChange={this.onChannelScheduleChange}
testPulse={testPulse}
toggleSkipIfEmpty={this.toggleSkipIfEmpty}
setPulse={this.setPulse}
@@ -433,7 +481,7 @@ class DashboardSubscriptionsSidebarInner extends Component {
);
}
- if (editingMode === EDITING_MODES.NEW_PULSE || pulses.length === 0) {
+ if (shouldDisplayNewPulse(editingMode, pulses)) {
const emailConfigured = formInput?.channels?.email?.configured || false;
const slackConfigured = formInput?.channels?.slack?.configured || false;
@@ -472,6 +520,72 @@ class DashboardSubscriptionsSidebarInner extends Component {
}
}
+function AddEditEmailSidebarWithHooks({
+ /* eslint-disable react/prop-types */
+ index,
+ pulse,
+ formInput,
+ channel,
+ channelSpec,
+ handleSave,
+ onCancel,
+ onChannelPropertyChange,
+ onChannelScheduleChange,
+ testPulse,
+ toggleSkipIfEmpty,
+ setPulse,
+ users,
+ handleArchive,
+ dashboard,
+ setPulseParameters,
+ /* eslint-enable react/prop-types */
+}) {
+ /**
+ * Memoized because it's used in `AddEditEmailSidebar.tsx` as a dependency
+ */
+ const handleChannelPropertyChange = useMemo(
+ () => _.partial(onChannelPropertyChange, index),
+ [index, onChannelPropertyChange],
+ );
+
+ const handleChannelScheduleChange = _.partial(onChannelScheduleChange, index);
+
+ return (
+ <AddEditEmailSidebar
+ pulse={pulse}
+ formInput={formInput}
+ channel={channel}
+ channelSpec={channelSpec}
+ handleSave={handleSave}
+ onCancel={onCancel}
+ onChannelPropertyChange={handleChannelPropertyChange}
+ onChannelScheduleChange={handleChannelScheduleChange}
+ testPulse={testPulse}
+ toggleSkipIfEmpty={toggleSkipIfEmpty}
+ setPulse={setPulse}
+ users={users}
+ handleArchive={handleArchive}
+ dashboard={dashboard}
+ setPulseParameters={setPulseParameters}
+ />
+ );
+}
+
+function shouldDisplayNewPulse(editingMode, pulses) {
+ if (editingMode === EDITING_MODES.NEW_PULSE) {
+ return true;
+ }
+
+ if (
+ editingMode === EDITING_MODES.LIST_PULSES_OR_NEW_PULSE &&
+ pulses?.length === 0
+ ) {
+ return true;
+ }
+
+ return false;
+}
+
const DashboardSubscriptionsSidebarConnected = _.compose(
Pulses.loadList({
query: (state, { dashboard }) => ({ dashboard_id: dashboard.id }),
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
index 37347930268..d9f3fa174c4 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
@@ -1,7 +1,8 @@
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
-import { screen } from "__support__/ui";
+import { screen, within } from "__support__/ui";
+import type { Pulse } from "metabase-types/api";
import { dashcard, hasBasicFilterOptions, setup, user } from "./setup";
@@ -41,6 +42,198 @@ describe("DashboardSubscriptionsSidebar", () => {
expect(await screen.findByText("Send it to Slack")).toBeInTheDocument();
});
+ it("should show email warning message", async () => {
+ setup({ email: true, slack: true });
+
+ await userEvent.click(await screen.findByText("Email it"));
+ expect(await screen.findByText("Email this dashboard")).toBeInTheDocument();
+ expect(
+ screen.getByText(
+ "Recipients will see this data just as you see it, regardless of their permissions.",
+ ),
+ ).toBeInTheDocument();
+ });
+
+ describe.each([
+ {
+ slack: true,
+ },
+ {
+ slack: false,
+ },
+ ])("Embedding SDK", ({ slack }) => {
+ const testScenarioCondition = slack
+ ? "Slack is set up"
+ : "Slack is not set up";
+
+ it(`should not show subscription options when ${testScenarioCondition}`, async () => {
+ setup({ isEmbeddingSdk: true, email: true, slack });
+
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+ });
+
+ // We don't test `email: false` because this sidebar is only accessible when email is already set up
+
+ it(`should not show email warning message when ${testScenarioCondition}`, async () => {
+ setup({ isEmbeddingSdk: true, email: true, slack });
+
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByText(
+ "Recipients will see this data just as you see it, regardless of their permissions.",
+ ),
+ ).not.toBeInTheDocument();
+ });
+
+ it(`should close the sidebar when the last pulse is archived and ${testScenarioCondition}`, async () => {
+ const pulses = [
+ {
+ channels: [
+ {
+ schedule_type: "daily",
+ schedule_hour: 0,
+ channel_type: "email",
+ enabled: true,
+ },
+ ],
+ name: "E-commerce Insights",
+ id: 10,
+ cards: [],
+ },
+ {
+ channels: [
+ {
+ schedule_type: "hourly",
+ channel_type: "email",
+ enabled: true,
+ },
+ ],
+ name: "E-commerce Insights",
+ id: 11,
+ cards: [],
+ },
+ ] satisfies (Pulse & { id: number })[];
+
+ // Dynamically modify `pulses` so that we get the new updated list of pulses after archiving
+ fetchMock.put({
+ url: "express:/api/pulse/:id",
+ response: ({ expressParams = {} }) => {
+ const pulseId = parseInt(expressParams?.id);
+ pulses.splice(
+ pulses.findIndex((pulse) => pulse.id === pulseId),
+ 1,
+ );
+ return {};
+ },
+ });
+
+ const setSharing = jest.fn();
+
+ setup({
+ isEmbeddingSdk: true,
+ email: true,
+ slack,
+ setSharing,
+ pulses,
+ });
+
+ // Delete the first subscription
+ expect(await screen.findByText("Subscriptions")).toBeInTheDocument();
+ await userEvent.click(
+ await screen.findByText("Emailed daily at 12:00 AM"),
+ );
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+ await userEvent.click(
+ await screen.findByText("Delete this subscription"),
+ );
+
+ let modal = screen.getByRole("dialog");
+ await userEvent.click(await within(modal).findByRole("checkbox"));
+ await userEvent.click(
+ within(modal).getByRole("button", { name: "Delete" }),
+ );
+
+ expect(setSharing).not.toHaveBeenCalled();
+
+ // Delete the last subscription
+ await userEvent.click(await screen.findByText("Emailed hourly"));
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+ await userEvent.click(
+ await screen.findByText("Delete this subscription"),
+ );
+
+ modal = screen.getByRole("dialog");
+ await userEvent.click(await within(modal).findByRole("checkbox"));
+ await userEvent.click(
+ within(modal).getByRole("button", { name: "Delete" }),
+ );
+
+ expect(setSharing).toHaveBeenCalledWith(false);
+ });
+
+ /**
+ * Isn't needed for EMB-1060 but I added it for completeness.
+ */
+ it(`should show pulse list view after creating the first subscription by a non-admin user ${testScenarioCondition}`, async () => {
+ const user = {
+ firstName: "John",
+ lastName: "Doe",
+ };
+ setup({
+ isEmbeddingSdk: true,
+ email: true,
+ slack,
+ currentUser: user,
+ pulseListDelay: 100,
+ });
+
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+
+ // Create the first subscription
+ await userEvent.click(screen.getByRole("button", { name: "Done" }));
+
+ expect(await screen.findByText("Subscriptions")).toBeInTheDocument();
+ expect(await screen.findByText("Emailed hourly")).toBeInTheDocument();
+ expect(await screen.findByText("John Doe")).toBeInTheDocument();
+ });
+
+ it(`should show pulse list view after creating the first subscription by an admin user ${testScenarioCondition} (EMB-1060)`, async () => {
+ const user = {
+ firstName: "Admin",
+ lastName: "User",
+ };
+ setup({
+ isAdmin: true,
+ isEmbeddingSdk: true,
+ email: true,
+ slack,
+ currentUser: user,
+ pulseListDelay: 100,
+ });
+
+ expect(
+ await screen.findByText("Email this dashboard"),
+ ).toBeInTheDocument();
+
+ // Create the first subscription
+ await userEvent.click(screen.getByRole("button", { name: "Done" }));
+
+ expect(await screen.findByText("Subscriptions")).toBeInTheDocument();
+ expect(await screen.findByText("Emailed hourly")).toBeInTheDocument();
+ expect(await screen.findByText("Admin User")).toBeInTheDocument();
+ });
+ });
+
describe("Slack Subscription sidebar", () => {
it("should not show advanced filter options in OSS", async () => {
setup();
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
index 04ad8af46cf..9f23cbcb81e 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
@@ -7,11 +7,14 @@ import { setupNotificationChannelsEndpoints } from "__support__/server-mocks/pul
import { mockSettings } from "__support__/settings";
import type { Screen } from "__support__/ui";
import { renderWithProviders } from "__support__/ui";
+import { getNextId } from "__support__/utils";
+import { isEmbeddingSdk as mockIsEmbeddingSdk } from "metabase/embedding-sdk/config";
import { MockDashboardContext } from "metabase/public/containers/PublicOrEmbeddedDashboard/mock-context";
import type { UiParameter } from "metabase-lib/v1/parameters/types";
import type {
Dashboard,
DashboardCard,
+ Pulse,
TokenFeatures,
} from "metabase-types/api";
import {
@@ -29,6 +32,10 @@ import {
import DashboardSubscriptionsSidebar from "../DashboardSubscriptionsSidebar";
+jest.mock("metabase/embedding-sdk/config", () => ({
+ isEmbeddingSdk: jest.fn(() => false),
+}));
+
export const dashcard = createMockDashboardCard();
const actionDashcard = createMockActionDashboardCard({
@@ -74,31 +81,38 @@ function createDashboardState(
});
}
-export function setup(
- {
- email,
- slack,
- tokenFeatures = {},
- hasEnterprisePlugins = false,
- isAdmin = false,
- dashcards = defaultDashcards,
- parameters = defaultParameters,
- }: {
- email?: boolean;
- slack?: boolean;
- tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
- isAdmin?: boolean;
- dashcards?: DashboardCard[];
- parameters?: UiParameter[];
- } = {
- email: true,
- slack: true,
- tokenFeatures: {},
- hasEnterprisePlugins: false,
- isAdmin: false,
- },
-) {
+type SetupOpts = {
+ email?: boolean;
+ slack?: boolean;
+ tokenFeatures?: Partial<TokenFeatures>;
+ hasEnterprisePlugins?: boolean;
+ isAdmin?: boolean;
+ dashcards?: DashboardCard[];
+ parameters?: UiParameter[];
+ isEmbeddingSdk?: boolean;
+ setSharing?: (sharing: boolean) => void;
+ pulses?: (Partial<Pulse> & { id: number })[];
+ currentUser?: {
+ firstName: string;
+ lastName: string;
+ };
+ pulseListDelay?: number;
+};
+
+export function setup({
+ email = true,
+ slack = true,
+ tokenFeatures = {},
+ hasEnterprisePlugins = false,
+ isAdmin = false,
+ dashcards = defaultDashcards,
+ parameters = defaultParameters,
+ isEmbeddingSdk = false,
+ setSharing,
+ pulses = [],
+ currentUser,
+ pulseListDelay = 0,
+}: SetupOpts = {}) {
const dashboard = createMockDashboard({
dashcards,
parameters,
@@ -141,6 +155,8 @@ export function setup(
};
}
+ (mockIsEmbeddingSdk as jest.Mock).mockReturnValue(isEmbeddingSdk);
+
setupNotificationChannelsEndpoints(channelData.channels);
setupUserRecipientsEndpoint({
@@ -150,7 +166,17 @@ export function setup(
fetchMock.get({
url: `path:/api/pulse`,
query: { dashboard_id: dashboard.id },
- response: [],
+ response: () => pulses,
+ // Delay is crucial to reproduce (EMB-1060), otherwise, the state updates too fast which isn't realistic
+ delay: pulseListDelay,
+ });
+
+ // Mock POST that updates the GET response
+ fetchMock.post("path:/api/pulse", ({ options }) => {
+ const body = JSON.parse(options.body as string);
+ const newPulse = { ...body, id: getNextId() } as Pulse & { id: number };
+ pulses.push(newPulse);
+ return newPulse;
});
fetchMock.post("path:/api/pulse/test", 200);
@@ -163,13 +189,15 @@ export function setup(
}
renderWithProviders(
- <MockDashboardContext dashboard={dashboard}>
+ <MockDashboardContext dashboard={dashboard} setSharing={setSharing}>
<DashboardSubscriptionsSidebar />
</MockDashboardContext>,
{
storeInitialState: createMockState({
settings: storeSettings,
currentUser: createMockUser({
+ first_name: currentUser?.firstName,
+ last_name: currentUser?.lastName,
is_superuser: isAdmin,
}),
dashboard: createDashboardState(dashboard, dashcards),
diff --git a/frontend/src/metabase/notifications/PulsesListSidebar.jsx b/frontend/src/metabase/notifications/PulsesListSidebar.jsx
index 147ea25733e..da38046da4d 100644
--- a/frontend/src/metabase/notifications/PulsesListSidebar.jsx
+++ b/frontend/src/metabase/notifications/PulsesListSidebar.jsx
@@ -39,6 +39,8 @@ function _PulsesListSidebar({
editPulse,
parameters,
}) {
+ const createSubscriptionLabel = t`Set up a new schedule`;
+ const closeSidebarLabel = t`Close`;
return (
<Sidebar>
<div
@@ -53,8 +55,9 @@ function _PulsesListSidebar({
<Subhead>{t`Subscriptions`}</Subhead>
<SidebarActions>
- <Tooltip label={t`Set up a new schedule`}>
+ <Tooltip label={createSubscriptionLabel}>
<Button
+ aria-label={createSubscriptionLabel}
leftSection={<Icon name="add" size={16} />}
variant="subtle"
mr="1rem"
@@ -62,8 +65,9 @@ function _PulsesListSidebar({
/>
</Tooltip>
- <Tooltip label={t`Close`}>
+ <Tooltip label={closeSidebarLabel}>
<Button
+ aria-label={closeSidebarLabel}
leftSection={<Icon name="close" size={16} />}
variant="subtle"
color="text-medium"
diff --git a/frontend/src/metabase/plugins/index.ts b/frontend/src/metabase/plugins/index.ts
index c8fd6afff35..97b1d9508e0 100644
--- a/frontend/src/metabase/plugins/index.ts
+++ b/frontend/src/metabase/plugins/index.ts
@@ -150,6 +150,8 @@ export type {
} from "./types";
// Export a single reinitialize function that calls all individual reinitialize functions
+import { reinitialize as reinitializeDashboardSubscriptionsSdk } from "../../embedding-sdk-bundle/components/public/subscriptions";
+
import { reinitialize as reinitializeAi } from "./oss/ai";
import { reinitialize as reinitializeApi } from "./oss/api";
import { reinitialize as reinitializeAudit } from "./oss/audit";
@@ -189,6 +191,8 @@ import { reinitialize as reinitializeWhitelabel } from "./oss/whitelabel";
* so reinitializing them all ensures that dependencies are correctly set up.
*/
export function reinitialize() {
+ reinitializeDashboardSubscriptionsSdk();
+
reinitializeAi();
reinitializeApi();
reinitializeAudit();
diff --git a/frontend/src/metabase/plugins/oss/embedding-iframe-sdk-setup.ts b/frontend/src/metabase/plugins/oss/embedding-iframe-sdk-setup.ts
index 49ef37da53f..01617de42a0 100644
--- a/frontend/src/metabase/plugins/oss/embedding-iframe-sdk-setup.ts
+++ b/frontend/src/metabase/plugins/oss/embedding-iframe-sdk-setup.ts
@@ -12,7 +12,7 @@ export type SdkIframeEmbedSetupModalInitialState = {
};
const getDefaultPluginEmbeddingIframeSdkSetup = () => ({
- isFeatureEnabled: () => false,
+ isEnabled: () => false,
});
export const PLUGIN_EMBEDDING_IFRAME_SDK_SETUP =
diff --git a/frontend/src/metabase/plugins/oss/embedding-iframe-sdk.ts b/frontend/src/metabase/plugins/oss/embedding-iframe-sdk.ts
index 190f9ba864a..f55a39e9e3d 100644
--- a/frontend/src/metabase/plugins/oss/embedding-iframe-sdk.ts
+++ b/frontend/src/metabase/plugins/oss/embedding-iframe-sdk.ts
@@ -1,5 +1,10 @@
+import type { DashboardSubscriptionsButtonProps } from "embedding-sdk-bundle/components/public/subscriptions";
+
const getDefaultPluginEmbeddingIframeSdk = () => ({
- hasValidLicense: () => false,
+ isEnabled: () => false,
+ DashboardSubscriptionsButton: (
+ _props: DashboardSubscriptionsButtonProps,
+ ): JSX.Element | null => null,
});
export const PLUGIN_EMBEDDING_IFRAME_SDK = getDefaultPluginEmbeddingIframeSdk();
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/mock-context.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/mock-context.tsx
index 03b3fbcc71e..44dabe74cc1 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/mock-context.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/mock-context.tsx
@@ -24,13 +24,18 @@ const DashboardContextWithReduxProps = (
const {
isEditing,
downloadsEnabled,
+ withSubscriptions,
dashboardActions: dashboardActionsOrGetter,
} = props;
// Use exact same implementation as in DashboardContextProviderInner
const dashboardActions =
typeof dashboardActionsOrGetter === "function"
- ? dashboardActionsOrGetter({ isEditing, downloadsEnabled })
+ ? dashboardActionsOrGetter({
+ isEditing,
+ downloadsEnabled,
+ withSubscriptions,
+ })
: (dashboardActionsOrGetter ?? null);
return (
diff --git a/frontend/test/__support__/enterprise-typed.ts b/frontend/test/__support__/enterprise-typed.ts
new file mode 100644
index 00000000000..5ac387df9f1
--- /dev/null
+++ b/frontend/test/__support__/enterprise-typed.ts
@@ -0,0 +1,60 @@
+export const ENTERPRISE_PLUGIN_NAME_MAPPING = {
+ database_routing: "metabase-enterprise/database_routing",
+ snippets: "metabase-enterprise/snippets",
+ embedding_iframe_sdk_setup: "metabase-enterprise/embedding_iframe_sdk_setup",
+ settings: "metabase-enterprise/settings",
+ model_persistence: "metabase-enterprise/model_persistence",
+ comments: "metabase-enterprise/comments",
+ whitelabel: "metabase-enterprise/whitelabel",
+ sandboxes: "metabase-enterprise/sandboxes",
+ clean_up: "metabase-enterprise/clean_up",
+ tools: "metabase-enterprise/tools",
+ advanced_permissions: "metabase-enterprise/advanced_permissions",
+ sharing: "metabase-enterprise/sharing",
+ metabot: "metabase-enterprise/metabot",
+ rich_text_editing: "metabase-enterprise/rich_text_editing",
+ "ai-entity-analysis": "metabase-enterprise/ai-entity-analysis",
+ license: "metabase-enterprise/license",
+ user_provisioning: "metabase-enterprise/user_provisioning",
+ application_permissions: "metabase-enterprise/application_permissions",
+ auth: "metabase-enterprise/auth",
+ "smtp-override": "metabase-enterprise/smtp-override",
+ "ai-sql-fixer": "metabase-enterprise/ai-sql-fixer",
+ embedding: "metabase-enterprise/embedding",
+ admin: "metabase-enterprise/admin",
+ dependencies: "metabase-enterprise/dependencies",
+ feature_level_permissions: "metabase-enterprise/feature_level_permissions",
+ shared: "metabase-enterprise/shared",
+ "transforms-python": "metabase-enterprise/transforms-python",
+ remote_sync: "metabase-enterprise/remote_sync",
+ public: "metabase-enterprise/public",
+ transforms: "metabase-enterprise/transforms",
+ support: "metabase-enterprise/support",
+ upload_management: "metabase-enterprise/upload_management",
+ "public-sharing": "metabase-enterprise/public-sharing",
+ embedding_iframe_sdk: "metabase-enterprise/embedding_iframe_sdk",
+ api: "metabase-enterprise/api",
+ "table-editing": "metabase-enterprise/table-editing",
+ resource_downloads: "metabase-enterprise/resource_downloads",
+ browse: "metabase-enterprise/browse",
+ documents: "metabase-enterprise/documents",
+ semantic_search: "metabase-enterprise/semantic_search",
+ database_replication: "metabase-enterprise/database_replication",
+ "data-studio": "metabase-enterprise/data-studio",
+ caching: "metabase-enterprise/caching",
+ group_managers: "metabase-enterprise/group_managers",
+ collections: "metabase-enterprise/collections",
+ audit_app: "metabase-enterprise/audit_app",
+ content_translation: "metabase-enterprise/content_translation",
+ "embedding-sdk": "metabase-enterprise/embedding-sdk",
+ entities: "metabase-enterprise/entities",
+ google_drive: "metabase-enterprise/google_drive",
+ content_verification: "metabase-enterprise/content_verification",
+ moderation: "metabase-enterprise/moderation",
+
+ // Embedding SDK specific plugins
+ sdk_subscriptions: "embedding-sdk-ee/subscriptions",
+};
+
+export type ENTERPRISE_PLUGIN_NAME =
+ keyof typeof ENTERPRISE_PLUGIN_NAME_MAPPING;
diff --git a/frontend/test/__support__/enterprise.js b/frontend/test/__support__/enterprise.js
index cd92f9e106c..ed29f726c20 100644
--- a/frontend/test/__support__/enterprise.js
+++ b/frontend/test/__support__/enterprise.js
@@ -1,3 +1,5 @@
+import { ENTERPRISE_PLUGIN_NAME_MAPPING } from "./enterprise-typed";
+
/**
* @deprecated use setupEnterprisePlugins with settings set via mockSettings
* ```ts
@@ -39,7 +41,13 @@ export function setupEnterprisePlugins() {
}
// function is used for optimization, so we don't need to import all plugins
+/**
+ *
+ * @param {import("./enterprise-typed").ENTERPRISE_PLUGIN_NAME} pluginName
+ */
export function setupEnterpriseOnlyPlugin(pluginName) {
- const { initializePlugin } = require(`metabase-enterprise/${pluginName}`);
+ const { initializePlugin } = require(
+ ENTERPRISE_PLUGIN_NAME_MAPPING[pluginName],
+ );
initializePlugin?.();
}
diff --git a/frontend/test/__support__/server-mocks/pulse.ts b/frontend/test/__support__/server-mocks/pulse.ts
index b0440f91707..6d47bc6dd38 100644
--- a/frontend/test/__support__/server-mocks/pulse.ts
+++ b/frontend/test/__support__/server-mocks/pulse.ts
@@ -1,9 +1,10 @@
import fetchMock from "fetch-mock";
+import type { DeepPartial } from "metabase/embedding-sdk/types/utils";
import type { ChannelApiResponse } from "metabase-types/api";
export const setupNotificationChannelsEndpoints = (
- channelData: Partial<ChannelApiResponse["channels"]>,
+ channelData: DeepPartial<Required<ChannelApiResponse["channels"]>>,
) => {
fetchMock.get("path:/api/pulse/form_input", { channels: channelData });
};
diff --git a/temp-h2-db/1.h2.mv.db b/temp-h2-db/1.h2.mv.db
new file mode 100644
index 00000000000..afcc79a2022
Binary files /dev/null and b/temp-h2-db/1.h2.mv.db differ