summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-06-07 20:55:19 -0400
committerJames Moger <james.moger@gitblit.com>2011-06-07 20:55:19 -0400
commit1fa5e85b2d208636a6237ef8930f200767165baa (patch)
tree8122ba9fae032b513f0e7bbfdba6c143104bac39 /src
parent16856603ec575718857768e2d18e455c95fd6ea4 (diff)
downloadgitblit-1fa5e85b2d208636a6237ef8930f200767165baa.tar.gz
gitblit-1fa5e85b2d208636a6237ef8930f200767165baa.zip
Improved metrics page and added metrics links to branches panel.
Diffstat (limited to 'src')
-rw-r--r--src/com/gitblit/models/RefModel.java5
-rw-r--r--src/com/gitblit/utils/MetricUtils.java21
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties6
-rw-r--r--src/com/gitblit/wicket/pages/MetricsPage.html26
-rw-r--r--src/com/gitblit/wicket/pages/MetricsPage.java55
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.java3
-rw-r--r--src/com/gitblit/wicket/pages/SummaryPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/SummaryPage.java12
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.html20
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.java33
-rw-r--r--src/com/gitblit/wicket/panels/RefsPanel.java8
-rw-r--r--src/com/gitblit/wicket/panels/TagsPanel.java9
-rw-r--r--src/com/gitblit/wicket/resources/gitblit.css23
14 files changed, 145 insertions, 80 deletions
diff --git a/src/com/gitblit/models/RefModel.java b/src/com/gitblit/models/RefModel.java
index 39bf19c9..0b65c092 100644
--- a/src/com/gitblit/models/RefModel.java
+++ b/src/com/gitblit/models/RefModel.java
@@ -127,4 +127,9 @@ public class RefModel implements Serializable, Comparable<RefModel> {
public int compareTo(RefModel o) {
return getDate().compareTo(o.getDate());
}
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
} \ No newline at end of file
diff --git a/src/com/gitblit/utils/MetricUtils.java b/src/com/gitblit/utils/MetricUtils.java
index d8286e29..492b0243 100644
--- a/src/com/gitblit/utils/MetricUtils.java
+++ b/src/com/gitblit/utils/MetricUtils.java
@@ -39,10 +39,12 @@ public class MetricUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(MetricUtils.class);
- public static List<Metric> getDateMetrics(Repository r, boolean includeTotal, String format) {
+ public static List<Metric> getDateMetrics(Repository r, String objectId, boolean includeTotal, String format) {
Metric total = new Metric("TOTAL");
final Map<String, Metric> metricMap = new HashMap<String, Metric>();
-
+ if (StringUtils.isEmpty(objectId)) {
+ objectId = Constants.HEAD;
+ }
if (JGitUtils.hasCommits(r)) {
final List<RefModel> tags = JGitUtils.getTags(r, true, -1);
final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();
@@ -51,7 +53,7 @@ public class MetricUtils {
}
try {
RevWalk walk = new RevWalk(r);
- ObjectId object = r.resolve(Constants.HEAD);
+ ObjectId object = r.resolve(objectId);
RevCommit lastCommit = walk.parseCommit(object);
walk.markStart(lastCommit);
@@ -62,12 +64,9 @@ public class MetricUtils {
int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime())
/ (60 * 60 * 24);
total.duration = diffDays;
- if (diffDays <= 90) {
+ if (diffDays <= 365) {
// Days
df = new SimpleDateFormat("yyyy-MM-dd");
- } else if (diffDays > 90 && diffDays < 365) {
- // Weeks
- df = new SimpleDateFormat("yyyy-MM (w)");
} else {
// Months
df = new SimpleDateFormat("yyyy-MM");
@@ -108,13 +107,15 @@ public class MetricUtils {
return metrics;
}
- public static List<Metric> getAuthorMetrics(Repository r, boolean byEmail) {
+ public static List<Metric> getAuthorMetrics(Repository r, String objectId, boolean byEmail) {
final Map<String, Metric> metricMap = new HashMap<String, Metric>();
-
+ if (StringUtils.isEmpty(objectId)) {
+ objectId = Constants.HEAD;
+ }
if (JGitUtils.hasCommits(r)) {
try {
RevWalk walk = new RevWalk(r);
- ObjectId object = r.resolve(Constants.HEAD);
+ ObjectId object = r.resolve(objectId);
RevCommit lastCommit = walk.parseCommit(object);
walk.markStart(lastCommit);
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties
index f64f1e56..d6102dbf 100644
--- a/src/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -55,6 +55,7 @@ gb.modification = modification
gb.deletion = deletion
gb.rename = rename
gb.metrics = metrics
+gb.stats = stats
gb.markdown = markdown
gb.changedFiles = changed files
gb.filesAdded = {0} files added
@@ -94,4 +95,7 @@ gb.showReadme = show readme
gb.showReadmeDescription = show a \"readme\" markdown file on the summary page
gb.nameDescription = use '/' to group repositories. e.g. libraries/mycoollib.git
gb.ownerDescription = the owner may edit repository settings
-gb.blob = blob \ No newline at end of file
+gb.blob = blob
+gb.commitActivityTrend = commit activity trend
+gb.commitActivityDOW = commit activity by day of week
+gb.commitActivityAuthors = primary authors by commit activity \ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/MetricsPage.html b/src/com/gitblit/wicket/pages/MetricsPage.html
index d6f23e01..734b9fad 100644
--- a/src/com/gitblit/wicket/pages/MetricsPage.html
+++ b/src/com/gitblit/wicket/pages/MetricsPage.html
@@ -6,18 +6,30 @@
<body>
<wicket:extend>
- <h2>Commit Activity</h2>
+ <div style="padding-top:10px;">
+ <!-- branch name -->
+ <div><span class="metricsTitle" wicket:id="branchTitle"></span></div>
+
+ <!-- placeholder for more info -->
+ <div style="float:right;width:200px;text-align: left;">
+ </div>
+
+ <!-- branch stats -->
+ <h2><wicket:message key="gb.stats"></wicket:message></h2>
+ <span wicket:id="branchStats"></span>
+
+ <!-- commit activity trend -->
+ <h2><wicket:message key="gb.commitActivityTrend"></wicket:message></h2>
<div><img wicket:id="commitsChart" /></div>
- <h2>Commit Activity by Day of Week</h2>
+ <!-- commit activity by day of week -->
+ <h2><wicket:message key="gb.commitActivityDOW"></wicket:message></h2>
<div><img wicket:id="dayOfWeekChart" /></div>
- <h2>Commit Activity by Time of Day</h2>
- <div><img wicket:id="timeOfDayChart" /></div>
-
- <h2>Most Prolific Authors</h2>
+ <!-- commit activity by primary authors -->
+ <h2><wicket:message key="gb.commitActivityAuthors"></wicket:message></h2>
<div><img wicket:id="authorsChart" /></div>
-
+ </div>
</wicket:extend>
</body>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/MetricsPage.java b/src/com/gitblit/wicket/pages/MetricsPage.java
index c6231e9d..9dd10d1b 100644
--- a/src/com/gitblit/wicket/pages/MetricsPage.java
+++ b/src/com/gitblit/wicket/pages/MetricsPage.java
@@ -17,16 +17,16 @@ package com.gitblit.wicket.pages;
import java.awt.Color;
import java.awt.Dimension;
-import java.text.ParseException;
+import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.List;
import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Repository;
import org.wicketstuff.googlecharts.Chart;
import org.wicketstuff.googlecharts.ChartAxis;
@@ -40,17 +40,28 @@ import org.wicketstuff.googlecharts.ShapeMarker;
import com.gitblit.models.Metric;
import com.gitblit.utils.MetricUtils;
+import com.gitblit.utils.TimeUtils;
import com.gitblit.wicket.WicketUtils;
public class MetricsPage extends RepositoryPage {
public MetricsPage(PageParameters params) {
- super(params);
+ super(params);
Repository r = getRepository();
- insertLinePlot("commitsChart", MetricUtils.getDateMetrics(r, false, null));
- insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r));
- insertLinePlot("timeOfDayChart", getTimeOfDayMetrics(r));
- insertPieChart("authorsChart", getAuthorMetrics(r));
+ add(new Label("branchTitle", objectId));
+ Metric metricsTotal = null;
+ List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null);
+ metricsTotal = metrics.remove(0);
+ if (metricsTotal == null) {
+ add(new Label("branchStats", ""));
+ } else {
+ add(new Label("branchStats", MessageFormat.format(
+ "{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,
+ TimeUtils.duration(metricsTotal.duration))));
+ }
+ insertLinePlot("commitsChart", metrics);
+ insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
+ insertPieChart("authorsChart", getAuthorMetrics(r, objectId));
}
private void insertLinePlot(String wicketId, List<Metric> metrics) {
@@ -118,8 +129,8 @@ public class MetricsPage extends RepositoryPage {
}
}
- private List<Metric> getDayOfWeekMetrics(Repository repository) {
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "E");
+ private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
+ List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E");
SimpleDateFormat sdf = new SimpleDateFormat("E");
Calendar cal = Calendar.getInstance();
@@ -143,35 +154,15 @@ public class MetricsPage extends RepositoryPage {
return sorted;
}
- private List<Metric> getTimeOfDayMetrics(Repository repository) {
- SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "yyyy-MM-dd HH:mm");
- Calendar cal = Calendar.getInstance();
-
- for (Metric metric : list) {
- try {
- Date date = sdf.parse(metric.name);
- cal.setTime(date);
- double y = cal.get(Calendar.HOUR_OF_DAY) + (cal.get(Calendar.MINUTE) / 60d);
- metric.duration = (int) (date.getTime() / 60000L);
- metric.count = y;
- metric.name = ndf.format(date);
- } catch (ParseException p) {
- }
- }
- return list;
- }
-
- private List<Metric> getAuthorMetrics(Repository repository) {
- List<Metric> authors = MetricUtils.getAuthorMetrics(repository, true);
+ private List<Metric> getAuthorMetrics(Repository repository, String objectId) {
+ List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);
Collections.sort(authors, new Comparator<Metric>() {
@Override
public int compare(Metric o1, Metric o2) {
if (o1.count > o2.count) {
return -1;
} else if (o1.count < o2.count) {
- return 1;
+ return 1;
}
return 0;
}
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.html b/src/com/gitblit/wicket/pages/RepositoryPage.html
index ffb484f1..0e0ce476 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.html
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.html
@@ -18,7 +18,7 @@
<!-- page nav links -->
<div class="page_nav">
- <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> | <a wicket:id="metrics"><wicket:message key="gb.metrics"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>
+ <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>
</div>
</div>
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java
index eceda998..3ceb9f5f 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -76,7 +76,6 @@ public abstract class RepositoryPage extends BasePage {
put("branches", "gb.branches");
put("tags", "gb.tags");
put("tree", "gb.tree");
- put("metrics", "gb.metrics");
put("tickets", "gb.tickets");
put("edit", "gb.edit");
}
@@ -105,8 +104,6 @@ public abstract class RepositoryPage extends BasePage {
WicketUtils.newRepositoryParameter(repositoryName)));
add(new BookmarkablePageLink<Void>("tree", TreePage.class,
WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
- WicketUtils.newRepositoryParameter(repositoryName)));
// per-repository extra page links
List<String> extraPageLinks = new ArrayList<String>();
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html
index 7d5629b6..7784a471 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.html
+++ b/src/com/gitblit/wicket/pages/SummaryPage.html
@@ -25,7 +25,7 @@
<tr><th><wicket:message key="gb.description">[description]</wicket:message></th><td><span wicket:id="repositoryDescription">[repository description]</span></td></tr>
<tr><th><wicket:message key="gb.owner">[owner]</wicket:message></th><td><span wicket:id="repositoryOwner">[repository owner]</span></td></tr>
<tr><th><wicket:message key="gb.lastChange">[last change]</wicket:message></th><td><span wicket:id="repositoryLastChange">[repository last change]</span></td></tr>
- <tr><th><wicket:message key="gb.metrics">[metrics]</wicket:message></th><td><span wicket:id="repositoryMetrics">[repository metrics]</span></td></tr>
+ <tr><th><wicket:message key="gb.stats">[stats]</wicket:message></th><td><span wicket:id="branchStats">[branch stats]</span> <span class="link"><a wicket:id="metrics"><wicket:message key="gb.metrics">[metrics]</wicket:message></a></span></td></tr>
<tr><th valign="top"><wicket:message key="gb.url">[URL]</wicket:message></th><td><img style="vertical-align: top; padding-right:5px;" wicket:id="accessRestrictionIcon" /><span wicket:id="repositoryCloneUrl">[repository clone url]</span></td></tr>
</table>
</div>
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java
index fd21ed64..03b1b1c7 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/com/gitblit/wicket/pages/SummaryPage.java
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.protocol.http.WebRequest;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -77,7 +78,7 @@ public class SummaryPage extends RepositoryPage {
List<Metric> metrics = null;
Metric metricsTotal = null;
if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
- metrics = MetricUtils.getDateMetrics(r, true, null);
+ metrics = MetricUtils.getDateMetrics(r, null, true, null);
metricsTotal = metrics.remove(0);
}
@@ -88,12 +89,13 @@ public class SummaryPage extends RepositoryPage {
add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r),
getTimeZone()));
if (metricsTotal == null) {
- add(new Label("repositoryMetrics", ""));
+ add(new Label("branchStats", ""));
} else {
- add(new Label("repositoryMetrics", MessageFormat.format(
+ add(new Label("branchStats", MessageFormat.format(
"{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,
TimeUtils.duration(metricsTotal.duration))));
}
+ add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
List<String> repositoryUrls = new ArrayList<String>();
@@ -141,8 +143,8 @@ public class SummaryPage extends RepositoryPage {
.setEscapeModelStrings(false));
add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0));
- add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));
- add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs));
+ add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
+ add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs).hideIfEmpty());
if (getRepositoryModel().showReadme) {
String htmlText = null;
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.html b/src/com/gitblit/wicket/panels/BranchesPanel.html
index 497003a5..91c34d2d 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.html
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.html
@@ -17,16 +17,28 @@
<td><span wicket:id="branchName">[branch name]</span></td>
<td><span wicket:id="branchType">[branch type]</span></td>
<td class="rightAlign">
- <span class="link">
- <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
- </span>
+ <span wicket:id="branchLinks"></span>
</td>
</tr>
</tbody>
</table>
<div wicket:id="allBranches">[all branches]</div>
-
+
+ <!-- branch page links -->
+ <wicket:fragment wicket:id="branchPageLinks">
+ <span class="link">
+ <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> | <a wicket:id="metrics"><wicket:message key="gb.metrics"></wicket:message></a>
+ </span>
+ </wicket:fragment>
+
+ <!-- branch panel links -->
+ <wicket:fragment wicket:id="branchPanelLinks">
+ <span class="link">
+ <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
+ </span>
+ </wicket:fragment>
+
</wicket:panel>
</body>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java
index 82f8a045..b11c03ab 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -35,6 +36,7 @@ import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BranchesPage;
import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.MetricsPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TreePage;
@@ -42,6 +44,8 @@ public class BranchesPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+ private final boolean hasBranches;
+
public BranchesPanel(String wicketId, final RepositoryModel model, Repository r,
final int maxCount) {
super(wicketId);
@@ -89,11 +93,23 @@ public class BranchesPanel extends BasePanel {
item.add(new Label("branchType", remote ? getString("gb.remote")
: getString("gb.local")).setVisible(maxCount <= 0));
- item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
- item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
-
+ if (maxCount <= 0) {
+ Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
+ WicketUtils.newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ } else {
+ Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ }
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
@@ -105,5 +121,12 @@ public class BranchesPanel extends BasePanel {
add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches",
this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));
}
+ // We always have 1 branch
+ hasBranches = branches.size() > 1;
+ }
+
+ public BranchesPanel hideIfEmpty() {
+ setVisible(hasBranches);
+ return this;
}
}
diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java
index 8cf137b1..f25b53b2 100644
--- a/src/com/gitblit/wicket/panels/RefsPanel.java
+++ b/src/com/gitblit/wicket/panels/RefsPanel.java
@@ -70,19 +70,19 @@ public class RefsPanel extends Panel {
Class<? extends RepositoryPage> linkClass = CommitPage.class;
String cssClass = "";
if (name.startsWith(Constants.R_HEADS)) {
- // local head
+ // local branch
linkClass = LogPage.class;
name = name.substring(Constants.R_HEADS.length());
- cssClass = "headRef";
+ cssClass = "localBranch";
} else if (name.equals(Constants.HEAD)) {
// local head
linkClass = LogPage.class;
cssClass = "headRef";
} else if (name.startsWith(Constants.R_REMOTES)) {
- // remote head
+ // remote branch
linkClass = LogPage.class;
name = name.substring(Constants.R_REMOTES.length());
- cssClass = "remoteRef";
+ cssClass = "remoteBranch";
} else if (name.startsWith(Constants.R_TAGS)) {
// tag
if (entry.isAnnotatedTag()) {
diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java
index f6dd762b..4504c511 100644
--- a/src/com/gitblit/wicket/panels/TagsPanel.java
+++ b/src/com/gitblit/wicket/panels/TagsPanel.java
@@ -44,6 +44,8 @@ import com.gitblit.wicket.pages.TreePage;
public class TagsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+
+ private final boolean hasTags;
public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) {
super(wicketId);
@@ -162,5 +164,12 @@ public class TagsPanel extends BasePanel {
add(new LinkPanel("allTags", "link", new StringResourceModel("gb.allTags", this, null),
TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
}
+
+ hasTags = tags.size() > 0;
+ }
+
+ public TagsPanel hideIfEmpty() {
+ setVisible(hasTags);
+ return this;
}
}
diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css
index 5dd0f160..a0ab10ab 100644
--- a/src/com/gitblit/wicket/resources/gitblit.css
+++ b/src/com/gitblit/wicket/resources/gitblit.css
@@ -708,7 +708,11 @@ td.treeLinks {
width: 13em;
}
-span .tagRef, span .headRef, span .remoteRef, span .otherRef {
+span.metricsTitle {
+ font-size: 2em;
+}
+
+span .tagRef, span .headRef, span .localBranch, span .remoteBranch, span .otherRef {
padding: 0px 3px;
margin-right:2px;
font-family: sans-serif;
@@ -718,26 +722,26 @@ span .tagRef, span .headRef, span .remoteRef, span .otherRef {
color: black;
}
-span .tagRef a span, span .headRef a span, span .remoteRef a span, span .otherRef a span {
+span .tagRef a span, span .headRef a span, span .localBranch a span, span .remoteBranch a span, span .otherRef a span {
font-size: 9px;
}
-span .tagRef a, span .headRef a, span .remoteRef a, span .otherRef a {
+span .tagRef a, span .headRef a, span .localBranch a, span .remoteBranch a, span .otherRef a {
text-decoration: none;
color: black !important;
}
-span .tagRef a:hover, span .headRef a:hover, span .remoteRef a:hover, span .otherRef a:hover {
+span .tagRef a:hover, span .headRef a:hover, span .localBranch a:hover, span .remoteBranch a:hover, span .otherRef a:hover {
color: black !important;
text-decoration: underline;
}
span .otherRef {
- background-color: #ffaaff;
- border-color: #ff00ee;
+ background-color: #80ccdd;
+ border-color: #80aaaa;
}
-span .remoteRef {
+span .remoteBranch {
background-color: #cAc2f5;
border-color: #6c6cbf;
}
@@ -748,6 +752,11 @@ span .tagRef {
}
span .headRef {
+ background-color: #ffaaff;
+ border-color: #ff00ee;
+}
+
+span .localBranch {
background-color: #ccffcc;
border-color: #00cc33;
}
22/stable29'>backport/49822/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/src/components/Comment.vue
blob: 5c58ec8b1fd4deb33f3bfc60308427ed602aae18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!--
  - @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com>
  -
  - @author John Molakvoæ <skjnldsv@protonmail.com>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
  -
  -->
<template>
	<component :is="tag"
		v-show="!deleted"
		:class="{'comment--loading': loading}"
		class="comment">
		<!-- Comment header toolbar -->
		<div class="comment__side">
			<!-- Author -->
			<NcAvatar class="comment__avatar"
				:display-name="actorDisplayName"
				:user="actorId"
				:size="32" />
		</div>
		<div class="comment__body">
			<div class="comment__header">
				<span class="comment__author">{{ actorDisplayName }}</span>

				<!-- Comment actions,
					show if we have a message id and current user is author -->
				<NcActions v-if="isOwnComment && id && !loading" class="comment__actions">
					<template v-if="!editing">
						<NcActionButton :close-after-click="true"
							icon="icon-rename"
							@click="onEdit">
							{{ t('comments', 'Edit comment') }}
						</NcActionButton>
						<NcActionSeparator />
						<NcActionButton :close-after-click="true"
							icon="icon-delete"
							@click="onDeleteWithUndo">
							{{ t('comments', 'Delete comment') }}
						</NcActionButton>
					</template>

					<NcActionButton v-else
						icon="icon-close"
						@click="onEditCancel">
						{{ t('comments', 'Cancel edit') }}
					</NcActionButton>
				</NcActions>

				<!-- Show loading if we're editing or deleting, not on new ones -->
				<div v-if="id && loading" class="comment_loading icon-loading-small" />

				<!-- Relative time to the comment creation -->
				<Moment v-else-if="creationDateTime" class="comment__timestamp" :timestamp="timestamp" />
			</div>

			<!-- Message editor -->
			<div v-if="editor || editing" class="comment__editor ">
				<NcRichContenteditable ref="editor"
					:auto-complete="autoComplete"
					:contenteditable="!loading"
					:value="localMessage"
					:user-data="userData"
					@update:value="updateLocalMessage"
					@submit="onSubmit" />
				<NcButton class="comment__submit"
					type="tertiary-no-background"
					native-type="submit"
					:aria-label="t('comments', 'Post comment')"
					:disabled="isEmptyMessage"
					@click="onSubmit">
					<template #icon>
						<span v-if="loading" class="icon-loading-small" />
						<ArrowRight v-else :size="20" />
					</template>
				</NcButton>
			</div>

			<!-- Message content -->
			<!-- The html is escaped and sanitized before rendering -->
			<!-- eslint-disable-next-line vue/no-v-html-->
			<div v-else
				:class="{'comment__message--expanded': expanded}"
				class="comment__message"
				@click="onExpand"
				v-html="renderedContent" />
		</div>
	</component>
</template>

<script>
import { getCurrentUser } from '@nextcloud/auth'
import moment from '@nextcloud/moment'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcRichContenteditable from '@nextcloud/vue/dist/Components/NcRichContenteditable.js'
import RichEditorMixin from '@nextcloud/vue/dist/Mixins/richEditor.js'
import ArrowRight from 'vue-material-design-icons/ArrowRight.vue'

import Moment from './Moment.vue'
import CommentMixin from '../mixins/CommentMixin.js'

export default {
	name: 'Comment',

	components: {
		NcActionButton,
		NcActions,
		NcActionSeparator,
		ArrowRight,
		NcAvatar,
		NcButton,
		Moment,
		NcRichContenteditable,
	},
	mixins: [RichEditorMixin, CommentMixin],

	inheritAttrs: false,

	props: {
		actorDisplayName: {
			type: String,
			required: true,
		},
		actorId: {
			type: String,
			required: true,
		},
		creationDateTime: {
			type: String,
			default: null,
		},

		/**
		 * Force the editor display
		 */
		editor: {
			type: Boolean,
			default: false,
		},

		/**
		 * Provide the autocompletion data
		 */
		autoComplete: {
			type: Function,
			required: true,
		},

		tag: {
			type: String,
			default: 'div',
		},
	},

	data() {
		return {
			expanded: false,
			// Only change data locally and update the original
			// parent data when the request is sent and resolved
			localMessage: '',
		}
	},

	computed: {

		/**
		 * Is the current user the author of this comment
		 *
		 * @return {boolean}
		 */
		isOwnComment() {
			return getCurrentUser().uid === this.actorId
		},

		/**
		 * Rendered content as html string
		 *
		 * @return {string}
		 */
		renderedContent() {
			if (this.isEmptyMessage) {
				return ''
			}
			return this.renderContent(this.localMessage)
		},

		isEmptyMessage() {
			return !this.localMessage || this.localMessage.trim() === ''
		},

		timestamp() {
			// seconds, not milliseconds
			return parseInt(moment(this.creationDateTime).format('x'), 10) / 1000
		},
	},

	watch: {
		// If the data change, update the local value
		message(message) {
			this.updateLocalMessage(message)
		},
	},

	beforeMount() {
		// Init localMessage
		this.updateLocalMessage(this.message)
	},

	methods: {
		/**
		 * Update local Message on outer change
		 *
		 * @param {string} message the message to set
		 */
		updateLocalMessage(message) {
			this.localMessage = message.toString()
		},

		/**
		 * Dispatch message between edit and create
		 */
		onSubmit() {
			// Do not submit if message is empty
			if (this.localMessage.trim() === '') {
				return
			}

			if (this.editor) {
				this.onNewComment(this.localMessage.trim())
				this.$nextTick(() => {
					// Focus the editor again
					this.$refs.editor.$el.focus()
				})
				return
			}
			this.onEditComment(this.localMessage.trim())
		},

		onExpand() {
			this.expanded = true
		},
	},

}
</script>

<style lang="scss" scoped>
@use "sass:math";

$comment-padding: 10px;

.comment {
	display: flex;
	gap: 16px;
	position: relative;
	padding: 5px $comment-padding;

	&__side {
		display: flex;
		align-items: flex-start;
		padding-top: 16px;
	}

	&__body {
		display: flex;
		flex-grow: 1;
		flex-direction: column;
	}

	&__header {
		display: flex;
		align-items: center;
		min-height: 44px;
	}

	&__actions {
		margin-left: $comment-padding !important;
	}

	&__author {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		color: var(--color-text-maxcontrast);
	}

	&_loading,
	&__timestamp {
		margin-left: auto;
		text-align: right;
		white-space: nowrap;
		color: var(--color-text-maxcontrast);
	}

	&__submit {
		position: absolute !important;
		right: 0;
		bottom: 0;
		// Align with input border
		margin: 1px;
	}

	&__message {
		white-space: pre-wrap;
		word-break: break-word;
		max-height: 70px;
		overflow: hidden;
		margin-top: -6px;
		&--expanded {
			max-height: none;
			overflow: visible;
		}
	}
}

.rich-contenteditable__input {
	min-height: 44px;
	margin: 0;
	padding: $comment-padding;
}

</style>