Add option to show ID in change table

Adds the ability for users to optionally select if they would
like to see the Change ID in the change table.

The following behaviour is expected:

As an anonymous/not logged in user the change table should
not show the ID.

For a logged in user by default the ID should not be shown
in the change table.

Once the user changes the setting in preferences the ID should
be shown in the change table.

The setting the user selects should be persistant across server
restarts.

Also updates Schema to 96.

Bug: issue 2646

Change-Id: I4f2d2df0b1d6e45958ddca952581410822f4895d
This commit is contained in:
Rob Ward 2014-05-02 17:16:12 +01:00
parent c32346958e
commit 5269a6090d
15 changed files with 103 additions and 12 deletions

View File

@ -85,7 +85,9 @@ public interface GerritCss extends CssResource {
String createGroupLink();
String createProjectPanel();
String dataCell();
String dataCellHidden();
String dataHeader();
String dataHeaderHidden();
String diffLinkCell();
String diffText();
String diffTextCONTEXT();

View File

@ -39,6 +39,7 @@ public interface AccountConstants extends Constants {
String buttonSaveChanges();
String showRelativeDateInChangeTable();
String showSizeBarInChangeTable();
String showLegacycidInChangeTable();
String myMenu();
String myMenuInfo();
String myMenuName();

View File

@ -19,6 +19,7 @@ contextWholeFile = Whole File
buttonSaveChanges = Save Changes
showRelativeDateInChangeTable = Show Relative Dates In Changes Table
showSizeBarInChangeTable = Show Change Sizes As Colored Bars In Changes Table
showLegacycidInChangeTable = Show Change Number In Changes Table
myMenu = My Menu
myMenuInfo = \
Menu items for the 'My' top level menu. \

View File

@ -52,6 +52,7 @@ public class MyPreferencesScreen extends SettingsScreen {
private CheckBox showUsernameInReviewCategory;
private CheckBox relativeDateInChangeTable;
private CheckBox sizeBarInChangeTable;
private CheckBox legacycidInChangeTable;
private ListBox maximumPageSize;
private ListBox dateFormat;
private ListBox timeFormat;
@ -145,8 +146,9 @@ public class MyPreferencesScreen extends SettingsScreen {
relativeDateInChangeTable = new CheckBox(Util.C.showRelativeDateInChangeTable());
sizeBarInChangeTable = new CheckBox(Util.C.showSizeBarInChangeTable());
legacycidInChangeTable = new CheckBox(Util.C.showLegacycidInChangeTable());
final Grid formGrid = new Grid(12, 2);
final Grid formGrid = new Grid(13, 2);
int row = 0;
formGrid.setText(row, labelIdx, "");
@ -185,6 +187,10 @@ public class MyPreferencesScreen extends SettingsScreen {
formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, sizeBarInChangeTable);
row++;
formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, legacycidInChangeTable);
row++;
}
formGrid.setText(row, labelIdx, Util.C.commentVisibilityLabel());
@ -226,6 +232,7 @@ public class MyPreferencesScreen extends SettingsScreen {
e.listenTo(timeFormat);
e.listenTo(relativeDateInChangeTable);
e.listenTo(sizeBarInChangeTable);
e.listenTo(legacycidInChangeTable);
e.listenTo(commentVisibilityStrategy);
e.listenTo(changeScreen);
e.listenTo(diffView);
@ -254,6 +261,7 @@ public class MyPreferencesScreen extends SettingsScreen {
timeFormat.setEnabled(on);
relativeDateInChangeTable.setEnabled(on);
sizeBarInChangeTable.setEnabled(on);
legacycidInChangeTable.setEnabled(on);
commentVisibilityStrategy.setEnabled(on);
changeScreen.setEnabled(on);
diffView.setEnabled(on);
@ -272,6 +280,7 @@ public class MyPreferencesScreen extends SettingsScreen {
p.timeFormat());
relativeDateInChangeTable.setValue(p.relativeDateInChangeTable());
sizeBarInChangeTable.setValue(p.sizeBarInChangeTable());
legacycidInChangeTable.setValue(p.legacycidInChangeTable());
setListBox(commentVisibilityStrategy,
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
p.commentVisibilityStrategy());
@ -359,6 +368,7 @@ public class MyPreferencesScreen extends SettingsScreen {
AccountGeneralPreferences.TimeFormat.values()));
p.setRelativeDateInChangeTable(relativeDateInChangeTable.getValue());
p.setSizeBarInChangeTable(sizeBarInChangeTable.getValue());
p.setLegacycidInChangeTable(legacycidInChangeTable.getValue());
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
CommentVisibilityStrategy.EXPAND_RECENT,
CommentVisibilityStrategy.values()));

View File

@ -46,6 +46,7 @@ public class Preferences extends JavaScriptObject {
p.showUsernameInReviewCategory(in.isShowUsernameInReviewCategory());
p.relativeDateInChangeTable(in.isRelativeDateInChangeTable());
p.sizeBarInChangeTable(in.isSizeBarInChangeTable());
p.legacycidInChangeTable(in.isLegacycidInChangeTable());
p.commentVisibilityStrategy(in.getCommentVisibilityStrategy());
p.diffView(in.getDiffView());
p.changeScreen(in.getChangeScreen());
@ -108,6 +109,9 @@ public class Preferences extends JavaScriptObject {
public final native boolean sizeBarInChangeTable()
/*-{ return this.size_bar_in_change_table || false }-*/;
public final native boolean legacycidInChangeTable()
/*-{ return this.legacycid_in_change_table || false }-*/;
public final CommentVisibilityStrategy commentVisibilityStrategy() {
String s = commentVisibilityStrategyRaw();
return s != null ? CommentVisibilityStrategy.valueOf(s) : null;
@ -180,6 +184,9 @@ public class Preferences extends JavaScriptObject {
public final native void sizeBarInChangeTable(boolean s)
/*-{ this.size_bar_in_change_table = s }-*/;
public final native void legacycidInChangeTable(boolean s)
/*-{ this.legacycid_in_change_table = s }-*/;
public final void commentVisibilityStrategy(CommentVisibilityStrategy s) {
commentVisibilityStrategyRaw(s != null ? s.toString() : null);
}

View File

@ -47,6 +47,7 @@ public interface ChangeConstants extends Constants {
String changeTableColumnProject();
String changeTableColumnBranch();
String changeTableColumnLastUpdate();
String changeTableColumnID();
String changeTableNone();
String changeTableNotMergeable();

View File

@ -27,6 +27,7 @@ changeTableColumnReviewers = Reviewers
changeTableColumnProject = Project
changeTableColumnBranch = Branch
changeTableColumnLastUpdate = Updated
changeTableColumnID = ID
changeTableNone = (None)
changeTableNotMergeable = Merge Conflict

View File

@ -48,14 +48,16 @@ import java.util.List;
public class ChangeTable2 extends NavigationTable<ChangeInfo> {
private static final int C_STAR = 1;
private static final int C_SUBJECT = 2;
private static final int C_STATUS = 3;
private static final int C_OWNER = 4;
private static final int C_PROJECT = 5;
private static final int C_BRANCH = 6;
private static final int C_LAST_UPDATE = 7;
private static final int C_SIZE = 8;
private static final int BASE_COLUMNS = 9;
private static final int C_ID = 2;
private static final int C_SUBJECT = 3;
private static final int C_STATUS = 4;
private static final int C_OWNER = 5;
private static final int C_PROJECT = 6;
private static final int C_BRANCH = 7;
private static final int C_LAST_UPDATE = 8;
private static final int C_SIZE = 9;
private static final int BASE_COLUMNS = 10;
private final boolean useNewFeatures = Gerrit.getConfig().getNewFeatures();
private final List<Section> sections;
@ -73,6 +75,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
sections = new ArrayList<>();
table.setText(0, C_STAR, "");
table.setText(0, C_ID, Util.C.changeTableColumnID());
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
table.setText(0, C_STATUS, Util.C.changeTableColumnStatus());
table.setText(0, C_OWNER, Util.C.changeTableColumnOwner());
@ -85,10 +88,16 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
final FlexCellFormatter fmt = table.getFlexCellFormatter();
fmt.addStyleName(0, C_STAR, Gerrit.RESOURCES.css().iconHeader());
for (int i = C_SUBJECT; i < columns; i++) {
for (int i = C_ID; i < columns; i++) {
fmt.addStyleName(0, i, Gerrit.RESOURCES.css().dataHeader());
}
if (!Gerrit.isSignedIn() ||
(!Gerrit.getUserAccount().getGeneralPreferences()
.isLegacycidInChangeTable())) {
fmt.addStyleName(0, C_ID, Gerrit.RESOURCES.css().dataHeaderHidden());
}
table.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
@ -139,7 +148,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
super.applyDataRowStyle(row);
final CellFormatter fmt = table.getCellFormatter();
fmt.addStyleName(row, C_STAR, Gerrit.RESOURCES.css().iconCell());
for (int i = C_SUBJECT; i < columns; i++) {
for (int i = C_ID; i < columns; i++) {
fmt.addStyleName(row, i, Gerrit.RESOURCES.css().dataCell());
}
fmt.addStyleName(row, C_SUBJECT, Gerrit.RESOURCES.css().cSUBJECT());
@ -147,6 +156,12 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
fmt.addStyleName(row, C_OWNER, Gerrit.RESOURCES.css().cOWNER());
fmt.addStyleName(row, C_LAST_UPDATE, Gerrit.RESOURCES.css().cLastUpdate());
if (!Gerrit.isSignedIn() ||
(!Gerrit.getUserAccount().getGeneralPreferences()
.isLegacycidInChangeTable())) {
fmt.addStyleName(row, C_ID, Gerrit.RESOURCES.css().dataCellHidden());
}
int i = C_SIZE;
if (useNewFeatures) {
fmt.addStyleName(row, i++, Gerrit.RESOURCES.css().cSIZE());
@ -207,6 +222,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
c.legacy_id(),
c.starred()));
}
table.setWidget(row, C_ID, new TableChangeLink(String.valueOf(c.legacy_id()), c));
String subject = Util.cropSubject(c.subject());
table.setWidget(row, C_SUBJECT, new TableChangeLink(subject, c));

View File

@ -545,6 +545,10 @@ a:hover {
height: 20px;
}
.changeTable .dataCellHidden {
display: none;
}
.changeTable a.gwt-InlineHyperlink,
.changeTable a.gwt-Anchor {
color: #222 !important;
@ -632,6 +636,10 @@ a:hover {
color: textColor;
}
.changeTable .dataHeaderHidden {
display: none;
}
.changeTable .sectionHeader {
border-top: 8px solid backgroundColor;
padding: 2px 6px 1px;

View File

@ -164,6 +164,9 @@ public final class AccountGeneralPreferences {
@Column(id = 16)
protected boolean sizeBarInChangeTable;
@Column(id = 17)
protected boolean legacycidInChangeTable;
public AccountGeneralPreferences() {
}
@ -314,6 +317,14 @@ public final class AccountGeneralPreferences {
this.sizeBarInChangeTable = sizeBarInChangeTable;
}
public boolean isLegacycidInChangeTable() {
return legacycidInChangeTable;
}
public void setLegacycidInChangeTable(boolean legacycidInChangeTable) {
this.legacycidInChangeTable = legacycidInChangeTable;
}
public void resetToDefaults() {
maximumPageSize = DEFAULT_PAGESIZE;
showSiteHeader = true;
@ -330,5 +341,6 @@ public final class AccountGeneralPreferences {
diffView = null;
changeScreen = null;
sizeBarInChangeTable = true;
legacycidInChangeTable = false;
}
}

View File

@ -111,6 +111,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
Boolean showUsernameInReviewCategory;
Boolean relativeDateInChangeTable;
Boolean sizeBarInChangeTable;
Boolean legacycidInChangeTable;
CommentVisibilityStrategy commentVisibilityStrategy;
DiffView diffView;
ChangeScreen changeScreen;
@ -131,6 +132,7 @@ public class GetPreferences implements RestReadView<AccountResource> {
showUsernameInReviewCategory = p.isShowUsernameInReviewCategory() ? true : null;
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
legacycidInChangeTable = p.isLegacycidInChangeTable() ? true : null;
commentVisibilityStrategy = p.getCommentVisibilityStrategy();
diffView = p.getDiffView();
changeScreen = p.getChangeScreen();

View File

@ -63,6 +63,7 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
public Boolean showUsernameInReviewCategory;
public Boolean relativeDateInChangeTable;
public Boolean sizeBarInChangeTable;
public Boolean legacycidInChangeTable;
public CommentVisibilityStrategy commentVisibilityStrategy;
public DiffView diffView;
public ChangeScreen changeScreen;
@ -153,6 +154,9 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
if (i.sizeBarInChangeTable != null) {
p.setSizeBarInChangeTable(i.sizeBarInChangeTable);
}
if (i.legacycidInChangeTable != null) {
p.setLegacycidInChangeTable(i.legacycidInChangeTable);
}
if (i.commentVisibilityStrategy != null) {
p.setCommentVisibilityStrategy(i.commentVisibilityStrategy);
}

View File

@ -51,6 +51,7 @@ public class SetPreferences implements RestModifyView<ConfigResource, Input> {
|| i.showUsernameInReviewCategory != null
|| i.relativeDateInChangeTable != null
|| i.sizeBarInChangeTable != null
|| i.legacycidInChangeTable != null
|| i.commentVisibilityStrategy != null || i.diffView != null
|| i.changeScreen != null) {
throw new BadRequestException("unsupported option");

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_95> C = Schema_95.class;
public static final Class<Schema_96> C = Schema_96.class;
public static class Module extends AbstractModule {
@Override

View File

@ -0,0 +1,25 @@
// 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.inject.Inject;
import com.google.inject.Provider;
public class Schema_96 extends SchemaVersion {
@Inject
Schema_96(Provider<Schema_95> prior) {
super(prior);
}
}