Skip to content

Commit ca5f406

Browse files
committed
Merge branch 'main' into fix/compact-dropdown-anchor-hidden-in-cell
2 parents 9b9adf6 + 8522a86 commit ca5f406

7 files changed

Lines changed: 45 additions & 33 deletions

File tree

src/views/manage-components-packs/view/components/pack-title-link.test.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ describe('PackTitleLink', () => {
3636
expect(getByText(packName)).toBeInTheDocument();
3737
});
3838

39-
it('renders the link with the correct href', () => {
40-
const { getByRole } = render(
41-
<PackTitleLink packId={packId} packName={packName} openFile={openFile} />
42-
);
43-
expect(getByRole('link', { name: 'Open pack URL' })).toHaveAttribute('href', packUrl);
44-
});
45-
4639
it('calls openFile with the pack URL and external=true on click', () => {
4740
const { getByRole } = render(
4841
<PackTitleLink packId={packId} packName={packName} openFile={openFile} />
@@ -51,13 +44,4 @@ describe('PackTitleLink', () => {
5144
expect(openFile).toHaveBeenCalledTimes(1);
5245
expect(openFile).toHaveBeenCalledWith(packUrl, true);
5346
});
54-
55-
it('prevents default navigation on click', () => {
56-
const { getByRole } = render(
57-
<PackTitleLink packId={packId} packName={packName} openFile={openFile} />
58-
);
59-
const link = getByRole('link', { name: 'Open pack URL' });
60-
const event = fireEvent.click(link);
61-
expect(event).toBe(false); // fireEvent.click returns false when preventDefault is called
62-
});
6347
});

src/views/manage-components-packs/view/components/pack-title-link.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import React from 'react';
18-
import { Space } from 'antd';
18+
import { Button, Space } from 'antd';
1919
import { CmsisCodicon } from '../../../common/components/cmsis-codicon';
2020
import { packURL } from '../../../../packs/pack-urls';
2121

@@ -35,18 +35,20 @@ export const PackTitleLink: React.FC<PackTitleLinkProps> = ({
3535
<>
3636
{packName ?? ''}
3737
<Space align='baseline' style={{ marginLeft: '8px' }}>
38-
<a
38+
<Button
39+
color="default"
40+
variant="link"
41+
role="link"
42+
style={{ padding: '0px 12px' }}
3943
title={packUrl}
4044
aria-label='Open pack URL'
4145
onClick={(e) => {
42-
e.preventDefault();
4346
e.stopPropagation();
4447
openFile(packUrl, true);
4548
}}
46-
href={packUrl}
4749
>
4850
<CmsisCodicon name='link-external' style={{ fontSize: '1em', display: 'inline' }} />
49-
</a>
51+
</Button>
5052
</Space>
5153
</>
5254
);

src/views/manage-components-packs/view/components/packs-view.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ describe('PacksView', () => {
206206
);
207207
});
208208

209-
const packLink = localContainer.querySelector("a[aria-label='Open pack URL']") as HTMLAnchorElement | null;
209+
const packLink = localContainer.querySelector("button[aria-label='Open pack URL']") as HTMLButtonElement | null;
210210
expect(packLink).not.toBeNull();
211211

212212
if (packLink) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export class ManageSolutionWebviewMain {
218218

219219
private async openFile(filePath: string, openExternal?: boolean): Promise<void> {
220220
const solutionDir = this.getSolutionDir();
221-
const resolvedPath = !path.isAbsolute(filePath) && solutionDir
221+
const resolvedPath = (!path.isAbsolute(filePath) && solutionDir) && !filePath.match(/^http.:\/\//)
222222
? path.join(solutionDir, filePath)
223223
: filePath;
224224
if (openExternal) {
@@ -234,7 +234,7 @@ export class ManageSolutionWebviewMain {
234234
await this.sendContextData();
235235
break;
236236
case 'OPEN_FILE':
237-
await this.openFile(message.path);
237+
await this.openFile(message.path, message.external);
238238
break;
239239
case 'SET_SELECTED_CONTEXTS':
240240
await this.setSelectedContexts(message.data);

src/views/manage-solution/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ActiveTargetSet, SolutionData } from './view/state/manage-solution-stat
2424
export type OutgoingMessage
2525
= { type: 'GET_CONTEXT_SELECTION_DATA' }
2626
| { type: 'SET_SELECTED_TARGET', target: string, set: string | undefined }
27-
| { type: 'OPEN_FILE', path: string }
27+
| { type: 'OPEN_FILE', path: string, external?: boolean }
2828
| { type: 'SET_SELECTED_CONTEXTS', data: SolutionData }
2929
| { type: 'GET_DEBUG_ADAPTERS' }
3030
| { type: 'SET_DEBUGGER', name: string }

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ describe('ContextSelection', () => {
181181

182182
postGenericDataContext();
183183

184-
const selectors = ['a[title="Active Target"]',
184+
const selectors = ['button[aria-label="Active Target"]',
185185
'.open-csolution-yml',
186-
'a[title="Configure Related Projects"]',
187-
'a[title="Debugger Configuration"]'];
186+
'button[aria-label="Configure Related Projects"]',
187+
'button[aria-label="Debug Adapter Configuration"]'];
188188

189189
React.act(() => {
190190
for (const selector of selectors) {
@@ -194,7 +194,7 @@ describe('ContextSelection', () => {
194194
}
195195
}
196196

197-
expect(listener).toHaveBeenCalledTimes(4);
197+
expect(listener).toHaveBeenCalledTimes(6);
198198
expect(listener).toHaveBeenCalledWith({ type: 'OPEN_HELP' });
199199
expect(listener).toHaveBeenCalledWith({ type: 'GET_CONTEXT_SELECTION_DATA' });
200200
expect(listener).toHaveBeenCalledWith({ type: 'GET_DEBUG_ADAPTERS' });

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const ManageSolution = (props: ManageSolutionProps) => {
8484
}, [props.messageHandler]);
8585

8686
const openFile = React.useCallback(
87-
(path: string) => props.messageHandler.push({ type: 'OPEN_FILE', path }),
87+
(path: string, external?: boolean) => props.messageHandler.push({ type: 'OPEN_FILE', path, external }),
8888
[props.messageHandler]
8989
);
9090

@@ -280,6 +280,23 @@ export const ManageSolution = (props: ManageSolutionProps) => {
280280

281281
const showCoreSelector = state.solutionData.availableCoreNames !== undefined && state.solutionData.availableCoreNames.length > 1;
282282

283+
const externalLink = (link: string, title: string, external?: boolean): React.JSX.Element => {
284+
return (<Button
285+
color="default"
286+
variant="link"
287+
style={{ padding: '0px 12px' }}
288+
title={title}
289+
aria-label={title}
290+
onClick={(e) => {
291+
e.preventDefault();
292+
e.stopPropagation();
293+
openFile(link, external);
294+
}}
295+
>
296+
<CmsisCodicon name='link-external' style={{ fontSize: '1em', display: 'inline' }} />
297+
</Button>);
298+
};
299+
283300
return (
284301
<React.StrictMode>
285302
<div className="manage-solution-frame">
@@ -302,7 +319,16 @@ export const ManageSolution = (props: ManageSolutionProps) => {
302319
<section className="targets-section">
303320
<div className='manage-solution-header'>
304321
<h3>Active Target</h3>
305-
<a onClick={() => openHelp()} title="Active Target" className="codicon codicon-link-external codicon-fix-size-sub"></a>
322+
<Button
323+
color="default"
324+
variant="link"
325+
style={{ padding: '0px 12px' }}
326+
title="Active Target"
327+
aria-label='Active Target'
328+
onClick={() => openHelp()}
329+
>
330+
<CmsisCodicon name='link-external' style={{ fontSize: '1em', display: 'inline' }} />
331+
</Button>
306332
</div>
307333
<div>
308334
Select target for build, load, and debug. The Target
@@ -319,7 +345,7 @@ export const ManageSolution = (props: ManageSolutionProps) => {
319345
<section className="projects-section">
320346
<div className='manage-solution-header'>
321347
<h3>Projects and Images for Target {state.solutionData.selectedTarget?.name}{state.solutionData.selectedTarget?.selectedSet && `@${state.solutionData.selectedTarget?.selectedSet}`}</h3>
322-
<a title="Configure Related Projects" href="https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/#configure-related-projects" className="codicon codicon-link-external codicon-fix-size-sub"></a>
348+
{externalLink('https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/#configure-related-projects', 'Configure Related Projects', true)}
323349
</div>
324350
<ProjectsTable
325351
projects={state.solutionData.projects}
@@ -336,7 +362,7 @@ export const ManageSolution = (props: ManageSolutionProps) => {
336362
<section className="debug-adapter">
337363
<div className='manage-solution-header'>
338364
<h3>Debug Adapter for Target {state.solutionData.selectedTarget?.name}{state.solutionData.selectedTarget?.selectedSet && `@${state.solutionData.selectedTarget?.selectedSet}`}</h3>
339-
<a title="Debugger Configuration" href="https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#debugger-configuration" className="codicon codicon-link-external codicon-fix-size-sub"></a>
365+
{externalLink('https://open-cmsis-pack.github.io/cmsis-toolbox/debugging/#debug-adapter-configuration', 'Debug Adapter Configuration', true)}
340366
</div>
341367

342368
<table>

0 commit comments

Comments
 (0)