Add new notify type that allows watching of new patch sets

Users can now watch the creation of new patch sets. They get notified
if a new patch set is uploaded, but also if a rebase is done from the
WebUI or the commit message is edited in the WebUI.

Change-Id: Ieabc4c00d2b185e5b452ac43706cb0fdd9d87f77
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-01-06 19:56:01 +01:00
committed by Shawn Pearce
parent 81f2be8cef
commit 1121475d1c
8 changed files with 53 additions and 6 deletions

View File

@@ -92,6 +92,7 @@ Types of notifications to send. If not specified, all notifications
are sent.
+
* `new_changes`: Only newly created changes.
* `new_patchsets`: Only newly created patch sets.
* `all_comments`: Only comments on existing changes.
* `submitted_changes`: Only changes that have been submitted.
* `all`: All notifications.

View File

@@ -96,6 +96,7 @@ public interface AccountConstants extends Constants {
String watchedProjectFilter();
String watchedProjectColumnEmailNotifications();
String watchedProjectColumnNewChanges();
String watchedProjectColumnNewPatchSets();
String watchedProjectColumnAllComments();
String watchedProjectColumnSubmittedChanges();

View File

@@ -95,6 +95,7 @@ watchedProjectName = Project Name
watchedProjectFilter = Only If
watchedProjectColumnEmailNotifications = Email Notifications
watchedProjectColumnNewChanges = New Changes
watchedProjectColumnNewPatchSets = New Patch Sets
watchedProjectColumnAllComments = All Comments
watchedProjectColumnSubmittedChanges = Submitted Changes

View File

@@ -51,13 +51,15 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
fmt.setRowSpan(0, 2, 2);
DOM.setElementProperty(fmt.getElement(0, 3), "align", "center");
fmt.setColSpan(0, 3, 3);
fmt.setColSpan(0, 3, 4);
table.setText(1, 0, Util.C.watchedProjectColumnNewChanges());
table.setText(1, 1, Util.C.watchedProjectColumnAllComments());
table.setText(1, 2, Util.C.watchedProjectColumnSubmittedChanges());
table.setText(1, 1, Util.C.watchedProjectColumnNewPatchSets());
table.setText(1, 2, Util.C.watchedProjectColumnAllComments());
table.setText(1, 3, Util.C.watchedProjectColumnSubmittedChanges());
fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(1, 1, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(1, 2, Gerrit.RESOURCES.css().dataHeader());
fmt.addStyleName(1, 3, Gerrit.RESOURCES.css().dataHeader());
}
public void deleteChecked() {
@@ -135,8 +137,9 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
table.setWidget(row, 2, fp);
addNotifyButton(AccountProjectWatch.NotifyType.NEW_CHANGES, info, row, 3);
addNotifyButton(AccountProjectWatch.NotifyType.ALL_COMMENTS, info, row, 4);
addNotifyButton(AccountProjectWatch.NotifyType.SUBMITTED_CHANGES, info, row, 5);
addNotifyButton(AccountProjectWatch.NotifyType.NEW_PATCHSETS, info, row, 4);
addNotifyButton(AccountProjectWatch.NotifyType.ALL_COMMENTS, info, row, 5);
addNotifyButton(AccountProjectWatch.NotifyType.SUBMITTED_CHANGES, info, row, 6);
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().iconCell());
@@ -144,6 +147,7 @@ public class MyWatchesTable extends FancyFlexTable<AccountProjectWatchInfo> {
fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 5, Gerrit.RESOURCES.css().dataCell());
fmt.addStyleName(row, 6, Gerrit.RESOURCES.css().dataCell());
setRowItem(row, info);
}

View File

@@ -22,7 +22,7 @@ import com.google.gwtorm.client.StringKey;
public final class AccountProjectWatch {
public enum NotifyType {
NEW_CHANGES, ALL_COMMENTS, SUBMITTED_CHANGES, ALL
NEW_CHANGES, NEW_PATCHSETS, ALL_COMMENTS, SUBMITTED_CHANGES, ALL
}
public static final String FILTER_ALL = "*";
@@ -109,6 +109,9 @@ public final class AccountProjectWatch {
@Column(id = 4)
protected boolean notifySubmittedChanges;
@Column(id = 5)
protected boolean notifyNewPatchSets;
protected AccountProjectWatch() {
}
@@ -137,6 +140,9 @@ public final class AccountProjectWatch {
case NEW_CHANGES:
return notifyNewChanges;
case NEW_PATCHSETS:
return notifyNewPatchSets;
case ALL_COMMENTS:
return notifyAllComments;
@@ -155,6 +161,10 @@ public final class AccountProjectWatch {
notifyNewChanges = v;
break;
case NEW_PATCHSETS:
notifyNewPatchSets = v;
break;
case ALL_COMMENTS:
notifyAllComments = v;
break;
@@ -165,6 +175,7 @@ public final class AccountProjectWatch {
case ALL:
notifyNewChanges = v;
notifyNewPatchSets = v;
notifyAllComments = v;
notifySubmittedChanges = v;
break;

View File

@@ -70,6 +70,8 @@ public class CreateChangeSender extends NewChangeSender {
// who have a lower interest in the change.
log.warn("Cannot notify watchers for new change", err);
}
includeWatchers(NotifyType.NEW_PATCHSETS);
}
private boolean isOwnerOfProjectOrBranch(Account.Id user) {

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.mail;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
import com.google.gerrit.server.config.AnonymousCowardName;
import com.google.gerrit.server.ssh.SshInfo;
import com.google.inject.Inject;
@@ -69,6 +70,7 @@ public class ReplacePatchSetSender extends ReplyToChangeSender {
add(RecipientType.CC, extraCC);
rcptToAuthors(RecipientType.CC);
bccStarredBy();
includeWatchers(NotifyType.NEW_PATCHSETS);
}
@Override

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.schema;
import com.google.inject.Inject;
import com.google.inject.Provider;
public class Schema_75 extends SchemaVersion {
@Inject
Schema_75(Provider<Schema_74> prior) {
super(prior);
}
}