summaryrefslogtreecommitdiffstats
path: root/webapp/utils
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-05-30 09:59:53 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-05-30 09:59:53 -0400
commit0dfac9875ef6f5f20318a3ef542b11592da8480e (patch)
treecf093fb2974535a0a6ab929af5e9d23032fafb01 /webapp/utils
parente4cb9141a456bbedc4f0e173bc1d912f33846043 (diff)
downloadchat-0dfac9875ef6f5f20318a3ef542b11592da8480e.tar.gz
chat-0dfac9875ef6f5f20318a3ef542b11592da8480e.tar.bz2
chat-0dfac9875ef6f5f20318a3ef542b11592da8480e.zip
Add license expiry messages (#3153)
Diffstat (limited to 'webapp/utils')
-rw-r--r--webapp/utils/constants.jsx4
-rw-r--r--webapp/utils/license_utils.jsx45
2 files changed, 48 insertions, 1 deletions
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index f1af112a9..b7ed97162 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -750,5 +750,7 @@ export default {
MHPNS: 'https://push.mattermost.com',
MTPNS: 'http://push-test.mattermost.com',
BOT_NAME: 'BOT',
- 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
};
diff --git a/webapp/utils/license_utils.jsx b/webapp/utils/license_utils.jsx
new file mode 100644
index 000000000..0ee8b75de
--- /dev/null
+++ b/webapp/utils/license_utils.jsx
@@ -0,0 +1,45 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import Constants from 'utils/constants.jsx';
+
+import React from 'react';
+import {FormattedDate} from 'react-intl';
+
+export function isLicenseExpiring() {
+ if (window.mm_license.IsLicensed !== 'true') {
+ return false;
+ }
+
+ const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
+ return timeDiff <= Constants.LICENSE_EXPIRY_NOTIFICATION;
+}
+
+export function isLicenseExpired() {
+ if (window.mm_license.IsLicensed !== 'true') {
+ return false;
+ }
+
+ const timeDiff = parseInt(global.window.mm_license.ExpiresAt, 10) - Date.now();
+ return timeDiff < 0;
+}
+
+export function isLicensePastGracePeriod() {
+ if (window.mm_license.IsLicensed !== 'true') {
+ return false;
+ }
+
+ const timeDiff = Date.now() - parseInt(global.window.mm_license.ExpiresAt, 10);
+ return timeDiff > Constants.LICENSE_GRACE_PERIOD;
+}
+
+export function displayExpiryDate() {
+ return (
+ <FormattedDate
+ value={new Date(parseInt(global.window.mm_license.ExpiresAt, 10))}
+ day='2-digit'
+ month='long'
+ year='numeric'
+ />
+ );
+}