From 7fc663ca75e966847243a845cff31c07737c4492 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 25 Apr 2017 12:39:08 -0400 Subject: PLT-6283 Hide Preview Mode error bar after enabling email notifications (#6180) --- webapp/components/error_bar.jsx | 56 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'webapp/components/error_bar.jsx') 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 = ( + + ); + } else if (message === ErrorBarTypes.LICENSE_EXPIRING) { message = ( ); - } else if (message === EXPIRED_ERROR) { + } else if (message === ErrorBarTypes.LICENSE_EXPIRED) { message = ( ); - } else if (message === PAST_GRACE_ERROR) { + } else if (message === ErrorBarTypes.LICENSE_PAST_GRACE) { message = ( ); - } else if (message === SITE_URL_ERROR) { + } else if (message === ErrorBarTypes.SITE_URL) { let id; let defaultMessage; if (global.mm_config.EnableSignUpWithGitLab === 'true') { -- cgit v1.2.3-1-g7c22