-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from dew326/cotf-config
EZP-28936/EZP-29000/EZP-29001/EZP-29002/EZP-29003/EZP-29004/EZP-29005/EZP-29007 - Content on the Fly configuration
- Loading branch information
Showing
22 changed files
with
578 additions
and
187 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/modules/universal-discovery/components/create/choose.language.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import './css/choose.language.component.css'; | ||
|
||
export default class ChooseLanguageComponent extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.updateSelection = this.updateSelection.bind(this); | ||
this.renderOption = this.renderOption.bind(this); | ||
|
||
let selectedLanguageCode = props.allowedLanguages.length ? props.allowedLanguages[0] : props.languages.priority[0]; | ||
|
||
if (props.preselectedLanguage) { | ||
selectedLanguageCode = props.preselectedLanguage; | ||
} | ||
|
||
if (props.forcedLanguage) { | ||
console.warn('[DEPRECATED] cotfForcedLanguage parameter is deprecated'); | ||
console.warn('[DEPRECATED] it will be removed from ezplatform-admin-ui-modules 2.0'); | ||
console.warn('[DEPRECATED] use cotfAllowedLanguages instead'); | ||
|
||
selectedLanguageCode = props.forcedLanguage; | ||
} | ||
|
||
if (props.allowedLanguages.length === 1) { | ||
selectedLanguageCode = props.allowedLanguages[0]; | ||
} | ||
|
||
this.state = { | ||
selectedLanguage: props.languages.mappings[selectedLanguageCode] | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.props.onLanguageSelected(this.state.selectedLanguage); | ||
} | ||
|
||
updateSelection(event) { | ||
const languageCode = event.target.value; | ||
const selectedLanguage = this.props.languages.mappings[languageCode]; | ||
|
||
this.props.onLanguageSelected(selectedLanguage); | ||
|
||
this.setState(state => Object.assign({}, state, { selectedLanguage })); | ||
} | ||
|
||
renderOption(languageCode, index) { | ||
const language = this.props.languages.mappings[languageCode]; | ||
const attrs = { | ||
key: index, | ||
value: language.languageCode | ||
}; | ||
|
||
if (this.state.selectedLanguage.languageCode === languageCode) { | ||
attrs.selected = true; | ||
} | ||
|
||
return ( | ||
<option {...attrs}>{language.name}</option> | ||
); | ||
} | ||
|
||
renderOptions() { | ||
const { allowedLanguages, languages } = this.props; | ||
const languagesList = allowedLanguages.length ? allowedLanguages : languages.priority; | ||
|
||
return ( | ||
languagesList.map(this.renderOption) | ||
); | ||
} | ||
|
||
render() { | ||
const selectAttrs = { | ||
className: 'form-control', | ||
onChange: this.updateSelection | ||
}; | ||
|
||
if (this.props.forcedLanguage) { | ||
console.warn('[DEPRECATED] forcedLanguage parameter is deprecated'); | ||
console.warn('[DEPRECATED] it will be removed from ezplatform-admin-ui-modules 2.0'); | ||
console.warn('[DEPRECATED] use allowedLanguages instead'); | ||
} | ||
|
||
// @Deprecated - `forcedLanguage` will be removed in 2.0 | ||
if (this.props.allowedLanguages.length === 1 || this.props.forcedLanguage) { | ||
selectAttrs.disabled = true; | ||
} | ||
|
||
return ( | ||
<div className="c-choose-language"> | ||
<p className="c-choose-language__title">{this.props.labels.contentOnTheFly.selectLanguage}</p> | ||
<div className="c-choose-lagauge__select-wrapper"> | ||
<select {...selectAttrs}> | ||
{this.renderOptions()} | ||
</select> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ChooseLanguageComponent.propTypes = { | ||
maxHeight: PropTypes.number.isRequired, | ||
labels: PropTypes.object.isRequired, | ||
languages: PropTypes.object.isRequired, | ||
onLanguageSelected: PropTypes.func.isRequired, | ||
forcedLanguage: PropTypes.string.isRequired, | ||
allowedLanguages: PropTypes.array.isRequired, | ||
preselectedLanguage: PropTypes.string.isRequired | ||
}; |
72 changes: 0 additions & 72 deletions
72
src/modules/universal-discovery/components/create/create.choose.language.component.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,8 @@ | |
color: #fff; | ||
outline: none; | ||
} | ||
|
||
.c-finder-tree-branch--collapsed { | ||
flex: 0 0 3ch; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.