PLT-5703 Update license expiry timing and text (#5602)

* Update license expiry timing and text

* Updating error bar (#5632)
Этот коммит содержится в:
Joram Wilander
2017-03-06 20:36:20 -05:00
коммит произвёл Corey Hulen
родитель 3f070fe4b8
Коммит f8aaf312c1
7 изменённых файлов: 93 добавлений и 56 удалений

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

@@ -118,6 +118,7 @@ func getClientLicense(l *model.License) map[string]string {
props["IsLicensed"] = strconv.FormatBool(IsLicensed) props["IsLicensed"] = strconv.FormatBool(IsLicensed)
if IsLicensed { if IsLicensed {
props["Id"] = l.Id
props["Users"] = strconv.Itoa(*l.Features.Users) props["Users"] = strconv.Itoa(*l.Features.Users)
props["LDAP"] = strconv.FormatBool(*l.Features.LDAP) props["LDAP"] = strconv.FormatBool(*l.Features.LDAP)
props["MFA"] = strconv.FormatBool(*l.Features.MFA) props["MFA"] = strconv.FormatBool(*l.Features.MFA)
@@ -166,6 +167,7 @@ func GetSanitizedClientLicense() map[string]string {
} }
if IsLicensed { if IsLicensed {
delete(sanitizedLicense, "Id")
delete(sanitizedLicense, "Name") delete(sanitizedLicense, "Name")
delete(sanitizedLicense, "Email") delete(sanitizedLicense, "Email")
delete(sanitizedLicense, "PhoneNumber") delete(sanitizedLicense, "PhoneNumber")

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

@@ -1,7 +1,6 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import Banner from 'components/admin_console/banner.jsx';
import LineChart from './line_chart.jsx'; import LineChart from './line_chart.jsx';
import DoughnutChart from './doughnut_chart.jsx'; import DoughnutChart from './doughnut_chart.jsx';
import StatisticCount from './statistic_count.jsx'; import StatisticCount from './statistic_count.jsx';
@@ -9,7 +8,6 @@ import StatisticCount from './statistic_count.jsx';
import AnalyticsStore from 'stores/analytics_store.jsx'; import AnalyticsStore from 'stores/analytics_store.jsx';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';
import {isLicenseExpired, isLicenseExpiring, displayExpiryDate} from 'utils/license_utils.jsx';
import * as AsyncClient from 'utils/async_client.jsx'; import * as AsyncClient from 'utils/async_client.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
const StatTypes = Constants.StatTypes; const StatTypes = Constants.StatTypes;
@@ -287,36 +285,6 @@ class SystemAnalytics extends React.Component {
{postTypeGraph} {postTypeGraph}
</div> </div>
); );
if (isLicenseExpired()) {
banner = (
<Banner
description={
<FormattedHTMLMessage
id='analytics.system.expiredBanner'
defaultMessage='The Enterprise license expired on {date}. You have 15 days from this date to renew the license, please contact <a href="mailto:commercial@mattermost.com">commercial@mattermost.com</a>.'
values={{
date: displayExpiryDate()
}}
/>
}
/>
);
} else if (isLicenseExpiring()) {
banner = (
<Banner
description={
<FormattedHTMLMessage
id='analytics.system.expiringBanner'
defaultMessage='The Enterprise license is expiring on {date}. To renew your license, please contact <a href="mailto:commercial@mattermost.com">commercial@mattermost.com</a>.'
values={{
date: displayExpiryDate()
}}
/>
}
/>
);
}
} }
const userCount = ( const userCount = (

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

@@ -1,26 +1,37 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015 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 ErrorStore from 'stores/error_store.jsx';
import UserStore from 'stores/user_store.jsx'; import UserStore from 'stores/user_store.jsx';
import * as Utils from 'utils/utils.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 {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} from 'react-intl'; import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
const EXPIRING_ERROR = 'error_bar.expiring'; const EXPIRING_ERROR = 'error_bar.expiring';
const EXPIRED_ERROR = 'error_bar.expired'; const EXPIRED_ERROR = 'error_bar.expired';
const PAST_GRACE_ERROR = 'error_bar.past_grace'; const PAST_GRACE_ERROR = 'error_bar.past_grace';
const RENEWAL_LINK = 'https://licensing.mattermost.com/renew';
const BAR_DEVELOPER_TYPE = 'developer';
const BAR_CRITICAL_TYPE = 'critical';
export default class ErrorBar extends React.Component { export default class ErrorBar extends React.Component {
constructor() { constructor() {
super(); super();
this.onErrorChange = this.onErrorChange.bind(this); this.onErrorChange = this.onErrorChange.bind(this);
this.onAnalyticsChange = this.onAnalyticsChange.bind(this);
this.handleClose = this.handleClose.bind(this); this.handleClose = this.handleClose.bind(this);
ErrorStore.clearNotificationError();
let isSystemAdmin = false; let isSystemAdmin = false;
const user = UserStore.getCurrentUser(); const user = UserStore.getCurrentUser();
if (user) { if (user) {
@@ -29,12 +40,16 @@ export default class ErrorBar extends React.Component {
if (!ErrorStore.getIgnoreNotification() && global.window.mm_config.SendEmailNotifications === 'false') { if (!ErrorStore.getIgnoreNotification() && global.window.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: Utils.localizeMessage('error_bar.preview_mode', 'Preview Mode: Email notifications have not been configured')});
} else if (isLicensePastGracePeriod()) {
if (isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: BAR_CRITICAL_TYPE});
} else {
ErrorStore.storeLastError({notification: true, message: PAST_GRACE_ERROR, type: BAR_CRITICAL_TYPE});
}
} else if (isLicenseExpired() && isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: BAR_CRITICAL_TYPE});
} else if (isLicenseExpiring() && isSystemAdmin) { } else if (isLicenseExpiring() && isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRING_ERROR}); ErrorStore.storeLastError({notification: true, message: EXPIRING_ERROR});
} else if (isLicenseExpired() && isSystemAdmin) {
ErrorStore.storeLastError({notification: true, message: EXPIRED_ERROR, type: 'developer'});
} else if (isLicensePastGracePeriod()) {
ErrorStore.storeLastError({notification: true, message: PAST_GRACE_ERROR});
} }
this.state = ErrorStore.getLastError(); this.state = ErrorStore.getLastError();
@@ -49,27 +64,41 @@ export default class ErrorBar extends React.Component {
return false; return false;
} }
if (s.message === EXPIRING_ERROR && !this.state.totalUsers) {
return false;
}
return true; return true;
} }
componentDidMount() { componentDidMount() {
ErrorStore.addChangeListener(this.onErrorChange); ErrorStore.addChangeListener(this.onErrorChange);
AnalyticsStore.addChangeListener(this.onAnalyticsChange);
} }
componentWillUnmount() { componentWillUnmount() {
ErrorStore.removeChangeListener(this.onErrorChange); ErrorStore.removeChangeListener(this.onErrorChange);
AnalyticsStore.removeChangeListener(this.onAnalyticsChange);
} }
onErrorChange() { onErrorChange() {
var newState = ErrorStore.getLastError(); var newState = ErrorStore.getLastError();
if (newState) { if (newState) {
if (newState.message === EXPIRING_ERROR && !this.state.totalUsers) {
AsyncClient.getStandardAnalytics();
}
this.setState(newState); this.setState(newState);
} else { } else {
this.setState({message: null}); this.setState({message: null});
} }
} }
onAnalyticsChange() {
const stats = AnalyticsStore.getAllSystem();
this.setState({totalUsers: stats[StatTypes.TOTAL_USERS]});
}
handleClose(e) { handleClose(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
@@ -91,33 +120,41 @@ export default class ErrorBar extends React.Component {
var errClass = 'error-bar'; var errClass = 'error-bar';
if (this.state.type && this.state.type === 'developer') { if (this.state.type === BAR_DEVELOPER_TYPE) {
errClass = 'error-bar-developer'; errClass = 'error-bar-developer';
} else if (this.state.type === BAR_CRITICAL_TYPE) {
errClass = 'error-bar-critical';
} }
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 === EXPIRING_ERROR) {
message = ( message = (
<FormattedMessage <FormattedHTMLMessage
id={EXPIRING_ERROR} id={EXPIRING_ERROR}
defaultMessage='The Enterprise license is expiring on {date}. To renew your license, please contact commercial@mattermost.com' defaultMessage='Enterprise license expires on {date}. <a href="{link}" target="_blank">Please renew.</a>'
values={{ values={{
date: displayExpiryDate() date: displayExpiryDate(),
link: renewalLink
}} }}
/> />
); );
} else if (message === EXPIRED_ERROR) { } else if (message === EXPIRED_ERROR) {
message = ( message = (
<FormattedMessage <FormattedHTMLMessage
id={EXPIRED_ERROR} id={EXPIRED_ERROR}
defaultMessage='Enterprise license has expired; you have 15 days from expiry to renew the license, please contact commercial@mattermost.com for details' 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 === PAST_GRACE_ERROR) {
message = ( message = (
<FormattedMessage <FormattedMessage
id={PAST_GRACE_ERROR} id={PAST_GRACE_ERROR}
defaultMessage='Enterprise license has expired, 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.'
/> />
); );
} }

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

@@ -941,8 +941,6 @@
"analytics.system.activeUsers": "Active Users With Posts", "analytics.system.activeUsers": "Active Users With Posts",
"analytics.system.channelTypes": "Channel Types", "analytics.system.channelTypes": "Channel Types",
"analytics.system.dailyActiveUsers": "Daily Active Users", "analytics.system.dailyActiveUsers": "Daily Active Users",
"analytics.system.expiredBanner": "The Enterprise license expired on {date}. You have 15 days from this date to renew the license, please contact <a href='mailto:commercial@mattermost.com'>commercial@mattermost.com</a>.",
"analytics.system.expiringBanner": "The Enterprise license is expiring on {date}. To renew your license, please contact <a href='mailto:commercial@mattermost.com'>commercial@mattermost.com</a>.",
"analytics.system.monthlyActiveUsers": "Monthly Active Users", "analytics.system.monthlyActiveUsers": "Monthly Active Users",
"analytics.system.postTypes": "Posts, Files and Hashtags", "analytics.system.postTypes": "Posts, Files and Hashtags",
"analytics.system.privateGroups": "Private Groups", "analytics.system.privateGroups": "Private Groups",
@@ -1293,9 +1291,9 @@
"error.not_found.title": "Page not found", "error.not_found.title": "Page not found",
"error.not_supported.message": "Private browsing is not supported", "error.not_supported.message": "Private browsing is not supported",
"error.not_supported.title": "Browser not supported", "error.not_supported.title": "Browser not supported",
"error_bar.expired": "Enterprise license has expired; you have 15 days from expiry to renew the license, please contact commercial@mattermost.com for details", "error_bar.expired": "Enterprise license is expired and some features may be disabled. <a href='{link}' target='_blank'>Please renew.</a>",
"error_bar.expiring": "The Enterprise license is expiring on {date}. To renew your license, please contact commercial@mattermost.com", "error_bar.expiring": "Enterprise license expires on {date}. <a href='{link}' target='_blank'>Please renew.</a>",
"error_bar.past_grace": "Enterprise license has expired, please contact your System Administrator for details", "error_bar.past_grace": "Enterprise license is expired and some features may be disabled. Please contact your System Administrator for details.",
"error_bar.preview_mode": "Preview Mode: Email notifications have not been configured", "error_bar.preview_mode": "Preview Mode: Email notifications have not been configured",
"file_attachment.download": "Download", "file_attachment.download": "Download",
"file_info_preview.size": "Size ", "file_info_preview.size": "Size ",

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

@@ -11,6 +11,9 @@
z-index: 9999; z-index: 9999;
a { a {
color: $white !important;
text-decoration: underline;
&.error-bar__close { &.error-bar__close {
color: $white; color: $white;
font-family: 'Open Sans', sans-serif; font-family: 'Open Sans', sans-serif;
@@ -30,7 +33,7 @@
} }
} }
.error-bar-developer { .error-bar-critical {
background-color: #B0171F; background-color: #B0171F;
color: white; color: white;
padding: 5px 30px; padding: 5px 30px;
@@ -59,3 +62,33 @@
} }
} }
} }
.error-bar-developer {
background-color: purple;
color: white;
padding: 5px 30px;
position: absolute;
text-align: center;
top: 0;
width: 100%;
z-index: 9999;
a {
&.error-bar__close {
color: $white;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
font-weight: 600;
padding: 0 10px;
position: absolute;
right: 0;
text-decoration: none;
top: 0;
&:hover {
color: $white;
text-decoration: none;
}
}
}
}

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

@@ -885,8 +885,6 @@ export const Constants = {
BOT_NAME: 'BOT', BOT_NAME: 'BOT',
MAX_PREV_MSGS: 100, MAX_PREV_MSGS: 100,
POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5, // five minutes POST_COLLAPSE_TIMEOUT: 1000 * 60 * 5, // five minutes
LICENSE_EXPIRY_NOTIFICATION: 1000 * 60 * 60 * 24 * 15, // 15 days
LICENSE_GRACE_PERIOD: 1000 * 60 * 60 * 24 * 15, // 15 days
PERMISSIONS_ALL: 'all', PERMISSIONS_ALL: 'all',
PERMISSIONS_CHANNEL_ADMIN: 'channel_admin', PERMISSIONS_CHANNEL_ADMIN: 'channel_admin',
PERMISSIONS_TEAM_ADMIN: 'team_admin', PERMISSIONS_TEAM_ADMIN: 'team_admin',

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

@@ -1,17 +1,18 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
import Constants from 'utils/constants.jsx';
import LocalizationStore from 'stores/localization_store.jsx'; import LocalizationStore from 'stores/localization_store.jsx';
const LICENSE_EXPIRY_NOTIFICATION = 1000 * 60 * 60 * 24 * 60; // 60 days
const LICENSE_GRACE_PERIOD = 1000 * 60 * 60 * 24 * 15; // 15 days
export function isLicenseExpiring() { export function isLicenseExpiring() {
if (window.mm_license.IsLicensed !== 'true') { if (window.mm_license.IsLicensed !== 'true') {
return false; return false;
} }
const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now(); const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
return timeDiff <= Constants.LICENSE_EXPIRY_NOTIFICATION; return timeDiff <= LICENSE_EXPIRY_NOTIFICATION;
} }
export function isLicenseExpired() { export function isLicenseExpired() {
@@ -29,7 +30,7 @@ export function isLicensePastGracePeriod() {
} }
const timeDiff = Date.now() - parseInt(global.window.mm_license.ExpiresAt, 10); const timeDiff = Date.now() - parseInt(global.window.mm_license.ExpiresAt, 10);
return timeDiff > Constants.LICENSE_GRACE_PERIOD; return timeDiff > LICENSE_GRACE_PERIOD;
} }
export function displayExpiryDate() { export function displayExpiryDate() {