Merge "In ProjectAccessScreen add link to history of project.config in gitweb"
This commit is contained in:
@@ -31,6 +31,7 @@ public class GitWebType {
|
||||
type.setProject("?p=${project}.git;a=summary");
|
||||
type.setRevision("?p=${project}.git;a=commit;h=${commit}");
|
||||
type.setBranch("?p=${project}.git;a=shortlog;h=${branch}");
|
||||
type.setFileHistory("?p=${project}.git;a=history;hb=${branch};f=${file}");
|
||||
|
||||
} else if (name.equalsIgnoreCase("cgit")) {
|
||||
type = new GitWebType();
|
||||
@@ -38,6 +39,7 @@ public class GitWebType {
|
||||
type.setProject("${project}/summary");
|
||||
type.setRevision("${project}/commit/?id=${commit}");
|
||||
type.setBranch("${project}/log/?h=${branch}");
|
||||
type.setFileHistory("${project}/log/${file}?h=${branch}");
|
||||
|
||||
} else if (name.equalsIgnoreCase("custom")) {
|
||||
type = new GitWebType();
|
||||
@@ -66,6 +68,9 @@ public class GitWebType {
|
||||
/** ParamertizedString for branch view url. */
|
||||
private String branch;
|
||||
|
||||
/** ParamertizedString for file history view url. */
|
||||
private String fileHistory;
|
||||
|
||||
/** Private default constructor for gson. */
|
||||
protected GitWebType() {
|
||||
}
|
||||
@@ -106,6 +111,15 @@ public class GitWebType {
|
||||
return revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the String for file history view.
|
||||
*
|
||||
* @return The String for file history view
|
||||
*/
|
||||
public String getFileHistory() {
|
||||
return fileHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pattern for branch view.
|
||||
*
|
||||
@@ -149,4 +163,15 @@ public class GitWebType {
|
||||
revision = pattern;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pattern for file history view.
|
||||
*
|
||||
* @param pattern The pattern for file history view
|
||||
*/
|
||||
public void setFileHistory(final String pattern) {
|
||||
if (pattern != null && !pattern.isEmpty()) {
|
||||
fileHistory = pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +65,14 @@ public class GitwebLink {
|
||||
p.put("branch", URL.encodeQueryString(branch.get()));
|
||||
return baseUrl + pattern.replace(p);
|
||||
}
|
||||
|
||||
public String toFileHistory(final Branch.NameKey branch, final String file) {
|
||||
ParameterizedString pattern = new ParameterizedString(type.getFileHistory());
|
||||
|
||||
final Map<String, String> p = new HashMap<String, String>();
|
||||
p.put("project", URL.encodeQueryString(branch.getParentKey().get()));
|
||||
p.put("branch", URL.encodeQueryString(branch.get()));
|
||||
p.put("file", URL.encodeQueryString(file));
|
||||
return baseUrl + pattern.replace(p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,24 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProjectAccess {
|
||||
protected Project.NameKey projectName;
|
||||
protected String revision;
|
||||
protected Project.NameKey inheritsFrom;
|
||||
protected List<AccessSection> local;
|
||||
protected Set<String> ownerOf;
|
||||
protected boolean isConfigVisible;
|
||||
|
||||
public ProjectAccess() {
|
||||
}
|
||||
|
||||
public Project.NameKey getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(Project.NameKey projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getRevision() {
|
||||
return revision;
|
||||
}
|
||||
@@ -76,4 +86,12 @@ public class ProjectAccess {
|
||||
public void setOwnerOf(Set<String> refs) {
|
||||
ownerOf = refs;
|
||||
}
|
||||
|
||||
public boolean isConfigVisible() {
|
||||
return isConfigVisible;
|
||||
}
|
||||
|
||||
public void setConfigVisible(boolean isConfigVisible) {
|
||||
this.isConfigVisible = isConfigVisible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
package com.google.gerrit.client.admin;
|
||||
|
||||
import com.google.gerrit.client.Dispatcher;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.ui.Hyperlink;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GitwebLink;
|
||||
import com.google.gerrit.common.data.ProjectAccess;
|
||||
import com.google.gerrit.reviewdb.Branch;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.DivElement;
|
||||
@@ -52,6 +55,12 @@ public class ProjectAccessEditor extends Composite implements
|
||||
@UiField
|
||||
Hyperlink parentProject;
|
||||
|
||||
@UiField
|
||||
DivElement history;
|
||||
|
||||
@UiField
|
||||
Anchor gitweb;
|
||||
|
||||
@UiField
|
||||
FlowPanel localContainer;
|
||||
ListEditor<AccessSection, AccessSectionEditor> local;
|
||||
@@ -101,6 +110,16 @@ public class ProjectAccessEditor extends Composite implements
|
||||
inheritsFrom.getStyle().setDisplay(Display.NONE);
|
||||
}
|
||||
|
||||
final GitwebLink c = Gerrit.getConfig().getGitwebLink();
|
||||
if (value.isConfigVisible() && c != null) {
|
||||
history.getStyle().setDisplay(Display.BLOCK);
|
||||
gitweb.setText(c.getLinkName());
|
||||
gitweb.setHref(c.toFileHistory(new Branch.NameKey(value.getProjectName(),
|
||||
"refs/meta/config"), "project.config"));
|
||||
} else {
|
||||
history.getStyle().setDisplay(Display.NONE);
|
||||
}
|
||||
|
||||
addSection.setVisible(value != null && editing && !value.getOwnerOf().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,16 @@ limitations under the License.
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.history {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.historyTitle {
|
||||
font-weight: bold;
|
||||
}
|
||||
.gitwebLink {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.addContainer {
|
||||
margin-top: 5px;
|
||||
font-size: 80%;
|
||||
@@ -47,6 +57,10 @@ limitations under the License.
|
||||
<span class='{style.parentTitle}'><ui:msg>Rights Inherit From:</ui:msg></span>
|
||||
<q:Hyperlink ui:field='parentProject' styleName='{style.parentLink}'/>
|
||||
</div>
|
||||
<div ui:field='history' class='{style.history}'>
|
||||
<span class='{style.historyTitle}'><ui:msg>History:</ui:msg></span>
|
||||
<g:Anchor ui:field='gitweb' styleName='{style.gitwebLink}'></g:Anchor>
|
||||
</div>
|
||||
|
||||
<g:FlowPanel ui:field='localContainer'/>
|
||||
<div class='{style.addContainer}'>
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
@@ -177,6 +178,7 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
|
||||
}
|
||||
|
||||
final ProjectAccess detail = new ProjectAccess();
|
||||
detail.setProjectName(projectName);
|
||||
detail.setRevision(config.getRevision().name());
|
||||
|
||||
if (projectName.equals(allProjectsName)) {
|
||||
@@ -194,6 +196,8 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
|
||||
|
||||
detail.setLocal(local);
|
||||
detail.setOwnerOf(ownerOf);
|
||||
detail.setConfigVisible(pc.isOwner()
|
||||
|| pc.controlForRef(GitRepositoryManager.REF_CONFIG).isVisible());
|
||||
return detail;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user