align-items: baseline;
}
+.display-inline-flex-start {
+ display: inline-flex !important;
+ align-items: flex-start;
+}
+
.display-inline-flex-center {
display: inline-flex !important;
align-items: center;
.hotspot-content .markdown {
line-height: 1.8;
}
+
+.status-radio i {
+ margin-top: 5px;
+}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import styled from '@emotion/styled';
+import classNames from 'classnames';
import * as React from 'react';
import { translate } from '../../../../helpers/l10n';
import { HotspotStatusOption } from '../../../../types/security-hotspots';
export interface StatusDescriptionProps {
statusOption: HotspotStatusOption;
showTitle?: boolean;
+ statusInBadge?: boolean;
}
export default function StatusDescription(props: StatusDescriptionProps) {
- const { statusOption, showTitle } = props;
+ const { statusOption, showTitle, statusInBadge = true } = props;
return (
<Container>
<h3>
{showTitle && `${translate('status')}: `}
- <div className="badge">{translate('hotspots.status_option', statusOption)}</div>
+ <div className={classNames({ badge: statusInBadge })}>
+ {translate('hotspots.status_option', statusOption)}
+ </div>
</h3>
<div className="little-spacer-top">
{translate('hotspots.status_option', statusOption, 'description')}
return (
<Radio
checked={selectedStatus === status}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
+ alignLabel={true}
onCheck={props.onStatusChange}
value={status}>
- <StatusDescription statusOption={status} />
+ <StatusDescription statusOption={status} statusInBadge={false} />
</Radio>
);
};
it('should render correctly', () => {
expect(shallowRender()).toMatchSnapshot();
expect(shallowRender({ showTitle: true })).toMatchSnapshot('with title');
+ expect(shallowRender({ statusInBadge: false })).toMatchSnapshot('without status in badge');
});
function shallowRender(props?: Partial<StatusDescriptionProps>) {
</div>
</Styled(div)>
`;
+
+exports[`should render correctly: without status in badge 1`] = `
+<Styled(div)>
+ <h3>
+ <div
+ className=""
+ >
+ hotspots.status_option.TO_REVIEW
+ </div>
+ </h3>
+ <div
+ className="little-spacer-top"
+ >
+ hotspots.status_option.TO_REVIEW.description
+ </div>
+</Styled(div)>
+`;
className="big-padded"
>
<Radio
+ alignLabel={true}
checked={true}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="TO_REVIEW"
>
<StatusDescription
+ statusInBadge={false}
statusOption="TO_REVIEW"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="ACKNOWLEDGED"
>
<StatusDescription
+ statusInBadge={false}
statusOption="ACKNOWLEDGED"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="FIXED"
>
<StatusDescription
+ statusInBadge={false}
statusOption="FIXED"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="SAFE"
>
<StatusDescription
+ statusInBadge={false}
statusOption="SAFE"
/>
</Radio>
className="big-padded"
>
<Radio
+ alignLabel={true}
checked={true}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="TO_REVIEW"
>
<StatusDescription
+ statusInBadge={false}
statusOption="TO_REVIEW"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="ACKNOWLEDGED"
>
<StatusDescription
+ statusInBadge={false}
statusOption="ACKNOWLEDGED"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="FIXED"
>
<StatusDescription
+ statusInBadge={false}
statusOption="FIXED"
/>
</Radio>
<Radio
+ alignLabel={true}
checked={false}
- className="big-spacer-bottom"
+ className="big-spacer-bottom status-radio"
onCheck={[MockFunction]}
value="SAFE"
>
<StatusDescription
+ statusInBadge={false}
statusOption="SAFE"
/>
</Radio>
interface Props {
checked: boolean;
className?: string;
+ alignLabel?: boolean;
disabled?: boolean;
onCheck: (value: string) => void;
value: string;
};
render() {
- const { className, checked, children, disabled } = this.props;
+ const { className, checked, children, disabled, alignLabel = false } = this.props;
return (
<a
aria-checked={checked}
- className={classNames('display-inline-flex-center link-radio', className, { disabled })}
+ className={classNames(
+ alignLabel ? 'display-inline-flex-start' : 'display-inline-flex-center',
+ 'link-radio',
+ className,
+ { disabled }
+ )}
href="#"
onClick={this.handleClick}
role="radio">