Don't allow name-value pairs in theme vector be localized (#5623)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
f7c8db99af
Коммит
f39681596e
@@ -156,21 +156,6 @@ class CustomThemeChooser extends React.Component {
|
|||||||
this.props.updateTheme(theme);
|
this.props.updateTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
getColors(text) {
|
|
||||||
const colorsText = text.split(',');
|
|
||||||
return colorsText.map((colorText) => {
|
|
||||||
const trimText = colorText.trim();
|
|
||||||
const keyValue = trimText.split(':');
|
|
||||||
const color = keyValue[1].trim() || trimText;
|
|
||||||
if (Utils.isHexColor(color)) {
|
|
||||||
return color;
|
|
||||||
} else if (keyValue[0] === 'Code Theme') {
|
|
||||||
return keyValue[1].trim();
|
|
||||||
}
|
|
||||||
return '#FFF';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pasteBoxChange(e) {
|
pasteBoxChange(e) {
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
||||||
@@ -184,20 +169,14 @@ class CustomThemeChooser extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// theme vectors are currently represented as a number of hex color codes followed by the code theme
|
let theme;
|
||||||
const colors = this.getColors(text);
|
try {
|
||||||
const theme = {type: 'custom'};
|
theme = JSON.parse(text);
|
||||||
let index = 0;
|
} catch (err) {
|
||||||
Constants.THEME_ELEMENTS.forEach((element) => {
|
return;
|
||||||
if (index < colors.length - 1) {
|
|
||||||
if (Utils.isHexColor(colors[index])) {
|
|
||||||
theme[element.id] = colors[index];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
index++;
|
|
||||||
});
|
|
||||||
theme.codeTheme = colors[colors.length - 1];
|
|
||||||
|
|
||||||
|
theme.type = 'custom';
|
||||||
this.props.updateTheme(theme);
|
this.props.updateTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +208,6 @@ class CustomThemeChooser extends React.Component {
|
|||||||
const sidebarElements = [];
|
const sidebarElements = [];
|
||||||
const centerChannelElements = [];
|
const centerChannelElements = [];
|
||||||
const linkAndButtonElements = [];
|
const linkAndButtonElements = [];
|
||||||
let colors = '';
|
|
||||||
Constants.THEME_ELEMENTS.forEach((element, index) => {
|
Constants.THEME_ELEMENTS.forEach((element, index) => {
|
||||||
if (element.id === 'codeTheme') {
|
if (element.id === 'codeTheme') {
|
||||||
const codeThemeOptions = [];
|
const codeThemeOptions = [];
|
||||||
@@ -313,8 +291,6 @@ class CustomThemeChooser extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
colors += formatMessage(messages[element.id]) + ': ' + theme[element.id] + ', ';
|
|
||||||
} else if (element.group === 'sidebarElements') {
|
} else if (element.group === 'sidebarElements') {
|
||||||
sidebarElements.push(
|
sidebarElements.push(
|
||||||
<div
|
<div
|
||||||
@@ -335,8 +311,6 @@ class CustomThemeChooser extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
colors += formatMessage(messages[element.id]) + ': ' + theme[element.id] + ', ';
|
|
||||||
} else {
|
} else {
|
||||||
linkAndButtonElements.push(
|
linkAndButtonElements.push(
|
||||||
<div
|
<div
|
||||||
@@ -357,12 +331,12 @@ class CustomThemeChooser extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
colors += formatMessage(messages[element.id]) + ': ' + theme[element.id] + ', ';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
colors += 'Code Theme: ' + theme.codeTheme;
|
const copyTheme = Object.assign({}, theme);
|
||||||
|
delete copyTheme.type;
|
||||||
|
delete copyTheme.image;
|
||||||
|
|
||||||
const pasteBox = (
|
const pasteBox = (
|
||||||
<div className='col-sm-12'>
|
<div className='col-sm-12'>
|
||||||
@@ -374,7 +348,7 @@ class CustomThemeChooser extends React.Component {
|
|||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
className='form-control'
|
className='form-control'
|
||||||
value={colors}
|
value={JSON.stringify(copyTheme)}
|
||||||
onPaste={this.pasteBoxChange}
|
onPaste={this.pasteBoxChange}
|
||||||
onChange={this.onChangeHandle}
|
onChange={this.onChangeHandle}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user