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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const GoalPageSelector: FunctionComponent<GoalPageSelectorProps> = ({
) => {
e.preventDefault();
(window as any).ModalWorkflow({
url: (window as any).chooserUrls.pageChooser,
url: (window as any).AB_TESTING_CHOOSE_PAGE_URL,
onload: (window as any).PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS,
responses: {
pageChosen: function (pageData: any) {
Expand Down
2 changes: 2 additions & 0 deletions wagtail_ab_testing/templates/wagtail_ab_testing/add_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<script>
{% url 'wagtailadmin_home' as wagtailadmin_root_url %}
wagtailConfig.ADMIN_ROOT_URL = '{{ wagtailadmin_root_url|escapejs }}';
{% 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.

</script>
<script src="{% url 'wagtail_ab_testing_admin:javascript_catalog' %}"></script>
<script type="text/javascript" src="{% versioned_static 'wagtailadmin/js/page-chooser-modal.js' %}"></script>
Expand Down