Skip to content

Commit c5bf2d6

Browse files
committed
Enhance file selection functionality with relative/absolute path configuration and update copyright notices
1 parent 6ace217 commit c5bf2d6

6 files changed

Lines changed: 57 additions & 43 deletions

File tree

src/debug/debug-adapters-yaml-file.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { PathType } from '../views/manage-solution/messages';
1718
import { createInterfaceFactory } from '../generic/interface-factory';
1819
import { ETextFileResult } from '../generic/text-file';
1920
import { ITreeItem, CTreeItem } from '../generic/tree-item';
@@ -27,7 +28,8 @@ export type UIOption<T extends string, V> = {
2728
description?: string; //Hover over text.
2829
'yml-node': string; //Name of the node in the csolution file under debugger: section.
2930
type: T; //Type of the option [number, enum, string, file]
30-
pname?: string; //If present, the option is pname based. Then the same property will be created for each pname instance.
31+
pname?: string; //If present, the option is pname based. Then the same property will be created for each pname instance.
32+
'path-type'?: PathType; //If the type is file, indicates if the path is absolute or relative to the solution file directory. Default is relative.
3133
} & V;
3234

3335
export type UIEnumValue = {

src/views/manage-solution/manage-solution-custom-editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2026 Arm Limited
2+
* Copyright (C) 2026 Arm Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/views/manage-solution/manage-solution-webview-main.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,13 @@ describe('ContextSelectionWebviewMain', () => {
560560

561561
const dialogOptions = showOpenDialogSpy.mock.calls[0][0];
562562
expect(dialogOptions?.defaultUri?.toString()).toBe(URI.file(path.dirname(defaultPath)).toString());
563-
expect(webviewManager.sendMessage).toHaveBeenCalledWith({
564-
type: 'FILE_SELECTED',
565-
data: ['images/app.axf'],
566-
for: 'image-path'
567-
});
563+
expect(webviewManager.sendMessage).toHaveBeenCalledWith(
564+
expect.objectContaining({
565+
type: 'FILE_SELECTED',
566+
data: expect.arrayContaining([expect.stringMatching(/root[/\\]images[/\\]app\.axf$/)]),
567+
for: 'image-path'
568+
})
569+
);
568570
});
569571
});
570572

src/views/manage-solution/manage-solution-webview-main.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024-2026 Arm Limited
2+
* Copyright (C) 2024-2026 Arm Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -440,7 +440,10 @@ export class ManageSolutionWebviewMain {
440440

441441
if (fileUri && fileUri[0]) {
442442
const paths = fileUri.map(u =>
443-
backToForwardSlashes(path.relative(solutionDir, u.fsPath))
443+
backToForwardSlashes(options?.pathType === 'absolute'
444+
? u.fsPath
445+
: path.relative(solutionDir, u.fsPath)
446+
)
444447
);
445448

446449
await this.webviewManager.sendMessage({ type: 'FILE_SELECTED', data: paths, for: targetElementId });

src/views/manage-solution/messages.ts

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,51 @@
1717
import { DebugAdapter } from '../../debug/debug-adapters-yaml-file';
1818
import { ActiveTargetSet, SolutionData } from './view/state/manage-solution-state';
1919

20+
export type PathType = 'absolute' | 'relative';
21+
2022
export type FileSelectorOptionsType = {
21-
canSelectMany?: boolean,
22-
defaultUri?: string,
23-
openLabel?: string,
24-
title?: string,
25-
filters?: { [key: string]: string[] }
23+
canSelectMany?: boolean,
24+
defaultUri?: string,
25+
openLabel?: string,
26+
title?: string,
27+
pathType?: PathType,
28+
filters?: { [key: string]: string[] }
2629
};
2730

2831
/**
2932
* Messages that the context selection view can pass to the extension.
3033
*/
3134
export type OutgoingMessage
32-
= { type: 'GET_CONTEXT_SELECTION_DATA' }
33-
| { type: 'SET_SELECTED_TARGET', target: string, set: string | undefined }
34-
| { type: 'OPEN_FILE', path: string }
35-
| { type: 'SET_SELECTED_CONTEXTS', data: SolutionData }
36-
| { type: 'GET_DEBUG_ADAPTERS' }
37-
| { type: 'SET_DEBUGGER', name: string }
38-
| { type: 'ADD_NEW_CONTEXT' }
39-
| { type: 'ADD_NEW_PROJECT' }
40-
| { type: 'ADD_NEW_IMAGE' }
41-
| { type: 'UNLINK_IMAGE', image: string }
42-
| { type: 'SET_START_PROCESSOR', value: string }
43-
| { type: 'SAVE_CONTEXT_SELECTION' }
44-
| { type: 'OPEN_HELP' }
45-
| { type: 'SET_DEBUG_ADAPTER_PROPERTY', service: string | undefined, key: string, value: string | number, pname?: string }
46-
| { type: 'SELECT_FILE', targetElementId: string, options?: FileSelectorOptionsType }
47-
| { type: 'SET_AUTO_UPDATE', value: boolean }
48-
| { type: 'TOGGLE_DEBUGGER', value: boolean }
49-
| { type: 'TOGGLE_DEBUG_ADAPTER_SECTION', section: string }
50-
;
35+
= { type: 'GET_CONTEXT_SELECTION_DATA' }
36+
| { type: 'SET_SELECTED_TARGET', target: string, set: string | undefined }
37+
| { type: 'OPEN_FILE', path: string }
38+
| { type: 'SET_SELECTED_CONTEXTS', data: SolutionData }
39+
| { type: 'GET_DEBUG_ADAPTERS' }
40+
| { type: 'SET_DEBUGGER', name: string }
41+
| { type: 'ADD_NEW_CONTEXT' }
42+
| { type: 'ADD_NEW_PROJECT' }
43+
| { type: 'ADD_NEW_IMAGE' }
44+
| { type: 'UNLINK_IMAGE', image: string }
45+
| { type: 'SET_START_PROCESSOR', value: string }
46+
| { type: 'SAVE_CONTEXT_SELECTION' }
47+
| { type: 'OPEN_HELP' }
48+
| { type: 'SET_DEBUG_ADAPTER_PROPERTY', service: string | undefined, key: string, value: string | number, pname?: string }
49+
| { type: 'SELECT_FILE', targetElementId: string, options?: FileSelectorOptionsType }
50+
| { type: 'SET_AUTO_UPDATE', value: boolean }
51+
| { type: 'TOGGLE_DEBUGGER', value: boolean }
52+
| { type: 'TOGGLE_DEBUG_ADAPTER_SECTION', section: string }
53+
;
5154

5255
/**
5356
* Messages that the extension can pass to the context selection view.
5457
*/
5558
export type IncomingMessage
56-
= { type: 'DATA_CONTEXT_SELECTION', data: SolutionData }
57-
| { type: 'DEBUG_ADAPTERS', data: DebugAdapter[], sectionsInUse: string[] }
58-
| { type: 'DEBUGGER', data: string }
59-
| { type: 'ACTIVE_TARGET_SET', data: ActiveTargetSet }
60-
| { type: 'IS_DIRTY', data: boolean }
61-
| { type: 'IS_BUSY', data: boolean }
62-
| { type: 'FILE_SELECTED', data: string[], for: string }
63-
| { type: 'AUTO_UPDATE', data: boolean }
64-
;
59+
= { type: 'DATA_CONTEXT_SELECTION', data: SolutionData }
60+
| { type: 'DEBUG_ADAPTERS', data: DebugAdapter[], sectionsInUse: string[] }
61+
| { type: 'DEBUGGER', data: string }
62+
| { type: 'ACTIVE_TARGET_SET', data: ActiveTargetSet }
63+
| { type: 'IS_DIRTY', data: boolean }
64+
| { type: 'IS_BUSY', data: boolean }
65+
| { type: 'FILE_SELECTED', data: string[], for: string }
66+
| { type: 'AUTO_UPDATE', data: boolean }
67+
;

src/views/manage-solution/view/components/manage-solution.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { SolutionUpdateAction, contextUpdateReducer, initialState, manageSolutio
2929
import './manage-solution.css';
3030
import { ProjectsTable } from './projects-table';
3131
import { TargetsTable } from './targets-table';
32+
import { PathType } from '../../messages';
3233

3334
export interface ManageSolutionProps {
3435
messageHandler: MessageHandler<IncomingMessage, OutgoingMessage>;
@@ -212,6 +213,7 @@ export const ManageSolution = (props: ManageSolutionProps) => {
212213
input?.setAttribute('id', id);
213214
}
214215
const title = input?.getAttribute('title') || 'Select File';
216+
const optionPathType = input?.getAttribute('data-option-path-type') as (PathType | undefined) ?? 'relative';
215217
const currentValue = input?.value || '';
216218
props.messageHandler.push({
217219
type: 'SELECT_FILE',
@@ -221,7 +223,8 @@ export const ManageSolution = (props: ManageSolutionProps) => {
221223
defaultUri: currentValue,
222224
openLabel: 'Select File', // title of the dialog button to choose the file
223225
title: title, // dialog title
224-
filters: { 'All Files': ['*'] }
226+
filters: { 'All Files': ['*'] },
227+
pathType: optionPathType
225228
}
226229
});
227230
};
@@ -433,6 +436,7 @@ export const ManageSolution = (props: ManageSolutionProps) => {
433436
addonAfter={<Button type="primary" className='file-button' onClick={selectFile}> Browse</Button>}
434437
value={(localValues[k] as string) ?? ''}
435438
data-yml-node={o['yml-node']}
439+
data-option-path-type={o['path-type']}
436440
onPressEnter={blurOnEnter}
437441
onChange={(e) => {
438442
setLocalValues(prev => ({ ...prev, [k]: e.target.value }));

0 commit comments

Comments
 (0)