Skip to content

Commit bbd6995

Browse files
fix: [UIE-10338] marketplace fixes (#13498)
* fix: [UIE-10338] marketplace fixes * fix: [UIE-10338] added changeset * fix: [UIE-10338] fixed unit tests
1 parent 6b9514b commit bbd6995

5 files changed

Lines changed: 62 additions & 20 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Marketplace Fixes: Improved texts and tooltips. Changed submit enable behavior in contact sales form ([#13498](https://github.com/linode/manager/pull/13498))

packages/manager/src/components/MultipleIPInput/MultipleIPInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface MultipeIPInputProps {
6868
/**
6969
* Text displayed on the button.
7070
*/
71-
buttonText?: string;
71+
buttonText?: React.ReactNode;
7272

7373
/**
7474
* Whether the first input field can be removed.

packages/manager/src/features/Marketplace/MarketplaceLanding/MarketplaceLanding.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export const MarketplaceLanding = () => {
199199
}}
200200
/>
201201
<Grid container mb={3} spacing={2}>
202-
<Grid size={{ xs: 12, sm: 12, md: 7 }}>
202+
<Grid size={{ xs: 12, sm: 12, md: 6 }}>
203203
<DebouncedSearchTextField
204204
clearable
205205
debounceTime={250}
@@ -218,16 +218,24 @@ export const MarketplaceLanding = () => {
218218
value={searchQuery ?? ''}
219219
/>
220220
</Grid>
221-
<Grid size={{ xs: 12, sm: 6, md: 2.5 }}>
221+
<Grid size={{ xs: 12, sm: 6, md: 3 }}>
222222
<Autocomplete
223223
data-pendo-id="Cloud Marketplace Catalog-Category"
224224
label="Category"
225+
noOptionsText="No categories match your search"
225226
onChange={(_, selected) =>
226227
updateSearchParam('category', selected?.label)
227228
}
228229
options={categoryOptions}
229230
placeholder="Category"
230231
renderOption={renderAutocompleteOption('category')}
232+
slotProps={{
233+
listbox: {
234+
sx: {
235+
maxHeight: '50vh',
236+
},
237+
},
238+
}}
231239
textFieldProps={{
232240
hideLabel: true,
233241
}}
@@ -236,10 +244,11 @@ export const MarketplaceLanding = () => {
236244
}
237245
/>
238246
</Grid>
239-
<Grid size={{ xs: 12, sm: 6, md: 2.5 }}>
247+
<Grid size={{ xs: 12, sm: 6, md: 3 }}>
240248
<Autocomplete
241249
data-pendo-id="Cloud Marketplace Catalog-Type"
242250
label="Type"
251+
noOptionsText="No types match your search"
243252
onChange={(_, selected) =>
244253
updateSearchParam('type', selected?.label)
245254
}

packages/manager/src/features/Marketplace/ProductDetails/ContactSalesDrawer.test.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('ContactSalesDrawer', () => {
8383
const noOfEmails = getAllByTestId('domain-transfer-input').length;
8484
if (noOfEmails < 2) {
8585
const addEmailButton = getByText(
86-
'Add a second, additional email address'
86+
'Click to add a second, additional email address'
8787
);
8888
expect(addEmailButton).toBeVisible();
8989
}
@@ -94,7 +94,9 @@ describe('ContactSalesDrawer', () => {
9494
<ContactSalesDrawer {...mockProps} />
9595
);
9696

97-
const addEmailButton = getByText('Add a second, additional email address');
97+
const addEmailButton = getByText(
98+
'Click to add a second, additional email address'
99+
);
98100
fireEvent.click(addEmailButton);
99101

100102
expect(getAllByTestId('domain-transfer-input')).toHaveLength(2);
@@ -105,7 +107,9 @@ describe('ContactSalesDrawer', () => {
105107
<ContactSalesDrawer {...mockProps} />
106108
);
107109

108-
const addEmailButton = getByText('Add a second, additional email address');
110+
const addEmailButton = getByText(
111+
'Click to add a second, additional email address'
112+
);
109113
fireEvent.click(addEmailButton);
110114

111115
let additionalEmailInputs = queryAllByTestId('domain-transfer-input');
@@ -176,18 +180,17 @@ describe('ContactSalesDrawer', () => {
176180
expect(selectedRegion).toHaveValue('United States Of America');
177181
});
178182

179-
it('shows an error message if a region is not selected on form submission', async () => {
180-
const { getByText, queryByText } = renderWithTheme(
183+
it('shows an error message if a region is not selected on blur', async () => {
184+
const { getByTestId, queryByText } = renderWithTheme(
181185
<ContactSalesDrawer {...mockProps} />
182186
);
183187

184-
const tc_consentCheckbox = screen
185-
.getByTestId('tc-consent-checkbox')
186-
.querySelector('input') as HTMLInputElement;
187-
fireEvent.click(tc_consentCheckbox);
188+
const regionInput = getByTestId('region-autocomplete').querySelector(
189+
'input'
190+
) as HTMLInputElement;
188191

189-
const submitButton = getByText('Submit');
190-
fireEvent.click(submitButton);
192+
fireEvent.focus(regionInput);
193+
fireEvent.blur(regionInput);
191194

192195
await waitFor(() => {
193196
expect(queryByText('Please select your region')).toBeVisible();
@@ -316,7 +319,8 @@ describe('ContactSalesDrawer', () => {
316319

317320
fireEvent.click(consentCheckbox);
318321

319-
expect(getByText('Submit')).toBeEnabled();
322+
// Submit should still be disabled because required fields (region, phone) are not filled
323+
expect(getByText('Submit')).toBeDisabled();
320324
});
321325

322326
it('expands the terms and conditions when the "Show details" button is clicked', async () => {

packages/manager/src/features/Marketplace/ProductDetails/ContactSalesDrawer.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
InputAdornment,
1212
LinkButton,
1313
Notice,
14+
PlusSignIcon,
1415
Stack,
1516
TextField,
1617
Typography,
@@ -124,6 +125,17 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
124125
});
125126

126127
const tcConsent = watch('tc_consent_given');
128+
const countryCode = watch('country_code');
129+
const phone = watch('phone');
130+
131+
const isSubmitDisabled =
132+
isSubmitting ||
133+
!tcConsent ||
134+
!countryCode ||
135+
!phone ||
136+
!!errors.country_code ||
137+
!!errors.phone ||
138+
!!errors.phone_country_code;
127139

128140
const dialingCodeFilterOptions = createFilterOptions({
129141
ignoreCase: true,
@@ -138,6 +150,7 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
138150
const handleFormReset = () => {
139151
reset();
140152
setSelectedCountry(null);
153+
setSelectedPhoneCountry(defaultCountry);
141154
};
142155

143156
const onSubmit = handleSubmit(async (values) => {
@@ -212,7 +225,16 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
212225
return (
213226
// Using MultipleIPInput component for additional emails since it allows for easy addition and removal of multiple entries, and it can display individual error messages for each email address.
214227
<MultipleIPInput
215-
buttonText="Add a second, additional email address"
228+
buttonText={
229+
<>
230+
<PlusSignIcon
231+
height={12}
232+
style={{ marginRight: 4 }}
233+
width={12}
234+
/>
235+
Click to add a second, additional email address
236+
</>
237+
}
216238
className={
217239
field.value?.length === MAX_ADDITIONAL_EMAILS
218240
? classes.hideAddEmailButton
@@ -265,6 +287,7 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
265287
}
266288
keepSearchEnabledOnMobile
267289
label="Region"
290+
noOptionsText="No regions match your search"
268291
onBlur={field.onBlur}
269292
onChange={(_event, country) => {
270293
setSelectedCountry(country);
@@ -337,6 +360,7 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
337360
option.label === value.label
338361
}
339362
label="Phone Number"
363+
noOptionsText="No country codes match your search"
340364
onBlur={field.onBlur}
341365
onChange={(_, country) => {
342366
setSelectedPhoneCountry(country);
@@ -625,11 +649,11 @@ export const ContactSalesDrawer = (props: ContactSalesDrawerProps) => {
625649
primaryButtonProps={{
626650
'data-pendo-id': 'Cloud Marketplace Contact Sales-Submit',
627651
label: 'Submit',
628-
disabled: isSubmitting || !tcConsent,
652+
disabled: isSubmitDisabled,
629653
type: 'submit',
630654
tooltipText:
631-
'Please agree to share your information with the partner to proceed.',
632-
alwaysShowTooltip: !tcConsent,
655+
'Please complete all required fields and agree to share your information with the partner to proceed',
656+
alwaysShowTooltip: isSubmitDisabled,
633657
}}
634658
secondaryButtonProps={{
635659
'data-pendo-id': 'Cloud Marketplace Contact Sales-Cancel',

0 commit comments

Comments
 (0)