SCM Graph - set the groundwork to show all history item groups (#227780)

This commit is contained in:
Ladislau Szomoru
2024-09-06 15:12:48 +02:00
committed by GitHub
parent bcb954e815
commit 5ae8ffb7e3
4 changed files with 52 additions and 15 deletions

View File

@@ -1174,6 +1174,9 @@ export class Repository {
}
if (options?.refNames) {
if (options.refNames.length === 0) {
args.push('--all');
}
args.push('--topo-order');
args.push('--decorate=full');
args.push(...options.refNames);

View File

@@ -396,7 +396,7 @@ function sanitizeRenderedMarkdown(
if (e.attrName === 'style' || e.attrName === 'class') {
if (element.tagName === 'SPAN') {
if (e.attrName === 'style') {
e.keepAttr = /^(color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z]+)+\));)?(background-color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z]+)+\));)?(border-radius:[0-9]+px;)?$/.test(e.attrValue);
e.keepAttr = /^(color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z0-9]+)+\));)?(background-color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z0-9]+)+\));)?(border-radius:[0-9]+px;)?$/.test(e.attrValue);
return;
} else if (e.attrName === 'class') {
e.keepAttr = /^codicon codicon-[a-z\-]+( codicon-modifier-[a-z\-]+)?$/.test(e.attrValue);

View File

@@ -305,7 +305,20 @@ export function toISCMHistoryItemViewModelArray(historyItems: ISCMHistoryItem[],
// Add colors to labels
const labels = (historyItem.labels ?? [])
.map(label => {
return { ...label, color: colorMap.get(label.title) };
let color = colorMap.get(label.title);
if (!color && colorMap.has('*')) {
// Find the history item in the input swimlanes
const inputIndex = inputSwimlanes.findIndex(node => node.id === historyItem.id);
// Circle index - use the input swimlane index if present, otherwise add it to the end
const circleIndex = inputIndex !== -1 ? inputIndex : inputSwimlanes.length;
// Circle color - use the output swimlane color if present, otherwise the input swimlane color
color = circleIndex < outputSwimlanes.length ? outputSwimlanes[circleIndex].color :
circleIndex < inputSwimlanes.length ? inputSwimlanes[circleIndex].color : historyItemGroupLocal;
}
return { ...label, color };
});
viewModels.push({

View File

@@ -574,7 +574,33 @@ class SCMHistoryViewModel extends Disposable {
* values are updated in the same transaction (or during the initial read of the observable value).
*/
readonly repository = latestChangedValue(this, [this._firstRepository, this._graphRepository]);
private readonly _historyItemGroupIds = observableValue<'all' | 'auto' | string[]>(this, 'auto');
private readonly _historyItemGroupFilter = observableValue<'all' | 'auto' | string[]>(this, 'auto');
readonly historyItemGroupFilter = derived<string[]>(reader => {
const filter = this._historyItemGroupFilter.read(reader);
if (Array.isArray(filter)) {
return filter;
}
if (filter === 'all') {
return [];
}
const repository = this.repository.get();
const historyProvider = repository?.provider.historyProvider.get();
const currentHistoryItemGroup = historyProvider?.currentHistoryItemGroup.get();
if (!currentHistoryItemGroup) {
return [];
}
return [
currentHistoryItemGroup.revision ?? currentHistoryItemGroup.id,
...currentHistoryItemGroup.remote ? [currentHistoryItemGroup.remote.revision ?? currentHistoryItemGroup.remote.id] : [],
...currentHistoryItemGroup.base ? [currentHistoryItemGroup.base.revision ?? currentHistoryItemGroup.base.id] : [],
];
});
private readonly _state = new Map<ISCMRepository, HistoryItemState>();
@@ -633,13 +659,9 @@ class SCMHistoryViewModel extends Disposable {
}
if (!state || state.loadMore) {
const historyItemGroupIds = [
currentHistoryItemGroup.revision ?? currentHistoryItemGroup.id,
...currentHistoryItemGroup.remote ? [currentHistoryItemGroup.remote.revision ?? currentHistoryItemGroup.remote.id] : [],
...currentHistoryItemGroup.base ? [currentHistoryItemGroup.base.revision ?? currentHistoryItemGroup.base.id] : [],
];
const existingHistoryItems = state?.items ?? [];
const historyItemGroupIds = this.historyItemGroupFilter.get();
const limit = clamp(this._configurationService.getValue<number>('scm.graph.pageSize'), 1, 1000);
const historyItems = await historyProvider.provideHistoryItems({
@@ -656,7 +678,7 @@ class SCMHistoryViewModel extends Disposable {
}
// Create the color map
const colorMap = this._getHistoryItemsColorMap(currentHistoryItemGroup);
const colorMap = this._getGraphColorMap(currentHistoryItemGroup);
return toISCMHistoryItemViewModelArray(state.items, colorMap)
.map(historyItemViewModel => ({
@@ -670,11 +692,7 @@ class SCMHistoryViewModel extends Disposable {
this._selectedRepository.set(repository, undefined);
}
private _getHistoryItemsColorMap(currentHistoryItemGroup: ISCMHistoryItemGroup): Map<string, ColorIdentifier> {
if (this._historyItemGroupIds.get() !== 'auto') {
return new Map<string, ColorIdentifier>();
}
private _getGraphColorMap(currentHistoryItemGroup: ISCMHistoryItemGroup): Map<string, ColorIdentifier> {
const colorMap = new Map<string, ColorIdentifier>([
[currentHistoryItemGroup.name, historyItemGroupLocal]
]);
@@ -684,6 +702,9 @@ class SCMHistoryViewModel extends Disposable {
if (currentHistoryItemGroup.base) {
colorMap.set(currentHistoryItemGroup.base.name, historyItemGroupBase);
}
if (this._historyItemGroupFilter.get() === 'all') {
colorMap.set('*', '');
}
return colorMap;
}