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

Sort control panels alphabetically by title within each group #3737

Merged
merged 17 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugfix

- Sort control panels alphabetically within each group @JeffersonBledsoe #3737

### Internal

### Documentation
Expand Down
38 changes: 22 additions & 16 deletions src/components/manage/Controlpanels/Controlpanels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { Link } from 'react-router-dom';
import { concat, filter, last, map, uniqBy } from 'lodash';
import { concat, filter, last, map, sortBy, uniqBy } from 'lodash';
import { Portal } from 'react-portal';
import { Helmet } from '@plone/volto/helpers';
import { Container, Grid, Header, Segment } from 'semantic-ui-react';
Expand Down Expand Up @@ -241,21 +241,27 @@ class Controlpanels extends Component {
<Segment key={`body-${group}`} attached>
<Grid columns={6}>
<Grid.Row>
{map(filter(controlpanels, { group }), (controlpanel) => (
<Grid.Column key={controlpanel.id}>
<Link to={`/controlpanel/${controlpanel.id}`}>
<Header as="h3" icon textAlign="center">
<Icon
name={icons?.[controlpanel.id] || icons.default}
size="48px"
/>
<Header.Content>
{controlpanel.title}
</Header.Content>
</Header>
</Link>
</Grid.Column>
))}
{map(
sortBy(
filter(controlpanels, { group }),
(controlpanel) => controlpanel.title,
),
(controlpanel) => (
<Grid.Column key={controlpanel.id}>
<Link to={`/controlpanel/${controlpanel.id}`}>
<Header as="h3" icon textAlign="center">
<Icon
name={icons?.[controlpanel.id] || icons.default}
size="48px"
/>
<Header.Content>
{controlpanel.title}
</Header.Content>
</Header>
</Link>
</Grid.Column>
),
)}
</Grid.Row>
</Grid>
</Segment>,
Expand Down