PLT-6283 Hide Preview Mode error bar after enabling email notifications (#6180)

Этот коммит содержится в:
Harrison Healey
2017-04-25 12:39:08 -04:00
коммит произвёл Corey Hulen
родитель 8d1a132eda
Коммит 7fc663ca75
5 изменённых файлов: 63 добавлений и 34 удалений

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

@@ -1,25 +1,20 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import AnalyticsStore from 'stores/analytics_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {isLicenseExpiring, isLicenseExpired, isLicensePastGracePeriod, displayExpiryDate} from 'utils/license_utils.jsx';
import Constants from 'utils/constants.jsx';
const StatTypes = Constants.StatTypes;
import React from 'react';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {Link} from 'react-router';
const EXPIRING_ERROR = 'error_bar.expiring';
const EXPIRED_ERROR = 'error_bar.expired';
const PAST_GRACE_ERROR = 'error_bar.past_grace';
import AnalyticsStore from 'stores/analytics_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import {ErrorBarTypes, StatTypes} from 'utils/constants.jsx';
import {isLicenseExpiring, isLicenseExpired, isLicensePastGracePeriod, displayExpiryDate} from 'utils/license_utils.jsx';
import * as Utils from 'utils/utils.jsx';
const RENEWAL_LINK = 'https://licensing.mattermost.com/renew';
const SITE_URL_ERROR = 'error_bar.site_url';
const BAR_DEVELOPER_TYPE = 'developer';
const BAR_CRITICAL_TYPE = 'critical';
@@ -36,7 +31,7 @@ export default class ErrorBar extends React.Component {
this.setInitialError();
this.state = ErrorStore.getLastError();
this.state = ErrorStore.getLastError() || {};
}
setInitialError() {
@@ -50,24 +45,24 @@ export default class ErrorBar extends React.Component {
if (!errorIgnored) {
if (isSystemAdmin && global.mm_config.SiteURL === '') {
ErrorStore.storeLastError({notification: true, message: SITE_URL_ERROR});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.SITE_URL});
return;
} else if (global.mm_config.SendEmailNotifications === 'false') {
ErrorStore.storeLastError({notification: true, message: Utils.localizeMessage('error_bar.preview_mode', 'Preview Mode: Email notifications have not been configured')});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.PREVIEW_MODE});
return;
}
}
if (isLicensePastGracePeriod()) {
if (isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: BAR_CRITICAL_TYPE});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRED, type: BAR_CRITICAL_TYPE});
} else {
ErrorStore.storeLastError({notification: true, message: PAST_GRACE_ERROR, type: BAR_CRITICAL_TYPE});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_PAST_GRACE, type: BAR_CRITICAL_TYPE});
}
} else if (isLicenseExpired() && isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: BAR_CRITICAL_TYPE});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRED, type: BAR_CRITICAL_TYPE});
} else if (isLicenseExpiring() && isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRING_ERROR});
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRING});
}
}
@@ -80,7 +75,7 @@ export default class ErrorBar extends React.Component {
return false;
}
if (s.message === EXPIRING_ERROR && !this.state.totalUsers) {
if (s.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) {
return false;
}
@@ -101,7 +96,7 @@ export default class ErrorBar extends React.Component {
var newState = ErrorStore.getLastError();
if (newState) {
if (newState.message === EXPIRING_ERROR && !this.state.totalUsers) {
if (newState.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) {
AsyncClient.getStandardAnalytics();
}
this.setState(newState);
@@ -145,10 +140,17 @@ export default class ErrorBar extends React.Component {
const renewalLink = RENEWAL_LINK + '?id=' + global.window.mm_license.Id + '&user_count=' + this.state.totalUsers;
let message = this.state.message;
if (message === EXPIRING_ERROR) {
if (message === ErrorBarTypes.PREVIEW_MODE) {
message = (
<FormattedMessage
id={ErrorBarTypes.PREVIEW_MODE}
defaultMessage='Preview Mode: Email notifications have not been configured'
/>
);
} else if (message === ErrorBarTypes.LICENSE_EXPIRING) {
message = (
<FormattedHTMLMessage
id={EXPIRING_ERROR}
id={ErrorBarTypes.LICENSE_EXPIRING}
defaultMessage='Enterprise license expires on {date}. <a href="{link}" target="_blank">Please renew.</a>'
values={{
date: displayExpiryDate(),
@@ -156,24 +158,24 @@ export default class ErrorBar extends React.Component {
}}
/>
);
} else if (message === EXPIRED_ERROR) {
} else if (message === ErrorBarTypes.LICENSE_EXPIRED) {
message = (
<FormattedHTMLMessage
id={EXPIRED_ERROR}
id={ErrorBarTypes.LICENSE_EXPIRED}
defaultMessage='Enterprise license is expired and some features may be disabled. <a href="{link}" target="_blank">Please renew.</a>'
values={{
link: renewalLink
}}
/>
);
} else if (message === PAST_GRACE_ERROR) {
} else if (message === ErrorBarTypes.LICENSE_PAST_GRACE) {
message = (
<FormattedMessage
id={PAST_GRACE_ERROR}
id={ErrorBarTypes.LICENSE_PAST_GRACE}
defaultMessage='Enterprise license is expired and some features may be disabled. Please contact your System Administrator for details.'
/>
);
} else if (message === SITE_URL_ERROR) {
} else if (message === ErrorBarTypes.SITE_URL) {
let id;
let defaultMessage;
if (global.mm_config.EnableSignUpWithGitLab === 'true') {