From 693e435f2fb8be8f60f73ee69fcb8f5297522a82 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Thu, 6 Sep 2018 05:13:44 +0100 Subject: port EE --- app/assets/javascripts/persistent_user_callout.js | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/assets/javascripts/persistent_user_callout.js (limited to 'app/assets/javascripts/persistent_user_callout.js') diff --git a/app/assets/javascripts/persistent_user_callout.js b/app/assets/javascripts/persistent_user_callout.js new file mode 100644 index 00000000000..d136b3bfee9 --- /dev/null +++ b/app/assets/javascripts/persistent_user_callout.js @@ -0,0 +1,32 @@ +import axios from './lib/utils/axios_utils'; +import { __ } from './locale'; +import Flash from './flash'; + +export default class PersistentUserCallout { + constructor(container) { + const { dismissEndpoint, featureId } = container.dataset; + this.container = container; + this.dismissEndpoint = dismissEndpoint; + this.featureId = featureId; + } + + init() { + const closeButton = this.container.querySelector('.js-close'); + closeButton.addEventListener('click', event => this.dismiss(event)); + } + + dismiss(event) { + event.preventDefault(); + + axios + .post(this.dismissEndpoint, { + feature_name: this.featureId, + }) + .then(() => { + this.container.remove(); + }) + .catch(() => { + Flash(__('An error occurred while dismissing the alert. Refresh the page and try again.')); + }); + } +} -- cgit v1.2.3