Browse Source

SONAR-14111 Fix label in IDE selection dropdown when description is empty

tags/8.6.0.39681
Jean-Baptiste Lievremont 3 years ago
parent
commit
0a6b1e71cd

+ 11
- 7
server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotOpenInIdeOverlay.tsx View File

@@ -30,12 +30,16 @@ export const HotspotOpenInIdeOverlay = ({
}) =>
ides.length > 1 ? (
<ul className="menu">
{ides.map(ide => (
<li key={ide.port}>
<a href="#" onClick={() => onIdeSelected(ide)}>
{ide.ideName} - {ide.description}
</a>
</li>
))}
{ides.map(ide => {
const { ideName, description } = ide;
const label = ideName + (description ? ` - ${description}` : '');
return (
<li key={ide.port}>
<a href="#" onClick={() => onIdeSelected(ide)}>
{label}
</a>
</li>
);
})}
</ul>
) : null;

+ 1
- 1
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/HotspotOpenInIdeOverlay-test.tsx View File

@@ -39,7 +39,7 @@ it('should render nothing with fewer than 2 IDE', () => {
it('should render menu and select the right IDE', () => {
const onIdeSelected = jest.fn();
const ide1 = { port: 0, ideName: 'Polop', description: 'Plouf' };
const ide2 = { port: 1, ideName: 'Foo', description: 'Bar' };
const ide2 = { port: 1, ideName: 'Foo', description: '' };
const wrapper = shallow(
<HotspotOpenInIdeOverlay ides={[ide1, ide2]} onIdeSelected={onIdeSelected} />
);

+ 1
- 5
server/sonar-web/src/main/js/apps/security-hotspots/components/__tests__/__snapshots__/HotspotOpenInIdeOverlay-test.tsx.snap View File

@@ -11,9 +11,7 @@ exports[`should render menu and select the right IDE 1`] = `
href="#"
onClick={[Function]}
>
Polop
-
Plouf
Polop - Plouf
</a>
</li>
<li
@@ -24,8 +22,6 @@ exports[`should render menu and select the right IDE 1`] = `
onClick={[Function]}
>
Foo
-
Bar
</a>
</li>
</ul>

Loading…
Cancel
Save