Skip to content

Commit

Permalink
[MM-10718] Move custom branding to TE (mattermost#1264)
Browse files Browse the repository at this point in the history
* move custom branding to TE
* rebase to master and fix merge conflict
  • Loading branch information
saturninoabril authored Jun 1, 2018
1 parent 4c1c99b commit 144d980
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 140 deletions.
26 changes: 9 additions & 17 deletions components/admin_console/admin_sidebar/admin_sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
if (license || audits) {
otherCategory = (
Expand Down Expand Up @@ -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}
<AdminSidebarSection
name='emoji'
Expand Down
72 changes: 25 additions & 47 deletions components/admin_console/custom_brand_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ import TextSetting from './text_setting.jsx';
export default class CustomBrandSettings extends AdminSettings {
getConfigFromState(config) {
config.TeamSettings.SiteName = this.state.siteName;

if (this.props.license.IsLicensed === 'true') {
config.TeamSettings.CustomDescriptionText = this.state.customDescriptionText;
}

if (this.props.license.IsLicensed === 'true' && this.props.license.CustomBrand === 'true') {
config.TeamSettings.EnableCustomBrand = this.state.enableCustomBrand;
config.TeamSettings.CustomBrandText = this.state.customBrandText;
}
config.TeamSettings.CustomDescriptionText = this.state.customDescriptionText;
config.TeamSettings.EnableCustomBrand = this.state.enableCustomBrand;
config.TeamSettings.CustomBrandText = this.state.customBrandText;

return config;
}
Expand All @@ -48,9 +42,28 @@ export default class CustomBrandSettings extends AdminSettings {
}

renderSettings() {
const enterpriseSettings = [];
if (this.props.license.IsLicensed === 'true' && this.props.license.CustomBrand === 'true') {
enterpriseSettings.push(
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')}
/>
<TextSetting
key='customDescriptionText'
id='customDescriptionText'
Expand All @@ -71,9 +84,6 @@ export default class CustomBrandSettings extends AdminSettings {
onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.CustomDescriptionText')}
/>
);

enterpriseSettings.push(
<BooleanSetting
key='enableCustomBrand'
id='enableCustomBrand'
Expand All @@ -93,16 +103,10 @@ export default class CustomBrandSettings extends AdminSettings {
onChange={this.handleChange}
setByEnv={this.isSetByEnv('TeamSettings.EnableCustomBrand')}
/>
);

enterpriseSettings.push(
<BrandImageSetting
key='customBrandImage'
disabled={!this.state.enableCustomBrand}
/>
);

enterpriseSettings.push(
<TextSetting
key='customBrandText'
id='customBrandText'
Expand All @@ -124,32 +128,6 @@ export default class CustomBrandSettings extends AdminSettings {
disabled={!this.state.enableCustomBrand}
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>
);
}
Expand Down
5 changes: 1 addition & 4 deletions components/common/site_name_and_description.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ import {FormattedMessage} from 'react-intl';
export default class SiteNameAndDescription extends React.PureComponent {
static propTypes = {
customDescriptionText: PropTypes.string,
isLicensed: PropTypes.bool,
siteName: PropTypes.string,
};

static defaultProps = {
isLicensed: false,
siteName: 'Mattermost',
};

render() {
const {
customDescriptionText,
isLicensed,
siteName,
} = this.props;
let description = null;
if (isLicensed && customDescriptionText) {
if (customDescriptionText) {
description = customDescriptionText;
} else {
description = (
Expand Down
7 changes: 0 additions & 7 deletions components/create_team/create_team.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default class CreateTeam extends React.PureComponent {
*/
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
*/
Expand Down Expand Up @@ -66,7 +61,6 @@ export default class CreateTeam extends React.PureComponent {
currentChannel,
currentTeam,
customDescriptionText,
isLicensed,
match,
siteName,
} = this.props;
Expand All @@ -87,7 +81,6 @@ export default class CreateTeam extends React.PureComponent {
<div className='signup-team__container'>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
<div className='signup__content'>
Expand Down
5 changes: 1 addition & 4 deletions components/create_team/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@

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 {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';

import CreateTeam from './create_team';

function mapStateToProps(state) {
const config = getConfig(state);
const license = getLicense(state);
const currentChannel = getCurrentChannel(state);
const currentTeam = getCurrentTeam(state);

const isLicensed = license.IsLicensed === 'true';
const customDescriptionText = config.CustomDescriptionText;
const siteName = config.SiteName;

return {
currentChannel,
currentTeam,
isLicensed,
customDescriptionText,
siteName,
};
Expand Down
2 changes: 0 additions & 2 deletions components/login/login_controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function mapStateToProps(state) {
const config = getConfig(state);
const license = getLicense(state);

const customBrand = license.CustomBrand === 'true';
const isLicensed = license.IsLicensed === 'true';

const customBrandText = config.CustomBrandText;
Expand All @@ -31,7 +30,6 @@ function mapStateToProps(state) {
const siteName = config.SiteName;

return {
customBrand,
isLicensed,
customBrandText,
customDescriptionText,
Expand Down
8 changes: 1 addition & 7 deletions components/login/login_controller/login_controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export default class LoginController extends React.Component {
static get propTypes() {
return {
location: PropTypes.object.isRequired,

customBrand: PropTypes.bool.isRequired,
isLicensed: PropTypes.bool.isRequired,

customBrandText: PropTypes.string,
Expand Down Expand Up @@ -266,9 +264,7 @@ export default class LoginController extends React.Component {
}

createCustomLogin() {
if (this.props.isLicensed &&
this.props.customBrand &&
this.props.enableCustomBrand) {
if (this.props.enableCustomBrand) {
const text = this.props.customBrandText || '';
const formattedText = TextFormatting.formatText(text);

Expand Down Expand Up @@ -628,7 +624,6 @@ export default class LoginController extends React.Component {
render() {
const {
customDescriptionText,
isLicensed,
siteName,
} = this.props;

Expand Down Expand Up @@ -666,7 +661,6 @@ export default class LoginController extends React.Component {
<div className='signup__content'>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
{content}
Expand Down
4 changes: 1 addition & 3 deletions components/select_team/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ import {withRouter} from 'react-router-dom';

import {getTeams} from 'mattermost-redux/actions/teams';
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 {getSortedJoinableTeams, getTeamMemberships} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';

import SelectTeam from './select_team.jsx';

function mapStateToProps(state) {
const license = getLicense(state);
const config = getConfig(state);
const currentUser = getCurrentUser(state);
const myTeamMemberships = Object.values(getTeamMemberships(state));

return {
isLicensed: license.IsLicensed === 'true',
currentUserRoles: currentUser.roles || '',
customDescriptionText: config.CustomDescriptionText,
roles: getRoles(state),
Expand Down
3 changes: 0 additions & 3 deletions components/select_team/select_team.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const TEAMS_PER_PAGE = 200;

export default class SelectTeam extends React.Component {
static propTypes = {
isLicensed: PropTypes.bool.isRequired,
currentUserRoles: PropTypes.string,
customDescriptionText: PropTypes.string,
isMemberOfTeam: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -122,7 +121,6 @@ export default class SelectTeam extends React.Component {
const {
currentUserRoles,
customDescriptionText,
isLicensed,
isMemberOfTeam,
joinableTeams,
siteName,
Expand Down Expand Up @@ -283,7 +281,6 @@ export default class SelectTeam extends React.Component {
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
{openContent}
Expand Down
9 changes: 1 addition & 8 deletions components/signup/signup_email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@
// See LICENSE.txt for license information.

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 SignupEmail from './signup_email.jsx';

function mapStateToProps(state) {
const license = getLicense(state);
const config = getConfig(state);

const isLicensed = license && license.IsLicensed === 'true';
const enableSignUpWithEmail = config.EnableSignUpWithEmail === 'true';
const siteName = config.SiteName;
const termsOfServiceLink = config.TermsOfServiceLink;
const privacyPolicyLink = config.PrivacyPolicyLink;
const customBrand = license.CustomBrand === 'true';
const enableCustomBrand = config.EnableCustomBrand === 'true';
const customDescriptionText = config.CustomDescriptionText;

return {
isLicensed,
enableSignUpWithEmail,
siteName,
termsOfServiceLink,
privacyPolicyLink,
customBrand,
enableCustomBrand,
customDescriptionText,
passwordConfig: getPasswordConfig(config),
};
Expand Down
5 changes: 0 additions & 5 deletions components/signup/signup_email/signup_email.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ export default class SignupEmail extends React.Component {
static get propTypes() {
return {
location: PropTypes.object,
isLicensed: PropTypes.bool.isRequired,
enableSignUpWithEmail: PropTypes.bool.isRequired,
siteName: PropTypes.string,
termsOfServiceLink: PropTypes.string,
privacyPolicyLink: PropTypes.string,
customBrand: PropTypes.bool.isRequired,
enableCustomBrand: PropTypes.bool.isRequired,
customDescriptionText: PropTypes.string,
passwordConfig: PropTypes.object,
};
Expand Down Expand Up @@ -426,7 +423,6 @@ export default class SignupEmail extends React.Component {
const {
customDescriptionText,
enableSignUpWithEmail,
isLicensed,
location,
privacyPolicyLink,
siteName,
Expand Down Expand Up @@ -485,7 +481,6 @@ export default class SignupEmail extends React.Component {
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
<h4 className='color--light'>
Expand Down
Loading

0 comments on commit 144d980

Please sign in to comment.