Skip to content

Commit e6089c7

Browse files
committedOct 20, 2017
Fix presentation of the notifications settings page
1 parent ec8262b commit e6089c7

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed
 

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ trait NotificationsControllerBase extends ControllerBase {
3838
get("/:userName/_notifications")(oneselfOnly {
3939
val userName = params("userName")
4040
getAccountByUserName(userName).map { account =>
41-
gitbucket.notifications.html.settings(account, isDisableEmailNotification(account))
41+
gitbucket.notifications.html.settings(account, isDisableEmailNotification(account), flash.get("info"))
4242
} getOrElse NotFound()
4343
})
4444

45-
ajaxPost("/:userName/_notifications")(oneselfOnly {
45+
post("/:userName/_notifications")(oneselfOnly {
4646
val userName = params("userName")
47-
params.getAs[Boolean]("disable").map { disable =>
48-
updateEmailNotification(userName, disable)
49-
Ok()
50-
} getOrElse NotFound()
47+
val disable = params.getAs[Boolean]("disable").getOrElse(false)
48+
updateEmailNotification(userName, disable)
49+
flash += "info" -> "Notification setting has been updated."
50+
redirect(s"/${userName}/_notifications")
5151
})
5252

5353
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
@(account: gitbucket.core.model.Account,
2-
disableEmail: Boolean)(implicit context: gitbucket.core.controller.Context)
3-
2+
disableEmail: Boolean, info: Option[Any])(implicit context: gitbucket.core.controller.Context)
3+
@import gitbucket.core.view.helpers
44
@gitbucket.core.html.main("Notifications"){
55
@gitbucket.core.account.html.menu("notifications", account.userName, account.isGroupAccount){
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>
6+
@gitbucket.core.helper.html.information(info)
7+
<form action="@helpers.url(account.userName)/_notifications" method="POST">
8+
<div class="panel panel-default">
9+
<div class="panel-heading strong">Email notification preferences</div>
10+
<div class="panel-body">
11+
<fieldset class="form-group">
12+
<label for="disable" class="checkbox">
13+
<input type="checkbox" name="disable" id="disable" value="true" @if(disableEmail){checked}/>
14+
Disable
15+
<div class="normal muted">If checked, never be notified of anything.</div>
16+
</label>
17+
</fieldset>
18+
</div>
1619
</div>
17-
</div>
20+
<div>
21+
<input type="submit" class="btn btn-success" value="Save">
22+
</div>
23+
</form>
1824
}
1925
}
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)
Please sign in to comment.