diff options
| author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-02 14:03:15 +0000 |
|---|---|---|
| committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-02 14:03:15 +0000 |
| commit | dab266219441144a74b86fa27f4e0528810482d1 (patch) | |
| tree | 1ac4d6a649cc568c38a1fff2a999811d432c5378 /app/assets/javascripts/flash.js | |
| parent | 84b9aae9cfb8c319d06bcce1e93c2b1bc6f44877 (diff) | |
| parent | 6838c16c49185fb72aa58a9c6591da4ec0fc7acb (diff) | |
| download | gitlab-ce-dab266219441144a74b86fa27f4e0528810482d1.tar.gz | |
Merge branch '31511-jira-settings' into 'master'
Simplify test&save actions when setting a service integration
Closes #31511
See merge request !11599
Diffstat (limited to 'app/assets/javascripts/flash.js')
| -rw-r--r-- | app/assets/javascripts/flash.js | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/flash.js index eec30624ff2..ccff8f0ace7 100644 --- a/app/assets/javascripts/flash.js +++ b/app/assets/javascripts/flash.js @@ -7,8 +7,21 @@ window.Flash = (function() { return $(this).fadeOut(); }; - function Flash(message, type, parent) { - var flash, textDiv; + /** + * Flash banner supports different types of Flash configurations + * along with ability to provide actionConfig which can be used to show + * additional action or link on banner next to message + * + * @param {String} message Flash message + * @param {String} type Type of Flash, it can be `notice` or `alert` (default) + * @param {Object} parent Reference to Parent element under which Flash needs to appear + * @param {Object} actionConfig Map of config to show action on banner + * @param {String} href URL to which action link should point (default '#') + * @param {String} title Title of action + * @param {Function} clickHandler Method to call when action is clicked on + */ + function Flash(message, type, parent, actionConfig) { + var flash, textDiv, actionLink; if (type == null) { type = 'alert'; } @@ -30,6 +43,23 @@ window.Flash = (function() { text: message }); textDiv.appendTo(flash); + + if (actionConfig) { + const actionLinkConfig = { + class: 'flash-action', + href: actionConfig.href || '#', + text: actionConfig.title + }; + + if (!actionConfig.href) { + actionLinkConfig.role = 'button'; + } + + actionLink = $('<a/>', actionLinkConfig); + + actionLink.appendTo(flash); + this.flashContainer.on('click', '.flash-action', actionConfig.clickHandler); + } if (this.flashContainer.parent().hasClass('content-wrapper')) { textDiv.addClass('container-fluid container-limited'); } |
