Skip to content

Do not show used and latest pack info if not available#266

Open
edriouk wants to merge 3 commits into
mainfrom
packDisplayName
Open

Do not show used and latest pack info if not available#266
edriouk wants to merge 3 commits into
mainfrom
packDisplayName

Conversation

@edriouk
Copy link
Copy Markdown
Collaborator

@edriouk edriouk commented May 26, 2026

Fixes

Changes

  • Do not show used pack if pack is not installed (not available)
  • do not show latest installed pack if no pack installed

Screenshots

image

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

@edriouk edriouk requested a review from Copilot May 26, 2026 15:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 26, 2026

2 new issues

Tool Category Rule Count
qlty Duplication Found 16 lines of similar code in 2 locations (mass = 77) 2

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the “Pack Properties” dialog in the Manage Components/Packs webview to avoid displaying “Used Pack” and “Latest Installed Pack” details when the selected pack is not installed/available (Issue #255).

Changes:

  • Introduces packDisplayName to suppress rendering pack identifiers when the pack is reported as “Pack not installed”.
  • Disables the “Update” action when there is no installed/latest pack to operate on.
  • Adds unit tests covering the new “hide when not installed” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/views/manage-components-packs/view/components/pack-properties.tsx Adjusts displayed pack identifiers and update-button enablement when pack info isn’t available.
src/views/manage-components-packs/view/components/pack-properties.test.tsx Adds tests intended to validate hiding/displaying “Used Pack” under different installation states.
Comments suppressed due to low confidence (2)

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

  • hasNewerOnlineVersion becomes true when latestInstalledPack is empty/undefined (because ''.endsWith(...) is false). That makes the “versions” button show the warning color even when there is no installed version to compare against, which is inconsistent with the meaning of “newer online version”. Gate this comparison on latestInstalledPack being truthy (or track installed version separately) so the warning state only appears when an installed version exists.
    const latestInstalledPack = latestUpgradable ? `${pack?.name}@${latestUpgradable}` : packDisplayName;
    const hasNewerOnlineVersion = !!pack?.latestOnlineVersion && !latestInstalledPack?.endsWith(pack.latestOnlineVersion);
    const onlineTooltip = hasNewerOnlineVersion ? <div>Latest version available online: {pack.latestOnlineVersion}</div> : undefined;

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

  • The “passes ... to PackTitleLink” tests only check that the cell textContent is empty/non-empty, but PackTitleLink always renders an external-link button even when packName is empty. This means the test can pass while still showing an unlabeled clickable icon in the UI. Consider asserting on the presence/absence of the link button (e.g., getByRole('link', { name: 'Open pack URL' })) and/or that the row is not rendered at all when the pack isn’t installed.
    it('passes empty packName to PackTitleLink when description is "Pack not installed" and openFile is provided', () => {
        const pack = createMockPack({ description: 'Pack not installed' });
        const mockOpenFile = jest.fn();

        render(
            <PackPropertiesDialog
                pack={pack}
                state={{ unlilnkRequestStack: [], selectedTargetType: selectedTargetType }}
                allOrigins={createMockAllOrigins()}
                openFile={mockOpenFile}
                onClose={mockOnClose}
            />
        );

        const table = screen.getByText('Used Pack:').closest('table');
        expect(table).toBeDefined();
        if (table) {
            const cells = table.querySelectorAll('td');
            const usedPackCell = Array.from(cells).find(cell => cell.textContent === 'Used Pack:');
            if (usedPackCell) {
                const valueCell = usedPackCell.nextElementSibling as HTMLElement;
                // PackTitleLink with empty packName should not display visible text
                expect(valueCell?.textContent?.trim()).toBe('');
            }
        }
    });

Comment thread src/views/manage-components-packs/view/components/pack-properties.tsx Outdated
@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 26, 2026

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
...ws/manage-components-packs/view/components/pack-properties.tsx100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

edriouk and others added 2 commits May 27, 2026 08:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
/>
);

expect(screen.queryByText('Used Pack:')).toBeNull();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 16 lines of similar code in 2 locations (mass = 77) [qlty:similar-code]

/>
);

expect(screen.getAllByText('ARM::CMSIS@6.1.0')).toBeDefined();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 16 lines of similar code in 2 locations (mass = 77) [qlty:similar-code]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants