PLT-6283 Hide Preview Mode error bar after enabling email notifications (#6180)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
8d1a132eda
Коммит
7fc663ca75
@@ -6,6 +6,7 @@ import {FormattedMessage} from 'react-intl';
|
|||||||
|
|
||||||
import ErrorStore from 'stores/error_store.jsx';
|
import ErrorStore from 'stores/error_store.jsx';
|
||||||
|
|
||||||
|
import {ErrorBarTypes} from 'utils/constants.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
import AdminSettings from './admin_settings.jsx';
|
import AdminSettings from './admin_settings.jsx';
|
||||||
@@ -67,10 +68,8 @@ export default class ConfigurationSettings extends AdminSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSaved(newConfig) {
|
handleSaved(newConfig) {
|
||||||
const lastError = ErrorStore.getLastError();
|
if (newConfig.ServiceSettings.SiteURL) {
|
||||||
|
ErrorStore.clearError(ErrorBarTypes.SITE_URL);
|
||||||
if (lastError && lastError.message === 'error_bar.site_url' && newConfig.ServiceSettings.SiteURL) {
|
|
||||||
ErrorStore.clearLastError(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
import React from 'react';
|
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 * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
import AdminSettings from './admin_settings.jsx';
|
import AdminSettings from './admin_settings.jsx';
|
||||||
@@ -19,6 +22,8 @@ export default class EmailSettings extends AdminSettings {
|
|||||||
|
|
||||||
this.getConfigFromState = this.getConfigFromState.bind(this);
|
this.getConfigFromState = this.getConfigFromState.bind(this);
|
||||||
|
|
||||||
|
this.handleSaved = this.handleSaved.bind(this);
|
||||||
|
|
||||||
this.renderSettings = this.renderSettings.bind(this);
|
this.renderSettings = this.renderSettings.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +44,12 @@ export default class EmailSettings extends AdminSettings {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSaved(newConfig) {
|
||||||
|
if (newConfig.EmailSettings.SendEmailNotifications) {
|
||||||
|
ErrorStore.clearError(ErrorBarTypes.PREVIEW_MODE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getStateFromConfig(config) {
|
getStateFromConfig(config) {
|
||||||
return {
|
return {
|
||||||
sendEmailNotifications: config.EmailSettings.SendEmailNotifications,
|
sendEmailNotifications: config.EmailSettings.SendEmailNotifications,
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// 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 React from 'react';
|
||||||
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
|
||||||
import {Link} from 'react-router';
|
import {Link} from 'react-router';
|
||||||
|
|
||||||
const EXPIRING_ERROR = 'error_bar.expiring';
|
import AnalyticsStore from 'stores/analytics_store.jsx';
|
||||||
const EXPIRED_ERROR = 'error_bar.expired';
|
import ErrorStore from 'stores/error_store.jsx';
|
||||||
const PAST_GRACE_ERROR = 'error_bar.past_grace';
|
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 RENEWAL_LINK = 'https://licensing.mattermost.com/renew';
|
||||||
const SITE_URL_ERROR = 'error_bar.site_url';
|
|
||||||
|
|
||||||
const BAR_DEVELOPER_TYPE = 'developer';
|
const BAR_DEVELOPER_TYPE = 'developer';
|
||||||
const BAR_CRITICAL_TYPE = 'critical';
|
const BAR_CRITICAL_TYPE = 'critical';
|
||||||
@@ -36,7 +31,7 @@ export default class ErrorBar extends React.Component {
|
|||||||
|
|
||||||
this.setInitialError();
|
this.setInitialError();
|
||||||
|
|
||||||
this.state = ErrorStore.getLastError();
|
this.state = ErrorStore.getLastError() || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
setInitialError() {
|
setInitialError() {
|
||||||
@@ -50,24 +45,24 @@ export default class ErrorBar extends React.Component {
|
|||||||
|
|
||||||
if (!errorIgnored) {
|
if (!errorIgnored) {
|
||||||
if (isSystemAdmin && global.mm_config.SiteURL === '') {
|
if (isSystemAdmin && global.mm_config.SiteURL === '') {
|
||||||
ErrorStore.storeLastError({notification: true, message: SITE_URL_ERROR});
|
ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.SITE_URL});
|
||||||
return;
|
return;
|
||||||
} else if (global.mm_config.SendEmailNotifications === 'false') {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLicensePastGracePeriod()) {
|
if (isLicensePastGracePeriod()) {
|
||||||
if (isSystemAdmin) {
|
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 {
|
} 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) {
|
} 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) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.message === EXPIRING_ERROR && !this.state.totalUsers) {
|
if (s.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +96,7 @@ export default class ErrorBar extends React.Component {
|
|||||||
var newState = ErrorStore.getLastError();
|
var newState = ErrorStore.getLastError();
|
||||||
|
|
||||||
if (newState) {
|
if (newState) {
|
||||||
if (newState.message === EXPIRING_ERROR && !this.state.totalUsers) {
|
if (newState.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) {
|
||||||
AsyncClient.getStandardAnalytics();
|
AsyncClient.getStandardAnalytics();
|
||||||
}
|
}
|
||||||
this.setState(newState);
|
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;
|
const renewalLink = RENEWAL_LINK + '?id=' + global.window.mm_license.Id + '&user_count=' + this.state.totalUsers;
|
||||||
|
|
||||||
let message = this.state.message;
|
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 = (
|
message = (
|
||||||
<FormattedHTMLMessage
|
<FormattedHTMLMessage
|
||||||
id={EXPIRING_ERROR}
|
id={ErrorBarTypes.LICENSE_EXPIRING}
|
||||||
defaultMessage='Enterprise license expires on {date}. <a href="{link}" target="_blank">Please renew.</a>'
|
defaultMessage='Enterprise license expires on {date}. <a href="{link}" target="_blank">Please renew.</a>'
|
||||||
values={{
|
values={{
|
||||||
date: displayExpiryDate(),
|
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 = (
|
message = (
|
||||||
<FormattedHTMLMessage
|
<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>'
|
defaultMessage='Enterprise license is expired and some features may be disabled. <a href="{link}" target="_blank">Please renew.</a>'
|
||||||
values={{
|
values={{
|
||||||
link: renewalLink
|
link: renewalLink
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (message === PAST_GRACE_ERROR) {
|
} else if (message === ErrorBarTypes.LICENSE_PAST_GRACE) {
|
||||||
message = (
|
message = (
|
||||||
<FormattedMessage
|
<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.'
|
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 id;
|
||||||
let defaultMessage;
|
let defaultMessage;
|
||||||
if (global.mm_config.EnableSignUpWithGitLab === 'true') {
|
if (global.mm_config.EnableSignUpWithGitLab === 'true') {
|
||||||
|
|||||||
@@ -62,6 +62,14 @@ class ErrorStoreClass extends EventEmitter {
|
|||||||
BrowserStore.setGlobalItem('last_error_conn', count);
|
BrowserStore.setGlobalItem('last_error_conn', count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearError(message) {
|
||||||
|
const lastError = this.getLastError();
|
||||||
|
|
||||||
|
if (lastError && lastError.message === message) {
|
||||||
|
this.clearLastError(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clearLastError(force) {
|
clearLastError(force) {
|
||||||
var lastError = this.getLastError();
|
var lastError = this.getLastError();
|
||||||
|
|
||||||
|
|||||||
@@ -287,6 +287,14 @@ export const ErrorPageTypes = {
|
|||||||
LOCAL_STORAGE: 'local_storage'
|
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 = {
|
export const Constants = {
|
||||||
Preferences,
|
Preferences,
|
||||||
SocketEvents,
|
SocketEvents,
|
||||||
@@ -297,6 +305,7 @@ export const Constants = {
|
|||||||
TutorialSteps,
|
TutorialSteps,
|
||||||
PostTypes,
|
PostTypes,
|
||||||
ErrorPageTypes,
|
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],
|
IGNORE_POST_TYPES: [PostTypes.JOIN_LEAVE, PostTypes.JOIN_CHANNEL, PostTypes.LEAVE_CHANNEL, PostTypes.REMOVE_FROM_CHANNEL, PostTypes.ADD_TO_CHANNEL, PostTypes.ADD_REMOVE],
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user