mirror of
https://github.com/theonedev/onedev.git
synced 2025-12-08 18:26:30 +00:00
Merge branch 'polish-commit-status'
This commit is contained in:
commit
04aa3c9d73
@ -7,9 +7,11 @@
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
<div class="body">
|
||||
<div wicket:id="builds" class="build clearfix">
|
||||
<span wicket:id="status" class="status pull-left"></span>
|
||||
<a wicket:id="title" class="title pull-right"><span wicket:id="label"></span></a>
|
||||
<div wicket:id="builds">
|
||||
<a wicket:id="build" class="build clearfix">
|
||||
<span wicket:id="status" class="status pull-left"></span>
|
||||
<span wicket:id="title" class="title pull-right"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -45,8 +45,11 @@ public class SimpleBuildListPanel extends GenericPanel<List<Build>> {
|
||||
protected void populateItem(ListItem<Build> item) {
|
||||
Build build = item.getModelObject();
|
||||
|
||||
Link<Void> buildLink = new BookmarkablePageLink<Void>("build",
|
||||
BuildLogPage.class, BuildLogPage.paramsOf(build, null));
|
||||
|
||||
Long buildId = build.getId();
|
||||
item.add(new BuildStatusIcon("status", new LoadableDetachableModel<Status>() {
|
||||
buildLink.add(new BuildStatusIcon("status", new LoadableDetachableModel<Status>() {
|
||||
|
||||
@Override
|
||||
protected Status load() {
|
||||
@ -55,13 +58,10 @@ public class SimpleBuildListPanel extends GenericPanel<List<Build>> {
|
||||
|
||||
}));
|
||||
|
||||
Link<Void> buildLink = new BookmarkablePageLink<Void>("title",
|
||||
BuildLogPage.class, BuildLogPage.paramsOf(build, null));
|
||||
|
||||
StringBuilder builder = new StringBuilder("#" + build.getNumber());
|
||||
if (build.getVersion() != null)
|
||||
builder.append(" (" + build.getVersion() + ")");
|
||||
buildLink.add(new Label("label", builder.toString()));
|
||||
buildLink.add(new Label("title", builder.toString()));
|
||||
item.add(buildLink);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
.simple-build-list>.head {
|
||||
padding: 8px 16px;
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #DDD;
|
||||
margin-bottom: 4px;
|
||||
min-width: 100px;
|
||||
@ -14,20 +14,20 @@
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.simple-build-list>.body>.build {
|
||||
padding: 4px 16px;
|
||||
.simple-build-list>.body {
|
||||
padding: 0 8px;
|
||||
}
|
||||
.simple-build-list>.body>.build>.title {
|
||||
margin: -2px 0 0 8px;
|
||||
.simple-build-list>.body>div>.build {
|
||||
padding: 4px 0;
|
||||
display: block;
|
||||
}
|
||||
.simple-build-list>.body>div:hover {
|
||||
.simple-build-list>.body>div>.build>.title {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.simple-build-list>.body>div>.build:hover {
|
||||
background: #F0F0F0;
|
||||
}
|
||||
.simple-build-list>.body>.no-builds {
|
||||
font-style: italic;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.commit-status, .commit-status>.job {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@ -2,9 +2,6 @@ package io.onedev.server.web.component.build.status;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.head.CssHeaderItem;
|
||||
@ -44,10 +41,6 @@ public class BuildStatusIcon extends GenericPanel<Status> {
|
||||
if (status == Status.RUNNING)
|
||||
cssClass += " fa-spin";
|
||||
tag.put("class", cssClass);
|
||||
|
||||
String title = getTooltip(status);
|
||||
if (title != null)
|
||||
tag.put("title", title);
|
||||
}
|
||||
|
||||
});
|
||||
@ -82,20 +75,6 @@ public class BuildStatusIcon extends GenericPanel<Status> {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getTooltip(@Nullable Status status) {
|
||||
String title;
|
||||
if (status == Status.WAITING)
|
||||
title = "Waiting for completion of dependency builds";
|
||||
else if (status == Status.PENDING)
|
||||
title = "Pending (preparing environments and/or waiting for resources)";
|
||||
else if (status != null)
|
||||
title = StringUtils.capitalize(status.getDisplayName().toLowerCase());
|
||||
else
|
||||
title = null;
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHead(IHeaderResponse response) {
|
||||
super.renderHead(response);
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
.build-status {
|
||||
font-size: 16px;
|
||||
}
|
||||
.build-status-running {
|
||||
font-size: 14px;
|
||||
}
|
||||
.build-status-successful:before {
|
||||
content: "\f058";
|
||||
}
|
||||
|
||||
@ -601,7 +601,14 @@ public class CommitListPanel extends Panel {
|
||||
item.add(new WebMarkupContainer("copyHash").add(new CopyClipboardBehavior(Model.of(commit.name()))));
|
||||
|
||||
getCommitIdsToQueryStatus().add(commit.copy());
|
||||
item.add(new CommitStatusPanel("buildStatus", getProject(), commit.copy()));
|
||||
item.add(new CommitStatusPanel("buildStatus", getProject(), commit.copy()) {
|
||||
|
||||
@Override
|
||||
protected String getCssClasses() {
|
||||
return "btn btn-default";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
item.add(AttributeAppender.append("class", "commit clearfix"));
|
||||
} else {
|
||||
|
||||
@ -68,9 +68,6 @@
|
||||
.commit-list>.body .commit>.pull-right.hash {
|
||||
margin-left: 4px;
|
||||
}
|
||||
.commit-list>.body .commit>.pull-right.build-status {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.commit-list>.body>.list {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
<wicket:panel>
|
||||
<a wicket:id="link" class="commit-status"><span wicket:id="icon"></span></a>
|
||||
<a wicket:id="status" class="commit-status"><span wicket:id="icon"></span> <i class="fa fa-angle-down"></i></a>
|
||||
<wicket:fragment wicket:id="detailFrag">
|
||||
<div class="commit-status-detail">
|
||||
<div wicket:id="jobs" class="job">
|
||||
<div class="head clearfix">
|
||||
<a wicket:id="jobDetailToggle" class="detail pull-left"><span wicket:id="icon"></span></a>
|
||||
<a wicket:id="jobDef" class="def pull-left" title="Goto job definition"><span wicket:id="label"></span></a>
|
||||
<a wicket:id="runJob" class="run pull-right" title="Run this job"><i class="fa fa-play"></i></a>
|
||||
<a wicket:id="name" class="name pull-left"><b wicket:id="label"></b></a>
|
||||
<a wicket:id="run" class="run pull-right" title="Run this job"><i class="fa fa-play"></i></a>
|
||||
<a wicket:id="showInList" class="show-in-list pull-right" title="Show in build list"><i class="fa fa-list-ul"></i></a>
|
||||
</div>
|
||||
<div wicket:id="jobDetail" class="body"></div>
|
||||
<div wicket:id="detail" class="body"></div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:fragment>
|
||||
|
||||
@ -5,9 +5,11 @@ import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.head.CssHeaderItem;
|
||||
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
@ -19,7 +21,6 @@ import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.RepeatingView;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -60,6 +61,15 @@ public class CommitStatusPanel extends Panel {
|
||||
|
||||
};
|
||||
|
||||
private IModel<Status> statusModel = new LoadableDetachableModel<Status>() {
|
||||
|
||||
@Override
|
||||
protected Status load() {
|
||||
return Status.getOverallStatus(getProject().getCommitStatus(commitId).values());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public CommitStatusPanel(String id, Project project, ObjectId commitId) {
|
||||
super(id);
|
||||
|
||||
@ -75,12 +85,8 @@ public class CommitStatusPanel extends Panel {
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
|
||||
DropdownLink link = new DropdownLink("link") {
|
||||
DropdownLink statusLink = new DropdownLink("status") {
|
||||
|
||||
private boolean isShowJobDetail(WebMarkupContainer jobItem) {
|
||||
return (boolean) jobItem.getDefaultModelObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component newContent(String id, FloatingPanel dropdown) {
|
||||
Fragment fragment = new Fragment(id, "detailFrag", CommitStatusPanel.this);
|
||||
@ -88,42 +94,14 @@ public class CommitStatusPanel extends Panel {
|
||||
RepeatingView jobsView = new RepeatingView("jobs");
|
||||
fragment.add(jobsView);
|
||||
for (Job job: jobsModel.getObject()) {
|
||||
WebMarkupContainer jobItem = new WebMarkupContainer(jobsView.newChildId(), Model.of(false));
|
||||
AjaxLink<Void> detailLink = new AjaxLink<Void>("jobDetailToggle") {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
jobItem.setDefaultModelObject(!isShowJobDetail(jobItem));
|
||||
target.add(jobItem);
|
||||
}
|
||||
|
||||
};
|
||||
WebMarkupContainer jobItem = new WebMarkupContainer(jobsView.newChildId());
|
||||
Status status = getProject().getCommitStatus(commitId).get(job.getName());
|
||||
detailLink.add(new BuildStatusIcon("icon", Model.of(status)) {
|
||||
|
||||
@Override
|
||||
protected String getTooltip(Status status) {
|
||||
String title;
|
||||
if (status != null) {
|
||||
if (status != Status.SUCCESSFUL)
|
||||
title = "Some builds in job are ";
|
||||
else
|
||||
title = "Builds in job are ";
|
||||
title += status.getDisplayName().toLowerCase() + ", click to toggle details";
|
||||
} else {
|
||||
title = "No builds in job";
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
});
|
||||
jobItem.add(detailLink);
|
||||
|
||||
Link<Void> defLink = new JobDefLink("jobDef", getProject(), commitId, job.getName());
|
||||
Link<Void> defLink = new JobDefLink("name", getProject(), commitId, job.getName());
|
||||
defLink.add(new Label("label", job.getName()));
|
||||
jobItem.add(defLink);
|
||||
|
||||
jobItem.add(new RunJobLink("runJob", getProject(), commitId, job.getName()) {
|
||||
jobItem.add(new RunJobLink("run", getProject(), commitId, job.getName()) {
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
@ -139,12 +117,12 @@ public class CommitStatusPanel extends Panel {
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(status != null && isShowJobDetail(jobItem));
|
||||
setVisible(status != null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jobItem.add(new SimpleBuildListPanel("jobDetail", new LoadableDetachableModel<List<Build>>() {
|
||||
jobItem.add(new SimpleBuildListPanel("detail", new LoadableDetachableModel<List<Build>>() {
|
||||
|
||||
@Override
|
||||
protected List<Build> load() {
|
||||
@ -154,15 +132,7 @@ public class CommitStatusPanel extends Panel {
|
||||
return builds;
|
||||
}
|
||||
|
||||
}) {
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(isShowJobDetail(jobItem));
|
||||
}
|
||||
|
||||
});
|
||||
}));
|
||||
|
||||
jobItem.setOutputMarkupId(true);
|
||||
jobsView.add(jobItem);
|
||||
@ -170,20 +140,14 @@ public class CommitStatusPanel extends Panel {
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
};
|
||||
link.add(new BuildStatusIcon("icon", new LoadableDetachableModel<Status>() {
|
||||
|
||||
@Override
|
||||
protected Status load() {
|
||||
return Status.getOverallStatus(getProject().getCommitStatus(commitId).values());
|
||||
}
|
||||
|
||||
}) {
|
||||
|
||||
@Override
|
||||
protected String getTooltip(Status status) {
|
||||
protected void onComponentTag(ComponentTag tag) {
|
||||
super.onComponentTag(tag);
|
||||
|
||||
String cssClasses = "commit-status ";
|
||||
String title;
|
||||
Build.Status status = statusModel.getObject();
|
||||
if (status != null) {
|
||||
if (status != Status.SUCCESSFUL)
|
||||
title = "Some builds are ";
|
||||
@ -193,22 +157,29 @@ public class CommitStatusPanel extends Panel {
|
||||
} else {
|
||||
title = "No builds";
|
||||
}
|
||||
return title;
|
||||
if (getCssClasses() != null)
|
||||
cssClasses += getCssClasses();
|
||||
tag.put("class", cssClasses);
|
||||
tag.put("title", title);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
statusLink.add(new BuildStatusIcon("icon", statusModel) {
|
||||
|
||||
@Override
|
||||
protected Collection<String> getWebSocketObservables() {
|
||||
return Lists.newArrayList("commit-status:" + getProject().getId() + ":" + commitId.name());
|
||||
}
|
||||
|
||||
});
|
||||
add(link);
|
||||
add(statusLink);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetach() {
|
||||
projectModel.detach();
|
||||
jobsModel.detach();
|
||||
statusModel.detach();
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@ -224,4 +195,9 @@ public class CommitStatusPanel extends Panel {
|
||||
response.render(CssHeaderItem.forReference(new CommitStatusCssResourceReference()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getCssClasses() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
.commit-status-detail {
|
||||
padding: 12px;
|
||||
}
|
||||
.commit-status-detail>.job {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.commit-status-detail>.job>.head {
|
||||
padding: 4px 0;
|
||||
}
|
||||
.commit-status-detail>.job>.head>.detail {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.commit-status-detail>.job>.head>.def {
|
||||
.commit-status-detail>.job>.head>.name {
|
||||
margin-right: 40px;
|
||||
}
|
||||
.commit-status-detail>.job>.head>.run {
|
||||
@ -22,8 +22,8 @@
|
||||
}
|
||||
.commit-status-detail>.job>.body {
|
||||
border-top: 1px solid #D8D8D8;
|
||||
padding: 8px 0 0 8px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
.commit-status-detail>.job>.head>.detail {
|
||||
margin-top: 2px;
|
||||
.commit-status-detail>.job>.body .body {
|
||||
padding: 0;
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
<wicket:panel>
|
||||
<a wicket:id="link" class="job-status"><span wicket:id="icon"></span></a>
|
||||
</wicket:panel>
|
||||
@ -1,140 +0,0 @@
|
||||
package io.onedev.server.web.component.job;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.markup.head.CssHeaderItem;
|
||||
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import io.onedev.server.OneDev;
|
||||
import io.onedev.server.ci.job.Job;
|
||||
import io.onedev.server.entitymanager.BuildManager;
|
||||
import io.onedev.server.model.Build;
|
||||
import io.onedev.server.model.Build.Status;
|
||||
import io.onedev.server.model.Project;
|
||||
import io.onedev.server.web.component.build.simplelist.SimpleBuildListPanel;
|
||||
import io.onedev.server.web.component.build.status.BuildStatusIcon;
|
||||
import io.onedev.server.web.component.commit.status.CommitStatusCssResourceReference;
|
||||
import io.onedev.server.web.component.floating.FloatingPanel;
|
||||
import io.onedev.server.web.component.link.DropdownLink;
|
||||
import io.onedev.server.web.model.EntityModel;
|
||||
import io.onedev.server.web.page.project.builds.ProjectBuildsPage;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class JobStatusPanel extends Panel {
|
||||
|
||||
private final IModel<Project> projectModel;
|
||||
|
||||
private final ObjectId commitId;
|
||||
|
||||
private final String jobName;
|
||||
|
||||
private final IModel<Status> statusModel = new LoadableDetachableModel<Status>() {
|
||||
|
||||
@Override
|
||||
protected Status load() {
|
||||
return getProject().getCommitStatus(commitId).get(jobName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public JobStatusPanel(String id, Project project, ObjectId commitId, String jobName) {
|
||||
super(id);
|
||||
|
||||
this.projectModel = new EntityModel<Project>(project);
|
||||
this.commitId = commitId;
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
|
||||
DropdownLink link = new DropdownLink("link") {
|
||||
|
||||
@Override
|
||||
protected Component newContent(String id, FloatingPanel dropdown) {
|
||||
return new SimpleBuildListPanel(id, new LoadableDetachableModel<List<Build>>() {
|
||||
|
||||
@Override
|
||||
protected List<Build> load() {
|
||||
BuildManager buildManager = OneDev.getInstance(BuildManager.class);
|
||||
List<Build> builds = new ArrayList<>(buildManager.query(getProject(), commitId, jobName));
|
||||
builds.sort(Comparator.comparing(Build::getNumber));
|
||||
return builds;
|
||||
}
|
||||
|
||||
}) {
|
||||
|
||||
@Override
|
||||
protected Component newListLink(String componentId) {
|
||||
return new BookmarkablePageLink<Void>(componentId, ProjectBuildsPage.class,
|
||||
ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, jobName), 0)) {
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(!getBuilds().isEmpty());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
link.add(new BuildStatusIcon("icon", statusModel) {
|
||||
|
||||
@Override
|
||||
protected String getTooltip(Status status) {
|
||||
String title;
|
||||
if (status != null) {
|
||||
if (status != Status.SUCCESSFUL)
|
||||
title = "Some builds are ";
|
||||
else
|
||||
title = "Builds are ";
|
||||
title += status.getDisplayName().toLowerCase() + ", click for details";
|
||||
} else {
|
||||
title = "No builds";
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getWebSocketObservables() {
|
||||
return Lists.newArrayList("job-status:" + getProject().getId() + ":" + commitId.name() + ":" + jobName);
|
||||
}
|
||||
|
||||
});
|
||||
add(link);
|
||||
}
|
||||
|
||||
private Project getProject() {
|
||||
return projectModel.getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetach() {
|
||||
projectModel.detach();
|
||||
statusModel.detach();
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHead(IHeaderResponse response) {
|
||||
super.renderHead(response);
|
||||
response.render(CssHeaderItem.forReference(new CommitStatusCssResourceReference()));
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,11 +26,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<wicket:enclosure child="jobs">
|
||||
<div class="jobs">
|
||||
<div wicket:id="jobs" class="job">
|
||||
<span wicket:id="status" class="status"></span>
|
||||
<a wicket:id="name" class="name"><span wicket:id="label"></span></a>
|
||||
<a wicket:id="run" class="run" title="Run this job"><i class="fa fa-play"></i></a>
|
||||
<div class="jobs clearfix">
|
||||
<div wicket:id="jobs" class="job pull-left">
|
||||
<span class="btn-group">
|
||||
<a wicket:id="detail" class="btn btn-default">
|
||||
<span wicket:id="status" class="status"></span>
|
||||
<b wicket:id="name" class="name"></b>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</a>
|
||||
<a wicket:id="run" class="run btn btn-default" title="Run this job"><i class="fa fa-play"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
|
||||
@ -3,6 +3,7 @@ package io.onedev.server.web.page.project.commits;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -14,12 +15,15 @@ import org.apache.wicket.Component;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.behavior.AttributeAppender;
|
||||
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
|
||||
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.head.IHeaderResponse;
|
||||
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
|
||||
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
@ -35,16 +39,20 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.onedev.server.OneDev;
|
||||
import io.onedev.server.cache.CommitInfoManager;
|
||||
import io.onedev.server.ci.CISpec;
|
||||
import io.onedev.server.ci.job.Job;
|
||||
import io.onedev.server.entitymanager.BuildManager;
|
||||
import io.onedev.server.entitymanager.CodeCommentManager;
|
||||
import io.onedev.server.git.BlobIdent;
|
||||
import io.onedev.server.git.GitUtils;
|
||||
import io.onedev.server.git.RefInfo;
|
||||
import io.onedev.server.model.Build;
|
||||
import io.onedev.server.model.Build.Status;
|
||||
import io.onedev.server.model.CodeComment;
|
||||
import io.onedev.server.model.Project;
|
||||
import io.onedev.server.model.PullRequest;
|
||||
@ -53,20 +61,24 @@ import io.onedev.server.search.code.CommitIndexed;
|
||||
import io.onedev.server.security.SecurityUtils;
|
||||
import io.onedev.server.util.CommitMessageTransformer;
|
||||
import io.onedev.server.util.diff.WhitespaceOption;
|
||||
import io.onedev.server.web.behavior.WebSocketObserver;
|
||||
import io.onedev.server.web.behavior.clipboard.CopyClipboardBehavior;
|
||||
import io.onedev.server.web.component.branch.create.CreateBranchLink;
|
||||
import io.onedev.server.web.component.build.simplelist.SimpleBuildListPanel;
|
||||
import io.onedev.server.web.component.build.status.BuildStatusIcon;
|
||||
import io.onedev.server.web.component.contributorpanel.ContributorPanel;
|
||||
import io.onedev.server.web.component.createtag.CreateTagLink;
|
||||
import io.onedev.server.web.component.diff.revision.CommentSupport;
|
||||
import io.onedev.server.web.component.diff.revision.RevisionDiffPanel;
|
||||
import io.onedev.server.web.component.job.JobDefLink;
|
||||
import io.onedev.server.web.component.job.JobStatusPanel;
|
||||
import io.onedev.server.web.component.floating.FloatingPanel;
|
||||
import io.onedev.server.web.component.job.RunJobLink;
|
||||
import io.onedev.server.web.component.link.DropdownLink;
|
||||
import io.onedev.server.web.component.link.ViewStateAwarePageLink;
|
||||
import io.onedev.server.web.component.user.contributoravatars.ContributorAvatars;
|
||||
import io.onedev.server.web.page.project.ProjectPage;
|
||||
import io.onedev.server.web.page.project.blob.ProjectBlobPage;
|
||||
import io.onedev.server.web.page.project.branches.ProjectBranchesPage;
|
||||
import io.onedev.server.web.page.project.builds.ProjectBuildsPage;
|
||||
import io.onedev.server.web.page.project.tags.ProjectTagsPage;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ -244,10 +256,101 @@ public class CommitDetailPage extends ProjectPage implements CommentSupport {
|
||||
protected void populateItem(ListItem<Job> item) {
|
||||
ObjectId commitId = getCommit().copy();
|
||||
Job job = item.getModelObject();
|
||||
Link<Void> jobLink = new JobDefLink("name", getProject(), commitId, job.getName());
|
||||
jobLink.add(new Label("label", job.getName()));
|
||||
item.add(jobLink);
|
||||
item.add(new JobStatusPanel("status", getProject(), commitId, job.getName()));
|
||||
|
||||
DropdownLink detailLink = new DropdownLink("detail") {
|
||||
|
||||
@Override
|
||||
protected Component newContent(String id, FloatingPanel dropdown) {
|
||||
return new SimpleBuildListPanel(id, new LoadableDetachableModel<List<Build>>() {
|
||||
|
||||
@Override
|
||||
protected List<Build> load() {
|
||||
BuildManager buildManager = OneDev.getInstance(BuildManager.class);
|
||||
List<Build> builds = new ArrayList<>(buildManager.query(getProject(), commitId, job.getName()));
|
||||
builds.sort(Comparator.comparing(Build::getNumber));
|
||||
return builds;
|
||||
}
|
||||
|
||||
}) {
|
||||
|
||||
@Override
|
||||
protected Component newListLink(String componentId) {
|
||||
return new BookmarkablePageLink<Void>(componentId, ProjectBuildsPage.class,
|
||||
ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, job.getName()), 0)) {
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(!getBuilds().isEmpty());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onComponentTag(ComponentTag tag) {
|
||||
super.onComponentTag(tag);
|
||||
|
||||
String cssClasses = "btn btn-default";
|
||||
Build.Status status = getProject().getCommitStatus(commitId).get(job.getName());
|
||||
String title;
|
||||
if (status != null) {
|
||||
if (status != Status.SUCCESSFUL)
|
||||
title = "Some builds are ";
|
||||
else
|
||||
title = "Builds are ";
|
||||
title += status.getDisplayName().toLowerCase() + ", click for details";
|
||||
} else {
|
||||
title = "No builds";
|
||||
cssClasses += " no-builds";
|
||||
}
|
||||
tag.put("class", cssClasses);
|
||||
tag.put("title", title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setEnabled(getProject().getCommitStatus(commitId).get(job.getName()) != null);
|
||||
}
|
||||
|
||||
};
|
||||
detailLink.add(new BuildStatusIcon("status", new LoadableDetachableModel<Status>() {
|
||||
|
||||
@Override
|
||||
protected Status load() {
|
||||
return getProject().getCommitStatus(commitId).get(job.getName());
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
detailLink.add(new Label("name", job.getName()));
|
||||
|
||||
detailLink.add(new WebSocketObserver() {
|
||||
|
||||
@Override
|
||||
public void onObservableChanged(IPartialPageRequestHandler handler, String observable) {
|
||||
handler.add(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionOpened(IPartialPageRequestHandler handler) {
|
||||
handler.add(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getObservables() {
|
||||
return Lists.newArrayList("job-status:" + getProject().getId() + ":" + commitId.name() + ":" + job.getName());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
detailLink.setOutputMarkupId(true);
|
||||
item.add(detailLink);
|
||||
|
||||
item.add(new RunJobLink("run", getProject(), commitId, job.getName()));
|
||||
}
|
||||
|
||||
|
||||
@ -86,16 +86,8 @@
|
||||
}
|
||||
|
||||
#commit-detail>.jobs>.job {
|
||||
border: 2px solid #DDD;
|
||||
padding: 4px 8px;
|
||||
margin-right: 20px;
|
||||
background: #F9F9F9;
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
}
|
||||
#commit-detail>.jobs>.job>.run {
|
||||
margin-left: 20px;
|
||||
color: #666;
|
||||
#commit-detail>.jobs>.job .no-builds i {
|
||||
display: none;
|
||||
}
|
||||
@ -104,11 +104,14 @@
|
||||
</wicket:enclosure>
|
||||
<wicket:enclosure child="jobs">
|
||||
<div class="jobs">
|
||||
<div class="head">Builds</div>
|
||||
<div class="body">
|
||||
<div wicket:id="jobs" class="job clearfix">
|
||||
<a wicket:id="status" class="status pull-left"><span wicket:id="icon"></span></a>
|
||||
<a wicket:id="name" class="name pull-left"><span wicket:id="label"></span></a>
|
||||
<div class="head">Jobs</div>
|
||||
<div class="body clearfix">
|
||||
<div wicket:id="jobs" class="job pull-left">
|
||||
<a wicket:id="job" class="btn btn-default">
|
||||
<span wicket:id="status" class="status"></span>
|
||||
<b wicket:id="name" class="name"></b>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -109,7 +109,6 @@ import io.onedev.server.web.component.build.status.BuildStatusIcon;
|
||||
import io.onedev.server.web.component.entity.nav.EntityNavPanel;
|
||||
import io.onedev.server.web.component.entity.watches.EntityWatchesPanel;
|
||||
import io.onedev.server.web.component.floating.FloatingPanel;
|
||||
import io.onedev.server.web.component.job.JobDefLink;
|
||||
import io.onedev.server.web.component.link.DropdownLink;
|
||||
import io.onedev.server.web.component.link.ViewStateAwarePageLink;
|
||||
import io.onedev.server.web.component.markdown.AttachmentSupport;
|
||||
@ -527,11 +526,15 @@ public abstract class PullRequestDetailPage extends ProjectPage {
|
||||
PullRequest request = getPullRequest();
|
||||
MergePreview preview = request.getMergePreview();
|
||||
Preconditions.checkState(preview != null && preview.getMerged() != null);
|
||||
ObjectId commitId = ObjectId.fromString(preview.getMerged());
|
||||
Project project = request.getTargetProject();
|
||||
String jobName = item.getModelObject();
|
||||
|
||||
WebMarkupContainer link = new DropdownLink("status") {
|
||||
Status status = Status.getOverallStatus(request.getPullRequestBuilds()
|
||||
.stream()
|
||||
.filter(it->it.getBuild().getJobName().equals(jobName))
|
||||
.map(it->it.getBuild().getStatus())
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
WebMarkupContainer link = new DropdownLink("job") {
|
||||
|
||||
@Override
|
||||
protected Component newContent(String id, FloatingPanel dropdown) {
|
||||
@ -562,19 +565,10 @@ public abstract class PullRequestDetailPage extends ProjectPage {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Status status = Status.getOverallStatus(request.getPullRequestBuilds()
|
||||
.stream()
|
||||
.filter(it->it.getBuild().getJobName().equals(jobName))
|
||||
.map(it->it.getBuild().getStatus())
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
link.add(new BuildStatusIcon("icon", Model.of(status)) {
|
||||
|
||||
@Override
|
||||
protected String getTooltip(Status status) {
|
||||
protected void onComponentTag(ComponentTag tag) {
|
||||
super.onComponentTag(tag);
|
||||
String title;
|
||||
if (status != null) {
|
||||
if (status != Status.SUCCESSFUL)
|
||||
@ -585,14 +579,15 @@ public abstract class PullRequestDetailPage extends ProjectPage {
|
||||
} else {
|
||||
title = "No builds";
|
||||
}
|
||||
return title;
|
||||
tag.put("title", title);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
link.add(new BuildStatusIcon("status", Model.of(status)));
|
||||
item.add(link);
|
||||
|
||||
link = new JobDefLink("name", project, commitId, jobName);
|
||||
link.add(new Label("label", jobName));
|
||||
link.add(new Label("name", jobName));
|
||||
item.add(link);
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,14 @@ class PullRequestUpdatedPanel extends GenericPanel<PullRequestUpdate> {
|
||||
Project project = getUpdate().getRequest().getTarget().getProject();
|
||||
item.add(new CommitMessagePanel("message", project, item.getModel()));
|
||||
|
||||
item.add(new CommitStatusPanel("buildStatus", project, commit.copy()));
|
||||
item.add(new CommitStatusPanel("buildStatus", project, commit.copy()) {
|
||||
|
||||
@Override
|
||||
protected String getCssClasses() {
|
||||
return "btn btn-default btn-xs";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
CommitDetailPage.State commitState = new CommitDetailPage.State();
|
||||
commitState.revision = commit.name();
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
width: 35px;
|
||||
}
|
||||
#request-detail>.main>.activities .PullRequestUpdatedActivity>td.content td.hash-and-status {
|
||||
width: 160px;
|
||||
width: 170px;
|
||||
}
|
||||
#request-detail>.main>.activities .PullRequestUpdatedActivity>td.content td.hash-and-status>span {
|
||||
margin-left: 8px;
|
||||
|
||||
@ -112,7 +112,14 @@ public class MergePreviewPage extends PullRequestDetailPage {
|
||||
fragment.add(hashLink);
|
||||
hashLink.add(new Label("hash", GitUtils.abbreviateSHA(preview.getMerged())));
|
||||
fragment.add(new WebMarkupContainer("copyMergedCommit").add(new CopyClipboardBehavior(Model.of(preview.getMerged()))));
|
||||
fragment.add(new CommitStatusPanel("buildStatus", getProject(), ObjectId.fromString(preview.getMerged())));
|
||||
fragment.add(new CommitStatusPanel("buildStatus", getProject(), ObjectId.fromString(preview.getMerged())) {
|
||||
|
||||
@Override
|
||||
protected String getCssClasses() {
|
||||
return "btn btn-default";
|
||||
}
|
||||
|
||||
});
|
||||
fragment.add(new WebMarkupContainer("outDated") {
|
||||
|
||||
@Override
|
||||
|
||||
@ -134,13 +134,11 @@ ul>li>a.code-comments.new .fa-circle {
|
||||
padding-top: 0;
|
||||
}
|
||||
#request-detail>.side-info>.content>.jobs>.body>.job {
|
||||
margin-bottom: 4px;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
#request-detail>.side-info>.content>.jobs>.body>.job:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#request-detail>.side-info>.content>.jobs>.body>.job>.name {
|
||||
margin: -3px 0 0 4px;
|
||||
#request-detail>.side-info>.content>.jobs>.body {
|
||||
margin-bottom: -8px;
|
||||
}
|
||||
|
||||
.floating>.content>.instruction {
|
||||
|
||||
@ -43,7 +43,7 @@ public class KubernetesModule extends AbstractPluginModule {
|
||||
@Override
|
||||
public JobExecutor discover() {
|
||||
Commandline kubectl = new Commandline("kubectl");
|
||||
kubectl.addArgs("version");
|
||||
kubectl.addArgs("cluster-info");
|
||||
try {
|
||||
kubectl.execute(new LineConsumer() {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user