mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
SCM - use custom hover for history item statistics (#209346)
This commit is contained in:
parent
dd0b11c533
commit
6e62970b05
|
@ -106,6 +106,8 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||||
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
|
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
|
||||||
import { clamp } from 'vs/base/common/numbers';
|
import { clamp } from 'vs/base/common/numbers';
|
||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
|
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
|
||||||
|
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
|
||||||
|
|
||||||
// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
|
// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
|
||||||
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
|
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
|
||||||
|
@ -891,6 +893,7 @@ interface HistoryItemTemplate {
|
||||||
readonly iconContainer: HTMLElement;
|
readonly iconContainer: HTMLElement;
|
||||||
readonly label: IconLabel;
|
readonly label: IconLabel;
|
||||||
readonly statsContainer: HTMLElement;
|
readonly statsContainer: HTMLElement;
|
||||||
|
readonly statsCustomHover: ICustomHover;
|
||||||
readonly filesLabel: HTMLElement;
|
readonly filesLabel: HTMLElement;
|
||||||
readonly insertionsLabel: HTMLElement;
|
readonly insertionsLabel: HTMLElement;
|
||||||
readonly deletionsLabel: HTMLElement;
|
readonly deletionsLabel: HTMLElement;
|
||||||
|
@ -928,7 +931,10 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
|
||||||
const insertionsLabel = append(statsContainer, $('.insertions-label'));
|
const insertionsLabel = append(statsContainer, $('.insertions-label'));
|
||||||
const deletionsLabel = append(statsContainer, $('.deletions-label'));
|
const deletionsLabel = append(statsContainer, $('.deletions-label'));
|
||||||
|
|
||||||
return { iconContainer, label: iconLabel, actionBar, statsContainer, filesLabel, insertionsLabel, deletionsLabel, elementDisposables: new DisposableStore(), disposables };
|
const statsCustomHover = setupCustomHover(getDefaultHoverDelegate('element'), statsContainer, '');
|
||||||
|
disposables.add(statsCustomHover);
|
||||||
|
|
||||||
|
return { iconContainer, label: iconLabel, actionBar, statsContainer, statsCustomHover, filesLabel, insertionsLabel, deletionsLabel, elementDisposables: new DisposableStore(), disposables };
|
||||||
}
|
}
|
||||||
|
|
||||||
renderElement(node: ITreeNode<SCMHistoryItemTreeElement, LabelFuzzyScore>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
|
renderElement(node: ITreeNode<SCMHistoryItemTreeElement, LabelFuzzyScore>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void {
|
||||||
|
@ -983,10 +989,9 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
|
||||||
historyItem.statistics.deletions > 1 ? localize('deletions', "{0} deletions{1}", historyItem.statistics.deletions, '(-)') : ''
|
historyItem.statistics.deletions > 1 ? localize('deletions', "{0} deletions{1}", historyItem.statistics.deletions, '(-)') : ''
|
||||||
];
|
];
|
||||||
|
|
||||||
const statsTitle = statsAriaLabel
|
const statsTitle = statsAriaLabel.filter(l => l !== '').join(', ');
|
||||||
.filter(l => l !== '').join(', ');
|
|
||||||
templateData.statsContainer.title = statsTitle;
|
|
||||||
templateData.statsContainer.setAttribute('aria-label', statsTitle);
|
templateData.statsContainer.setAttribute('aria-label', statsTitle);
|
||||||
|
templateData.statsCustomHover.update(statsTitle);
|
||||||
|
|
||||||
templateData.filesLabel.textContent = historyItem.statistics.files.toString();
|
templateData.filesLabel.textContent = historyItem.statistics.files.toString();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue