wagtail/client/src/api/admin.js
Tim Heap 1f2b8ccaf1 Filter pop-out explorer pages using 'construct_explorer_page_queryset'
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.
2017-10-31 15:55:01 +00:00

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);
};