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

Fix page chooser #85

Merged
merged 4 commits into from
Sep 14, 2024
Merged

Fix page chooser #85

merged 4 commits into from
Sep 14, 2024

Conversation

mgax
Copy link
Contributor

@mgax mgax commented Aug 4, 2024

`chooserUrls.pageChooser` has been removed in Wagtail 6.1
Copy link

codecov bot commented Aug 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.44%. Comparing base (cbeff6f) to head (8e3598d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #85   +/-   ##
=======================================
  Coverage   88.44%   88.44%           
=======================================
  Files          15       15           
  Lines         753      753           
  Branches      140      140           
=======================================
  Hits          666      666           
  Misses         51       51           
  Partials       36       36           

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

Comment on lines 37 to 38
{% url 'wagtailadmin_choose_page' as wagtailadmin_choose_page_url %}
window.AB_TESTING_CHOOSE_PAGE_URL = '{{ wagtailadmin_choose_page_url|escapejs }}';
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather see us change this to something that is inherently compatible with strict content security policies.

@mgax could you change this to use json_script instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think that the patten on the above two lines is okay, i.e. setting the value on wagtailConfig? If not, I'd better change that one too.

{% url 'wagtailadmin_home' as wagtailadmin_root_url %}
wagtailConfig.ADMIN_ROOT_URL = '{{ wagtailadmin_root_url|escapejs }}';

Copy link
Member

Choose a reason for hiding this comment

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

Yes, changing that too would make sense now that I look at it more closely!

Checking its usage, it appears to only be used to construct a URL to fetch page information:

`${wagtailConfig.ADMIN_ROOT_URL}api/main/pages/${selectedPageId}/`,

ADMIN_ROOT_URL is internal to us, there is no reference inside the (current) Wagtail codebase. No need to put this in wagtailConfig I feel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed now.

@mgax mgax requested a review from Stormheg August 12, 2024 13:40
@mgax
Copy link
Contributor Author

mgax commented Aug 12, 2024

I'm having a hard time fixing the frontend lint error (https://github.com/wagtail-nest/wagtail-ab-testing/actions/runs/10353044821/job/28654997687?pr=85). If I run this locally:

npm ci
npm run lint

I don't get any errors. I've confirmed that I'm running Node 20.

```
./node_modules/.bin/prettier --write 'wagtail_ab_testing/**/*.{ts,tsx,scss}'
```
@mgax
Copy link
Contributor Author

mgax commented Aug 16, 2024

I'm having a hard time fixing the frontend lint error

Fixed with help from @siimonevans (thanks!).

Copy link
Member

@Stormheg Stormheg left a comment

Choose a reason for hiding this comment

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

Great work Alex! I'm happy with this 👍

@Stormheg Stormheg merged commit b22a554 into main Sep 14, 2024
11 checks passed
@Stormheg Stormheg deleted the fix/page-chooser-url branch September 14, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants