Skip to content

Commit a5ad371

Browse files
feat(git-graph): adding avatar hover operation displays name (DevCloudFE#1728)
Co-authored-by: huaweidevcloud <devcloudmobile@huawei.com>
1 parent 234be39 commit a5ad371

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/devui-vue/devui/git-graph/src/git-graph-class.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class GitGraph {
8282
this.barHeight = Math.max(this.graphHeight, this.unitTime * this.commits.length + 320);
8383

8484
const _ref = this.commits;
85-
for (let _i = 0; _i < _ref.length; _i ++) {
85+
for (let _i = 0; _i < _ref.length; _i++) {
8686
c = _ref[_i];
8787
this.preparedCommits[c.id] = c;
8888
}
@@ -130,8 +130,8 @@ export class GitGraph {
130130
day = _ref[mm].date;
131131
if (
132132
curDay.getDate() !== new Date(day).getDate() ||
133-
curDay.getMonth() !== new Date(day).getMonth() ||
134-
curDay.getFullYear() !== new Date(day).getFullYear()
133+
curDay.getMonth() !== new Date(day).getMonth() ||
134+
curDay.getFullYear() !== new Date(day).getFullYear()
135135
) {
136136
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
137137
const date = new Date(day);
@@ -183,7 +183,7 @@ export class GitGraph {
183183
}
184184

185185
renderPartialGraph(refName: string) {
186-
let commit ;
186+
let commit;
187187
let end;
188188
let i;
189189
let isGraphEdge;
@@ -257,13 +257,18 @@ export class GitGraph {
257257
style: 'clip-path: circle(50%)'
258258
};
259259
this.setNodeAttr(img, imgAttrs);
260+
261+
const authorText = document.createElementNS('http://www.w3.org/2000/svg', 'title');
262+
authorText.appendChild(document.createTextNode(commit.author.name));
263+
img.appendChild(authorText);
264+
260265
this.svg.appendChild(img);
261266

262267
if (!this.messageBoxWidth) {
263268
this.messageBoxWidth = this.svg.getBoundingClientRect.width - (avatar_box_x + 40);
264269
}
265270
// 画竖线
266-
let route = ['M', avatar_box_x + 15, avatar_box_y - 20, 'L', avatar_box_x + 15, avatar_box_y];
271+
let route = ['M', avatar_box_x + 15, avatar_box_y - 20, 'L', avatar_box_x + 15, avatar_box_y];
267272
const line1 = document.createElementNS('http://www.w3.org/2000/svg', 'path');
268273
const lineAttrs1 = {
269274
d: route.join(' '),
@@ -307,7 +312,7 @@ export class GitGraph {
307312
commitText.appendChild(titleText);
308313
this.svg.appendChild(commitText);
309314

310-
(commitText as any).onclick = function() {
315+
(commitText as any).onclick = function () {
311316
const url = commit.customUrl || options?.commit_url.replace('{commitId}', commit.id);
312317
return window.open(url, '_blank');
313318
};
@@ -334,7 +339,7 @@ export class GitGraph {
334339
parentX1 = this.offsetX + this.unitSpace * (this.mspace - parentCommit.space);
335340
parentX2 = this.offsetX + this.unitSpace * (this.mspace - parent[1]);
336341
if (parentCommit.space <= commit.space) {
337-
color = this.colors[commit.space];
342+
color = this.colors[commit.space];
338343
} else {
339344
color = this.colors[parentCommit.space];
340345
}
@@ -588,7 +593,7 @@ export class GitGraph {
588593
});
589594
}
590595

591-
textWrap (t: any, width: any, x: any) {
596+
textWrap(t: any, width: any, x: any) {
592597
const content = t.children[0].innerHTML;
593598
let words = content.split('\n').filter((item: any) => item !== '');
594599
words = words.map((str: any) => {

0 commit comments

Comments
 (0)