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 {
);
}
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 = (
......@@ -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'
......
......@@ -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;
}
......@@ -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'
......@@ -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'
......@@ -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'
......@@ -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>
);
}
......
......@@ -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 = (
......
......@@ -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
*/
......@@ -66,7 +61,6 @@ export default class CreateTeam extends React.PureComponent {
currentChannel,
currentTeam,
customDescriptionText,
isLicensed,
match,
siteName,
} = this.props;
......@@ -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'>
......
......@@ -3,7 +3,7 @@
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';
......@@ -11,18 +11,15 @@ 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,
};
......
......@@ -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;
......@@ -31,7 +30,6 @@ function mapStateToProps(state) {
const siteName = config.SiteName;
return {
customBrand,
isLicensed,
customBrandText,
customDescriptionText,
......
......@@ -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,
......@@ -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);
......@@ -628,7 +624,6 @@ export default class LoginController extends React.Component {
render() {
const {
customDescriptionText,
isLicensed,
siteName,
} = this.props;
......@@ -666,7 +661,6 @@ export default class LoginController extends React.Component {
<div className='signup__content'>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
{content}
......
......@@ -7,7 +7,7 @@ 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';
......@@ -15,13 +15,11 @@ 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),
......
......@@ -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,
......@@ -122,7 +121,6 @@ export default class SelectTeam extends React.Component {
const {
currentUserRoles,
customDescriptionText,
isLicensed,
isMemberOfTeam,
joinableTeams,
siteName,
......@@ -283,7 +281,6 @@ export default class SelectTeam extends React.Component {
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
{openContent}
......
......@@ -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),
};
......
......@@ -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,
};
......@@ -426,7 +423,6 @@ export default class SignupEmail extends React.Component {
const {
customDescriptionText,
enableSignUpWithEmail,
isLicensed,
location,
privacyPolicyLink,
siteName,
......@@ -485,7 +481,6 @@ export default class SignupEmail extends React.Component {
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
<h4 className='color--light'>
......
......@@ -124,7 +124,6 @@ export default class SignupLdap extends React.Component {
render() {
const {
customDescriptionText,
isLicensed,
siteName,
} = this.props;
......@@ -230,7 +229,6 @@ export default class SignupLdap extends React.Component {
/>
<SiteNameAndDescription
customDescriptionText={customDescriptionText}
isLicensed={isLicensed}
siteName={siteName}
/>
<h4 className='color--light'>
......
......@@ -18,23 +18,6 @@ exports[`/components/common/SiteNameAndDescription should match snapshot, defaul
`;
exports[`/components/common/SiteNameAndDescription should match snapshot, with custom site name and description 1`] = `
<React.Fragment>
<h1>
other_site
</h1>
<h4
className="color--light"
>
<FormattedMessage
defaultMessage="All team communication in one place, searchable and accessible anywhere"
id="web.root.signup_info"
values={Object {}}
/>
</h4>
</React.Fragment>
`;
exports[`/components/common/SiteNameAndDescription should match snapshot, with custom site name and description 2`] = `
<React.Fragment>
<h1>
other_site
......
......@@ -10,7 +10,6 @@ import SiteNameAndDescription from 'components/common/site_name_and_description.
describe('/components/common/SiteNameAndDescription', () => {
const baseProps = {
customDescriptionText: '',
isLicensed: false,
siteName: 'Mattermost',
};
......@@ -25,11 +24,6 @@ describe('/components/common/SiteNameAndDescription', () => {
const props = {...baseProps, customDescriptionText: 'custom_description_text', siteName: 'other_site'};
const wrapper = shallow(<SiteNameAndDescription {...props}/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('h1').text()).toEqual(props.siteName);
expect(wrapper.find('h4').text()).not.toEqual(props.customDescriptionText);
wrapper.setProps({isLicensed: true});
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('h1').text()).toEqual(props.siteName);
expect(wrapper.find('h4').text()).toEqual(props.customDescriptionText);
......
......@@ -14,7 +14,6 @@ exports[`/components/create_team should match snapshot 1`] = `
>
<SiteNameAndDescription
customDescriptionText="Welcome to our custom branded site!"
isLicensed={true}
siteName="Mattermost"
/>
<div
......
......@@ -16,7 +16,6 @@ describe('/components/create_team', () => {
currentChannel: {name: 'test-channel'},
currentTeam: {name: 'test-team'},
siteName: 'Mattermost',
isLicensed: true,
customBrand: true,
enableCustomBrand: true,
customDescriptionText: 'Welcome to our custom branded site!',
......
......@@ -17,7 +17,6 @@ exports[`components/select_team/SelectTeam should match snapshot 1`] = `
src={null}
/>
<SiteNameAndDescription
isLicensed={true}
siteName="Mattermost"
/>
<div
......@@ -137,7 +136,6 @@ exports[`components/select_team/SelectTeam should match snapshot, on error 1`] =
src={null}
/>
<SiteNameAndDescription
isLicensed={true}
siteName="Mattermost"
/>
<div
......@@ -228,7 +226,6 @@ exports[`components/select_team/SelectTeam should match snapshot, on loading 1`]
src={null}
/>
<SiteNameAndDescription
isLicensed={true}
siteName="Mattermost"
/>
<LoadingScreen
......@@ -310,7 +307,6 @@ exports[`components/select_team/SelectTeam should match snapshot, on no joinable
src={null}
/>
<SiteNameAndDescription
isLicensed={true}
siteName="Mattermost"
/>
<div
......@@ -429,7 +425,6 @@ exports[`components/select_team/SelectTeam should match snapshot, on no joinable
src={null}
/>
<SiteNameAndDescription
isLicensed={true}
siteName="Mattermost"
/>
<div
......
......@@ -25,7 +25,6 @@ jest.mock('utils/policy_roles_adapter', () => ({
describe('components/select_team/SelectTeam', () => {
const baseProps = {
isLicensed: true,
currentUserRoles: 'system_admin',
enableTeamCreation: true,
isMemberOfTeam: true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment