-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[desk-tool] Add support for live edit (#741)
* [schema] First pass at draft: true * [test-studio] Add a type to the test studio schema for playing around with draft: true * [schema] Apply document core types on extend * [desk-tool] Commit the published document on change if drafts are disabled * [desk-tool] Only render Publish Changes button if drafts are enabled * [desk-tool] Only render the has-unpublished-stuff tooltip if drafts are enabled * [desk-tool] Fix a couple of imports and proptypes * [test-studio] Renae draft flag to liveEdit * [schema] Roll back draft flag on document schema type * [schema] Update components following rename of schema flag draft --> liveEdit * [desk-tool] In case of liveEdit, don't render unpublish and discard choices from dropdown
- Loading branch information
Showing
5 changed files
with
158 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import BookIcon from 'react-icons/lib/fa/book' | ||
|
||
function formatSubtitle(thesis) { | ||
if (thesis.authorName && thesis.publicationYear) { | ||
return `By ${thesis.authorName} (${thesis.publicationYear})` | ||
} | ||
return thesis.authorName ? `By ${thesis.authorName}` : String(thesis.publicationYear || '') | ||
} | ||
|
||
export default { | ||
title: 'Thesis (live edit)', | ||
name: 'thesis', | ||
type: 'document', | ||
liveEdit: true, | ||
description: 'A simple type for testing draft: false', | ||
icon: BookIcon, | ||
fields: [ | ||
{ | ||
name: 'title', | ||
title: 'Title', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'author', | ||
title: 'Author', | ||
type: 'reference', | ||
to: {type: 'author', title: 'Author'} | ||
}, | ||
{ | ||
name: 'coverImage', | ||
title: 'Cover Image', | ||
type: 'image' | ||
}, | ||
{ | ||
name: 'publicationYear', | ||
title: 'Year of publication', | ||
type: 'number' | ||
} | ||
], | ||
preview: { | ||
select: { | ||
title: 'title', | ||
authorName: 'author.name', | ||
publicationYear: 'publicationYear' | ||
}, | ||
prepare(thesis, options = {}) { | ||
return Object.assign({}, thesis, { | ||
title: thesis.title, | ||
subtitle: formatSubtitle(thesis) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters