stream settings: Fix bug in deactivate stream modal appearance.

Stream deactivation modal should be append to main
unique id, stream overlay element.
This commit also add `new-style` class to modal.

Fixes #12394
This commit is contained in:
Yashashvi Dave
2019-06-13 00:31:38 +05:30
committed by Tim Abbott
parent b530c87d26
commit 25dbda1e53
3 changed files with 11 additions and 5 deletions

View File

@@ -598,6 +598,7 @@ run_test('custom_user_profile_field', () => {
run_test('deactivate_stream_modal', () => {
var args = {
stream_name: "Public stream",
stream_id: 1,
};
var html = render('deactivation-stream-modal', args);
@@ -606,6 +607,7 @@ run_test('deactivate_stream_modal', () => {
var button = $(html).find("#do_deactivate_stream_button");
assert.equal(button.text(), "translated: Yes, delete this stream");
assert.equal(button.data('stream-id'), args.stream_id);
});
run_test('dev_env_email_access', () => {

View File

@@ -598,13 +598,17 @@ exports.initialize = function () {
return;
}
var stream_name = stream_data.maybe_get_stream_name(stream_id);
var deactivate_stream_modal = templates.render("deactivation-stream-modal", {stream_name: stream_name});
$(".subscription_settings").append(deactivate_stream_modal);
var deactivate_stream_modal = templates.render("deactivation-stream-modal", {
stream_name: stream_name,
stream_id: stream_id,
});
$("#deactivation_stream_modal").remove();
$("#subscriptions_table").append(deactivate_stream_modal);
overlays.open_modal('deactivation_stream_modal');
});
$("#subscriptions_table").on("click", "#do_deactivate_stream_button", function (e) {
var stream_id = get_stream_id(e.target);
var stream_id = $(e.target).data("stream-id");
overlays.close_modal('deactivation_stream_modal');
$("#deactivation_stream_modal").remove();
if (!stream_id) {

View File

@@ -1,4 +1,4 @@
<div id="deactivation_stream_modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="deactivation_stream_modal_label" aria-hidden="true">
<div id="deactivation_stream_modal" class="modal modal-bg hide fade new-style" tabindex="-1" role="dialog" aria-labelledby="deactivation_stream_modal_label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">&times;</span></button>
<h3 id="deactivation_stream_modal_label">{{t "Delete stream" }} <span class="stream_name">{{stream_name}}</span></h3>
@@ -8,6 +8,6 @@
</div>
<div class="modal-footer">
<button class="button rounded" data-dismiss="modal">{{t "Cancel" }}</button>
<button class="button rounded btn-danger" id="do_deactivate_stream_button">{{t "Yes, delete this stream" }}</button>
<button class="button rounded btn-danger" id="do_deactivate_stream_button" data-stream-id="{{stream_id}}">{{t "Yes, delete this stream" }}</button>
</div>
</div>