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

Closes #3209 #3210

Merged
merged 1 commit into from
Oct 3, 2018
Merged
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
11 changes: 7 additions & 4 deletions web/client/components/TOC/fragments/settings/General.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ class General extends React.Component {
onChange: PropTypes.func,
element: PropTypes.object,
groups: PropTypes.array,
nodeType: PropTypes.string
nodeType: PropTypes.string,
pluginCfg: PropTypes.object
};

static defaultProps = {
element: {},
onChange: () => {},
nodeType: 'layers'
nodeType: 'layers',
pluginCfg: {}
};

getGroups = (groups, idx = 0) => {
Expand All @@ -52,6 +54,7 @@ class General extends React.Component {
render() {
const locales = LocaleUtils.getSupportedLocales();
const translations = isObject(this.props.element.title) ? assign({}, this.props.element.title) : { 'default': this.props.element.title };
const {hideTitleTranslations = false} = this.props.pluginCfg;
return (
<Grid fluid style={{paddingTop: 15, paddingBottom: 15}}>
<form ref="settings">
Expand All @@ -63,7 +66,7 @@ class General extends React.Component {
type="text"
onChange={this.updateTranslation.bind(null, 'default')}/>
</FormGroup>
<FormGroup>
{hideTitleTranslations || (<FormGroup>
<ControlLabel><Message msgId="layerProperties.titleTranslations" /></ControlLabel>
{Object.keys(locales).map((a) => {
let flagImgSrc;
Expand All @@ -81,7 +84,7 @@ class General extends React.Component {
onChange={this.updateTranslation.bind(null, locales[a].code)}/>
</InputGroup>) : null; }
)}
</FormGroup>
</FormGroup>)}
<FormGroup>
<ControlLabel><Message msgId="layerProperties.name" /></ControlLabel>
<FormControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,31 @@ describe('test Layer Properties General module component', () => {
ReactTestUtils.Simulate.change(inputs[0]);
expect(spy.calls.length).toBe(1);
});
it('tests hidden title translations', () => {
const l = {
name: 'layer00',
title: 'Layer',
visibility: true,
storeIndex: 9,
type: 'wms',
url: 'fakeurl'
};
const settings = {
options: {opacity: 1}
};
const handlers = {
onChange() {}
};
const pluginCfg = {
hideTitleTranslations: true
};
// wrap in a stateful component, stateless components render return null
// see: https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
const comp = ReactDOM.render(<General pluginCfg={pluginCfg} element={l} settings={settings} onChange={handlers.onChange}/>, document.getElementById("container"));
expect(comp).toExist();
const forms = ReactTestUtils.scryRenderedDOMComponentsWithClass( comp, "form-group" );
expect(forms).toExist();
expect(forms.length).toBe(3);
});

});
2 changes: 1 addition & 1 deletion web/client/plugins/TOCItemsSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const tocItemsSettingsSelector = createSelector([
* @prop cfg.width {number} width of panel
* @prop cfg.showFeatureInfoTab {bool} enable/disbale feature info settings
* @prop cfg.enableIFrameModule {bool} enable iframe in template editor of feature info, default true
*
* @prop cfg.hideTitleTranslations {bool} if true hide the title translations tool
* @example
* {
* "name": "TOCItemsSettings",
Expand Down