Discontinue draft workflow

Migration is implemented to either replace draft changes with private
(default) or work-in-progress changes.

We bump the change index version to trigger online reindexing.
That's needed because we don't support reindexing during init step, and
we need to reindex all changes, because DRAFT is removed from the
Change.Status enum and index still contains the old references to the
changes that were migrated to private or work-in-progress changes. To
make online reindexing work, draft status is replaced with the new
change status.

PolyGerrit UI is not addressed in this change and will be done in a
follow-up change.

User branches are not updated in this change to clean-up My-Menu entry
in user preferences. This will be done in a follow-up change.

refs/meta/config is not updated in this change to clean-up draft
related permissions. This will be done in a follow-up change.

ChangeControl#isPatchVisible() call sites are migrated to the
ChangeControl#isVisible() and isVisible() is made public again. This and
other temporary changes to ChangeControl class will be cleaned up in
follow up changes.

Bug: Issue 6880
Change-Id: Icfcb34efe1ff0ea1d39e94ed500db776f5770d8f
This commit is contained in:
David Ostrovsky
2017-02-13 21:16:58 +01:00
committed by Changcheng Xiao
parent 80522c3e22
commit 6ffb7d9358
129 changed files with 237 additions and 2908 deletions

View File

@@ -91,8 +91,6 @@ public interface GerritConstants extends Constants {
String menuMyChanges();
String menuMyDrafts();
String menuMyWatchedChanges();
String menuMyStarredChanges();
@@ -175,8 +173,6 @@ public interface GerritConstants extends Constants {
String jumpMine();
String jumpMineDrafts();
String jumpMineWatched();
String jumpMineStarred();

View File

@@ -53,7 +53,6 @@ menuAllAbandoned = Abandoned
menuMine = My
menuMyChanges = Changes
menuMyDrafts = Drafts
menuMyStarredChanges = Starred Changes
menuMyWatchedChanges = Watched Changes
menuMyDraftComments = Draft Comments
@@ -105,7 +104,6 @@ jumpAllMerged = Go to all merged changes
jumpAllAbandoned = Go to all abandoned changes
jumpMine = Go to my dashboard
jumpMineWatched = Go to watched changes
jumpMineDrafts = Go to drafts
jumpMineStarred = Go to starred changes
jumpMineDraftComments = Go to draft comments

View File

@@ -70,13 +70,6 @@ public class JumpKeys {
Gerrit.display(PageLinks.MINE);
}
});
jumps.add(
new KeyCommand(0, 'd', Gerrit.C.jumpMineDrafts()) {
@Override
public void onKeyPress(KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("owner:self is:draft"));
}
});
jumps.add(
new KeyCommand(0, 'c', Gerrit.C.jumpMineDraftComments()) {
@Override

View File

@@ -129,7 +129,6 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
suggestions.add("is:reviewer");
suggestions.add("is:open");
suggestions.add("is:pending");
suggestions.add("is:draft");
suggestions.add("is:private");
suggestions.add("is:closed");
suggestions.add("is:merged");
@@ -145,7 +144,6 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
suggestions.add("status:closed");
suggestions.add("status:merged");
suggestions.add("status:abandoned");
suggestions.add("status:draft");
suggestions.add("added:");
suggestions.add("deleted:");

View File

@@ -137,7 +137,6 @@ permissionNames = \
createTag, \
createSignedTag, \
delete, \
deleteDrafts, \
deleteOwnChanges, \
editAssignee, \
editHashtags, \
@@ -146,7 +145,6 @@ permissionNames = \
forgeCommitter, \
forgeServerAsCommitter, \
owner, \
publishDrafts, \
push, \
pushMerge, \
read, \
@@ -154,7 +152,6 @@ permissionNames = \
removeReviewer, \
submit, \
submitAs, \
viewDrafts, \
viewPrivateChanges
abandon = Abandon
@@ -163,7 +160,6 @@ create = Create Reference
createTag = Create Annotated Tag
createSignedTag = Create Signed Tag
delete = Delete Reference
deleteDrafts = Delete Drafts
deleteOwnChanges = Delete Own Changes
editAssignee = Edit Assignee
editHashtags = Edit Hashtags
@@ -172,7 +168,6 @@ forgeAuthor = Forge Author Identity
forgeCommitter = Forge Committer Identity
forgeServerAsCommitter = Forge Server Identity
owner = Owner
publishDrafts = Publish Drafts
push = Push
pushMerge = Push Merge Commit
read = Read
@@ -180,7 +175,6 @@ rebase = Rebase
removeReviewer = Remove Reviewer
submit = Submit
submitAs = Submit (On Behalf Of)
viewDrafts = View Drafts
viewPrivateChanges = View Private Changes
refErrorEmpty = Reference must be supplied

View File

@@ -26,16 +26,6 @@ import com.google.gwt.user.client.ui.Button;
public class ChangeActions {
static void publish(
Project.NameKey project, Change.Id id, String revision, Button... draftButtons) {
ChangeApi.publish(project.get(), id.get(), revision, cs(project, id, draftButtons));
}
static void delete(
Project.NameKey project, Change.Id id, String revision, Button... draftButtons) {
ChangeApi.deleteRevision(project.get(), id.get(), revision, cs(project, id, draftButtons));
}
static void delete(Project.NameKey project, Change.Id id, Button... draftButtons) {
ChangeApi.deleteChange(project.get(), id.get(), mine(draftButtons));
}

View File

@@ -43,8 +43,6 @@ public interface ChangeConstants extends Constants {
String author();
String draft();
String notAvailable();
String relatedChanges();
@@ -78,6 +76,4 @@ public interface ChangeConstants extends Constants {
String deleteChangeEdit();
String deleteChange();
String deleteDraftRevision();
}

View File

@@ -13,7 +13,6 @@ patchSet = Patch Set
commit = Commit
date = Date
author = Author / Committer
draft = (DRAFT)
notAvailable = N/A
relatedChanges = Related Changes
@@ -35,4 +34,3 @@ deleteChangeEdit = Delete Change Edit?\n\
\n\
All changes made in the edit revision will be lost.
deleteChange = Delete Change?
deleteDraftRevision = Delete Draft Revision?

View File

@@ -234,8 +234,6 @@ public class ChangeScreen extends Screen {
@UiField Button publishEdit;
@UiField Button rebaseEdit;
@UiField Button deleteEdit;
@UiField Button publish;
@UiField Button deleteRevision;
@UiField Button openAll;
@UiField Button editMode;
@UiField Button reviewMode;
@@ -562,8 +560,7 @@ public class ChangeScreen extends Screen {
}
}
private void initRevisionsAction(
ChangeInfo info, String revision, NativeMap<ActionInfo> actions) {
private void initRevisionsAction(ChangeInfo info, String revision) {
int currentPatchSet;
if (info.currentRevision() != null && info.revisions().containsKey(info.currentRevision())) {
currentPatchSet = info.revision(info.currentRevision())._number();
@@ -591,18 +588,6 @@ public class ChangeScreen extends Screen {
patchSetsAction =
new PatchSetsAction(
info.projectNameKey(), info.legacyId(), revision, edit, style, headerLine, patchSets);
RevisionInfo revInfo = info.revision(revision);
if (revInfo.draft()) {
if (actions.containsKey("publish")) {
publish.setVisible(true);
publish.setTitle(actions.get("publish").title());
}
if (actions.containsKey("/")) {
deleteRevision.setVisible(true);
deleteRevision.setTitle(actions.get("/").title());
}
}
}
private void initDownloadAction(ChangeInfo info, String revision) {
@@ -702,18 +687,6 @@ public class ChangeScreen extends Screen {
}
}
@UiHandler("publish")
void onPublish(@SuppressWarnings("unused") ClickEvent e) {
ChangeActions.publish(getProject(), changeId, revision, publish, deleteRevision);
}
@UiHandler("deleteRevision")
void onDeleteRevision(@SuppressWarnings("unused") ClickEvent e) {
if (Window.confirm(Resources.C.deleteDraftRevision())) {
ChangeActions.delete(getProject(), changeId, revision, publish, deleteRevision);
}
}
@Override
public void registerKeys() {
super.registerKeys();
@@ -1323,10 +1296,7 @@ public class ChangeScreen extends Screen {
}
private boolean isSubmittable(ChangeInfo info) {
boolean canSubmit =
info.status().isOpen()
&& revision.equals(info.currentRevision())
&& !info.revision(revision).draft();
boolean canSubmit = info.status().isOpen() && revision.equals(info.currentRevision());
if (canSubmit && info.status() == Change.Status.NEW) {
for (String name : info.labels()) {
LabelInfo label = info.label(name);
@@ -1404,7 +1374,7 @@ public class ChangeScreen extends Screen {
// Properly render revision actions initially while waiting for
// the callback to populate them correctly.
NativeMap<ActionInfo> emptyMap = NativeMap.<ActionInfo>create();
initRevisionsAction(info, revision, emptyMap);
initRevisionsAction(info, revision);
quickApprove.setVisible(false);
actions.reloadRevisionActions(emptyMap);
@@ -1416,8 +1386,7 @@ public class ChangeScreen extends Screen {
statusText.setInnerText(Util.C.notCurrent());
labels.setVisible(false);
} else {
Status s = info.revision(revision).draft() ? Status.DRAFT : info.status();
statusText.setInnerText(Util.toLongString(s));
statusText.setInnerText(Util.toLongString(info.status()));
}
if (info.isPrivate()) {
@@ -1444,7 +1413,7 @@ public class ChangeScreen extends Screen {
}
private void renderRevisionInfo(ChangeInfo info, NativeMap<ActionInfo> actionMap) {
initRevisionsAction(info, revision, actionMap);
initRevisionsAction(info, revision);
commit.setParentNotCurrent(
actionMap.containsKey("rebase") && actionMap.get("rebase").enabled());
actions.reloadRevisionActions(actionMap);

View File

@@ -415,13 +415,6 @@ limitations under the License.
<g:Button ui:field='deleteEdit' styleName='' visible='false'>
<div><ui:msg>Delete Edit</ui:msg></div>
</g:Button>
<g:Button ui:field='publish'
styleName='{style.highlight}' visible='false'>
<div><ui:msg>Publish</ui:msg></div>
</g:Button>
<g:Button ui:field='deleteRevision' styleName='' visible='false'>
<div><ui:msg>Delete Revision</ui:msg></div>
</g:Button>
<g:SimplePanel ui:field='headerExtensionMiddle' styleName='{style.headerExtension}'/>
</div>
</div>

View File

@@ -192,9 +192,6 @@ class PatchSetsBox extends Composite {
}
sb.openTd().setStyleName(style.legacy_id());
if (r.draft()) {
sb.append(Resources.C.draft()).append(' ');
}
sb.append(r.id());
sb.closeTd();

View File

@@ -49,7 +49,7 @@ class QuickApprove extends Button implements ClickHandler {
setVisible(false);
return;
}
if (info.revision(commit).isEdit() || info.revision(commit).draft()) {
if (info.revision(commit).isEdit()) {
setVisible(false);
return;
}

View File

@@ -245,25 +245,12 @@ public class ChangeApi {
call(project, id, commit, "submit").post(in, cb);
}
/** Publish a specific revision of a draft change. */
public static void publish(
@Nullable String project, int id, String commit, AsyncCallback<JavaScriptObject> cb) {
JavaScriptObject in = JavaScriptObject.createObject();
call(project, id, commit, "publish").post(in, cb);
}
/** Delete a specific draft change. */
public static void deleteChange(
@Nullable String project, int id, AsyncCallback<JavaScriptObject> cb) {
change(project, id).delete(cb);
}
/** Delete a specific draft patch set. */
public static void deleteRevision(
@Nullable String project, int id, String commit, AsyncCallback<JavaScriptObject> cb) {
revision(project, id, commit).delete(cb);
}
/** Delete change edit. */
public static void deleteEdit(
@Nullable String project, int id, AsyncCallback<JavaScriptObject> cb) {

View File

@@ -30,8 +30,6 @@ public class Util {
return "";
}
switch (status) {
case DRAFT:
return C.statusLongDraft();
case NEW:
return C.statusLongNew();
case MERGED:

View File

@@ -398,7 +398,6 @@ abstract class DiffScreen extends Screen {
if (Gerrit.isSignedIn()) {
keyMap
.on("G I", () -> Gerrit.display(PageLinks.MINE))
.on("G D", () -> Gerrit.display(PageLinks.toChangeQuery("owner:self is:draft")))
.on("G C", () -> Gerrit.display(PageLinks.toChangeQuery("has:draft")))
.on("G W", () -> Gerrit.display(PageLinks.toChangeQuery("is:watched status:open")))
.on("G S", () -> Gerrit.display(PageLinks.toChangeQuery("is:starred")));