diff options
Diffstat (limited to 'webapp/components')
-rw-r--r-- | webapp/components/admin_console/banner.jsx | 40 | ||||
-rw-r--r-- | webapp/components/admin_console/ldap_settings.jsx | 37 | ||||
-rw-r--r-- | webapp/components/analytics/system_analytics.jsx | 36 | ||||
-rw-r--r-- | webapp/components/error_bar.jsx | 64 |
4 files changed, 144 insertions, 33 deletions
diff --git a/webapp/components/admin_console/banner.jsx b/webapp/components/admin_console/banner.jsx new file mode 100644 index 000000000..2071fff93 --- /dev/null +++ b/webapp/components/admin_console/banner.jsx @@ -0,0 +1,40 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; +import {FormattedMessage} from 'react-intl'; + +export default class Banner extends React.Component { + render() { + let title = ( + <FormattedMessage + id='admin.banner.heading' + defaultMessage='Note:' + /> + ); + + if (this.props.title) { + title = this.props.title; + } + + return ( + <div className='banner'> + <div className='banner__content'> + <h4 className='banner__heading'> + {title} + </h4> + <p> + {this.props.description} + </p> + </div> + </div> + ); + } +} + +Banner.defaultProps = { +}; +Banner.propTypes = { + title: React.PropTypes.node, + description: React.PropTypes.node.isRequired +}; diff --git a/webapp/components/admin_console/ldap_settings.jsx b/webapp/components/admin_console/ldap_settings.jsx index d47a1f8c2..80c1a7867 100644 --- a/webapp/components/admin_console/ldap_settings.jsx +++ b/webapp/components/admin_console/ldap_settings.jsx @@ -1,17 +1,18 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import React from 'react'; - -import * as Utils from 'utils/utils.jsx'; - import AdminSettings from './admin_settings.jsx'; +import Banner from './banner.jsx'; import BooleanSetting from './boolean_setting.jsx'; import ConnectionSecurityDropdownSetting from './connection_security_dropdown_setting.jsx'; -import {FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; +import * as Utils from 'utils/utils.jsx'; + +import React from 'react'; +import {FormattedMessage} from 'react-intl'; + export default class LdapSettings extends AdminSettings { constructor(props) { super(props); @@ -90,22 +91,14 @@ export default class LdapSettings extends AdminSettings { } > - <div className='banner'> - <div className='banner__content'> - <h4 className='banner__heading'> - <FormattedMessage - id='admin.ldap.bannerHeading' - defaultMessage='Note:' - /> - </h4> - <p> - <FormattedMessage - id='admin.ldap.bannerDesc' - defaultMessage='If a user attribute changes on the LDAP server it will be updated the next time the user enters their credentials to log in to Mattermost. This includes if a user is made inactive or removed from an LDAP server. Synchronization with LDAP servers is planned in a future release.' - /> - </p> - </div> - </div> + <Banner + description={ + <FormattedMessage + id='admin.ldap.bannerDesc' + defaultMessage='If a user attribute changes on the LDAP server it will be updated the next time the user enters their credentials to log in to Mattermost. This includes if a user is made inactive or removed from an LDAP server. Synchronization with LDAP servers is planned in a future release.' + /> + } + /> <BooleanSetting id='enable' label={ @@ -412,4 +405,4 @@ export default class LdapSettings extends AdminSettings { </SettingsGroup> ); } -}
\ No newline at end of file +} diff --git a/webapp/components/analytics/system_analytics.jsx b/webapp/components/analytics/system_analytics.jsx index 8decf523d..5bd8b1d28 100644 --- a/webapp/components/analytics/system_analytics.jsx +++ b/webapp/components/analytics/system_analytics.jsx @@ -1,6 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import Banner from 'components/admin_console/banner.jsx'; import LineChart from './line_chart.jsx'; import DoughnutChart from './doughnut_chart.jsx'; import StatisticCount from './statistic_count.jsx'; @@ -8,11 +9,12 @@ import StatisticCount from './statistic_count.jsx'; import AnalyticsStore from 'stores/analytics_store.jsx'; import * as Utils from 'utils/utils.jsx'; +import {isLicenseExpired, isLicenseExpiring, displayExpiryDate} from 'utils/license_utils.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import Constants from 'utils/constants.jsx'; const StatTypes = Constants.StatTypes; -import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'react-intl'; +import {injectIntl, intlShape, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl'; const holders = defineMessages({ analyticsPublicChannels: { @@ -81,6 +83,7 @@ class SystemAnalytics extends React.Component { let advancedCounts; let advancedGraphs; + let banner; if (global.window.mm_license.IsLicensed === 'true') { advancedCounts = ( <div className='row'> @@ -156,6 +159,36 @@ class SystemAnalytics extends React.Component { /> </div> ); + + if (isLicenseExpired()) { + banner = ( + <Banner + description={ + <FormattedHTMLMessage + id='analytics.system.expiredBanner' + defaultMessage='The Enterprise license expired on {date}. You have 15 days from this date to renew the license, please contact <a href="mailto:commercial@mattermost.com">commercial@mattermost.com</a>.' + values={{ + date: displayExpiryDate() + }} + /> + } + /> + ); + } else if (isLicenseExpiring()) { + banner = ( + <Banner + description={ + <FormattedHTMLMessage + id='analytics.system.expiringBanner' + defaultMessage='The Enterprise license is expiring on {date}. To renew your license, please contact <a href="mailto:commercial@mattermost.com">commercial@mattermost.com</a>.' + values={{ + date: displayExpiryDate() + }} + /> + } + /> + ); + } } const postCountsDay = formatPostsPerDayData(stats[StatTypes.POST_PER_DAY]); @@ -169,6 +202,7 @@ class SystemAnalytics extends React.Component { defaultMessage='System Statistics' /> </h3> + {banner} <div className='row'> <StatisticCount title={ diff --git a/webapp/components/error_bar.jsx b/webapp/components/error_bar.jsx index c13d0dd6a..affaf6f5d 100644 --- a/webapp/components/error_bar.jsx +++ b/webapp/components/error_bar.jsx @@ -2,9 +2,17 @@ // See License.txt for license information. import ErrorStore from 'stores/error_store.jsx'; +import UserStore from 'stores/user_store.jsx'; + import * as Utils from 'utils/utils.jsx'; +import {isLicenseExpiring, isLicenseExpired, isLicensePastGracePeriod, displayExpiryDate} from 'utils/license_utils.jsx'; import React from 'react'; +import {FormattedMessage} from 'react-intl'; + +const EXPIRING_ERROR = 'error_bar.expiring'; +const EXPIRED_ERROR = 'error_bar.expired'; +const PAST_GRACE_ERROR = 'error_bar.past_grace'; export default class ErrorBar extends React.Component { constructor() { @@ -13,6 +21,22 @@ export default class ErrorBar extends React.Component { this.onErrorChange = this.onErrorChange.bind(this); this.handleClose = this.handleClose.bind(this); + let isSystemAdmin = false; + const user = UserStore.getCurrentUser(); + if (user) { + isSystemAdmin = Utils.isSystemAdmin(user.roles); + } + + if (!ErrorStore.getIgnoreNotification() && global.window.mm_config.SendEmailNotifications === 'false') { + ErrorStore.storeLastError({notification: true, message: Utils.localizeMessage('error_bar.preview_mode', 'Preview Mode: Email notifications have not been configured')}); + } else if (isLicenseExpiring() && isSystemAdmin) { + ErrorStore.storeLastError({notification: true, message: EXPIRING_ERROR}); + } else if (isLicenseExpired() && isSystemAdmin) { + ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: 'developer'}); + } else if (isLicensePastGracePeriod()) { + ErrorStore.storeLastError({notification: true, message: PAST_GRACE_ERROR}); + } + this.state = ErrorStore.getLastError(); } @@ -28,13 +52,6 @@ export default class ErrorBar extends React.Component { return true; } - componentWillMount() { - if (!ErrorStore.getIgnoreEmailPreview() && global.window.mm_config.SendEmailNotifications === 'false') { - ErrorStore.storeLastError({email_preview: true, message: Utils.localizeMessage('error_bar.preview_mode', 'Preview Mode: Email notifications have not been configured')}); - this.onErrorChange(); - } - } - componentDidMount() { ErrorStore.addChangeListener(this.onErrorChange); } @@ -58,8 +75,8 @@ export default class ErrorBar extends React.Component { e.preventDefault(); } - if (ErrorStore.getLastError() && ErrorStore.getLastError().email_preview) { - ErrorStore.clearPreviewError(); + if (ErrorStore.getLastError() && ErrorStore.getLastError().notification) { + ErrorStore.clearNotificationError(); } else { ErrorStore.clearLastError(); } @@ -78,9 +95,36 @@ export default class ErrorBar extends React.Component { errClass = 'error-bar-developer'; } + let message = this.state.message; + if (message === EXPIRING_ERROR) { + message = ( + <FormattedMessage + id={EXPIRING_ERROR} + defaultMessage='The Enterprise license is expiring on {date}. To renew your license, please contact commercial@mattermost.com' + values={{ + date: displayExpiryDate() + }} + /> + ); + } else if (message === EXPIRED_ERROR) { + message = ( + <FormattedMessage + id={EXPIRED_ERROR} + defaultMessage='Enterprise license has expired; you have 15 days from expiry to renew the license, please contact commercial@mattermost.com for details' + /> + ); + } else if (message === PAST_GRACE_ERROR) { + message = ( + <FormattedMessage + id={PAST_GRACE_ERROR} + defaultMessage='Enterprise license has expired, please contact your System Administrator for details' + /> + ); + } + return ( <div className={errClass}> - <span>{this.state.message}</span> + <span>{message}</span> <a href='#' className='error-bar__close' |