From 49894d9fd9660fbf40145e266bff7b8ede5ced82 Mon Sep 17 00:00:00 2001 From: Pedro Duarte Date: Mon, 19 Feb 2018 17:00:52 +0000 Subject: [PATCH] Add `label_singular` to collection config (#1086) --- .all-contributorsrc | 11 +++++++++++ README.md | 6 +++--- example/config.yml | 6 ++++-- src/components/App/Header.js | 2 +- src/components/Collection/Collection.js | 1 + src/components/Collection/CollectionTop.js | 3 ++- src/components/EditorWidgets/List/ListControl.js | 3 ++- website/site/content/docs/configuration-options.md | 1 + 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6a450fbc4805..51753a0141f2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -750,6 +750,17 @@ "code" ] }, + { + "login": "peduarte", + "name": "Pedro Duarte", + "avatar_url": "https://avatars1.githubusercontent.com/u/372831?v=4", + "profile": "http://pedroduarte.me", + "contributions": [ + "bug", + "code", + "doc" + ] + }, { "login": "Strangehill", "name": "Antonio Argote", diff --git a/README.md b/README.md index 9b2d7535714f..0260bbae074c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Netlify CMS -[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg)](#contributors) [![Open Source Helpers](https://www.codetriage.com/netlify/netlify-cms/badges/users.svg)](https://www.codetriage.com/netlify/netlify-cms) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms) @@ -61,8 +61,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
Etienne Bernard](https://github.com/ebernard)
[📖](https://github.com/netlify/netlify-cms/commits?author=ebernard "Documentation") | [
Eli Williamson](http://eliwilliamson.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=eliwilliamson "Code") [🎨](#design-eliwilliamson "Design") | [
Covington Doan](https://www.covingtondoan.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=covingtondoan "Documentation") | [
Lennart Ziburski](http://lennartziburski.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=ziburski "Code") [🎨](#design-ziburski "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=ziburski "Documentation") | [
Darrel O'Pry](http://darrelopry.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=dopry "Code") [🚇](#infra-dopry "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/netlify/netlify-cms/commits?author=dopry "Tests") | [
Erin Symons](https://github.com/yourfrienderin)
[📖](https://github.com/netlify/netlify-cms/commits?author=yourfrienderin "Documentation") | [
Austin Green](https://github.com/AustinGreen)
[📖](https://github.com/netlify/netlify-cms/commits?author=AustinGreen "Documentation") [💡](#example-AustinGreen "Examples") | | [
Bryan Robinson](http://bryanlrobinson.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=brob "Documentation") | [
Darren](https://github.com/dardub)
[📖](https://github.com/netlify/netlify-cms/commits?author=dardub "Documentation") | [
Richard Pullinger](http://www.richardpullinger.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=rpullinger "Code") | [
Taylor Bryant](https://taylorbryant.blog)
[📖](https://github.com/netlify/netlify-cms/commits?author=taylorbryant "Documentation") | [
kvanerkelens](https://github.com/kvanerkelens)
[📖](https://github.com/netlify/netlify-cms/commits?author=kvanerkelens "Documentation") | [
Patrick Sier](https://patsier.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pjsier "Code") | [
Christian Nolte](http://noltech.net)
[💻](https://github.com/netlify/netlify-cms/commits?author=drlogout "Code") | | [
Edward Betts](http://edwardbetts.com/)
[📖](https://github.com/netlify/netlify-cms/commits?author=EdwardBetts "Documentation") | [
Josh Hardman](https://github.com/jhardman0830)
[📖](https://github.com/netlify/netlify-cms/commits?author=jhardman0830 "Documentation") | [
Mantas](https://behance.net/mistermantas)
[📖](https://github.com/netlify/netlify-cms/commits?author=mistermantas "Documentation") | [
Marco Biedermann](https://www.marcobiedermann.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=marcobiedermann "Documentation") | [
Max Stoiber](https://mxstbr.blog/newsletter)
[📖](https://github.com/netlify/netlify-cms/commits?author=mxstbr "Documentation") | [
Vyacheslav Matyukhin](http://berekuk.ru)
[📖](https://github.com/netlify/netlify-cms/commits?author=berekuk "Documentation") | [
jimmaaay](https://jimmythompson.me)
[💻](https://github.com/netlify/netlify-cms/commits?author=jimmaaay "Code") | -| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | -| [
Tim Carry](http://www.pixelastic.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | [
Sol Park](https://github.com/solpark)
[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [
Michael Romani](https://github.com/michaelromani)
[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | [
Antonio Argote](http://antonioargote.com)
[🎨](#design-Strangehill "Design") | +| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Tim Carry](http://www.pixelastic.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | +| [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | [
Sol Park](https://github.com/solpark)
[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [
Michael Romani](https://github.com/michaelromani)
[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | [
Pedro Duarte](http://pedroduarte.me)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Apeduarte "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=peduarte "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=peduarte "Documentation") | [
Antonio Argote](http://antonioargote.com)
[🎨](#design-Strangehill "Design") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! diff --git a/example/config.yml b/example/config.yml index 3a2a746fca0d..9e245c33c788 100644 --- a/example/config.yml +++ b/example/config.yml @@ -6,7 +6,8 @@ media_folder: "assets/uploads" collections: # A list of collections the CMS should be able to edit - name: "posts" # Used in routes, ie.: /admin/collections/:slug/edit - label: "Post" # Used in the UI, ie.: "New Post" + label: "Posts" # Used in the UI + label_singular: "Post" # Used in the UI, ie: "New Post" description: > The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection. @@ -22,7 +23,7 @@ collections: # A list of collections the CMS should be able to edit - {label: "SEO Description", name: "description", widget: "text"} - name: "faq" # Used in routes, ie.: /admin/collections/:slug/edit - label: "FAQ" # Used in the UI, ie.: "New Post" + label: "FAQ" # Used in the UI folder: "_faqs" create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have @@ -56,6 +57,7 @@ collections: # A list of collections the CMS should be able to edit fields: - name: authors label: Authors + label_singular: "Author" widget: list fields: - {label: "Name", name: "name", widget: "string"} diff --git a/src/components/App/Header.js b/src/components/App/Header.js index 1d770fab4fde..4c439c0e33a2 100644 --- a/src/components/App/Header.js +++ b/src/components/App/Header.js @@ -73,7 +73,7 @@ export default class Header extends React.Component { collections.filter(collection => collection.get('create')).toList().map(collection => this.handleCreatePostClick(collection.get('name'))} /> ) diff --git a/src/components/Collection/Collection.js b/src/components/Collection/Collection.js index 8f3294c73b07..3a4ac7d95ba6 100644 --- a/src/components/Collection/Collection.js +++ b/src/components/Collection/Collection.js @@ -46,6 +46,7 @@ class Collection extends React.Component { ? null : - {`New ${collectionLabel}`} + {`New ${collectionLabelSingular || collectionLabel}`} : null } diff --git a/src/components/EditorWidgets/List/ListControl.js b/src/components/EditorWidgets/List/ListControl.js index 0b689174e2fb..aec504eba38b 100644 --- a/src/components/EditorWidgets/List/ListControl.js +++ b/src/components/EditorWidgets/List/ListControl.js @@ -254,12 +254,13 @@ export default class ListControl extends Component { const { value, forID, field, classNameWrapper } = this.props; const { itemsCollapsed } = this.state; const items = value || List(); + const label = field.get('label_singular') || field.get('label'); return (
val === true)} itemsCount={items.size} diff --git a/website/site/content/docs/configuration-options.md b/website/site/content/docs/configuration-options.md index d744c27b4b5a..8cfab4149a01 100644 --- a/website/site/content/docs/configuration-options.md +++ b/website/site/content/docs/configuration-options.md @@ -71,6 +71,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it - `name` (required): unique identifier for the collection, used as the key when referenced in other contexts (like the [relation widget](https://www.netlifycms.org/docs/widgets/#relation)) - `Label`: label for the collection in the editor UI; defaults to the value of `name` +- `label_singular`: singular label for certain elements in the editor; defaults to the value of `label` - `file` or `folder` (requires one of these): specifies the collection type and location; details in [Collection Types](https://www.netlifycms.org/docs/collection-types) - `filter`: optional filter for `folder` collections; details in [Collection Types](https://www.netlifycms.org/docs/collection-types) - `create`: for `folder` collections only; `true` allows users to create new items in the collection; defaults to `false`