summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-04-25 12:39:08 -0400
committerCorey Hulen <corey@hulen.com>2017-04-25 09:39:08 -0700
commit7fc663ca75e966847243a845cff31c07737c4492 (patch)
treef70c33a2bebae66c7eb0f608d509cf0cf4857177 /webapp
parent8d1a132eda861f3e491a406233b726ff953cdffd (diff)
downloadchat-7fc663ca75e966847243a845cff31c07737c4492.tar.gz
chat-7fc663ca75e966847243a845cff31c07737c4492.tar.bz2
chat-7fc663ca75e966847243a845cff31c07737c4492.zip
PLT-6283 Hide Preview Mode error bar after enabling email notifications (#6180)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/admin_console/configuration_settings.jsx7
-rw-r--r--webapp/components/admin_console/email_settings.jsx11
-rw-r--r--webapp/components/error_bar.jsx56
-rw-r--r--webapp/stores/error_store.jsx8
-rw-r--r--webapp/utils/constants.jsx9
5 files changed, 60 insertions, 31 deletions
diff --git a/webapp/components/admin_console/configuration_settings.jsx b/webapp/components/admin_console/configuration_settings.jsx
index 47d3a665e..29901ad90 100644
--- a/webapp/components/admin_console/configuration_settings.jsx
+++ b/webapp/components/admin_console/configuration_settings.jsx
@@ -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);
}
}
diff --git a/webapp/components/admin_console/email_settings.jsx b/webapp/components/admin_console/email_settings.jsx
index 959bbec7f..ddfe3c38f 100644
--- a/webapp/components/admin_console/email_settings.jsx
+++ b/webapp/components/admin_console/email_settings.jsx
@@ -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,
diff --git a/webapp/components/error_bar.jsx b/webapp/components/error_bar.jsx
index d0ecd604e..94555ce04 100644
--- a/webapp/components/error_bar.jsx
+++ b/webapp/components/error_bar.jsx
@@ -1,25 +1,20 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
+import React from 'react';
+import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
+import {Link} from 'react-router';
+
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 {ErrorBarTypes, StatTypes} from 'utils/constants.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';
+import * as Utils from 'utils/utils.jsx';
-const EXPIRING_ERROR = 'error_bar.expiring';
-const EXPIRED_ERROR = 'error_bar.expired';
-const PAST_GRACE_ERROR = 'error_bar.past_grace';
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') {
diff --git a/webapp/stores/error_store.jsx b/webapp/stores/error_store.jsx
index b72c45ed4..38f5eb249 100644
--- a/webapp/stores/error_store.jsx
+++ b/webapp/stores/error_store.jsx
@@ -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();
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 1960fb050..2b6c5d6be 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -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],