From c34fc36ca36273f0b920b7e75a1264cc6261027c Mon Sep 17 00:00:00 2001 From: Guillaume Peoc'h Date: Tue, 15 Mar 2022 12:05:08 +0100 Subject: [PATCH] SONAR-16141 Security hotspot status radio UI --- .../src/main/js/app/styles/init/misc.css | 5 +++ .../components/HotspotViewer.css | 4 +++ .../components/status/StatusDescription.tsx | 8 +++-- .../status/StatusSelectionRenderer.tsx | 5 +-- .../__tests__/StatusDescription-test.tsx | 1 + .../StatusDescription-test.tsx.snap | 17 ++++++++++ .../StatusSelectionRenderer-test.tsx.snap | 32 ++++++++++++++----- .../src/main/js/components/controls/Radio.tsx | 10 ++++-- 8 files changed, 68 insertions(+), 14 deletions(-) diff --git a/server/sonar-web/src/main/js/app/styles/init/misc.css b/server/sonar-web/src/main/js/app/styles/init/misc.css index ecb1d640698..b5269470f8a 100644 --- a/server/sonar-web/src/main/js/app/styles/init/misc.css +++ b/server/sonar-web/src/main/js/app/styles/init/misc.css @@ -489,6 +489,11 @@ th.huge-spacer-right { 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; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.css b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.css index 30cf6cd2522..08bc0491165 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.css +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/HotspotViewer.css @@ -33,3 +33,7 @@ .hotspot-content .markdown { line-height: 1.8; } + +.status-radio i { + margin-top: 5px; +} diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusDescription.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusDescription.tsx index 63eb4abc3b9..2f6ccbc222b 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusDescription.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusDescription.tsx @@ -18,6 +18,7 @@ * 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'; @@ -25,16 +26,19 @@ 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 (

{showTitle && `${translate('status')}: `} -
{translate('hotspots.status_option', statusOption)}
+
+ {translate('hotspots.status_option', statusOption)} +

{translate('hotspots.status_option', statusOption, 'description')} diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx index e9af5ed7f5e..4260f4cc978 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/StatusSelectionRenderer.tsx @@ -45,10 +45,11 @@ export default function StatusSelectionRenderer(props: StatusSelectionRendererPr return ( - + ); }; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/StatusDescription-test.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/StatusDescription-test.tsx index 025b58e844e..8fca0afc6c5 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/StatusDescription-test.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/StatusDescription-test.tsx @@ -25,6 +25,7 @@ import StatusDescription, { StatusDescriptionProps } from '../StatusDescription' 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) { diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusDescription-test.tsx.snap b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusDescription-test.tsx.snap index 6eb6b70e5fb..a2062714e3b 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusDescription-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusDescription-test.tsx.snap @@ -34,3 +34,20 @@ exports[`should render correctly: with title 1`] = `
`; + +exports[`should render correctly: without status in badge 1`] = ` + +

+
+ hotspots.status_option.TO_REVIEW +
+

+
+ hotspots.status_option.TO_REVIEW.description +
+
+`; diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap index 0f1f287ca77..d0f786cb32b 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/security-hotspots/components/status/__tests__/__snapshots__/StatusSelectionRenderer-test.tsx.snap @@ -8,42 +8,50 @@ exports[`should render correctly 1`] = ` className="big-padded" > @@ -88,42 +96,50 @@ exports[`should render correctly: loading 1`] = ` className="big-padded" > diff --git a/server/sonar-web/src/main/js/components/controls/Radio.tsx b/server/sonar-web/src/main/js/components/controls/Radio.tsx index 1af39aca0d2..08891b07b67 100644 --- a/server/sonar-web/src/main/js/components/controls/Radio.tsx +++ b/server/sonar-web/src/main/js/components/controls/Radio.tsx @@ -24,6 +24,7 @@ import './Radio.css'; interface Props { checked: boolean; className?: string; + alignLabel?: boolean; disabled?: boolean; onCheck: (value: string) => void; value: string; @@ -39,12 +40,17 @@ export default class Radio extends React.PureComponent { }; render() { - const { className, checked, children, disabled } = this.props; + const { className, checked, children, disabled, alignLabel = false } = this.props; return ( -- 2.39.5