aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Perrin <philippe.perrin@sonarsource.com>2023-06-22 16:06:10 +0200
committersonartech <sonartech@sonarsource.com>2023-06-23 20:03:17 +0000
commit6ab6cc4f0e7549d38ff7ef7ed761699729ac1ebd (patch)
tree464ba50eb4f0a0618efa601f3170f5764f65fe39
parent92a8b0c4db4d7a3de4929e4add44137f23f9cd10 (diff)
downloadsonarqube-6ab6cc4f0e7549d38ff7ef7ed761699729ac1ebd.tar.gz
sonarqube-6ab6cc4f0e7549d38ff7ef7ed761699729ac1ebd.zip
SONAR-19510 Improve styling of disabled radio buttons
-rw-r--r--server/sonar-web/design-system/src/components/RadioButton.tsx21
-rw-r--r--server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx12
-rw-r--r--server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx4
-rw-r--r--server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionDaysOption.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionPreviousVersionOption.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionSelector.tsx15
9 files changed, 38 insertions, 24 deletions
diff --git a/server/sonar-web/design-system/src/components/RadioButton.tsx b/server/sonar-web/design-system/src/components/RadioButton.tsx
index 7bfd61f4bbc..f374db14dc7 100644
--- a/server/sonar-web/design-system/src/components/RadioButton.tsx
+++ b/server/sonar-web/design-system/src/components/RadioButton.tsx
@@ -53,7 +53,16 @@ export function RadioButton({
};
return (
- <label className={classNames('sw-flex sw-items-center sw-cursor-pointer', className)}>
+ <label
+ className={classNames(
+ 'sw-flex sw-items-center',
+ {
+ 'sw-cursor-pointer': !disabled,
+ 'sw-cursor-not-allowed': disabled,
+ },
+ className
+ )}
+ >
<RadioButtonStyled
aria-disabled={disabled}
checked={checked}
@@ -72,6 +81,8 @@ export const RadioButtonStyled = styled.input`
appearance: none; //disables native style
border: ${themeBorder('default', 'radioBorder')};
+ ${tw`sw-cursor-pointer`}
+
${tw`sw-w-4 sw-min-w-4 sw-h-4 sw-min-h-4`}
${tw`sw-p-1 sw-mr-2`}
${tw`sw-inline-block`}
@@ -107,8 +118,6 @@ export const RadioButtonStyled = styled.input`
border: ${themeBorder('default', 'radioDisabledBorder')};
background-clip: unset;
- ${tw`sw-cursor-not-allowed`}
-
&.is-checked,
&:checked {
background-image: linear-gradient(
@@ -120,9 +129,9 @@ export const RadioButtonStyled = styled.input`
to right,
${themeColor('radioDisabledBackground')},
${themeColor('radioDisabledBackground')}
- );
- background-clip: content-box, padding-box;
- border: ${themeBorder('default', 'radioDisabledBorder')};
+ ) !important;
+ background-clip: content-box, padding-box !important;
+ border: ${themeBorder('default', 'radioDisabledBorder')} !important;
}
}
`;
diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx b/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx
index dfa41c26dd8..daffdc75925 100644
--- a/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx
+++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/Manual-it.tsx
@@ -149,7 +149,7 @@ it('global NCD option should be disabled if not compliant', async () => {
expect(ui.newCodeDefinitionHeader.get()).toBeInTheDocument();
expect(ui.inheritGlobalNcdRadio.get()).toBeInTheDocument();
- expect(ui.inheritGlobalNcdRadio.get()).toHaveClass('disabled');
+ expect(ui.inheritGlobalNcdRadio.get()).toBeDisabled();
expect(ui.projectCreateButton.get()).toBeDisabled();
});
@@ -182,9 +182,9 @@ it.each([ui.ncdOptionRefBranchRadio, ui.ncdOptionPreviousVersionRadio])(
expect(ui.newCodeDefinitionHeader.get()).toBeInTheDocument();
expect(ui.inheritGlobalNcdRadio.get()).toBeInTheDocument();
- expect(ui.inheritGlobalNcdRadio.get()).toHaveClass('disabled');
+ expect(ui.inheritGlobalNcdRadio.get()).toBeDisabled();
expect(ui.projectCreateButton.get()).toBeDisabled();
- expect(ui.overrideNcdRadio.get()).not.toHaveClass('disabled');
+ expect(ui.overrideNcdRadio.get()).toBeEnabled();
expect(option.get()).toHaveClass('disabled');
await user.click(ui.overrideNcdRadio.get());
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx
index 458436640ba..ca5db89b7e0 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingAnalysis.tsx
@@ -30,6 +30,7 @@ export interface Props {
export default function BaselineSettingAnalysis({ onSelect, selected }: Props) {
return (
<RadioCard
+ noRadio
disabled
onClick={() => onSelect(NewCodePeriodSettingType.SPECIFIC_ANALYSIS)}
selected={selected}
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx
index 36f9b536d8e..adf4c56df1b 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/BaselineSettingReferenceBranch.tsx
@@ -95,6 +95,7 @@ export default function BaselineSettingReferenceBranch(props: BaselineSettingRef
return (
<RadioCard
+ noRadio
className={className}
disabled={disabled}
onClick={() => props.onSelect(NewCodePeriodSettingType.REFERENCE_BRANCH)}
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx
index f1104622cfe..f20cc30acfc 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/ProjectBaselineSelector.tsx
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import classNames from 'classnames';
+import { RadioButton } from 'design-system';
import * as React from 'react';
-import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons';
-import Radio from '../../../components/controls/Radio';
import Tooltip from '../../../components/controls/Tooltip';
+import { ResetButtonLink, SubmitButton } from '../../../components/controls/buttons';
import GlobalNewCodeDefinitionDescription from '../../../components/new-code-definition/GlobalNewCodeDefinitionDescription';
import NewCodeDefinitionDaysOption from '../../../components/new-code-definition/NewCodeDefinitionDaysOption';
import NewCodeDefinitionPreviousVersionOption from '../../../components/new-code-definition/NewCodeDefinitionPreviousVersionOption';
@@ -99,7 +99,7 @@ export default function ProjectBaselineSelector(props: ProjectBaselineSelectorPr
return (
<form className="project-baseline-selector" onSubmit={props.onSubmit}>
<div className="big-spacer-top spacer-bottom" role="radiogroup">
- <Radio
+ <RadioButton
checked={!overrideGeneralSetting}
className="big-spacer-bottom"
disabled={!isGlobalNcdCompliant}
@@ -115,7 +115,7 @@ export default function ProjectBaselineSelector(props: ProjectBaselineSelectorPr
>
<span>{translate('project_baseline.global_setting')}</span>
</Tooltip>
- </Radio>
+ </RadioButton>
<div className="sw-ml-4">
<GlobalNewCodeDefinitionDescription
@@ -125,14 +125,14 @@ export default function ProjectBaselineSelector(props: ProjectBaselineSelectorPr
/>
</div>
- <Radio
+ <RadioButton
checked={overrideGeneralSetting}
className="huge-spacer-top"
onCheck={() => props.onToggleSpecificSetting(true)}
value="specific"
>
{translate('project_baseline.specific_setting')}
- </Radio>
+ </RadioButton>
</div>
<div className="big-spacer-left big-spacer-right project-baseline-setting">
diff --git a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx
index c26cbc5c972..b10faa7cdec 100644
--- a/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx
+++ b/server/sonar-web/src/main/js/apps/projectBaseline/components/__tests__/ProjectBaselineApp-it.tsx
@@ -75,7 +75,7 @@ it('prevents selection of global setting if it is not compliant and warns non-ad
await ui.appIsLoaded();
expect(ui.generalSettingRadio.get()).toBeChecked();
- expect(ui.generalSettingRadio.get()).toHaveClass('disabled');
+ expect(ui.generalSettingRadio.get()).toBeDisabled();
expect(ui.complianceWarning.get()).toBeVisible();
});
@@ -91,7 +91,7 @@ it('prevents selection of global setting if it is not compliant and warns admin
await ui.appIsLoaded();
expect(ui.generalSettingRadio.get()).toBeChecked();
- expect(ui.generalSettingRadio.get()).toHaveClass('disabled');
+ expect(ui.generalSettingRadio.get()).toBeDisabled();
expect(ui.complianceWarningAdmin.get()).toBeVisible();
expect(ui.complianceWarning.query()).not.toBeInTheDocument();
});
diff --git a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionDaysOption.tsx b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionDaysOption.tsx
index e6482306e27..3d9511bbfc0 100644
--- a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionDaysOption.tsx
+++ b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionDaysOption.tsx
@@ -41,6 +41,7 @@ export default function NewCodeDefinitionDaysOption(props: Props) {
return (
<RadioCard
+ noRadio
className={className}
disabled={disabled}
onClick={() => onSelect(NewCodePeriodSettingType.NUMBER_OF_DAYS)}
diff --git a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionPreviousVersionOption.tsx b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionPreviousVersionOption.tsx
index 263dbc0429e..ec113fb06a1 100644
--- a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionPreviousVersionOption.tsx
+++ b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionPreviousVersionOption.tsx
@@ -37,6 +37,7 @@ export default function NewCodeDefinitionPreviousVersionOption({
}: Props) {
return (
<RadioCard
+ noRadio
disabled={disabled}
onClick={() => onSelect(NewCodePeriodSettingType.PREVIOUS_VERSION)}
selected={selected}
diff --git a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionSelector.tsx b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionSelector.tsx
index a6d8887f6c0..ef28eeff0fe 100644
--- a/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionSelector.tsx
+++ b/server/sonar-web/src/main/js/components/new-code-definition/NewCodeDefinitionSelector.tsx
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { RadioButton } from 'design-system/lib';
import { noop } from 'lodash';
import * as React from 'react';
import { useEffect } from 'react';
@@ -28,7 +29,6 @@ import {
NewCodePeriodSettingType,
NewCodePeriodWithCompliance,
} from '../../types/types';
-import Radio from '../controls/Radio';
import RadioCard from '../controls/RadioCard';
import Tooltip from '../controls/Tooltip';
import { Alert } from '../ui/Alert';
@@ -95,8 +95,8 @@ export default function NewCodeDefinitionSelector(props: Props) {
<strong>{translate('new_code_definition.question')}</strong>
</p>
<div className="big-spacer-top spacer-bottom" role="radiogroup">
- <Radio
- ariaLabel={translate('new_code_definition.global_setting')}
+ <RadioButton
+ aria-label={translate('new_code_definition.global_setting')}
checked={selectedNcdType === NewCodePeriodSettingType.INHERITED}
className="big-spacer-bottom"
disabled={!iGlobalNcdCompliant}
@@ -112,7 +112,7 @@ export default function NewCodeDefinitionSelector(props: Props) {
>
<span>{translate('new_code_definition.global_setting')}</span>
</Tooltip>
- </Radio>
+ </RadioButton>
<div className="sw-ml-4">
{globalNcd && (
@@ -124,8 +124,8 @@ export default function NewCodeDefinitionSelector(props: Props) {
)}
</div>
- <Radio
- ariaLabel={translate('new_code_definition.specific_setting')}
+ <RadioButton
+ aria-label={translate('new_code_definition.specific_setting')}
checked={Boolean(
selectedNcdType && selectedNcdType !== NewCodePeriodSettingType.INHERITED
)}
@@ -134,7 +134,7 @@ export default function NewCodeDefinitionSelector(props: Props) {
value="specific"
>
{translate('new_code_definition.specific_setting')}
- </Radio>
+ </RadioButton>
</div>
<div className="big-spacer-left big-spacer-right project-baseline-setting">
@@ -160,6 +160,7 @@ export default function NewCodeDefinitionSelector(props: Props) {
/>
<RadioCard
+ noRadio
disabled={Boolean(
!selectedNcdType || selectedNcdType === NewCodePeriodSettingType.INHERITED
)}
29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/ServicesTest.php
blob: a46e28235f5529dbcd42b89bdf77c482e69ef6b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
 * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
 *
 * @author Joas Schilling <coding@schilljs.com>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace OCA\Theming\Tests;

use OCA\Theming\Capabilities;
use OCA\Theming\Controller\ThemingController;
use OCA\Theming\Settings\Admin;
use OCA\Theming\Settings\Section;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\AppFramework\App;
use OCP\Capabilities\ICapability;
use OCP\IL10N;
use OCP\Settings\ISection;
use OCP\Settings\ISettings;
use Test\TestCase;

/**
 * Class ServicesTest
 *
 * @group DB
 * @package OCA\Theming\Tests
 */
class ServicesTest extends TestCase  {
	/** @var \OCA\Activity\AppInfo\Application */
	protected $app;

	/** @var \OCP\AppFramework\IAppContainer */
	protected $container;

	protected function setUp() {
		parent::setUp();
		$this->app = new App('theming');
		$this->container = $this->app->getContainer();
	}

	public function queryData() {
		return [
			[IL10N::class],

			// lib/
			[Capabilities::class],
			[Capabilities::class, ICapability::class],
			[ThemingDefaults::class],
			[ThemingDefaults::class, \OC_Defaults::class],
			[Util::class],

			// Controller
			[ThemingController::class, ThemingController::class],

			// Settings
			[Admin::class],
			[Admin::class, ISettings::class],
			[Section::class],
			[Section::class, ISection::class],
		];
	}

	/**
	 * @dataProvider queryData
	 * @param string $service
	 * @param string $expected
	 */
	public function testContainerQuery($service, $expected = null) {
		if ($expected === null) {
			$expected = $service;
		}
		$this->assertTrue($this->container->query($service) instanceof $expected);
	}
}