InlineEdit: Always load file content from change edit
Even when another patch set is currently loaded on change screen the load REST API should fetch the file content from the change edit and not the patch set. Change-Id: Ic35e127dbafb6fa8d5001d56e0f29c8d4c2649df
This commit is contained in:
		@@ -428,7 +428,7 @@ public class ChangeScreen2 extends Screen {
 | 
			
		||||
    }
 | 
			
		||||
    RevisionInfo rev = info.revision(revision);
 | 
			
		||||
    editFileAction = new EditFileAction(
 | 
			
		||||
        new PatchSet.Id(changeId, rev._number()),
 | 
			
		||||
        new PatchSet.Id(changeId, edit == null ? rev._number() : 0),
 | 
			
		||||
        "", "", style, editMessage, reply);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -665,7 +665,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 +720,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);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
            }
 | 
			
		||||
          });
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user