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 удалений

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

@@ -6,6 +6,7 @@ import {FormattedMessage} from 'react-intl';
import ErrorStore from 'stores/error_store.jsx';
import {ErrorBarTypes} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
@@ -67,10 +68,8 @@ export default class ConfigurationSettings extends AdminSettings {
}
handleSaved(newConfig) {
const lastError = ErrorStore.getLastError();
if (lastError && lastError.message === 'error_bar.site_url' && newConfig.ServiceSettings.SiteURL) {
ErrorStore.clearLastError(true);
if (newConfig.ServiceSettings.SiteURL) {
ErrorStore.clearError(ErrorBarTypes.SITE_URL);
}
}

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

@@ -3,6 +3,9 @@
import React from 'react';
import ErrorStore from 'stores/error_store.jsx';
import {ErrorBarTypes} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
@@ -19,6 +22,8 @@ export default class EmailSettings extends AdminSettings {
this.getConfigFromState = this.getConfigFromState.bind(this);
this.handleSaved = this.handleSaved.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
@@ -39,6 +44,12 @@ export default class EmailSettings extends AdminSettings {
return config;
}
handleSaved(newConfig) {
if (newConfig.EmailSettings.SendEmailNotifications) {
ErrorStore.clearError(ErrorBarTypes.PREVIEW_MODE);
}
}
getStateFromConfig(config) {
return {
sendEmailNotifications: config.EmailSettings.SendEmailNotifications,

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

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

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

@@ -62,6 +62,14 @@ class ErrorStoreClass extends EventEmitter {
BrowserStore.setGlobalItem('last_error_conn', count);
}
clearError(message) {
const lastError = this.getLastError();
if (lastError && lastError.message === message) {
this.clearLastError(true);
}
}
clearLastError(force) {
var lastError = this.getLastError();

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

@@ -287,6 +287,14 @@ export const ErrorPageTypes = {
LOCAL_STORAGE: 'local_storage'
};
export const ErrorBarTypes = {
LICENSE_EXPIRING: 'error_bar.license_expiring',
LICENSE_EXPIRED: 'error_bar.license_expired',
LICENSE_PAST_GRACE: 'error_bar.past_grace',
PREVIEW_MODE: 'error_bar.preview_mode',
SITE_URL: 'error_bar.site_url'
};
export const Constants = {
Preferences,
SocketEvents,
@@ -297,6 +305,7 @@ export const Constants = {
TutorialSteps,
PostTypes,
ErrorPageTypes,
ErrorBarTypes,
IGNORE_POST_TYPES: [PostTypes.JOIN_LEAVE, PostTypes.JOIN_CHANNEL, PostTypes.LEAVE_CHANNEL, PostTypes.REMOVE_FROM_CHANNEL, PostTypes.ADD_TO_CHANNEL, PostTypes.ADD_REMOVE],