Merge topic 'inline-bugfix'

* changes:
  Edit button should not appear in the file table except:
  InlineEdit: Always load file content from change edit
This commit is contained in:
Dave Borowitz 2014-09-11 10:54:42 +00:00 committed by Gerrit Code Review
commit 59396a4818
3 changed files with 37 additions and 16 deletions

View File

@ -422,14 +422,31 @@ public class ChangeScreen2 extends Screen {
private void initEditMode(ChangeInfo info) {
if (Gerrit.isSignedIn() && info.status() == Status.NEW) {
editMode.setVisible(fileTableMode == FileTable.Mode.REVIEW);
addFile.setVisible(!editMode.isVisible());
reviewMode.setVisible(!editMode.isVisible());
RevisionInfo rev = info.revision(revision);
if (isEditModeEnabled(info, rev)) {
editMode.setVisible(fileTableMode == FileTable.Mode.REVIEW);
addFile.setVisible(!editMode.isVisible());
reviewMode.setVisible(!editMode.isVisible());
editFileAction = new EditFileAction(
new PatchSet.Id(changeId, edit == null ? rev._number() : 0),
"", "", style, editMessage, reply);
} else {
editMode.setVisible(false);
addFile.setVisible(false);
reviewMode.setVisible(false);
}
}
RevisionInfo rev = info.revision(revision);
editFileAction = new EditFileAction(
new PatchSet.Id(changeId, rev._number()),
"", "", style, editMessage, reply);
}
private boolean isEditModeEnabled(ChangeInfo info, RevisionInfo rev) {
if (rev.is_edit()) {
return true;
}
if (edit == null) {
return revision.equals(info.current_revision());
}
return rev._number() == RevisionInfo.findEditParent(
info.revisions().values());
}
private void initEditMessageAction(ChangeInfo info, String revision) {
@ -665,7 +682,7 @@ public class ChangeScreen2 extends Screen {
files.set(
b != null ? new PatchSet.Id(changeId, b._number()) : null,
new PatchSet.Id(changeId, rev._number()),
style, editMessage, reply);
style, editMessage, reply, edit != null);
files.setValue(info.edit().files(), myLastReply(info),
emptyComment,
emptyComment,
@ -720,7 +737,7 @@ public class ChangeScreen2 extends Screen {
files.set(
base != null ? new PatchSet.Id(changeId, base._number()) : null,
new PatchSet.Id(changeId, rev._number()),
style, editMessage, reply);
style, editMessage, reply, edit != null);
files.setValue(m, myLastReply, comments.get(0),
drafts.get(0), fileTableMode);
}

View File

@ -40,9 +40,9 @@ class EditFileBox extends Composite {
interface Binder extends UiBinder<HTMLPanel, EditFileBox> {}
private static final Binder uiBinder = GWT.create(Binder.class);
final private PatchSet.Id id;
final private String fileName;
final private String fileContent;
private final PatchSet.Id id;
private final String fileName;
private final String fileContent;
@UiField FileTextBox file;
@UiField NpTextArea content;

View File

@ -192,6 +192,7 @@ public class FileTable extends FlowPanel {
private ChangeScreen2.Style style;
private Widget editButton;
private Widget replyButton;
private boolean editExists;
@Override
protected void onLoad() {
@ -200,12 +201,13 @@ public class FileTable extends FlowPanel {
}
public void set(PatchSet.Id base, PatchSet.Id curr, ChangeScreen2.Style style,
Widget editButton, Widget replyButton) {
Widget editButton, Widget replyButton, boolean editExists) {
this.base = base;
this.curr = curr;
this.style = style;
this.editButton = editButton;
this.replyButton = replyButton;
this.editExists = editExists;
}
void setValue(NativeMap<FileInfo> fileMap,
@ -322,13 +324,15 @@ public class FileTable extends FlowPanel {
void onEdit(int idx) {
final String path = list.get(idx).path();
ChangeFileApi.getContent(curr, path,
final PatchSet.Id id = editExists && curr.get() != 0
? new PatchSet.Id(curr.getParentKey(), 0)
: curr;
ChangeFileApi.getContent(id, path,
new GerritCallback<String>() {
@Override
public void onSuccess(String result) {
EditFileAction edit = new EditFileAction(
curr, result, path,
style, editButton, replyButton);
id, result, path, style, editButton, replyButton);
edit.onEdit();
}
});