InlineEdit: Allow to revert file changes in file table

Currently revert is supported as two click UI operation: delete file
from the change and restore the deleted file. Pros: only one icon is
rendered to the left of the file name. Cons: it's not intuitive and
most often used operation in this context is revert and not delete.

Offer restore/revert icon in the file table. The same icon acts as
restore for deleted file and revert for changed files. Delete file
icon is still rendered for changed files only.

Bug: Issue 3294
Change-Id: I1557297a3dc583c0a67141343ab0932e47620b52
This commit is contained in:
David Ostrovsky
2015-05-04 08:00:54 +02:00
committed by David Ostrovsky
parent 2a29136e6c
commit 2051486fd6
4 changed files with 53 additions and 20 deletions

View File

@@ -455,6 +455,30 @@ public class ChangeEditIT extends AbstractDaemonTest {
ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
}
@Test
public void revertChanges() throws Exception {
assertThat(modifier.createEdit(change2, ps2)).isEqualTo(
RefUpdate.Result.NEW);
Optional<ChangeEdit> edit = editUtil.byChange(change2);
assertThat(modifier.restoreFile(edit.get(), FILE_NAME)).isEqualTo(
RefUpdate.Result.FORCED);
edit = editUtil.byChange(change2);
assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
assertThat(
modifier.modifyFile(editUtil.byChange(change2).get(), FILE_NAME,
RestSession.newRawInput(CONTENT_NEW))).isEqualTo(RefUpdate.Result.FORCED);
edit = editUtil.byChange(change2);
assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_NEW);
assertThat(modifier.restoreFile(edit.get(), FILE_NAME)).isEqualTo(
RefUpdate.Result.FORCED);
edit = editUtil.byChange(change2);
assertByteArray(fileUtil.getContent(projectCache.get(edit.get().getChange().getProject()),
ObjectId.fromString(edit.get().getRevision().get()), FILE_NAME), CONTENT_OLD);
editUtil.delete(edit.get());
}
@Test
public void renameFileRest() throws Exception {
assertThat(modifier.createEdit(change, ps)).isEqualTo(RefUpdate.Result.NEW);