summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/persistent_user_callout.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/assets/javascripts/persistent_user_callout.js
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
downloadgitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/assets/javascripts/persistent_user_callout.js')
-rw-r--r--app/assets/javascripts/persistent_user_callout.js35
1 files changed, 32 insertions, 3 deletions
diff --git a/app/assets/javascripts/persistent_user_callout.js b/app/assets/javascripts/persistent_user_callout.js
index b3068c46bcb..b8a1397d8f6 100644
--- a/app/assets/javascripts/persistent_user_callout.js
+++ b/app/assets/javascripts/persistent_user_callout.js
@@ -18,17 +18,21 @@ export default class PersistentUserCallout {
init() {
const closeButton = this.container.querySelector('.js-close');
+ const followLink = this.container.querySelector('.js-follow-link');
- if (!closeButton) {
- return;
+ if (closeButton) {
+ this.handleCloseButtonCallout(closeButton);
+ } else if (followLink) {
+ this.handleFollowLinkCallout(followLink);
}
+ }
+ handleCloseButtonCallout(closeButton) {
closeButton.addEventListener('click', event => this.dismiss(event));
if (this.deferLinks) {
this.container.addEventListener('click', event => {
const isDeferredLink = event.target.classList.contains(DEFERRED_LINK_CLASS);
-
if (isDeferredLink) {
const { href, target } = event.target;
@@ -38,6 +42,10 @@ export default class PersistentUserCallout {
}
}
+ handleFollowLinkCallout(followLink) {
+ followLink.addEventListener('click', event => this.registerCalloutWithLink(event));
+ }
+
dismiss(event, deferredLinkOptions = null) {
event.preventDefault();
@@ -58,6 +66,27 @@ export default class PersistentUserCallout {
});
}
+ registerCalloutWithLink(event) {
+ event.preventDefault();
+
+ const { href } = event.currentTarget;
+
+ axios
+ .post(this.dismissEndpoint, {
+ feature_name: this.featureId,
+ })
+ .then(() => {
+ window.location.assign(href);
+ })
+ .catch(() => {
+ Flash(
+ __(
+ 'An error occurred while acknowledging the notification. Refresh the page and try again.',
+ ),
+ );
+ });
+ }
+
static factory(container, options) {
if (!container) {
return undefined;