Skip to content

Commit 5b75d78

Browse files
committed
Improve merge UX: clarify tooltip and separate status from action
1 parent de254f2 commit 5b75d78

8 files changed

Lines changed: 9 additions & 126 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@
649649
{
650650
"category": "CMSIS",
651651
"command": "cmsis-csolution.mergeFile",
652-
"title": "Merge Updated Config File",
652+
"title": "Open Merge View",
653653
"icon": "$(git-merge)"
654654
},
655655
{

src/views/solution-outline/tree-structure/solution-outline-file-item.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ describe('FileItem', () => {
9494
expect(createdChildren.length).toBe(2);
9595

9696
// check attributes and merge features for each file node
97-
const fileLabels = ['RTX_Config.c', 'RTX_Config.h'];
98-
const fileStatuses = ["- 'RTX_Config.c' is incompatible. A file update is mandatory.", "- 'RTX_Config.h' has corrections. A file update is suggested."];
97+
const fileLabels = ['RTX_Config.c', 'RTX_Config.h'];
9998
createdChildren.forEach((child, idx) => {
10099
expect(child.getTag()).toBe('file');
101100
expect(child.getAttribute('label')).toContain(fileLabels[idx]);
102101
expect(child.getAttribute('update')).toContain('update');
103102
expect(child.getAttribute('base')).toContain('base');
104-
expect(child.getAttribute('description')).toBeUndefined();
105-
expect(child.getAttribute('tooltip')).toContain(fileStatuses[idx]);
103+
expect(child.getAttribute('description')).toBeUndefined();
106104
});
107105

108106
});

src/views/solution-outline/tree-structure/solution-outline-file-item.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import path from 'path';
1818
import { CTreeItem, ITreeItem } from '../../../generic/tree-item';
1919
import { FILE_TAGS } from '../../../solutions/constants';
2020
import { COutlineItem } from './solution-outline-item';
21-
import { getStatusTooltip, setContextMenuAttributes, setHeaderContext, setMergeFileContext } from './solution-outline-utils';
21+
import { setContextMenuAttributes, setHeaderContext, setMergeFileContext } from './solution-outline-utils';
2222
import { matchesContext } from '../../../utils/context-utils';
2323
import { SolutionOutlineItemBuilder } from './solution-outline-item-builder';
2424
import { CSolution } from '../../../solutions/csolution';
@@ -131,21 +131,6 @@ export class FileItemBuilder extends SolutionOutlineItemBuilder {
131131

132132
// assign merge context
133133
setMergeFileContext(cfileItem);
134-
135-
// set tooltip
136-
const existingTooltip = cfileItem.getValue('tooltip');
137-
const label = cfileItem.getValue('label');
138-
139-
if (label) {
140-
const statusTooltip = getStatusTooltip(label, fileStatus);
141-
142-
if (existingTooltip) {
143-
cfileItem.setAttribute('tooltip', existingTooltip + '\n' + statusTooltip);
144-
} else {
145-
cfileItem.setAttribute('tooltip', statusTooltip);
146-
}
147-
}
148-
149134
cfileItem.setAttribute('local', localPath);
150135
cfileItem.setAttribute('update', updatePath);
151136
cfileItem.setAttribute('base', basePath);

src/views/solution-outline/tree-structure/solution-outline-hardware-item.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ describe('HardwareItemBuilder', () => {
106106
const base = device?.getAttribute('base');
107107
const gotBase = base ? path.basename(base) : '';
108108
const wantBase = 'Hello+CS300.dbgconf.base@0.0.1';
109-
expect(gotBase).toEqual(wantBase);
110-
111-
expect(device?.getAttribute('tooltip')).toContain("- 'Hello+CS300.dbgconf' has corrections. A file update is suggested.");
109+
expect(gotBase).toEqual(wantBase);
112110
});
113111

114112
});

src/views/solution-outline/tree-structure/solution-outline-project-items.ts

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { FileItemBuilder } from './solution-outline-file-item';
2121
import { COutlineItem } from './solution-outline-item';
2222
import * as manifest from '../../../manifest';
2323
import { CSolution } from '../../../solutions/csolution';
24-
import { getMapFilePath, getStatusTooltip, setDocContext, setHeaderContext, setLinkerContext } from './solution-outline-utils';
24+
import { getMapFilePath, setDocContext, setHeaderContext, setLinkerContext } from './solution-outline-utils';
2525
import { CProjectYamlFile } from '../../../solutions/files/cproject-yaml-file';
2626
import { SolutionOutlineItemBuilder } from './solution-outline-item-builder';
2727

2828
export class ProjectItemsBuilder extends SolutionOutlineItemBuilder {
29-
private _lastPrioritizedComponentList: COutlineItem[] = [];
29+
private readonly _lastPrioritizedComponentList: COutlineItem[] = [];
3030

3131
public get lastPrioritizedComponentList(): COutlineItem[] {
3232
return this._lastPrioritizedComponentList;
@@ -222,58 +222,9 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder {
222222
}
223223

224224
this.addComponentOptions(componentNodes);
225-
226-
// add merge description
227-
const components = Array.from(componentNodes.values());
228-
const fileStatus = this.getMergeDescriptionAtParentComponentLevel(components);
229-
if (fileStatus) {
230-
// assign tooltip with component ids
231-
const prioritizedList = this._lastPrioritizedComponentList;
232-
let newTooltip = 'Components with updated configuration files:';
233-
for (const comp of prioritizedList) {
234-
const compId = comp.getAttribute('label');
235-
const compStatus = comp.getAttribute('status');
236-
if (compId && compStatus) {
237-
newTooltip += `\n- ${compId}: ${compStatus}`;
238-
}
239-
}
240-
componentsItem.setAttribute('tooltip', newTooltip);
241-
}
242225
return true; // do have components to edit
243226
}
244227

245-
private getMergeDescriptionAtParentComponentLevel(components: COutlineItem[]): string | undefined {
246-
let result: string | undefined = undefined;
247-
const updateRequired: COutlineItem[] = [];
248-
const updateRecommended: COutlineItem[] = [];
249-
const updateSuggested: COutlineItem[] = [];
250-
251-
for (const component of components) {
252-
const status = component.getAttribute('status');
253-
if (!status) {
254-
continue;
255-
}
256-
if (status == 'update required') {
257-
updateRequired.push(component);
258-
} else if (status == 'update recommended') {
259-
updateRecommended.push(component);
260-
} else if (status == 'update suggested') {
261-
updateSuggested.push(component);
262-
}
263-
}
264-
265-
const prioritizedList = [...updateRequired, ...updateRecommended, ...updateSuggested];
266-
this._lastPrioritizedComponentList = prioritizedList;
267-
const prioritizedFile = prioritizedList[0];
268-
269-
const fileStatus = prioritizedFile?.getAttribute('status');
270-
if (fileStatus) {
271-
result = fileStatus;
272-
}
273-
274-
return result;
275-
}
276-
277228
private addComponentOptions(componentNodes: Map<string, COutlineItem>) {
278229
const components = componentNodes.values();
279230

@@ -433,25 +384,6 @@ export class ProjectItemsBuilder extends SolutionOutlineItemBuilder {
433384

434385
// set status at component level
435386
node.setAttribute('status', fileStatus);
436-
437-
// set tooltip
438-
const prevTooltip = node.getValue('tooltip');
439-
let newTooltip: string = '';
440-
for (const file of prioritizedList) {
441-
const fileLabel = file.getValue('file');
442-
const fileStatus = file.getValue('status');
443-
if (fileLabel && fileStatus) {
444-
const tooltip = getStatusTooltip(fileLabel, fileStatus);
445-
newTooltip += `\n ${tooltip}`;
446-
}
447-
}
448-
449-
if (prevTooltip) {
450-
node.setAttribute('tooltip', prevTooltip + '\n' + newTooltip);
451-
} else {
452-
node.setAttribute('tooltip', newTooltip);
453-
}
454-
455387
}
456388

457389
private getPrioritizedMergeFile(files: ITreeItem<CTreeItem>[]): ITreeItem<CTreeItem>[] {

src/views/solution-outline/tree-structure/solution-outline-tree.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,6 @@ export class SolutionOutlineTree extends SolutionOutlineItemBuilder {
121121
if (cproject) {
122122
const projectItems = new ProjectItemsBuilder(this.csolution, this.rpcData, context);
123123
projectItems.addProjectChildren(this.csolution, cprojectItem, cprojectFile, cbuild);
124-
125-
// get prioritized component list and set merge description if available
126-
const prioritizedList = projectItems.lastPrioritizedComponentList;
127-
if (prioritizedList && prioritizedList.length > 0) {
128-
const fileStatus = prioritizedList[0].getAttribute('status');
129-
if (fileStatus) {
130-
// set tooltip
131-
const existingTooltip = cprojectItem.getAttribute('tooltip');
132-
const newTooltip = `- Component config files: ${fileStatus}`;
133-
134-
if (existingTooltip) {
135-
cprojectItem.setAttribute('tooltip', existingTooltip + '\n' + newTooltip);
136-
} else {
137-
cprojectItem.setAttribute('tooltip', newTooltip);
138-
}
139-
}
140-
}
141124
} else {
142125
cprojectItem.setAttribute('description', 'error loading project');
143126
}

src/views/solution-outline/tree-structure/solution-outline-utils.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ export function setMergeFiles(component: COutlineItem, file: ITreeItem<CTreeItem
5252
component.setAttribute('base', basePath);
5353
}
5454

55-
export function getStatusTooltip(label: string, status: string): string | undefined {
56-
switch (status) {
57-
case 'update suggested':
58-
return `- '${label}' has corrections. A file update is suggested.`;
59-
case 'update recommended':
60-
return `- '${label}' has new features. A file update is recommended.`;
61-
case 'update required':
62-
return `- '${label}' is incompatible. A file update is mandatory.`;
63-
default:
64-
return undefined;
65-
}
66-
}
67-
6855
export function setLinkerContext(node: COutlineItem, mapFilePath: string): void {
6956
node.addFeature(`${manifest.LINKER_CONTEXT}`);
7057
node.setAttribute('type', 'linkerMapFile');

src/views/solution-outline/treeview-decoration-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class TreeViewFileDecorationProvider implements vscode.FileDecorationProv
2828
static readonly themeColor: string = 'descriptionForeground';
2929

3030
static readonly mergeBadge: string = 'N';
31-
static readonly mergeTooltip: string = 'Merge update available';
32-
static readonly mergeColor: string = 'charts.green';
31+
static readonly mergeTooltip: string = 'New Version Available for Merge';
32+
static readonly mergeColor: string = 'charts.blue';
3333

3434
static readonly excludedBadge: string = 'X';
3535
static readonly excludedTooltip: string = 'Excluded from build';

0 commit comments

Comments
 (0)