Allow RestApiView<RevisionResource> to add buttons on patch sets
RestApiViews that accept a RevisionResource may now also describe buttons that should appear on a patch set. Description is given to Gerrit by implementing the UiCommand interface and returning useful information from the getter methods. Change-Id: I2b9445e73448968f1e3234812cc28b57e9ec7250
This commit is contained in:
@@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PatchSetDetail {
|
||||
@@ -26,6 +27,7 @@ public class PatchSetDetail {
|
||||
protected PatchSetInfo info;
|
||||
protected List<Patch> patches;
|
||||
protected Project.NameKey project;
|
||||
protected List<UiCommandDetail> commands;
|
||||
|
||||
public PatchSetDetail() {
|
||||
}
|
||||
@@ -61,4 +63,15 @@ public class PatchSetDetail {
|
||||
public void setProject(final Project.NameKey p) {
|
||||
project = p;
|
||||
}
|
||||
|
||||
public List<UiCommandDetail> getCommands() {
|
||||
if (commands != null) {
|
||||
return commands;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void setCommands(List<UiCommandDetail> cmds) {
|
||||
commands = cmds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
/** Detail necessary to display an action. */
|
||||
public class UiCommandDetail {
|
||||
public String id;
|
||||
public String method;
|
||||
public String label;
|
||||
public String title;
|
||||
public boolean enabled;
|
||||
}
|
||||
Reference in New Issue
Block a user