};
return (
- <label
+ <LabelStyled
className={classNames(
- 'sw-flex sw-items-center',
{
- 'sw-cursor-pointer': !disabled,
- 'sw-cursor-not-allowed': disabled,
+ disabled,
},
className
)}
{...htmlProps}
/>
{children}
- </label>
+ </LabelStyled>
);
}
+const LabelStyled = styled.label<{ disabled?: boolean }>`
+ ${tw`sw-flex sw-items-center`}
+ ${tw`sw-cursor-pointer`}
+
+ &.disabled {
+ color: ${themeColor('radioDisabledLabel')};
+ ${tw`sw-cursor-not-allowed`}
+ }
+`;
+
export const RadioButtonStyled = styled.input`
appearance: none; //disables native style
border: ${themeBorder('default', 'radioBorder')};
radioDisabled: secondary.default,
radioDisabledBackground: secondary.light,
radioDisabledBorder: secondary.default,
+ radioDisabledLabel: COLORS.blueGrey[300],
// switch
switch: secondary.default,
{({ data: githubProvisioningStatus, isFetching }) => (
<VisibilitySelector
canTurnToPrivate={canTurnToPrivate}
- className="big-spacer-top big-spacer-bottom"
+ className="sw-flex big-spacer-top big-spacer-bottom"
onChange={this.handleVisibilityChange}
loading={loading || isFetching}
disabled={isGitHubProject && !!githubProvisioningStatus}
);
await ui.appLoaded();
- expect(ui.visibilityRadio(Visibility.Public).get()).toHaveClass('disabled');
+ expect(ui.visibilityRadio(Visibility.Public).get()).toBeDisabled();
expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked();
- expect(ui.visibilityRadio(Visibility.Private).get()).toHaveClass('disabled');
+ expect(ui.visibilityRadio(Visibility.Private).get()).toBeDisabled();
await act(async () => {
await ui.turnProjectPrivate();
});
* 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 Radio from '../../components/controls/Radio';
import { translate } from '../../helpers/l10n';
import { Visibility } from '../../types/component';
return (
<div className={classNames(className)}>
{Object.values(Visibility).map((v) => (
- <Radio
+ <RadioButton
className={`huge-spacer-right visibility-${v}`}
key={v}
value={v}
<p className="note">{translate('visibility', v, 'description.long')}</p>
)}
</div>
- </Radio>
+ </RadioButton>
))}
</div>
);
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2023 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import Radio from '../../../components/controls/Radio';
-import { Visibility } from '../../../types/component';
-import VisibilitySelector, { VisibilitySelectorProps } from '../VisibilitySelector';
-
-it('changes visibility', () => {
- const onChange = jest.fn();
- const wrapper = shallowRender({ onChange });
- expect(wrapper).toMatchSnapshot();
-
- wrapper.find(Radio).first().props().onCheck(Visibility.Private);
- expect(onChange).toHaveBeenCalledWith(Visibility.Private);
-
- wrapper.setProps({ visibility: Visibility.Private });
- expect(wrapper).toMatchSnapshot();
-
- wrapper.find(Radio).first().props().onCheck(Visibility.Public);
- expect(onChange).toHaveBeenCalledWith(Visibility.Public);
-});
-
-it('renders disabled', () => {
- expect(shallowRender({ canTurnToPrivate: false })).toMatchSnapshot();
-});
-
-function shallowRender(props?: Partial<VisibilitySelectorProps>) {
- return shallow<VisibilitySelectorProps>(
- <VisibilitySelector
- className="test-classname"
- canTurnToPrivate
- onChange={jest.fn()}
- visibility={Visibility.Public}
- {...props}
- />
- );
-}
+++ /dev/null
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`changes visibility 1`] = `
-<div
- className="test-classname"
->
- <Radio
- checked={true}
- className="huge-spacer-right visibility-public"
- disabled={false}
- key="public"
- onCheck={[MockFunction]}
- value="public"
- >
- <div>
- visibility.public
- </div>
- </Radio>
- <Radio
- checked={false}
- className="huge-spacer-right visibility-private"
- disabled={false}
- key="private"
- onCheck={[MockFunction]}
- value="private"
- >
- <div>
- visibility.private
- </div>
- </Radio>
-</div>
-`;
-
-exports[`changes visibility 2`] = `
-<div
- className="test-classname"
->
- <Radio
- checked={false}
- className="huge-spacer-right visibility-public"
- disabled={false}
- key="public"
- onCheck={
- [MockFunction] {
- "calls": [
- [
- "private",
- ],
- ],
- "results": [
- {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- value="public"
- >
- <div>
- visibility.public
- </div>
- </Radio>
- <Radio
- checked={true}
- className="huge-spacer-right visibility-private"
- disabled={false}
- key="private"
- onCheck={
- [MockFunction] {
- "calls": [
- [
- "private",
- ],
- ],
- "results": [
- {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- value="private"
- >
- <div>
- visibility.private
- </div>
- </Radio>
-</div>
-`;
-
-exports[`renders disabled 1`] = `
-<div
- className="test-classname"
->
- <Radio
- checked={true}
- className="huge-spacer-right visibility-public"
- disabled={false}
- key="public"
- onCheck={[MockFunction]}
- value="public"
- >
- <div>
- visibility.public
- </div>
- </Radio>
- <Radio
- checked={false}
- className="huge-spacer-right visibility-private"
- disabled={true}
- key="private"
- onCheck={[MockFunction]}
- value="private"
- >
- <div>
- visibility.private
- </div>
- </Radio>
-</div>
-`;