Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
164df6eb
Commit
164df6eb
authored
Jul 05, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactor, add detailed cookie handling info
parent
60117f52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
+39
-2
No files found.
app/assets/javascripts/ee_trial_banner/ee_trial_banner.js
View file @
164df6eb
...
...
@@ -10,6 +10,45 @@ export default class EETrialBanner {
}
init
()
{
this
.
setCookies
();
this
.
$trialBanner
.
on
(
'
close.bs.alert
'
,
e
=>
this
.
handleTrialBannerDismiss
(
e
));
}
/**
* Trial Expiring/Expired Banner has two stages;
* 1. Show banner when user enters last 7 days of trial
* 2. Show banner again when last 7 days are over and license has expired
*
* Stage 1:
* Banner is showed when `trial_license_message` is sent by backend
* for the first time (in `app/views/layouts/header/_default.html.haml`).
* Here, we perform following steps;
*
* 1. Set cookie `show_ee_trial_banner` with expiry same as license
* 2. Set cookie value to `true`
* 3. Show banner using `toggleBanner(true)`
*
* At this stage, if user dismisses banner, we set cookie value to `false`
* and everytime page is initialized, we check for cookie existence as
* well as its value, and decide show/hide status of banner
*
* Stage 2:
* At this point, Cookie we had set earlier will be expired and
* backend will now send updated message in `trial_license_message`.
* Here, we perform following steps;
*
* 1. Check if cookie is defined (it'll not be defined as it is expired now)
* 2. If cookie is gone, we re-set `show_ee_trial_banner` cookie but with
* expiry of 20 years
* 3. Set cookie value to `true`
* 4. Show banner using `toggleBanner(true)`, which now has updated message
*
* At this stage, if user dismisses banner, we set cookie value to `false`
* and our existing logic of show/hide banner based on cookie value continues
* to work. And since, cookie is set to expire after 20 years, user won't be
* seeing banner again.
*/
setCookies
()
{
const
today
=
new
Date
();
// Check if Cookie is defined
...
...
@@ -31,8 +70,6 @@ export default class EETrialBanner {
// Cookie was defined, let's read value and show/hide banner
this
.
toggleBanner
(
Cookies
.
get
(
this
.
COOKIE_KEY
)
===
'
true
'
);
}
this
.
$trialBanner
.
on
(
'
close.bs.alert
'
,
e
=>
this
.
handleTrialBannerDismiss
(
e
));
}
toggleBanner
(
state
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment