Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate accounts onboarding: Automatically preselect a Google Ads account when there is only one, as well as adjust the UI presentation #2608

Merged
21 changes: 18 additions & 3 deletions js/src/components/app-select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,29 @@
* it will be added to the container div's `className`,
* so that you can further control its style.
*
* @param {*} props
* @param {*} props The component props.
* @param {boolean} [props.selectSingleValue=false] Whether the select should show only one value.
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
*/
const AppSelectControl = ( props ) => {
const { className, ...rest } = props;
const { className, options, selectSingleValue, ...rest } = props;
asvinb marked this conversation as resolved.
Show resolved Hide resolved
const showSingleValue = selectSingleValue && options?.length === 1;

const selectProps = showSingleValue
? {

Check warning on line 27 in js/src/components/app-select-control/index.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/app-select-control/index.js#L27

Added line #L27 was not covered by tests
suffix: ' ',
tabIndex: '-1',
style: {
pointerEvents: 'none',
},
readOnly: true,
options,
...rest,
}
: { options, ...rest };

return (
<div className={ classNames( 'app-select-control', className ) }>
<SelectControl { ...rest } />
<SelectControl { ...selectProps } />
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const AdsAccountSelectControl = ( props ) => {
} ) ),
];

return <AppSelectControl options={ options } { ...rest } />;
return (
<AppSelectControl
selecSingleValue={ true }
options={ options }
{ ...rest }
/>
);
};

export default AdsAccountSelectControl;
1 change: 1 addition & 0 deletions js/src/components/merchant-center-select-control/index.js
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const MerchantCenterSelectControl = ( {
return (
<AppSelectControl
options={ options }
selectSingleValue={ true }
onChange={ onChange }
value={ value }
{ ...props }
Expand Down