Get commentlinks per-project in UI code
Remove commentlinks from GerritConfig and instead provide them in JSON form from GET /projects/X/config. On the client side, create new CommentLinkProcessor instances when loading a change or patch. Fortunately, even though this requires another RPC to get the project config, in all existing screen instances, there is already an RPC we can parallelize it with. In the long term we may want to enable server-side HTML rendering, but that requires enabling this option on a variety of RPC endpoints, not all of which are converted to the new REST API. In addition, there is the problem of defining a stable HTML fragment style. For example, the commit message template is currently implemented using a not-quite-trivial template in GWT's UiBinder, so some of that formatting and styling would need to be hoisted out into the server side; doable, but we're not there yet. Change-Id: Iaecbeff939c8fcbc1c6f500e0b04ce03f35e1fd3
This commit is contained in:
@@ -18,7 +18,11 @@ import com.google.gerrit.client.Dispatcher;
|
||||
import com.google.gerrit.client.FormatUtil;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.account.AccountInfo;
|
||||
import com.google.gerrit.client.projects.ConfigInfo;
|
||||
import com.google.gerrit.client.projects.ProjectApi;
|
||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||
import com.google.gerrit.client.ui.CommentPanel;
|
||||
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
||||
import com.google.gerrit.client.ui.ExpandAllCommand;
|
||||
@@ -79,6 +83,7 @@ public class ChangeScreen extends Screen
|
||||
private PatchSetsBlock patchSetsBlock;
|
||||
|
||||
private Panel comments;
|
||||
private CommentLinkProcessor commentLinkProcessor;
|
||||
|
||||
private KeyCommandSet keysNavigation;
|
||||
private KeyCommandSet keysAction;
|
||||
@@ -260,10 +265,25 @@ public class ChangeScreen extends Screen
|
||||
@Override
|
||||
public void onValueChange(final ValueChangeEvent<ChangeDetail> event) {
|
||||
if (isAttached()) {
|
||||
// Until this screen is fully migrated to the new API, this call must be
|
||||
// sequential, because we can't start an async get at the source of every
|
||||
// call that might trigger a value change.
|
||||
ChangeApi.detail(event.getValue().getChange().getId().get(),
|
||||
// Until this screen is fully migrated to the new API, these calls must
|
||||
// happen sequentially after the ChangeDetail lookup, because we can't
|
||||
// start an async get at the source of every call that might trigger a
|
||||
// value change.
|
||||
CallbackGroup cbs = new CallbackGroup();
|
||||
ProjectApi.config(event.getValue().getChange().getProject())
|
||||
.get(cbs.add(new GerritCallback<ConfigInfo>() {
|
||||
@Override
|
||||
public void onSuccess(ConfigInfo result) {
|
||||
commentLinkProcessor =
|
||||
new CommentLinkProcessor(result.commentlinks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// Handled by last callback's onFailure.
|
||||
}
|
||||
}));
|
||||
ChangeApi.detail(event.getValue().getChange().getId().get(), cbs.add(
|
||||
new GerritCallback<com.google.gerrit.client.changes.ChangeInfo>() {
|
||||
@Override
|
||||
public void onSuccess(
|
||||
@@ -271,7 +291,7 @@ public class ChangeScreen extends Screen
|
||||
changeInfo = result;
|
||||
display(event.getValue());
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +312,8 @@ public class ChangeScreen extends Screen
|
||||
detail.isStarred(),
|
||||
detail.canEditCommitMessage(),
|
||||
detail.getCurrentPatchSetDetail().getInfo(),
|
||||
detail.getAccounts(), detail.getSubmitTypeRecord());
|
||||
detail.getAccounts(), detail.getSubmitTypeRecord(),
|
||||
commentLinkProcessor);
|
||||
dependsOn.display(detail.getDependsOn());
|
||||
neededBy.display(detail.getNeededBy());
|
||||
approvals.display(changeInfo);
|
||||
@@ -411,8 +432,8 @@ public class ChangeScreen extends Screen
|
||||
isRecent = msg.getWrittenOn().after(aged);
|
||||
}
|
||||
|
||||
final CommentPanel cp =
|
||||
new CommentPanel(author, msg.getWrittenOn(), msg.getMessage());
|
||||
final CommentPanel cp = new CommentPanel(author, msg.getWrittenOn(),
|
||||
msg.getMessage(), commentLinkProcessor);
|
||||
cp.setRecent(isRecent);
|
||||
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
|
||||
if (i == msgList.size() - 1) {
|
||||
|
Reference in New Issue
Block a user