From e7c105e8b722e212a9f2396e54f7c1f2b6309951 Mon Sep 17 00:00:00 2001 From: Revanshu Paliwal Date: Mon, 2 Oct 2023 17:39:36 +0200 Subject: [PATCH] SONAR-20500 Background, layout and other fixes for rules page --- .../js/app/components/GlobalContainer.tsx | 1 + .../coding-rules/components/BulkChange.tsx | 6 +- .../components/CodingRulesApp.tsx | 235 ++++++++++-------- .../coding-rules/components/RuleDetails.tsx | 15 +- .../coding-rules/components/RuleListItem.tsx | 4 +- .../main/js/components/common/PageCounter.tsx | 2 +- .../__snapshots__/PageCounter-test.tsx.snap | 2 +- .../resources/org/sonar/l10n/core.properties | 2 +- 8 files changed, 148 insertions(+), 119 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/GlobalContainer.tsx b/server/sonar-web/src/main/js/app/components/GlobalContainer.tsx index 375edebed50..d099db095ad 100644 --- a/server/sonar-web/src/main/js/app/components/GlobalContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/GlobalContainer.tsx @@ -51,6 +51,7 @@ const TEMP_PAGELIST_WITH_NEW_BACKGROUND = [ '/project/information', '/web_api_v2', '/quality_gates', + '/coding_rules', ]; const TEMP_PAGELIST_WITH_NEW_BACKGROUND_WHITE = ['/tutorials', '/projects/create']; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx index bf8ff0c4caa..0dde26c5ffb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx @@ -108,7 +108,8 @@ export default class BulkChange extends React.PureComponent { {allowActivateOnProfile && profile && ( - {translate('coding_rules.activate_in')} {profile.name} + {translate('coding_rules.activate_in')}{' '} + {profile.name} )} @@ -118,7 +119,8 @@ export default class BulkChange extends React.PureComponent { {allowDeactivateOnProfile && profile && ( - {translate('coding_rules.deactivate_in')} {profile.name} + {translate('coding_rules.deactivate_in')}{' '} + {profile.name} )} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx index ad4b71ea151..c787c6dddbb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/CodingRulesApp.tsx @@ -17,7 +17,16 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { InputSearch } from 'design-system'; +import styled from '@emotion/styled'; +import { + InputSearch, + LAYOUT_FOOTER_HEIGHT, + LAYOUT_GLOBAL_NAV_HEIGHT, + LargeCenteredLayout, + PageContentFontWrapper, + themeBorder, + themeColor, +} from 'design-system'; import { keyBy } from 'lodash'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; @@ -26,11 +35,9 @@ import { getRulesApp, searchRules } from '../../../api/rules'; import { getValue } from '../../../api/settings'; import withCurrentUserContext from '../../../app/components/current-user/withCurrentUserContext'; import A11ySkipTarget from '../../../components/a11y/A11ySkipTarget'; -import ScreenPositionHelper from '../../../components/common/ScreenPositionHelper'; import ListFooter from '../../../components/controls/ListFooter'; import Suggestions from '../../../components/embed-docs-modal/Suggestions'; import { Location, Router, withRouter } from '../../../components/hoc/withRouter'; -import BackIcon from '../../../components/icons/BackIcon'; import '../../../components/search-navigator.css'; import { isDatePicker, isInput, isShortcut } from '../../../helpers/keyboardEventHelpers'; import { KeyboardKeys } from '../../../helpers/keycodes'; @@ -97,6 +104,8 @@ interface State { rules: Rule[]; } +const RULE_LIST_HEADER_HEIGHT = 68; + export class CodingRulesApp extends React.PureComponent { mounted = false; @@ -585,119 +594,117 @@ export class CodingRulesApp extends React.PureComponent { )} -
- - {({ top }) => ( - - )} - - -
-
-
-
- -
- - - {openRule ? ( - - - {usingPermalink - ? translate('coding_rules.see_all') - : translate('coding_rules.return_to_list')} - - ) : ( - this.renderBulkButton() - )} - {!usingPermalink && ( - - )} -
-
-
-
- -
- {openRule ? ( - - ) : ( - <> -
    - {rules.map((rule) => ( - - ))} -
- {paging !== undefined && ( - + ) : ( + <> +
    + {rules.map((rule) => ( + + ))} +
+ {paging !== undefined && ( + + )} + )} - - )} +
+
- - + + ); } @@ -727,3 +734,11 @@ function parseFacets(rawFacets: { property: string; values: { count: number; val } export default withRouter(withCurrentUserContext(CodingRulesApp)); + +const StyledContentWrapper = styled.div` + box-sizing: border-box; + background-color: ${themeColor('filterbar')}; + border: ${themeBorder('default', 'filterbarBorder')}; + border-bottom: none; + overflow-x: hidden; +`; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx index cdf4b644195..49ca07211b6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetails.tsx @@ -17,11 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import styled from '@emotion/styled'; import { ButtonSecondary, DangerButtonSecondary, HelperHintIcon, SubHeadingHighlight, + themeBorder, + themeColor, } from 'design-system'; import * as React from 'react'; import { Profile } from '../../../api/quality-profiles'; @@ -168,7 +171,7 @@ export default class RuleDetails extends React.PureComponent { const isEditable = canWrite && !!this.props.allowCustomRules && isCustom; return ( -
+ {
- + ); } } + +const StyledRuleDetails = styled.div` + box-sizing: border-box; + border-radius: 4px; + background-color: ${themeColor('filterbar')}; + border: ${themeBorder('default', 'filterbarBorder')}; + overflow-x: hidden; +`; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index 753585d3382..c38cf54d036 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -96,7 +96,7 @@ export default class RuleListItem extends React.PureComponent { } return ( -
+
{selectedProfile && selectedProfile.parentName && ( <> @@ -201,7 +201,7 @@ export default class RuleListItem extends React.PureComponent { return ( diff --git a/server/sonar-web/src/main/js/components/common/PageCounter.tsx b/server/sonar-web/src/main/js/components/common/PageCounter.tsx index 8ad2fa057e5..8ef45129e65 100644 --- a/server/sonar-web/src/main/js/components/common/PageCounter.tsx +++ b/server/sonar-web/src/main/js/components/common/PageCounter.tsx @@ -31,7 +31,7 @@ export interface PageCounterProps { export default function PageCounter({ className, current, label, total }: PageCounterProps) { return (
- + {current !== undefined && formatMeasure(current + 1, MetricType.Integer) + ' / '} {formatMeasure(total, MetricType.Integer)} diff --git a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/PageCounter-test.tsx.snap b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/PageCounter-test.tsx.snap index 2ac7d76bea8..a36f29997fd 100644 --- a/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/PageCounter-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/common/__tests__/__snapshots__/PageCounter-test.tsx.snap @@ -3,7 +3,7 @@ exports[`should render correctly 1`] = `
124 /