Skip to content

Commit 0cc028a

Browse files
committed
Show pack links
1 parent dabf200 commit 0cc028a

3 files changed

Lines changed: 81 additions & 5 deletions

File tree

src/packs/pack-urls.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright 2026 Arm Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import 'jest';
18+
import { packURL } from './pack-urls';
19+
20+
describe('packURL', () => {
21+
it('returns a versions URL for a versioned pack ID', () => {
22+
expect(packURL('My::Pack@1.2.3', 'versions')).toBe('https://www.keil.arm.com/packs/pack-my/versions/');
23+
});
24+
25+
it('returns a base URL for a versioned pack ID when suffix is undefined', () => {
26+
expect(packURL('My::Pack@1.2.3', undefined)).toBe('https://www.keil.arm.com/packs/pack-my/');
27+
});
28+
29+
it('returns a versions URL for a versionless pack ID', () => {
30+
expect(packURL('My::Pack', 'versions')).toBe('https://www.keil.arm.com/packs/pack-my/versions/');
31+
});
32+
33+
it('returns a base URL for a versionless pack ID when suffix is undefined', () => {
34+
expect(packURL('My::Pack', undefined)).toBe('https://www.keil.arm.com/packs/pack-my/');
35+
});
36+
37+
it('returns the base packs URL for an empty pack ID when suffix is provided', () => {
38+
expect(packURL('', 'versions')).toBe('https://www.keil.arm.com/packs');
39+
});
40+
41+
it('returns the base packs URL for an empty pack ID when suffix is undefined', () => {
42+
expect(packURL('', undefined)).toBe('https://www.keil.arm.com/packs');
43+
});
44+
});

src/packs/pack-urls.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright 2026 Arm Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { extractPrefix, stripAffix } from "../utils/string-utils";
18+
19+
export const KEIL_ARM_COM_PACKS = 'https://www.keil.arm.com/packs';
20+
21+
export function packURL(packId: string | undefined, suffix?: string) {
22+
const vendor = extractPrefix(packId, '::').toLowerCase();
23+
const name = stripAffix(packId, '::', '@').toLowerCase();
24+
if (!name || !vendor) {
25+
return KEIL_ARM_COM_PACKS;
26+
}
27+
let url = `${KEIL_ARM_COM_PACKS}/${name}-${vendor}/`;
28+
if (suffix) {
29+
url += `${suffix}/`;
30+
}
31+
return url;
32+
}

src/views/manage-components-packs/view/components/pack-properties.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { parsePackId } from '../../data/pack-parse';
2424
import { EditFilled, MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
2525
import { CmsisCodicon } from '../../../common/components/cmsis-codicon';
2626
import { TargetSetData } from '../../components-data';
27+
import { packURL } from '../../../../packs/pack-urls';
2728

2829
interface PackPropertiesDialogProperties {
2930
pack?: PackRowDataType;
@@ -103,8 +104,7 @@ export const PackPropertiesDialog: React.FC<PackPropertiesDialogProperties> = ({
103104
setUnlockOf(pack?.name);
104105
};
105106

106-
const p = parsePackId(pack?.packId || '');
107-
const packUri = `https://www.keil.arm.com/packs/${p?.packName}-${p?.vendor}/versions/`.toLowerCase();
107+
const packVersionsUrl = packURL(pack?.packId, 'versions');
108108
const firstReferenceWithPath = pack?.references.find(reference => Boolean(reference.relPath?.trim()));
109109
const firstReferencePath = firstReferenceWithPath?.relPath?.trim();
110110
const versionOperators = firstReferencePath ? [none] : [none, '@', '@>=', '@^', '@~'];
@@ -231,12 +231,12 @@ export const PackPropertiesDialog: React.FC<PackPropertiesDialogProperties> = ({
231231
</Tooltip>
232232
</Col>
233233
<Col flex={1}>
234-
<Tooltip title={<><div>Show pack history on web portal</div>{onlineTooltip}</>}>
234+
<Tooltip title={<><div>Software pack versions</div>{onlineTooltip}</>}>
235235
<Button
236236
type="text"
237237
style={{ color: onlineTooltip ? 'var(--vscode-list-warningForeground)' : undefined }}
238-
onClick={() => { if (openFile) openFile(packUri, true); }}
239-
icon={<CmsisCodicon name="version-history" />}
238+
onClick={() => { if (openFile) openFile(packVersionsUrl, true); }}
239+
icon={<CmsisCodicon name="link-external" />}
240240
/>
241241
</Tooltip>
242242
</Col>

0 commit comments

Comments
 (0)