kopia lustrzana https://github.com/wagtail/wagtail
Update the React Explorer to use the admin_display_title instead of the regular page title
rodzic
a77ad34df3
commit
36d3f5dfec
|
@ -20,7 +20,7 @@ const ExplorerHeader = ({ page, depth, onClick }) => {
|
||||||
>
|
>
|
||||||
<div className="c-explorer__header__inner">
|
<div className="c-explorer__header__inner">
|
||||||
<Icon name={isRoot ? 'home' : 'arrow-left'} />
|
<Icon name={isRoot ? 'home' : 'arrow-left'} />
|
||||||
<span>{page.title || STRINGS.PAGES}</span>
|
<span>{page.admin_display_title || STRINGS.PAGES}</span>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
@ -29,7 +29,7 @@ const ExplorerHeader = ({ page, depth, onClick }) => {
|
||||||
ExplorerHeader.propTypes = {
|
ExplorerHeader.propTypes = {
|
||||||
page: PropTypes.shape({
|
page: PropTypes.shape({
|
||||||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
title: PropTypes.string,
|
admin_display_title: PropTypes.string,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
depth: PropTypes.number.isRequired,
|
depth: PropTypes.number.isRequired,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('ExplorerHeader', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#page', () => {
|
it('#page', () => {
|
||||||
expect(shallow(<ExplorerHeader {...mockProps} page={{ id: 'a', title: 'test' }} />)).toMatchSnapshot();
|
expect(shallow(<ExplorerHeader {...mockProps} page={{ id: 'a', admin_display_title: 'test' }} />)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#onClick', () => {
|
it('#onClick', () => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const nextIcon = (
|
||||||
* and information depending on the metadata of the page.
|
* and information depending on the metadata of the page.
|
||||||
*/
|
*/
|
||||||
const ExplorerItem = ({ item, onClick }) => {
|
const ExplorerItem = ({ item, onClick }) => {
|
||||||
const { id, title, meta } = item;
|
const { id, admin_display_title: title, meta } = item;
|
||||||
const hasChildren = meta.children.count > 0;
|
const hasChildren = meta.children.count > 0;
|
||||||
const isPublished = meta.status.live && !meta.status.has_unpublished_changes;
|
const isPublished = meta.status.live && !meta.status.has_unpublished_changes;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ const ExplorerItem = ({ item, onClick }) => {
|
||||||
ExplorerItem.propTypes = {
|
ExplorerItem.propTypes = {
|
||||||
item: PropTypes.shape({
|
item: PropTypes.shape({
|
||||||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
||||||
title: PropTypes.string.isRequired,
|
admin_display_title: PropTypes.string.isRequired,
|
||||||
meta: PropTypes.shape({
|
meta: PropTypes.shape({
|
||||||
status: PropTypes.object.isRequired,
|
status: PropTypes.object.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ExplorerItem from './ExplorerItem';
|
||||||
const mockProps = {
|
const mockProps = {
|
||||||
item: {
|
item: {
|
||||||
id: 5,
|
id: 5,
|
||||||
title: 'test',
|
admin_display_title: 'test',
|
||||||
meta: {
|
meta: {
|
||||||
latest_revision_created_at: null,
|
latest_revision_created_at: null,
|
||||||
status: {
|
status: {
|
||||||
|
|
|
@ -57,8 +57,8 @@ describe('ExplorerPanel', () => {
|
||||||
{...mockProps}
|
{...mockProps}
|
||||||
page={{ children: { items: [1, 2] } }}
|
page={{ children: { items: [1, 2] } }}
|
||||||
nodes={{
|
nodes={{
|
||||||
1: { id: 1, title: 'Test', meta: { status: {}, type: 'test' } },
|
1: { id: 1, admin_display_title: 'Test', meta: { status: {}, type: 'test' } },
|
||||||
2: { id: 2, title: 'Foo', meta: { status: {}, type: 'foo' } },
|
2: { id: 2, admin_display_title: 'Foo', meta: { status: {}, type: 'foo' } },
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))).toMatchSnapshot();
|
))).toMatchSnapshot();
|
||||||
|
@ -103,7 +103,7 @@ describe('ExplorerPanel', () => {
|
||||||
{...mockProps}
|
{...mockProps}
|
||||||
path={[1]}
|
path={[1]}
|
||||||
page={{ children: { items: [1] } }}
|
page={{ children: { items: [1] } }}
|
||||||
nodes={{ 1: { id: 1, title: 'Test', meta: { status: {}, type: 'test' } } }}
|
nodes={{ 1: { id: 1, admin_display_title: 'Test', meta: { status: {}, type: 'test' } } }}
|
||||||
/>
|
/>
|
||||||
)).find('ExplorerItem').prop('onClick')({
|
)).find('ExplorerItem').prop('onClick')({
|
||||||
preventDefault() {},
|
preventDefault() {},
|
||||||
|
|
|
@ -190,12 +190,12 @@ exports[`ExplorerPanel #items 1`] = `
|
||||||
<ExplorerItem
|
<ExplorerItem
|
||||||
item={
|
item={
|
||||||
Object {
|
Object {
|
||||||
|
"admin_display_title": "Test",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"meta": Object {
|
"meta": Object {
|
||||||
"status": Object {},
|
"status": Object {},
|
||||||
"type": "test",
|
"type": "test",
|
||||||
},
|
},
|
||||||
"title": "Test",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
@ -203,12 +203,12 @@ exports[`ExplorerPanel #items 1`] = `
|
||||||
<ExplorerItem
|
<ExplorerItem
|
||||||
item={
|
item={
|
||||||
Object {
|
Object {
|
||||||
|
"admin_display_title": "Foo",
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"meta": Object {
|
"meta": Object {
|
||||||
"status": Object {},
|
"status": Object {},
|
||||||
"type": "foo",
|
"type": "foo",
|
||||||
},
|
},
|
||||||
"title": "Foo",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
|
Ładowanie…
Reference in New Issue