Skip to content

Commit 624bdcd

Browse files
committed
(refs #1)Change to disable email notification using ajaxPost.
1 parent ad19c60 commit 624bdcd

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/main/scala/Plugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Plugin extends gitbucket.core.plugin.Plugin {
7272
Link(
7373
id = "notifications",
7474
label = "Notifications",
75-
path = s"/${account.userName}/_notifications"
75+
path = s"${account.userName}/_notifications"
7676
)
7777
}
7878
)

src/main/scala/gitbucket/notifications/controller/NotificationsController.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ trait NotificationsControllerBase extends ControllerBase {
4242
} getOrElse NotFound()
4343
})
4444

45-
post("/:userName/_notifications")(oneselfOnly {
45+
ajaxPost("/:userName/_notifications")(oneselfOnly {
4646
val userName = params("userName")
4747
params.getAs[Boolean]("disable").map { disable =>
4848
updateEmailNotification(userName, disable)
49-
redirect(s"/${userName}/_notifications")
49+
Ok()
5050
} getOrElse NotFound()
5151
})
5252

src/main/twirl/gitbucket/notifications/settings.scala.html

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@
33

44
@gitbucket.core.html.main("Notifications"){
55
@gitbucket.core.account.html.menu("notifications", account.userName, account.isGroupAccount){
6-
<form method="POST" action="@context.path/@account.userName/_notifications">
7-
<div class="panel panel-default">
8-
<div class="panel-heading strong">Email notification preferences</div>
9-
<div class="panel-body">
10-
<fieldset class="form-group">
11-
<p class="muted">If checked, never be notified of anything.</p>
12-
<label for="disable">
13-
<input type="checkbox" name="disable" id="disable" value="true" @if(disableEmail){checked}/>
14-
Disable
15-
</label>
16-
</fieldset>
17-
<input type="submit" class="btn btn-success" value="Save"/>
18-
</div>
6+
<div class="panel panel-default">
7+
<div class="panel-heading strong">Email notification preferences</div>
8+
<div class="panel-body">
9+
<fieldset class="form-group">
10+
<p class="muted">If checked, never be notified of anything.</p>
11+
<label for="disable">
12+
<input type="checkbox" name="disable" id="disable" value="true" @if(disableEmail){checked}/>
13+
Disable
14+
</label>
15+
</fieldset>
1916
</div>
20-
</form>
17+
</div>
2118
}
22-
}
19+
}
20+
<script>
21+
$(function(){
22+
$('#disable').click(function(){
23+
$.post('@context.path/@account.userName/_notifications', { 'disable': this.checked });
24+
});
25+
});
26+
</script>

0 commit comments

Comments
 (0)