import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon';
import { PopupPlacement } from 'sonar-ui-common/components/ui/popups';
import { translate } from 'sonar-ui-common/helpers/l10n';
-import { HotspotUpdateFields } from '../../../types/security-hotspots';
+import { DetailedHotspot, HotspotUpdateFields } from '../../../types/security-hotspots';
import HotspotActionsForm from './HotspotActionsForm';
export interface HotspotActionsProps {
- hotspotKey: string;
+ hotspot: DetailedHotspot;
onSubmit: (hotspot: HotspotUpdateFields) => void;
}
const ESCAPE_KEY = 'Escape';
export default function HotspotActions(props: HotspotActionsProps) {
+ const { hotspot } = props;
const [open, setOpen] = React.useState(false);
React.useEffect(() => {
return (
<div className="dropdown">
<Button onClick={() => setOpen(!open)}>
- {translate('hotspots.review_hotspot')}
+ {translate('hotspot.change_status', hotspot.status)}
<DropdownIcon className="little-spacer-left" />
</Button>
<OutsideClickHandler onClickOutside={() => setOpen(false)}>
<DropdownOverlay placement={PopupPlacement.BottomRight}>
<HotspotActionsForm
- hotspotKey={props.hotspotKey}
+ hotspotKey={hotspot.key}
onSubmit={data => {
setOpen(false);
props.onSubmit(data);
<div className="display-flex-space-between">
<h1>{hotspot.message}</h1>
{isLoggedIn(currentUser) && (
- <HotspotActions hotspotKey={hotspot.key} onSubmit={props.onUpdateHotspot} />
+ <HotspotActions hotspot={hotspot} onSubmit={props.onUpdateHotspot} />
)}
</div>
<div className="text-muted">
import * as React from 'react';
import { Button } from 'sonar-ui-common/components/controls/buttons';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { HotspotStatus } from '../../../../types/security-hotspots';
import HotspotActions, { HotspotActionsProps } from '../HotspotActions';
it('should render correctly', () => {
});
function shallowRender(props: Partial<HotspotActionsProps> = {}) {
- return shallow(<HotspotActions hotspotKey="key" onSubmit={jest.fn()} {...props} />);
+ return shallow(
+ <HotspotActions
+ hotspotKey="key"
+ hotspotStatus={HotspotStatus.TO_REVIEW}
+ onSubmit={jest.fn()}
+ {...props}
+ />
+ );
}
<Button
onClick={[Function]}
>
- hotspots.review_hotspot
+ hotspot.change_status.TO_REVIEW
<DropdownIcon
className="little-spacer-left"
/>
<Button
onClick={[Function]}
>
- hotspots.review_hotspot
+ hotspot.change_status.TO_REVIEW
<DropdownIcon
className="little-spacer-left"
/>
<Button
onClick={[Function]}
>
- hotspots.review_hotspot
+ hotspot.change_status.TO_REVIEW
<DropdownIcon
className="little-spacer-left"
/>
<Button
onClick={[Function]}
>
- hotspots.review_hotspot
+ hotspot.change_status.TO_REVIEW
<DropdownIcon
className="little-spacer-left"
/>
<Button
onClick={[Function]}
>
- hotspots.review_hotspot
+ hotspot.change_status.TO_REVIEW
<DropdownIcon
className="little-spacer-left"
/>
</h1>
<HotspotActions
hotspotKey="01fc972e-2a3c-433e-bcae-0bd7f88f5123"
+ hotspotStatus="RESOLVED"
onSubmit={[MockFunction]}
/>
</div>
hotspot.tabs.risk_description=What's the risk?
hotspot.tabs.vulnerability_description=Are you vulnerable?
hotspot.tabs.fix_recommendations=How can you fix it?
-hotspots.review_hotspot=Review Hotspot
+hotspot.change_status.REVIEWED=Change status
+hotspot.change_status.TO_REVIEW=Review Hotspot
hotspot.status.TO_REVIEW=To review
hotspot.status.FIXED=Fixed