mirror of
https://github.com/strapi/strapi.git
synced 2025-10-30 17:37:26 +00:00
Add flags for languages
This commit is contained in:
parent
9508421b66
commit
d5adb8cdaa
@ -11,7 +11,7 @@ import WithFormSection from 'components/WithFormSection';
|
|||||||
class EditFormSectionSubNested extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
class EditFormSectionSubNested extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.styles.padded}>
|
<div className={`${this.props.styles.padded} ${this.props.styles.subNestedFormContainer}`}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{map(this.props.section, (item, key) => (
|
{map(this.props.section, (item, key) => (
|
||||||
this.props.renderInput(item, key)
|
this.props.renderInput(item, key)
|
||||||
|
|||||||
@ -116,9 +116,7 @@ class InputText extends React.Component { // eslint-disable-line react/prefer-st
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(this.props)
|
|
||||||
const inputValue = this.props.value || '';
|
const inputValue = this.props.value || '';
|
||||||
console.log(inputValue)
|
|
||||||
// override default onBlur
|
// override default onBlur
|
||||||
const handleBlur = this.props.handleBlur || this.handleBlur;
|
const handleBlur = this.props.handleBlur || this.handleBlur;
|
||||||
// override bootStrapClass
|
// override bootStrapClass
|
||||||
|
|||||||
@ -16,3 +16,10 @@
|
|||||||
.padded {
|
.padded {
|
||||||
padding: 0 15px 0 15px;
|
padding: 0 15px 0 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.subNestedFormContainer {
|
||||||
|
margin: 1rem 15px;
|
||||||
|
padding: 0 2rem;
|
||||||
|
background: #FAFAFB;
|
||||||
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { connect } from 'react-redux';
|
|||||||
import { createStructuredSelector } from 'reselect';
|
import { createStructuredSelector } from 'reselect';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { map } from 'lodash';
|
import { map } from 'lodash';
|
||||||
|
import 'flag-icon-css/css/flag-icon.css';
|
||||||
import { pluginId } from 'app';
|
import { pluginId } from 'app';
|
||||||
import PluginLeftMenu from 'components/PluginLeftMenu';
|
import PluginLeftMenu from 'components/PluginLeftMenu';
|
||||||
import { define } from 'i18n';
|
import { define } from 'i18n';
|
||||||
@ -24,6 +25,7 @@ define(map(messages, (message, id) => ({
|
|||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.menuFetch();
|
this.props.menuFetch();
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { forEach, has, remove } from 'lodash';
|
import { includes, forEach, has, remove, get, split } from 'lodash';
|
||||||
import {
|
import {
|
||||||
CONFIG_FETCH,
|
CONFIG_FETCH,
|
||||||
LANGUAGES_FETCH,
|
LANGUAGES_FETCH,
|
||||||
@ -123,9 +123,17 @@ function getDataFromConfigs(configs) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (configs.name === 'form.security.name' && includes(split(get(data, 'security.xframe.value'), ' '), 'ALLOW-FROM')) {
|
||||||
|
const allowFromValue = split(get(data, 'security.xframe.value'), ' ')[0];
|
||||||
|
const allowFromValueNested = split(get(data, 'security.xframe.value'), ' ')[1];
|
||||||
|
data['security.xframe.value'] = allowFromValue;
|
||||||
|
data['security.xframe.value.nested'] = allowFromValueNested;
|
||||||
|
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function changeDefaultLanguage(configsDisplay, newLanguage) {
|
export function changeDefaultLanguage(configsDisplay, newLanguage) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_DEFAULT_LANGUAGE,
|
type: CHANGE_DEFAULT_LANGUAGE,
|
||||||
|
|||||||
@ -242,7 +242,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (has(this.props.home.modifiedData, 'security.xframe.value.nested')) {
|
if (has(this.props.home.modifiedData, 'security.xframe.value.nested') && this.props.home.modifiedData['security.xframe.value'] === 'ALLOW-FROM') {
|
||||||
const value = includes(this.props.home.modifiedData['security.xframe.value.nested'], 'ALLOW-FROM') ?
|
const value = includes(this.props.home.modifiedData['security.xframe.value.nested'], 'ALLOW-FROM') ?
|
||||||
`ALLOW-FROM ${this.props.home.modifiedData['security.xframe.value.nested']}`
|
`ALLOW-FROM ${this.props.home.modifiedData['security.xframe.value.nested']}`
|
||||||
: `ALLOW-FROM.ALLOW-FROM ${this.props.home.modifiedData['security.xframe.value.nested']}`;
|
: `ALLOW-FROM.ALLOW-FROM ${this.props.home.modifiedData['security.xframe.value.nested']}`;
|
||||||
@ -289,11 +289,24 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
)}
|
)}
|
||||||
</FormattedMessage>;
|
</FormattedMessage>;
|
||||||
|
|
||||||
|
const flagName = this.formatLanguageLocale(props.name);
|
||||||
|
let flag;
|
||||||
|
switch (flagName.length) {
|
||||||
|
case 2:
|
||||||
|
flag = toLower(flagName[1]);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
flag = toLower(flagName[2]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
flag = toLower(flagName[0]);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={key}>
|
<li key={key}>
|
||||||
<div className={liStyles.flexLi}>
|
<div className={liStyles.flexLi}>
|
||||||
<div className={liStyles.flexed}>
|
<div className={liStyles.flexed}>
|
||||||
<div>{key}</div>
|
<div><span className={`flag-icon flag-icon-${flag}`} /></div>
|
||||||
<div className={`${liStyles.label} ${liStyles.capitalized}`}>{languageDisplay}</div>
|
<div className={`${liStyles.label} ${liStyles.capitalized}`}>{languageDisplay}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>{props.name}</div>
|
<div>{props.name}</div>
|
||||||
@ -339,11 +352,12 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
renderPopUpFormLanguage = (section, props) => (
|
renderPopUpFormLanguage = (section, props) => (
|
||||||
map(section.items, (item, key) => (
|
map(section.items, (item, key) => (
|
||||||
<div key={key}>
|
<div key={key}>
|
||||||
{props.renderInput(item, key)}
|
{props.renderInput(item, key, this.renderCustomLanguagesSelectOption)}
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
renderRowDatabase = (props, key) => (
|
renderRowDatabase = (props, key) => (
|
||||||
// const isDefaultConnection = this.props.home.modifiedData['database.defaultConnection'] === props.host;
|
// const isDefaultConnection = this.props.home.modifiedData['database.defaultConnection'] === props.host;
|
||||||
<RowDatabase
|
<RowDatabase
|
||||||
@ -462,6 +476,7 @@ export class Home extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
name={this.props.home.configsDisplay.name}
|
name={this.props.home.configsDisplay.name}
|
||||||
description={this.props.home.configsDisplay.description}
|
description={this.props.home.configsDisplay.description}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{this.renderComponent()}
|
{this.renderComponent()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { LOCATION_CHANGE } from 'react-router-redux';
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
||||||
|
|
||||||
import { forEach, set } from 'lodash';
|
import { forEach, set, join, split, toLower, upperCase } from 'lodash';
|
||||||
import { takeLatest } from 'redux-saga';
|
import { takeLatest } from 'redux-saga';
|
||||||
import { call, take, put, fork, cancel, select } from 'redux-saga/effects';
|
import { call, take, put, fork, cancel, select } from 'redux-saga/effects';
|
||||||
import request from 'utils/request';
|
import request from 'utils/request';
|
||||||
@ -165,8 +165,18 @@ export function* fetchLanguages() {
|
|||||||
export function* postLanguage() {
|
export function* postLanguage() {
|
||||||
try {
|
try {
|
||||||
const newLanguage = yield select(makeSelectModifiedData());
|
const newLanguage = yield select(makeSelectModifiedData());
|
||||||
|
const languageArray = [];
|
||||||
|
|
||||||
|
forEach(split(newLanguage['language.defaultLocale'], '_'), (value, key) => {
|
||||||
|
if (key === 0){
|
||||||
|
languageArray.push(toLower(value));
|
||||||
|
} else {
|
||||||
|
languageArray.push(upperCase(value));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
name: newLanguage['language.language.defaultLocale'],
|
name: join(languageArray, '_'),
|
||||||
};
|
};
|
||||||
const opts = {
|
const opts = {
|
||||||
body,
|
body,
|
||||||
|
|||||||
@ -1371,6 +1371,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flag-icon-css": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/flag-icon-css/-/flag-icon-css-2.8.0.tgz",
|
||||||
|
"integrity": "sha1-7BDCD+QXreeHoJUgBjAGnKQ2pWk="
|
||||||
|
},
|
||||||
"flagged-respawn": {
|
"flagged-respawn": {
|
||||||
"version": "0.3.2",
|
"version": "0.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz",
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap": "^4.0.0-alpha.6",
|
"bootstrap": "^4.0.0-alpha.6",
|
||||||
|
"flag-icon-css": "^2.8.0",
|
||||||
"react": "^15.6.1",
|
"react": "^15.6.1",
|
||||||
"react-dom": "^15.6.1",
|
"react-dom": "^15.6.1",
|
||||||
"react-transition-group": "^1.2.0",
|
"react-transition-group": "^1.2.0",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user