summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-08 13:56:57 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-08 13:56:57 +0300
commit9021debf50d979fc7d62ece432a0071c10e6868e (patch)
treefeb0a5e94f807f6599316f4df91d5408671aeb42
parente8a826030e8616261aac4e0865200d63dc9821b4 (diff)
downloadgitlab-ce-9021debf50d979fc7d62ece432a0071c10e6868e.tar.gz
ConfirmDangerModal window added. It will be used for confirmation of dangerous actions
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/assets/javascripts/confirm_danger_modal.js.coffee20
-rw-r--r--app/views/shared/_confirm_modal.html.haml22
2 files changed, 42 insertions, 0 deletions
diff --git a/app/assets/javascripts/confirm_danger_modal.js.coffee b/app/assets/javascripts/confirm_danger_modal.js.coffee
new file mode 100644
index 00000000000..1687b7d961c
--- /dev/null
+++ b/app/assets/javascripts/confirm_danger_modal.js.coffee
@@ -0,0 +1,20 @@
+class ConfirmDangerModal
+ constructor: (form, text) ->
+ @form = form
+ $('.js-confirm-text').text(text || '')
+ $('.js-confirm-danger-input').val('')
+ $('#modal-confirm-danger').modal('show')
+ project_path = $('.js-confirm-danger-match').text()
+ submit = $('.js-confirm-danger-submit')
+ submit.disable()
+
+ $('.js-confirm-danger-input').on 'input', ->
+ if rstrip($(@).val()) is project_path
+ submit.enable()
+ else
+ submit.disable()
+
+ $('.js-confirm-danger-submit').on 'click', =>
+ @form.submit()
+
+@ConfirmDangerModal = ConfirmDangerModal
diff --git a/app/views/shared/_confirm_modal.html.haml b/app/views/shared/_confirm_modal.html.haml
new file mode 100644
index 00000000000..30ba361c860
--- /dev/null
+++ b/app/views/shared/_confirm_modal.html.haml
@@ -0,0 +1,22 @@
+#modal-confirm-danger.modal.hide{tabindex: -1}
+ .modal-dialog
+ .modal-content
+ .modal-header
+ %a.close{href: "#", "data-dismiss" => "modal"} ×
+ %h4 Confirmation required
+
+ .modal-body
+ %p.cred.lead.js-confirm-text
+
+ %p
+ This action can lead to data loss.
+ To prevent accidental actions we ask you to confirm your intention.
+ %br
+ Please type
+ %code.js-confirm-danger-match #{phrase}
+ to proceed or close this modal to cancel
+
+ .form-group
+ = text_field_tag 'confirm_name_input', '', class: 'form-control js-confirm-danger-input'
+ .form-group
+ = submit_tag 'Confirm', class: "btn btn-danger js-confirm-danger-submit"