Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify icon for admin sections #4497

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/client/App/screens/Home/components/Section.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getRelatedIconClass from '../utils/getRelatedIconClass';

class Section extends React.Component {
render () {
const iconClass = this.props.icon || getRelatedIconClass(this.props.id);
const iconClass = this.props.icon ? `octicon octicon-${this.props.icon}` : getRelatedIconClass(this.props.id);
return (
<div className="dashboard-group" data-section-label={this.props.label}>
<div className="dashboard-group__heading">
Expand Down
2 changes: 1 addition & 1 deletion admin/client/App/screens/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var HomeView = React.createClass({
{/* Render nav with sections */}
{Keystone.nav.sections.map((navSection) => {
return (
<Section key={navSection.key} id={navSection.key} label={navSection.label}>
<Section key={navSection.key} id={navSection.key} label={navSection.label} icon={navSection.icon}>
<Lists
counts={this.props.counts}
lists={navSection.lists}
Expand Down
10 changes: 10 additions & 0 deletions docs/documentation/Configuration/Project-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ keystone.set('nav', {
});
```

If you want to specify the icon, use an object (you will find the icon name [here](https://octicons.github.com)):

```javascript
keystone.set('nav', {
posts: ['posts', 'post-categories'],
galleries: {icon: 'rocket', paths: ['galleries', 'enquiries']},
users: 'users'
};
```

<h4 data-primitive-type="String"><code>csv field delimiter</code></h4>

Allow you to choose a custom field delimiter to be used for CSV export instead of the default comma.
Expand Down
23 changes: 17 additions & 6 deletions lib/core/initNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,25 @@ module.exports = function initNav (sections) {
});
}

_.forEach(sections, function (section, key) {
if (typeof section === 'string') {
section = [section];
_.forEach(sections, function (spec, key) {
var lists;
if (typeof spec === 'string') {
lists = [spec];
}
section = {
lists: section,
label: nav.flat ? keystone.list(section[0]).label : utils.keyToLabel(key),
else if (Array.isArray(spec)) {
lists = spec;
}
else {
lists = spec.paths;
}

var section = {
lists: lists,
label: nav.flat ? keystone.list(spec[0]).label : utils.keyToLabel(key),
};
if (spec.icon) {
section.icon = spec.icon;
}
section.key = key;
section.lists = _.map(section.lists, function (i) {
if (typeof i === 'string') {
Expand Down