mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-22 14:01:53 +00:00
The pages listed when browsing the /admin/pages/ explorer differed from the pages listed in the new React/admin API powered pop-out explorer. The latter did not pass the queryset through the 'construct_explorer_page_queryset' hook, so pages that should have been hidden were visible. Visiting these pages in the explorer could then lead to unexpected behaviours, as hidden sections of the site became browsable. A new `for_explorer=1` query parameter has been added to the admin API, which will pass the page queryset through the 'construct_explorer_page_queryset' hooks.
30 lines
625 B
JavaScript
30 lines
625 B
JavaScript
import { get } from '../api/client';
|
|
|
|
import { ADMIN_API } from '../config/wagtailConfig';
|
|
|
|
|
|
export const getPage = (id) => {
|
|
const url = `${ADMIN_API.PAGES}${id}/`;
|
|
|
|
return get(url);
|
|
};
|
|
|
|
export const getPageChildren = (id, options = {}) => {
|
|
let url = `${ADMIN_API.PAGES}?child_of=${id}&for_explorer=1`;
|
|
|
|
if (options.fields) {
|
|
url += `&fields=${global.encodeURIComponent(options.fields.join(','))}`;
|
|
}
|
|
|
|
if (options.onlyWithChildren) {
|
|
url += '&has_children=1';
|
|
}
|
|
|
|
if (options.offset) {
|
|
url += `&offset=${options.offset}`;
|
|
}
|
|
|
|
url += ADMIN_API.EXTRA_CHILDREN_PARAMETERS;
|
|
|
|
return get(url);
|
|
};
|