From d8bd57901e33a7057e26e782e295099ffcc0da89 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 6 Sep 2017 23:04:13 -0700 Subject: Removing webapp --- .../announcement_bar/announcement_bar.jsx | 322 --------------------- webapp/components/announcement_bar/index.js | 16 - 2 files changed, 338 deletions(-) delete mode 100644 webapp/components/announcement_bar/announcement_bar.jsx delete mode 100644 webapp/components/announcement_bar/index.js (limited to 'webapp/components/announcement_bar') diff --git a/webapp/components/announcement_bar/announcement_bar.jsx b/webapp/components/announcement_bar/announcement_bar.jsx deleted file mode 100644 index cd0cd0cb9..000000000 --- a/webapp/components/announcement_bar/announcement_bar.jsx +++ /dev/null @@ -1,322 +0,0 @@ -// 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 AdminActions from 'actions/admin_actions.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'; -import * as TextFormatting from 'utils/text_formatting.jsx'; - -const RENEWAL_LINK = 'https://licensing.mattermost.com/renew'; - -const BAR_DEVELOPER_TYPE = 'developer'; -const BAR_CRITICAL_TYPE = 'critical'; -const BAR_ANNOUNCEMENT_TYPE = 'announcement'; - -const ANNOUNCEMENT_KEY = 'announcement--'; - -export default class AnnouncementBar extends React.PureComponent { - static propTypes = { - - /* - * Set if the user is logged in - */ - isLoggedIn: React.PropTypes.bool.isRequired - } - - constructor() { - super(); - - this.onErrorChange = this.onErrorChange.bind(this); - this.onAnalyticsChange = this.onAnalyticsChange.bind(this); - this.handleClose = this.handleClose.bind(this); - - ErrorStore.clearLastError(); - - this.setInitialError(); - - this.state = this.getState(); - } - - setInitialError() { - let isSystemAdmin = false; - const user = UserStore.getCurrentUser(); - if (user) { - isSystemAdmin = Utils.isSystemAdmin(user.roles); - } - - const errorIgnored = ErrorStore.getIgnoreNotification(); - - if (!errorIgnored) { - if (isSystemAdmin && global.mm_config.SiteURL === '') { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.SITE_URL}); - return; - } else if (global.mm_config.SendEmailNotifications === 'false') { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.PREVIEW_MODE}); - return; - } - } - - if (isLicensePastGracePeriod()) { - if (isSystemAdmin) { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRED, type: BAR_CRITICAL_TYPE}); - } else { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_PAST_GRACE, type: BAR_CRITICAL_TYPE}); - } - } else if (isLicenseExpired() && isSystemAdmin) { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRED, type: BAR_CRITICAL_TYPE}); - } else if (isLicenseExpiring() && isSystemAdmin) { - ErrorStore.storeLastError({notification: true, message: ErrorBarTypes.LICENSE_EXPIRING, type: BAR_CRITICAL_TYPE}); - } - } - - getState() { - const error = ErrorStore.getLastError(); - if (error) { - return {message: error.message, color: null, textColor: null, type: error.type, allowDismissal: true}; - } - - const bannerText = global.window.mm_config.BannerText || ''; - const allowDismissal = global.window.mm_config.AllowBannerDismissal === 'true'; - const bannerDismissed = localStorage.getItem(ANNOUNCEMENT_KEY + global.window.mm_config.BannerText); - - if (global.window.mm_config.EnableBanner === 'true' && - bannerText.length > 0 && - (!bannerDismissed || !allowDismissal)) { - // Remove old local storage items - Utils.removePrefixFromLocalStorage(ANNOUNCEMENT_KEY); - return { - message: bannerText, - color: global.window.mm_config.BannerColor, - textColor: global.window.mm_config.BannerTextColor, - type: BAR_ANNOUNCEMENT_TYPE, - allowDismissal - }; - } - - return {message: null, color: null, colorText: null, textColor: null, type: null, allowDismissal: true}; - } - - isValidState(s) { - if (!s) { - return false; - } - - if (!s.message) { - return false; - } - - if (s.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) { - return false; - } - - return true; - } - - componentDidMount() { - if (this.props.isLoggedIn && !this.state.allowDismissal) { - document.body.classList.add('error-bar--fixed'); - } - - ErrorStore.addChangeListener(this.onErrorChange); - AnalyticsStore.addChangeListener(this.onAnalyticsChange); - } - - componentWillUnmount() { - document.body.classList.remove('error-bar--fixed'); - ErrorStore.removeChangeListener(this.onErrorChange); - AnalyticsStore.removeChangeListener(this.onAnalyticsChange); - } - - componentDidUpdate(prevProps, prevState) { - if (!this.props.isLoggedIn) { - return; - } - - if (!prevState.allowDismissal && this.state.allowDismissal) { - document.body.classList.remove('error-bar--fixed'); - } else if (prevState.allowDismissal && !this.state.allowDismissal) { - document.body.classList.add('error-bar--fixed'); - } - } - - onErrorChange() { - const newState = this.getState(); - if (newState.message === ErrorBarTypes.LICENSE_EXPIRING && !this.state.totalUsers) { - AdminActions.getStandardAnalytics(); - } - this.setState(newState); - } - - onAnalyticsChange() { - const stats = AnalyticsStore.getAllSystem(); - this.setState({totalUsers: stats[StatTypes.TOTAL_USERS]}); - } - - handleClose(e) { - if (e) { - e.preventDefault(); - } - - if (this.state.type === BAR_ANNOUNCEMENT_TYPE) { - localStorage.setItem(ANNOUNCEMENT_KEY + this.state.message, true); - } - - if (ErrorStore.getLastError() && ErrorStore.getLastError().notification) { - ErrorStore.clearNotificationError(); - } else { - ErrorStore.clearLastError(); - } - - this.setState(this.getState()); - } - - render() { - if (!this.isValidState(this.state)) { - return
; - } - - if (!this.props.isLoggedIn && this.state.type === BAR_ANNOUNCEMENT_TYPE) { - return
; - } - - let errClass = 'error-bar'; - let dismissClass = ' error-bar--fixed'; - const barStyle = {}; - const linkStyle = {}; - if (this.state.color && this.state.textColor) { - barStyle.backgroundColor = this.state.color; - barStyle.color = this.state.textColor; - linkStyle.color = this.state.textColor; - } else if (this.state.type === BAR_DEVELOPER_TYPE) { - errClass = 'error-bar error-bar-developer'; - } else if (this.state.type === BAR_CRITICAL_TYPE) { - errClass = 'error-bar error-bar-critical'; - } - - let closeButton; - if (this.state.allowDismissal) { - dismissClass = ''; - closeButton = ( - - {'×'} - - ); - } - - const renewalLink = RENEWAL_LINK + '?id=' + global.window.mm_license.Id + '&user_count=' + this.state.totalUsers; - - let message = this.state.message; - if (this.state.type === BAR_ANNOUNCEMENT_TYPE) { - message = ( - - ); - } else if (message === ErrorBarTypes.PREVIEW_MODE) { - message = ( - - ); - } else if (message === ErrorBarTypes.LICENSE_EXPIRING) { - message = ( - - ); - } else if (message === ErrorBarTypes.LICENSE_EXPIRED) { - message = ( - - ); - } else if (message === ErrorBarTypes.LICENSE_PAST_GRACE) { - message = ( - - ); - } else if (message === ErrorBarTypes.WEBSOCKET_PORT_ERROR) { - message = ( - - ); - } else if (message === ErrorBarTypes.SITE_URL) { - let id; - let defaultMessage; - if (global.mm_config.EnableSignUpWithGitLab === 'true') { - id = 'error_bar.site_url_gitlab'; - defaultMessage = 'Please configure your {docsLink} in the System Console or in gitlab.rb if you\'re using GitLab Mattermost.'; - } else { - id = 'error_bar.site_url'; - defaultMessage = 'Please configure your {docsLink} in the System Console.'; - } - - message = ( - - - - ), - link: ( - - - - ) - }} - /> - ); - } - - return ( -
- {message} - {closeButton} -
- ); - } -} diff --git a/webapp/components/announcement_bar/index.js b/webapp/components/announcement_bar/index.js deleted file mode 100644 index 8fe4f56b4..000000000 --- a/webapp/components/announcement_bar/index.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {connect} from 'react-redux'; -import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; - -import AnnouncementBar from './announcement_bar.jsx'; - -function mapStateToProps(state, ownProps) { - return { - ...ownProps, - isLoggedIn: Boolean(getCurrentUserId(state)) - }; -} - -export default connect(mapStateToProps)(AnnouncementBar); -- cgit v1.2.3-1-g7c22