Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Disable ?locale on static embeds/public links #50391

Merged

Conversation

WiNloSt
Copy link
Member

@WiNloSt WiNloSt commented Nov 22, 2024

Note

Do not backport this PR because it targets 52

Closes #50313

Description

Since we have the new hash option #locale on static embeds/public links. We want to avoid confusion on the undocumented ?locale parameter by removing it and opt for #locale instead.

How to verify

  1. Try setting the search param ?locale=xx with the locale of your choice e.g. ?locale=ko in either a static embed or a public link on either a dashboard or a question. And none of it should work
  2. Try setting ?locale=xx with the locale of your choice on normal Metabase and it should work. This means the interactive embed would work as well.
  3. Now test the static embed/public link again with #locale, and it should only work when you have a Pro license (Put #locale under whitelabel feature flag #50199).

Demo

with ?locale=en, it doesn't work anymore

image

with #localo=en, only when we use the hash locale, then it would work

image

Checklist

  • Tests have been added/updated to cover changes in this PR

@WiNloSt WiNloSt added the no-backport Do not backport this PR to any branch label Nov 22, 2024
Copy link

trunk-io bot commented Nov 22, 2024

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@@ -1009,7 +1009,7 @@ describeEE("scenarios > embedding > dashboard appearance", () => {
});
});

it("should allow to set locale from the `locale` query parameter", () => {
it("should allow to set locale from the `#locale` hash parameter (metabase#50182)", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

All tests that were tested with search param ?locale need to be migrated to test with hash param and only in EE, since this feature only works with Pro plan.

@@ -198,24 +198,42 @@ describe("scenarios > embedding > questions", () => {
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.contains("October 7, 2023, 1:34 AM");
});
});

describeEE("scenarios [EE] > embedding > questions", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The previous test was in describe, so I need to move it inside describeEE. This uses the same setup as describe but add setTokenFeatures("all")

cy.request("PUT", `/api/card/${ORDERS_QUESTION_ID}`, {
enable_embedding: true,
});

visitQuestion(ORDERS_QUESTION_ID);

openStaticEmbeddingModal({ activeTab: "parameters" });
openStaticEmbeddingModal({ activeTab: "parameters", acceptTerms: false });
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't need to accept terms and condition on Pro plan.

@@ -1138,7 +1138,7 @@ describeEE("issue 8490", () => {
});
});

it("static embeddings should respect `#locale` hash in the URL (metabase#8490)", () => {
it("static embeddings should respect `#locale` hash parameter (metabase#8490, metabase#50182)", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

just a name update for tracking purposes.

@@ -357,4 +345,16 @@ describeEE("scenarios [EE] > public > dashboard", () => {
cy.title().should("eq", "Test Dashboard · Custom Application Name");
});
});

it("should allow to set locale from the `#locale` hash parameter (metabase#50182)", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

moved from describe to describeEE

updateSetting("enable-public-sharing", true);
});

it("should allow to set locale from the `#locale` hash parameter (metabase#50182)", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to describeEE

{:bootstrapJS (load-inline-js "index_bootstrap")
:bootstrapJSON (escape-script (json/generate-string public-settings))
:assetOnErrorJS (load-inline-js "asset_loading_error")
:userLocalizationJSON (escape-script (load-localization (:locale params)))
:userLocalizationJSON (escape-script (load-localization (when should-load-locale-params? (:locale params))))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is where we inject _metabaseUserLocalization into the HTML. We only want to do this when we're not using static embeds or public links.

We will still inject the locale on interactive embedding.

@WiNloSt WiNloSt requested review from a team November 22, 2024 12:00
* @param {Record<string, string>} options.params
* @param {Record<string, string>} options.hash
*/
export function visitPublicQuestion(id, { params = {}, hash = {} } = {}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This function never receives params, or hash before, so I make it the same interface as visitPublicDashboard for consistency, and use it to replace some direct cy.visit calls.

@WiNloSt WiNloSt merged commit ee23a50 into master Nov 26, 2024
136 checks passed
@WiNloSt WiNloSt deleted the 50313-locale-remove-locale-parameter-from-static-embeds branch November 26, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/Embedding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove ?locale support on static embeds/public links
3 participants