Unverified Commit 144d980d authored by Saturnino Abril's avatar Saturnino Abril Committed by GitHub
Browse files

[MM-10718] Move custom branding to TE (#1264)

* move custom branding to TE
* rebase to master and fix merge conflict
parent 4c1c99b5
...@@ -246,22 +246,6 @@ export default class AdminSidebar extends React.Component { ...@@ -246,22 +246,6 @@ export default class AdminSidebar extends React.Component {
); );
} }
let customBranding = null;
if (this.props.license.IsLicensed === 'true') {
customBranding = (
<AdminSidebarSection
name='custom_brand'
title={
<FormattedMessage
id='admin.sidebar.customBrand'
defaultMessage='Custom Branding'
/>
}
/>
);
}
let otherCategory = null; let otherCategory = null;
if (license || audits) { if (license || audits) {
otherCategory = ( otherCategory = (
...@@ -727,7 +711,15 @@ export default class AdminSidebar extends React.Component { ...@@ -727,7 +711,15 @@ export default class AdminSidebar extends React.Component {
/> />
} }
> >
{customBranding} <AdminSidebarSection
name='custom_brand'
title={
<FormattedMessage
id='admin.sidebar.customBrand'
defaultMessage='Custom Branding'
/>
}
/>
{announcement} {announcement}
<AdminSidebarSection <AdminSidebarSection
name='emoji' name='emoji'
......
...@@ -16,15 +16,9 @@ import TextSetting from './text_setting.jsx'; ...@@ -16,15 +16,9 @@ import TextSetting from './text_setting.jsx';
export default class CustomBrandSettings extends AdminSettings { export default class CustomBrandSettings extends AdminSettings {
getConfigFromState(config) { getConfigFromState(config) {
config.TeamSettings.SiteName = this.state.siteName; config.TeamSettings.SiteName = this.state.siteName;
config.TeamSettings.CustomDescriptionText = this.state.customDescriptionText;
if (this.props.license.IsLicensed === 'true') { config.TeamSettings.EnableCustomBrand = this.state.enableCustomBrand;
config.TeamSettings.CustomDescriptionText = this.state.customDescriptionText; config.TeamSettings.CustomBrandText = this.state.customBrandText;
}
if (this.props.license.IsLicensed === 'true' && this.props.license.CustomBrand === 'true') {
config.TeamSettings.EnableCustomBrand = this.state.enableCustomBrand;
config.TeamSettings.CustomBrandText = this.state.customBrandText;
}
return config; return config;
} }
...@@ -48,9 +42,28 @@ export default class CustomBrandSettings extends AdminSettings { ...@@ -48,9 +42,28 @@ export default class CustomBrandSettings extends AdminSettings {
} }
renderSettings() { renderSettings() {
const enterpriseSettings = []; return (
if (this.props.license.IsLicensed === 'true' && this.props.license.CustomBrand === 'true') { <SettingsGroup>
enterpriseSettings.push( <TextSetting
id='siteName'
label={
<FormattedMessage
id='admin.team.siteNameTitle'
defaultMessage='Site Name:'
/>
}
maxLength={Constants.MAX_SITENAME_LENGTH}
placeholder={Utils.localizeMessage('admin.team.siteNameExample', 'E.g.: "Mattermost"')}
helpText={
<FormattedMessage
id='admin.team.siteNameDescription'
defaultMessage='Name of service shown in login screens and UI.'
/>
}
value={this.state.siteName}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.SiteName')}
/>
<TextSetting <TextSetting
key='customDescriptionText' key='customDescriptionText'
id='customDescriptionText' id='customDescriptionText'
...@@ -71,9 +84,6 @@ export default class CustomBrandSettings extends AdminSettings { ...@@ -71,9 +84,6 @@ export default class CustomBrandSettings extends AdminSettings {
onChange={this.handleChange} onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.CustomDescriptionText')} setByEnv={this.isSetByEnv('TeamSettings.CustomDescriptionText')}
/> />
);
enterpriseSettings.push(
<BooleanSetting <BooleanSetting
key='enableCustomBrand' key='enableCustomBrand'
id='enableCustomBrand' id='enableCustomBrand'
...@@ -93,16 +103,10 @@ export default class CustomBrandSettings extends AdminSettings { ...@@ -93,16 +103,10 @@ export default class CustomBrandSettings extends AdminSettings {
onChange={this.handleChange} onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.EnableCustomBrand')} setByEnv={this.isSetByEnv('TeamSettings.EnableCustomBrand')}
/> />
);
enterpriseSettings.push(
<BrandImageSetting <BrandImageSetting
key='customBrandImage' key='customBrandImage'
disabled={!this.state.enableCustomBrand} disabled={!this.state.enableCustomBrand}
/> />
);
enterpriseSettings.push(
<TextSetting <TextSetting
key='customBrandText' key='customBrandText'
id='customBrandText' id='customBrandText'
...@@ -124,32 +128,6 @@ export default class CustomBrandSettings extends AdminSettings { ...@@ -124,32 +128,6 @@ export default class CustomBrandSettings extends AdminSettings {
disabled={!this.state.enableCustomBrand} disabled={!this.state.enableCustomBrand}
setByEnv={this.isSetByEnv('TeamSettings.CustomBrandText')} setByEnv={this.isSetByEnv('TeamSettings.CustomBrandText')}
/> />
);
}
return (
<SettingsGroup>
<TextSetting
id='siteName'
label={
<FormattedMessage
id='admin.team.siteNameTitle'
defaultMessage='Site Name:'
/>
}
maxLength={Constants.MAX_SITENAME_LENGTH}
placeholder={Utils.localizeMessage('admin.team.siteNameExample', 'E.g.: "Mattermost"')}
helpText={
<FormattedMessage
id='admin.team.siteNameDescription'
defaultMessage='Name of service shown in login screens and UI.'
/>
}
value={this.state.siteName}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.SiteName')}
/>
{enterpriseSettings}
</SettingsGroup> </SettingsGroup>
); );
} }
......
...@@ -8,23 +8,20 @@ import {FormattedMessage} from 'react-intl'; ...@@ -8,23 +8,20 @@ import {FormattedMessage} from 'react-intl';
export default class SiteNameAndDescription extends React.PureComponent { export default class SiteNameAndDescription extends React.PureComponent {
static propTypes = { static propTypes = {
customDescriptionText: PropTypes.string, customDescriptionText: PropTypes.string,
isLicensed: PropTypes.bool,
siteName: PropTypes.string, siteName: PropTypes.string,
}; };
static defaultProps = { static defaultProps = {
isLicensed: false,
siteName: 'Mattermost', siteName: 'Mattermost',
}; };
render() { render() {
const { const {
customDescriptionText, customDescriptionText,
isLicensed,
siteName, siteName,
} = this.props; } = this.props;
let description = null; let description = null;
if (isLicensed && customDescriptionText) { if (customDescriptionText) {
description = customDescriptionText; description = customDescriptionText;
} else { } else {
description = ( description = (
......
...@@ -24,11 +24,6 @@ export default class CreateTeam extends React.PureComponent { ...@@ -24,11 +24,6 @@ export default class CreateTeam extends React.PureComponent {
*/ */
currentChannel: PropTypes.object, currentChannel: PropTypes.object,
/*
* Boolean value that determines whether server has a valid Enterprise license
*/
isLicensed: PropTypes.bool.isRequired,
/* /*
* String containing the custom branding's text * String containing the custom branding's text
*/ */
...@@ -66,7 +61,6 @@ export default class CreateTeam extends React.PureComponent { ...@@ -66,7 +61,6 @@ export default class CreateTeam extends React.PureComponent {
currentChannel, currentChannel,
currentTeam, currentTeam,
customDescriptionText, customDescriptionText,
isLicensed,
match, match,
siteName, siteName,
} = this.props; } = this.props;
...@@ -87,7 +81,6 @@ export default class CreateTeam extends React.PureComponent { ...@@ -87,7 +81,6 @@ export default class CreateTeam extends React.PureComponent {
<div className='signup-team__container'> <div className='signup-team__container'>
<SiteNameAndDescription <SiteNameAndDescription
customDescriptionText={customDescriptionText} customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName} siteName={siteName}
/> />
<div className='signup__content'> <div className='signup__content'>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams'; import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
...@@ -11,18 +11,15 @@ import CreateTeam from './create_team'; ...@@ -11,18 +11,15 @@ import CreateTeam from './create_team';
function mapStateToProps(state) { function mapStateToProps(state) {
const config = getConfig(state); const config = getConfig(state);
const license = getLicense(state);
const currentChannel = getCurrentChannel(state); const currentChannel = getCurrentChannel(state);
const currentTeam = getCurrentTeam(state); const currentTeam = getCurrentTeam(state);
const isLicensed = license.IsLicensed === 'true';
const customDescriptionText = config.CustomDescriptionText; const customDescriptionText = config.CustomDescriptionText;
const siteName = config.SiteName; const siteName = config.SiteName;
return { return {
currentChannel, currentChannel,
currentTeam, currentTeam,
isLicensed,
customDescriptionText, customDescriptionText,
siteName, siteName,
}; };
......
...@@ -10,7 +10,6 @@ function mapStateToProps(state) { ...@@ -10,7 +10,6 @@ function mapStateToProps(state) {
const config = getConfig(state); const config = getConfig(state);
const license = getLicense(state); const license = getLicense(state);
const customBrand = license.CustomBrand === 'true';
const isLicensed = license.IsLicensed === 'true'; const isLicensed = license.IsLicensed === 'true';
const customBrandText = config.CustomBrandText; const customBrandText = config.CustomBrandText;
...@@ -31,7 +30,6 @@ function mapStateToProps(state) { ...@@ -31,7 +30,6 @@ function mapStateToProps(state) {
const siteName = config.SiteName; const siteName = config.SiteName;
return { return {
customBrand,
isLicensed, isLicensed,
customBrandText, customBrandText,
customDescriptionText, customDescriptionText,
......
...@@ -32,8 +32,6 @@ export default class LoginController extends React.Component { ...@@ -32,8 +32,6 @@ export default class LoginController extends React.Component {
static get propTypes() { static get propTypes() {
return { return {
location: PropTypes.object.isRequired, location: PropTypes.object.isRequired,
customBrand: PropTypes.bool.isRequired,
isLicensed: PropTypes.bool.isRequired, isLicensed: PropTypes.bool.isRequired,
customBrandText: PropTypes.string, customBrandText: PropTypes.string,
...@@ -266,9 +264,7 @@ export default class LoginController extends React.Component { ...@@ -266,9 +264,7 @@ export default class LoginController extends React.Component {
} }
createCustomLogin() { createCustomLogin() {
if (this.props.isLicensed && if (this.props.enableCustomBrand) {
this.props.customBrand &&
this.props.enableCustomBrand) {
const text = this.props.customBrandText || ''; const text = this.props.customBrandText || '';
const formattedText = TextFormatting.formatText(text); const formattedText = TextFormatting.formatText(text);
...@@ -628,7 +624,6 @@ export default class LoginController extends React.Component { ...@@ -628,7 +624,6 @@ export default class LoginController extends React.Component {
render() { render() {
const { const {
customDescriptionText, customDescriptionText,
isLicensed,
siteName, siteName,
} = this.props; } = this.props;
...@@ -666,7 +661,6 @@ export default class LoginController extends React.Component { ...@@ -666,7 +661,6 @@ export default class LoginController extends React.Component {
<div className='signup__content'> <div className='signup__content'>
<SiteNameAndDescription <SiteNameAndDescription
customDescriptionText={customDescriptionText} customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName} siteName={siteName}
/> />
{content} {content}
......
...@@ -7,7 +7,7 @@ import {withRouter} from 'react-router-dom'; ...@@ -7,7 +7,7 @@ import {withRouter} from 'react-router-dom';
import {getTeams} from 'mattermost-redux/actions/teams'; import {getTeams} from 'mattermost-redux/actions/teams';
import {loadRolesIfNeeded} from 'mattermost-redux/actions/roles'; import {loadRolesIfNeeded} from 'mattermost-redux/actions/roles';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getRoles} from 'mattermost-redux/selectors/entities/roles'; import {getRoles} from 'mattermost-redux/selectors/entities/roles';
import {getSortedJoinableTeams, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams'; import {getSortedJoinableTeams, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users'; import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
...@@ -15,13 +15,11 @@ import {getCurrentUser} from 'mattermost-redux/selectors/entities/users'; ...@@ -15,13 +15,11 @@ import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import SelectTeam from './select_team.jsx'; import SelectTeam from './select_team.jsx';
function mapStateToProps(state) { function mapStateToProps(state) {
const license = getLicense(state);
const config = getConfig(state); const config = getConfig(state);
const currentUser = getCurrentUser(state); const currentUser = getCurrentUser(state);
const myTeamMemberships = Object.values(getTeamMemberships(state)); const myTeamMemberships = Object.values(getTeamMemberships(state));
return { return {
isLicensed: license.IsLicensed === 'true',
currentUserRoles: currentUser.roles || '', currentUserRoles: currentUser.roles || '',
customDescriptionText: config.CustomDescriptionText, customDescriptionText: config.CustomDescriptionText,
roles: getRoles(state), roles: getRoles(state),
......
...@@ -29,7 +29,6 @@ const TEAMS_PER_PAGE = 200; ...@@ -29,7 +29,6 @@ const TEAMS_PER_PAGE = 200;
export default class SelectTeam extends React.Component { export default class SelectTeam extends React.Component {
static propTypes = { static propTypes = {
isLicensed: PropTypes.bool.isRequired,
currentUserRoles: PropTypes.string, currentUserRoles: PropTypes.string,
customDescriptionText: PropTypes.string, customDescriptionText: PropTypes.string,
isMemberOfTeam: PropTypes.bool.isRequired, isMemberOfTeam: PropTypes.bool.isRequired,
...@@ -122,7 +121,6 @@ export default class SelectTeam extends React.Component { ...@@ -122,7 +121,6 @@ export default class SelectTeam extends React.Component {
const { const {
currentUserRoles, currentUserRoles,
customDescriptionText, customDescriptionText,
isLicensed,
isMemberOfTeam, isMemberOfTeam,
joinableTeams, joinableTeams,
siteName, siteName,
...@@ -283,7 +281,6 @@ export default class SelectTeam extends React.Component { ...@@ -283,7 +281,6 @@ export default class SelectTeam extends React.Component {
/> />
<SiteNameAndDescription <SiteNameAndDescription
customDescriptionText={customDescriptionText} customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName} siteName={siteName}
/> />
{openContent} {openContent}
......
...@@ -2,33 +2,26 @@ ...@@ -2,33 +2,26 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getPasswordConfig} from 'utils/utils.jsx'; import {getPasswordConfig} from 'utils/utils.jsx';
import SignupEmail from './signup_email.jsx'; import SignupEmail from './signup_email.jsx';
function mapStateToProps(state) { function mapStateToProps(state) {
const license = getLicense(state);
const config = getConfig(state); const config = getConfig(state);
const isLicensed = license && license.IsLicensed === 'true';
const enableSignUpWithEmail = config.EnableSignUpWithEmail === 'true'; const enableSignUpWithEmail = config.EnableSignUpWithEmail === 'true';
const siteName = config.SiteName; const siteName = config.SiteName;
const termsOfServiceLink = config.TermsOfServiceLink; const termsOfServiceLink = config.TermsOfServiceLink;
const privacyPolicyLink = config.PrivacyPolicyLink; const privacyPolicyLink = config.PrivacyPolicyLink;
const customBrand = license.CustomBrand === 'true';
const enableCustomBrand = config.EnableCustomBrand === 'true';
const customDescriptionText = config.CustomDescriptionText; const customDescriptionText = config.CustomDescriptionText;
return { return {
isLicensed,
enableSignUpWithEmail, enableSignUpWithEmail,
siteName, siteName,
termsOfServiceLink, termsOfServiceLink,
privacyPolicyLink, privacyPolicyLink,
customBrand,
enableCustomBrand,
customDescriptionText, customDescriptionText,
passwordConfig: getPasswordConfig(config), passwordConfig: getPasswordConfig(config),
}; };
......
...@@ -26,13 +26,10 @@ export default class SignupEmail extends React.Component { ...@@ -26,13 +26,10 @@ export default class SignupEmail extends React.Component {
static get propTypes() { static get propTypes() {
return { return {
location: PropTypes.object, location: PropTypes.object,
isLicensed: PropTypes.bool.isRequired,
enableSignUpWithEmail: PropTypes.bool.isRequired, enableSignUpWithEmail: PropTypes.bool.isRequired,
siteName: PropTypes.string, siteName: PropTypes.string,
termsOfServiceLink: PropTypes.string, termsOfServiceLink: PropTypes.string,
privacyPolicyLink: PropTypes.string, privacyPolicyLink: PropTypes.string,
customBrand: PropTypes.bool.isRequired,
enableCustomBrand: PropTypes.bool.isRequired,
customDescriptionText: PropTypes.string, customDescriptionText: PropTypes.string,
passwordConfig: PropTypes.object, passwordConfig: PropTypes.object,
}; };
...@@ -426,7 +423,6 @@ export default class SignupEmail extends React.Component { ...@@ -426,7 +423,6 @@ export default class SignupEmail extends React.Component {
const { const {
customDescriptionText, customDescriptionText,
enableSignUpWithEmail, enableSignUpWithEmail,
isLicensed,
location, location,
privacyPolicyLink, privacyPolicyLink,
siteName, siteName,
...@@ -485,7 +481,6 @@ export default class SignupEmail extends React.Component { ...@@ -485,7 +481,6 @@ export default class SignupEmail extends React.Component {
/> />
<SiteNameAndDescription <SiteNameAndDescription
customDescriptionText={customDescriptionText} customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName} siteName={siteName}
/> />
<h4 className='color--light'> <h4 className='color--light'>
......
...@@ -124,7 +124,6 @@ export default class SignupLdap extends React.Component { ...@@ -124,7 +124,6 @@ export default class SignupLdap extends React.Component {
render() { render() {
const { const {
customDescriptionText, customDescriptionText,
isLicensed,
siteName, siteName,
} = this.props; } = this.props;
...@@ -230,7 +229,6 @@ export default class SignupLdap extends React.Component { ...@@ -230,7 +229,6 @@ export default class SignupLdap extends React.Component {
/> />