Add a dropdown to control email notifications on user preference page

Add a dropdown 'Email Notifications' in the user preferences to allow
users to control their email notifications.

On selecting 'Disabled' user will not receive any email notifications
from Gerrit.

Remove the checkbox 'CC Me On Comments I write' and add it to the new
dropdown. Functionality remains the same as the original checkbox.

Options in the dropdown are:

1. Enabled
2. CC On Own Comments
3. Disabled

Feature: Issue 989
Change-Id: If40d0d34f39415d5c64ccaa5803fc6321bddd322
This commit is contained in:
Mani Chandel
2014-07-08 17:13:12 +05:30
committed by Michael Zhou
parent 2e66f80a4f
commit 207fa6e5db
12 changed files with 165 additions and 53 deletions

View File

@@ -32,7 +32,7 @@ import java.util.List;
/** A version of the database schema. */
public abstract class SchemaVersion {
/** The current schema version. */
public static final Class<Schema_115> C = Schema_115.class;
public static final Class<Schema_116> C = Schema_116.class;
public static int getBinaryVersion() {
return guessVersion(C);

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2014 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.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.sql.SQLException;
import java.sql.Statement;
public class Schema_116 extends SchemaVersion {
@Inject
Schema_116(Provider<Schema_115> prior) {
super(prior);
}
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws SQLException {
ui.message("Migrate user preference copySelfOnEmail to emailStrategy");
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement()) {
stmt.executeUpdate("UPDATE accounts SET "
+ "EMAIL_STRATEGY='ENABLED' "
+ "WHERE (COPY_SELF_ON_EMAIL='N')");
stmt.executeUpdate("UPDATE accounts SET "
+ "EMAIL_STRATEGY='CC_ON_OWN_COMMENTS' "
+ "WHERE (COPY_SELF_ON_EMAIL='Y')");
}
}
}