Render per-project themes on the client side

Always include the relevant <style>/<div> tags in the host page, even
if they are empty. Have Gerrit store the sitewide values, and swap
them in and out when loading project-specific screens.

Change-Id: Iab6d2c91bf636ef361e2031dd39904e0c7e9bf41
This commit is contained in:
Dave Borowitz
2013-04-09 14:48:42 -07:00
parent 1e49e143ec
commit de117a33fb
12 changed files with 183 additions and 36 deletions

View File

@@ -371,44 +371,39 @@ public abstract class PatchScreen extends Screen implements
fileList.movePointerTo(patchKey);
}
com.google.gwtjsonrpc.common.AsyncCallback<PatchScript> pscb =
new ScreenLoadCallback<PatchScript>(this) {
CallbackGroup cb = new CallbackGroup();
ConfigInfoCache.get(patchSetDetail.getProject(),
cb.add(new AsyncCallback<ConfigInfoCache.Entry>() {
@Override
protected void preDisplay(final PatchScript result) {
if (rpcSequence == rpcseq) {
onResult(result, isFirst);
}
public void onSuccess(ConfigInfoCache.Entry result) {
commentLinkProcessor = result.getCommentLinkProcessor();
contentTable.setCommentLinkProcessor(commentLinkProcessor);
setTheme(result.getTheme());
}
@Override
public void onFailure(final Throwable caught) {
if (rpcSequence == rpcseq) {
settingsPanel.setEnabled(true);
super.onFailure(caught);
}
public void onFailure(Throwable caught) {
// Handled by ScreenLoadCallback.onFailure.
}
};
if (commentLinkProcessor == null) {
// Fetch config in parallel if we haven't previously.
CallbackGroup cb = new CallbackGroup();
ConfigInfoCache.get(patchSetDetail.getProject(),
cb.add(new AsyncCallback<ConfigInfoCache.Entry>() {
@Override
public void onSuccess(ConfigInfoCache.Entry result) {
commentLinkProcessor = result.getCommentLinkProcessor();
contentTable.setCommentLinkProcessor(commentLinkProcessor);
}
}));
PatchUtil.DETAIL_SVC.patchScript(patchKey, idSideA, idSideB,
settingsPanel.getValue(), cb.addGwtjsonrpc(
new ScreenLoadCallback<PatchScript>(this) {
@Override
protected void preDisplay(final PatchScript result) {
if (rpcSequence == rpcseq) {
onResult(result, isFirst);
}
}
@Override
public void onFailure(Throwable caught) {
// Handled by ScreenLoadCallback.onFailure.
}
}));
pscb = cb.addGwtjsonrpc(pscb);
}
PatchUtil.DETAIL_SVC.patchScript(patchKey, idSideA, idSideB, //
settingsPanel.getValue(), pscb);
@Override
public void onFailure(final Throwable caught) {
if (rpcSequence == rpcseq) {
settingsPanel.setEnabled(true);
super.onFailure(caught);
}
}
}));
}
private void onResult(final PatchScript script, final boolean isFirst) {