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

locale query string support on public links and static embeds #47186

Merged
merged 13 commits into from
Aug 29, 2024

Conversation

npretto
Copy link
Member

@npretto npretto commented Aug 23, 2024

This pr addresses Support language localization in static embedding.

The feature was apparently already working with one small caveat: we have some code that removes all querystring parameters that are not filters, this refreshing the page losing the locale as reported by Jeff on slack

The rest of the code changes are tests for the 4 different contexts (public/static, question/dashboard)

@npretto npretto added no-backport Do not backport this PR to any branch backport Automatically create PR on current release branch on merge and removed no-backport Do not backport this PR to any branch labels Aug 26, 2024
@npretto npretto changed the title locale query string support (mostly tests as the thing already worked) locale query string support on public links and static embeds Aug 26, 2024
@npretto npretto requested review from a team August 26, 2024 15:25
@npretto npretto marked this pull request as ready for review August 26, 2024 15:26
e2e/test/scenarios/sharing/public-question.cy.spec.js Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Why are we skipping these three tests in that file?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a mistake 🙃

@@ -122,7 +122,7 @@ export function useDashboardUrlQuery(
}, [router, location, selectedTab, dispatch]);
}

const QUERY_PARAMS_ALLOW_LIST = ["objectId"];
const QUERY_PARAMS_ALLOW_LIST = ["objectId", "locale"];
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should also update the parameters allow list for the SyncedParametersList component (used for native question parameters)?

Copy link
Member Author

Choose a reason for hiding this comment

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

💯 yes!
Thank you for pointing that out, let me change one of the e2e tests to cover that scenario

Copy link
Member

@kulyk kulyk Aug 28, 2024

Choose a reason for hiding this comment

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

Awesome! It'd be great to unify this logic at some point in the future, but it's kind of hard to do while native question parameters are using history instead of react-router-redux. #44639 should have more context around that

@kulyk kulyk requested a review from a team August 27, 2024 16:35
Copy link
Member

@WiNloSt WiNloSt left a comment

Choose a reason for hiding this comment

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

I tested public dashboards with tabs and parameters. Refreshing still leaves the locale parameter 👍 I'd wait for the native question tests before giving you a stamp.

e2e/support/helpers/e2e-embedding-helpers.js Outdated Show resolved Hide resolved
// > `url` - one that begins with `http`. By default `cy.request()` will use
// > either the current window's origin or the `baseUrl` in
// > `e2e/support/cypress.config.js`. Neither of those values were present.
Cypress.config("baseUrl", originalBaseUrl);
Copy link
Member

Choose a reason for hiding this comment

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

For anyone who is still confused about this line. Because of the way Cypress.config works, it only is reset when the whole suite is completed, so this is a way to restore the value back in between tests.

By the way, it's used here.

@npretto npretto requested review from kulyk and WiNloSt August 28, 2024 18:48
Copy link
Member

@WiNloSt WiNloSt left a comment

Choose a reason for hiding this comment

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

The new test native question with a parameter looks good, I also ran it locally, and it behaved as expected.

@npretto npretto merged commit 76b0a3f into master Aug 29, 2024
121 of 122 checks passed
@npretto npretto deleted the public-embed-locale-support branch August 29, 2024 13:14
npretto added a commit that referenced this pull request Aug 29, 2024
* keep locale in url query params

* e2e tests

* ugly fix for the missing baseUrl error

* applies suggestion from Kelvin to make code more demure

* Update e2e/test/scenarios/sharing/public-question.cy.spec.js

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>

* remove it.skip added by mistake

* sort imports

* handle native question/ SyncedParametersList too

* shorter and more accurate comment 😅

* Update e2e/support/helpers/e2e-embedding-helpers.js

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

---------

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
qnkhuat pushed a commit that referenced this pull request Aug 30, 2024
* keep locale in url query params

* e2e tests

* ugly fix for the missing baseUrl error

* applies suggestion from Kelvin to make code more demure

* Update e2e/test/scenarios/sharing/public-question.cy.spec.js

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>

* remove it.skip added by mistake

* sort imports

* handle native question/ SyncedParametersList too

* shorter and more accurate comment 😅

* Update e2e/support/helpers/e2e-embedding-helpers.js

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

---------

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
npretto added a commit that referenced this pull request Aug 30, 2024
…embeds" (#47393)

* locale query string support on public links and static embeds (#47186)

* keep locale in url query params

* e2e tests

* ugly fix for the missing baseUrl error

* applies suggestion from Kelvin to make code more demure

* Update e2e/test/scenarios/sharing/public-question.cy.spec.js

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>

* remove it.skip added by mistake

* sort imports

* handle native question/ SyncedParametersList too

* shorter and more accurate comment 😅

* Update e2e/support/helpers/e2e-embedding-helpers.js

Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

---------

Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>

* fix tests, the button i was looking for is not on v50

---------

Co-authored-by: Nicolò Pretto <info@npretto.com>
Co-authored-by: Anton Kulyk <kuliks.anton@gmail.com>
Co-authored-by: Mahatthana (Kelvin) Nomsawadi <me@bboykelvin.dev>
@github-actions github-actions bot added this to the 0.50.24 milestone Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Automatically create PR on current release branch on merge .Team/Embedding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants