Skip to content

Commit

Permalink
Merge pull request #3670 from neos/feature/allow-grouping-in-dimensio…
Browse files Browse the repository at this point in the history
…n-switcher

FEATURE: Allow grouping in DimensionSwitcher
  • Loading branch information
markusguenther authored Dec 20, 2023
2 parents 24eadd6 + 97eaf40 commit 5cb3978
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,42 @@ Neos:
values:
- en_US
uriSegment: en
group: NON-EU
en_UK:
label: 'English (UK)'
values:
- en_UK
- en_US
uriSegment: uk
group: NON-EU
de:
label: German
values:
- de
uriSegment: de
group: EU
fr:
label: French
values:
- fr
uriSegment: fr
group: EU
nl:
label: Dutch
values:
- nl
- de
uriSegment: nl
group: EU
da:
label: Danish
values:
- da
uriSegment: da
group: EU
lv:
label: Latvian
values:
- lv
uriSegment: lv
group: EU
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Page,
DimensionSwitcher
} from './../../pageModel';
import {Selector} from 'testcafe';

/* global fixture:true */

Expand Down Expand Up @@ -30,3 +31,9 @@ test('Switching dimensions', async t => {
.expect(await Page.getReduxState(state => state.cr.contentDimensions.active.language[0])).eql('en_US', 'Dimension back to English')
.expect(Page.treeNode.withText(otherPageName).exists).ok('Untranslated node back in the tree');
});

test('Grouping of dimensions', async t => {
await t
.click(DimensionSwitcher.dimensionSwitcher)
.expect(Selector('div[class*="selectBox__groupHeader"]').withExactText('EU').exists).ok('Languages group exists');
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import SelectBox from '@neos-project/react-ui-components/src/SelectBox/';
import style from './style.module.css';
import {$get, $transform} from 'plow-js';
import mapValues from 'lodash.mapvalues';
import sortBy from 'lodash.sortby';
import {neos} from '@neos-project/neos-ui-decorators';
Expand Down Expand Up @@ -46,18 +45,16 @@ export default class DimensionSelector extends PureComponent {
const presetOptions = mapValues(
presets,
(presetConfiguration, presetName) => {
return $transform(
{
label: $get('label'),
value: presetName,
disallowed: $get('disallowed')
},
presetConfiguration
);
return {
label: presetConfiguration?.label,
value: presetName,
disallowed: presetConfiguration?.disallowed,
group: presetConfiguration?.group
};
}
);

const sortedPresetOptions = sortBy(presetOptions, ['label']);
const sortedPresetOptions = sortBy(presetOptions, ['group', 'label']);

const onPresetSelect = presetName => {
onSelect(dimensionName, presetName);
Expand Down

0 comments on commit 5cb3978

Please sign in to comment.