Этот коммит содержится в:
Joram Wilander
2016-05-30 09:59:53 -04:00
коммит произвёл Harrison Healey
родитель e4cb9141a4
Коммит 0dfac9875e
10 изменённых файлов: 210 добавлений и 46 удалений

Просмотреть файл

@@ -8,7 +8,7 @@ const ActionTypes = Constants.ActionTypes;
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'utils/web_client.jsx';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {browserHistory} from 'react-router';

40
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
};

Просмотреть файл

@@ -1,16 +1,17 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
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 SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
import BooleanSetting from './boolean_setting.jsx';
import ConnectionSecurityDropdownSetting from './connection_security_dropdown_setting.jsx';
import React from 'react';
import {FormattedMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
export default class LdapSettings extends AdminSettings {
constructor(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>
);
}
}
}

Просмотреть файл

@@ -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={

Просмотреть файл

@@ -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'

Просмотреть файл

@@ -81,6 +81,7 @@
"add_outgoing_webhook.triggerWordsOrChannelRequired": "A valid channel or a list of trigger words is required",
"admin.audits.reload": "Reload User Activity Logs",
"admin.audits.title": "User Activity Logs",
"admin.banner.heading": "Note:",
"admin.compliance.directoryDescription": "Directory to which compliance reports are written. If blank, will be set to ./data/.",
"admin.compliance.directoryExample": "Ex \"./data/\"",
"admin.compliance.directoryTitle": "Compliance Directory Location:",
@@ -240,7 +241,6 @@
"admin.image.thumbWidthExample": "Ex \"120\"",
"admin.image.thumbWidthTitle": "Thumbnail Width:",
"admin.ldap.bannerDesc": "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.",
"admin.ldap.bannerHeading": "Note:",
"admin.ldap.baseDesc": "The Base DN is the Distinguished Name of the location where Mattermost should start its search for users in the LDAP tree.",
"admin.ldap.baseEx": "Ex \"ou=Unit Name,dc=corp,dc=example,dc=com\"",
"admin.ldap.baseTitle": "BaseDN:",
@@ -545,6 +545,8 @@
"admin.user_item.teamAdmin": "Team Admin",
"analytics.chart.loading": "Loading...",
"analytics.chart.meaningful": "Not enough data for a meaningful representation.",
"analytics.system.expiredBanner": "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>.",
"analytics.system.expiringBanner": "The Enterprise license is expiring on {date}. To renew your license, please contact <a href='mailto:commercial@mattermost.com'>commercial@mattermost.com</a>.",
"analytics.system.activeUsers": "Active Users With Posts",
"analytics.system.channelTypes": "Channel Types",
"analytics.system.postTypes": "Posts, Files and Hashtags",
@@ -828,6 +830,9 @@
"email_verify.verified": "{siteName} Email Verified",
"email_verify.verifiedBody": "<p>Your email has been verified! Click <a href={url}>here</a> to log in.</p>",
"email_verify.verifyFailed": "Failed to verify your email.",
"error_bar.expiring": "The Enterprise license is expiring on {date}. To renew your license, please contact commercial@mattermost.com",
"error_bar.expired": "Enterprise license has expired; you have 15 days from expiry to renew the license, please contact commercial@mattermost.com for details",
"error_bar.past_grace": "Enterprise license has expired, please contact your System Administrator for details",
"error_bar.preview_mode": "Preview Mode: Email notifications have not been configured",
"file_attachment.download": "Download",
"file_info_preview.size": "Size ",

Просмотреть файл

@@ -145,6 +145,7 @@
.banner__heading {
font-size: 1.5em;
margin-bottom: 0.5em;
}
.banner__content {
@@ -374,4 +375,4 @@
.recycle-db {
margin-top: 50px !important;
}
}

Просмотреть файл

@@ -20,12 +20,12 @@ class ErrorStoreClass extends EventEmitter {
this.removeChangeListener = this.removeChangeListener.bind(this);
this.getLastError = this.getLastError.bind(this);
this.storeLastError = this.storeLastError.bind(this);
this.getIgnoreEmailPreview = this.getIgnoreEmailPreview.bind(this);
this.ignore_email_preview = false;
this.getIgnoreNotification = this.getIgnoreNotification.bind(this);
this.ignore_notification = false;
}
getIgnoreEmailPreview() {
return this.ignore_email_preview;
getIgnoreNotification() {
return this.ignore_notification;
}
emitChange() {
@@ -65,8 +65,8 @@ class ErrorStoreClass extends EventEmitter {
clearLastError() {
var lastError = this.getLastError();
// preview message can only be cleared by clearPreviewError
if (lastError && lastError.email_preview) {
// preview message can only be cleared by clearNotificationError
if (lastError && lastError.notification) {
return;
}
@@ -77,8 +77,8 @@ class ErrorStoreClass extends EventEmitter {
}
}
clearPreviewError() {
this.ignore_email_preview = true;
clearNotificationError() {
this.ignore_notification = true;
this.storeLastError('');
this.clearLastError();
}

Просмотреть файл

@@ -750,5 +750,7 @@ export default {
MHPNS: 'https://push.mattermost.com',
MTPNS: 'http://push-test.mattermost.com',
BOT_NAME: 'BOT',
POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5 // five minutes
POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5, // five minutes
LICENSE_EXPIRY_NOTIFICATION: 1000 * 60 * 60 * 24 * 15, // 15 days
LICENSE_GRACE_PERIOD: 1000 * 60 * 60 * 24 * 15 // 15 days
};

45
webapp/utils/license_utils.jsx Обычный файл
Просмотреть файл

@@ -0,0 +1,45 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import Constants from 'utils/constants.jsx';
import React from 'react';
import {FormattedDate} from 'react-intl';
export function isLicenseExpiring() {
if (window.mm_license.IsLicensed !== 'true') {
return false;
}
const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
return timeDiff <= Constants.LICENSE_EXPIRY_NOTIFICATION;
}
export function isLicenseExpired() {
if (window.mm_license.IsLicensed !== 'true') {
return false;
}
const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
return timeDiff < 0;
}
export function isLicensePastGracePeriod() {
if (window.mm_license.IsLicensed !== 'true') {
return false;
}
const timeDiff = Date.now() - parseInt(global.window.mm_license.ExpiresAt, 10);
return timeDiff > Constants.LICENSE_GRACE_PERIOD;
}
export function displayExpiryDate() {
return (
<FormattedDate
value={new Date(parseInt(global.window.mm_license.ExpiresAt, 10))}
day='2-digit'
month='long'
year='numeric'
/>
);
}