Add option to set default visibility of change comments
Change-Id: I6d6b8152d40c828ddead39954f2170c0cd83a1ea
This commit is contained in:
@@ -24,6 +24,7 @@ public interface AccountConstants extends Constants {
|
|||||||
String registeredOn();
|
String registeredOn();
|
||||||
String accountId();
|
String accountId();
|
||||||
|
|
||||||
|
String commentVisibilityLabel();
|
||||||
String maximumPageSizeFieldLabel();
|
String maximumPageSizeFieldLabel();
|
||||||
String dateFormatLabel();
|
String dateFormatLabel();
|
||||||
String contextWholeFile();
|
String contextWholeFile();
|
||||||
|
@@ -10,6 +10,7 @@ copySelfOnEmails = CC Me On Comments I Write
|
|||||||
reversePatchSetOrder = Display Patch Sets In Reverse Order
|
reversePatchSetOrder = Display Patch Sets In Reverse Order
|
||||||
showUsernameInReviewCategory = Display Person Name In Review Category
|
showUsernameInReviewCategory = Display Person Name In Review Category
|
||||||
maximumPageSizeFieldLabel = Maximum Page Size:
|
maximumPageSizeFieldLabel = Maximum Page Size:
|
||||||
|
commentVisibilityLabel = Comment Visibility:
|
||||||
dateFormatLabel = Date/Time Format:
|
dateFormatLabel = Date/Time Format:
|
||||||
contextWholeFile = Whole File
|
contextWholeFile = Whole File
|
||||||
buttonSaveChanges = Save Changes
|
buttonSaveChanges = Save Changes
|
||||||
|
@@ -23,6 +23,7 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
|||||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
@@ -46,6 +47,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private ListBox maximumPageSize;
|
private ListBox maximumPageSize;
|
||||||
private ListBox dateFormat;
|
private ListBox dateFormat;
|
||||||
private ListBox timeFormat;
|
private ListBox timeFormat;
|
||||||
|
private ListBox commentVisibilityStrategy;
|
||||||
private Button save;
|
private Button save;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,6 +64,24 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commentVisibilityStrategy = new ListBox();
|
||||||
|
commentVisibilityStrategy.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.messageCollapseAll(),
|
||||||
|
AccountGeneralPreferences.CommentVisibilityStrategy.COLLAPSE_ALL.name()
|
||||||
|
);
|
||||||
|
commentVisibilityStrategy.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.messageExpandMostRecent(),
|
||||||
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_MOST_RECENT.name()
|
||||||
|
);
|
||||||
|
commentVisibilityStrategy.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.messageExpandRecent(),
|
||||||
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT.name()
|
||||||
|
);
|
||||||
|
commentVisibilityStrategy.addItem(
|
||||||
|
com.google.gerrit.client.changes.Util.C.messageExpandAll(),
|
||||||
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name()
|
||||||
|
);
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
dateFormat = new ListBox();
|
dateFormat = new ListBox();
|
||||||
for (AccountGeneralPreferences.DateFormat fmt : AccountGeneralPreferences.DateFormat
|
for (AccountGeneralPreferences.DateFormat fmt : AccountGeneralPreferences.DateFormat
|
||||||
@@ -98,7 +118,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
|
|
||||||
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
|
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
|
||||||
|
|
||||||
final Grid formGrid = new Grid(8, 2);
|
final Grid formGrid = new Grid(9, 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
@@ -133,6 +153,10 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
formGrid.setWidget(row, fieldIdx, relativeDateInChangeTable);
|
formGrid.setWidget(row, fieldIdx, relativeDateInChangeTable);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
formGrid.setText(row, labelIdx, Util.C.commentVisibilityLabel());
|
||||||
|
formGrid.setWidget(row, fieldIdx, commentVisibilityStrategy);
|
||||||
|
row++;
|
||||||
|
|
||||||
add(formGrid);
|
add(formGrid);
|
||||||
|
|
||||||
save = new Button(Util.C.buttonSaveChanges());
|
save = new Button(Util.C.buttonSaveChanges());
|
||||||
@@ -155,6 +179,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
e.listenTo(dateFormat);
|
e.listenTo(dateFormat);
|
||||||
e.listenTo(timeFormat);
|
e.listenTo(timeFormat);
|
||||||
e.listenTo(relativeDateInChangeTable);
|
e.listenTo(relativeDateInChangeTable);
|
||||||
|
e.listenTo(commentVisibilityStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,6 +202,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
dateFormat.setEnabled(on);
|
dateFormat.setEnabled(on);
|
||||||
timeFormat.setEnabled(on);
|
timeFormat.setEnabled(on);
|
||||||
relativeDateInChangeTable.setEnabled(on);
|
relativeDateInChangeTable.setEnabled(on);
|
||||||
|
commentVisibilityStrategy.setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(final AccountGeneralPreferences p) {
|
private void display(final AccountGeneralPreferences p) {
|
||||||
@@ -191,6 +217,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
setListBox(timeFormat, AccountGeneralPreferences.TimeFormat.HHMM_12, //
|
setListBox(timeFormat, AccountGeneralPreferences.TimeFormat.HHMM_12, //
|
||||||
p.getTimeFormat());
|
p.getTimeFormat());
|
||||||
relativeDateInChangeTable.setValue(p.isRelativeDateInChangeTable());
|
relativeDateInChangeTable.setValue(p.isRelativeDateInChangeTable());
|
||||||
|
setListBox(commentVisibilityStrategy,
|
||||||
|
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_MOST_RECENT,
|
||||||
|
p.getCommentVisibilityStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListBox(final ListBox f, final short defaultValue,
|
private void setListBox(final ListBox f, final short defaultValue,
|
||||||
@@ -255,6 +284,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
AccountGeneralPreferences.TimeFormat.HHMM_12,
|
AccountGeneralPreferences.TimeFormat.HHMM_12,
|
||||||
AccountGeneralPreferences.TimeFormat.values()));
|
AccountGeneralPreferences.TimeFormat.values()));
|
||||||
p.setRelativeDateInChangeTable(relativeDateInChangeTable.getValue());
|
p.setRelativeDateInChangeTable(relativeDateInChangeTable.getValue());
|
||||||
|
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
|
||||||
|
CommentVisibilityStrategy.EXPAND_MOST_RECENT,
|
||||||
|
CommentVisibilityStrategy.values()));
|
||||||
|
|
||||||
enable(false);
|
enable(false);
|
||||||
save.setEnabled(false);
|
save.setEnabled(false);
|
||||||
|
@@ -113,6 +113,7 @@ public interface ChangeConstants extends Constants {
|
|||||||
String includedInTableTag();
|
String includedInTableTag();
|
||||||
|
|
||||||
String messageNoAuthor();
|
String messageNoAuthor();
|
||||||
|
String messageExpandMostRecent();
|
||||||
String messageExpandRecent();
|
String messageExpandRecent();
|
||||||
String messageExpandAll();
|
String messageExpandAll();
|
||||||
String messageCollapseAll();
|
String messageCollapseAll();
|
||||||
|
@@ -90,6 +90,7 @@ includedInTableBranch = Branch Name
|
|||||||
includedInTableTag = Tag Name
|
includedInTableTag = Tag Name
|
||||||
|
|
||||||
messageNoAuthor = Gerrit Code Review
|
messageNoAuthor = Gerrit Code Review
|
||||||
|
messageExpandMostRecent = Expand Most Recent
|
||||||
messageExpandRecent = Expand Recent
|
messageExpandRecent = Expand Recent
|
||||||
messageExpandAll = Expand All
|
messageExpandAll = Expand All
|
||||||
messageCollapseAll = Collapse All
|
messageCollapseAll = Collapse All
|
||||||
|
@@ -28,6 +28,7 @@ import com.google.gerrit.client.ui.Screen;
|
|||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
import com.google.gerrit.common.data.AccountInfoCache;
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
import com.google.gerrit.common.data.ChangeDetail;
|
||||||
import com.google.gerrit.common.data.ChangeInfo;
|
import com.google.gerrit.common.data.ChangeInfo;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
import com.google.gerrit.reviewdb.client.Change.Status;
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||||
@@ -385,6 +386,13 @@ public class ChangeScreen extends Screen
|
|||||||
final long AGE = 7 * 24 * 60 * 60 * 1000L;
|
final long AGE = 7 * 24 * 60 * 60 * 1000L;
|
||||||
final Timestamp aged = new Timestamp(System.currentTimeMillis() - AGE);
|
final Timestamp aged = new Timestamp(System.currentTimeMillis() - AGE);
|
||||||
|
|
||||||
|
CommentVisibilityStrategy commentVisibilityStrategy =
|
||||||
|
CommentVisibilityStrategy.EXPAND_MOST_RECENT;
|
||||||
|
if (Gerrit.isSignedIn()) {
|
||||||
|
commentVisibilityStrategy = Gerrit.getUserAccount()
|
||||||
|
.getGeneralPreferences().getCommentVisibilityStrategy();
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < msgList.size(); i++) {
|
for (int i = 0; i < msgList.size(); i++) {
|
||||||
final ChangeMessage msg = msgList.get(i);
|
final ChangeMessage msg = msgList.get(i);
|
||||||
|
|
||||||
@@ -409,8 +417,23 @@ public class ChangeScreen extends Screen
|
|||||||
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
|
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
|
||||||
if (i == msgList.size() - 1) {
|
if (i == msgList.size() - 1) {
|
||||||
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelLast());
|
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelLast());
|
||||||
cp.setOpen(true);
|
|
||||||
}
|
}
|
||||||
|
boolean isOpen = false;
|
||||||
|
switch (commentVisibilityStrategy) {
|
||||||
|
case COLLAPSE_ALL:
|
||||||
|
break;
|
||||||
|
case EXPAND_RECENT:
|
||||||
|
isOpen = isRecent;
|
||||||
|
break;
|
||||||
|
case EXPAND_ALL:
|
||||||
|
isOpen = true;
|
||||||
|
break;
|
||||||
|
case EXPAND_MOST_RECENT:
|
||||||
|
default:
|
||||||
|
isOpen = i == msgList.size() - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cp.setOpen(isOpen);
|
||||||
comments.add(cp);
|
comments.add(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,6 +65,13 @@ public final class AccountGeneralPreferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum CommentVisibilityStrategy {
|
||||||
|
COLLAPSE_ALL,
|
||||||
|
EXPAND_MOST_RECENT,
|
||||||
|
EXPAND_RECENT,
|
||||||
|
EXPAND_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
public static enum TimeFormat {
|
public static enum TimeFormat {
|
||||||
/** 12-hour clock: 1:15 am, 2:13 pm */
|
/** 12-hour clock: 1:15 am, 2:13 pm */
|
||||||
HHMM_12("h:mm a"),
|
HHMM_12("h:mm a"),
|
||||||
@@ -126,6 +133,9 @@ public final class AccountGeneralPreferences {
|
|||||||
@Column(id = 12)
|
@Column(id = 12)
|
||||||
protected boolean relativeDateInChangeTable;
|
protected boolean relativeDateInChangeTable;
|
||||||
|
|
||||||
|
@Column(id = 13, length = 20, notNull = false)
|
||||||
|
protected String commentVisibilityStrategy;
|
||||||
|
|
||||||
public AccountGeneralPreferences() {
|
public AccountGeneralPreferences() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +247,18 @@ public final class AccountGeneralPreferences {
|
|||||||
this.relativeDateInChangeTable = relativeDateInChangeTable;
|
this.relativeDateInChangeTable = relativeDateInChangeTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommentVisibilityStrategy getCommentVisibilityStrategy() {
|
||||||
|
if (commentVisibilityStrategy == null) {
|
||||||
|
return CommentVisibilityStrategy.EXPAND_MOST_RECENT;
|
||||||
|
}
|
||||||
|
return CommentVisibilityStrategy.valueOf(commentVisibilityStrategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentVisibilityStrategy(
|
||||||
|
CommentVisibilityStrategy strategy) {
|
||||||
|
commentVisibilityStrategy = strategy.name();
|
||||||
|
}
|
||||||
|
|
||||||
public void resetToDefaults() {
|
public void resetToDefaults() {
|
||||||
maximumPageSize = DEFAULT_PAGESIZE;
|
maximumPageSize = DEFAULT_PAGESIZE;
|
||||||
showSiteHeader = true;
|
showSiteHeader = true;
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
/** A version of the database schema. */
|
/** A version of the database schema. */
|
||||||
public abstract class SchemaVersion {
|
public abstract class SchemaVersion {
|
||||||
/** The current schema version. */
|
/** The current schema version. */
|
||||||
public static final Class<Schema_78> C = Schema_78.class;
|
public static final Class<Schema_79> C = Schema_79.class;
|
||||||
|
|
||||||
public static class Module extends AbstractModule {
|
public static class Module extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
// 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_79 extends SchemaVersion {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Schema_79(Provider<Schema_78> prior) {
|
||||||
|
super(prior);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user