-
Notifications
You must be signed in to change notification settings - Fork 364
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
upcoming: [M3-7874] - Linode Create Refactor - Marketplace - Part 1 #10401
Merged
bnussman-akamai
merged 5 commits into
linode:develop
from
bnussman-akamai:M3-7572-linode-create-refactor-marketplace-part-1
Apr 25, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2ae14b
initial marketplace UI
bnussman 262cdd8
unit test
bnussman e26ba06
Added changeset: Linode Create Refactor - Marketplace - Part 1
bnussman 798bc6d
Merge branch 'develop' into M3-7572-linode-create-refactor-marketplacβ¦
bnussman 4f592f8
make categories dynamic - thanks @abailly-akamai
bnussman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10401-upcoming-features-1713899458134.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Linode Create Refactor - Marketplace - Part 1 ([#10401](https://github.com/linode/manager/pull/10401)) |
74 changes: 74 additions & 0 deletions
74
packages/manager/src/features/Linodes/LinodeCreatev2/Tabs/Marketplace/Marketplace.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { userEvent } from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { renderWithThemeAndHookFormContext } from 'src/utilities/testHelpers'; | ||
|
||
import { Marketplace } from './Marketplace'; | ||
import { uniqueCategories } from './utilities'; | ||
|
||
describe('Marketplace', () => { | ||
it('should render a header', () => { | ||
const { getByText } = renderWithThemeAndHookFormContext({ | ||
component: <Marketplace />, | ||
}); | ||
|
||
const heading = getByText('Select an App'); | ||
|
||
expect(heading).toBeVisible(); | ||
expect(heading.tagName).toBe('H2'); | ||
}); | ||
|
||
it('should render a search field', () => { | ||
const { getByPlaceholderText } = renderWithThemeAndHookFormContext({ | ||
component: <Marketplace />, | ||
}); | ||
|
||
const input = getByPlaceholderText('Search for app name'); | ||
|
||
expect(input).toBeVisible(); | ||
expect(input).toBeEnabled(); | ||
}); | ||
|
||
it('should render a category select', () => { | ||
const { getByPlaceholderText } = renderWithThemeAndHookFormContext({ | ||
component: <Marketplace />, | ||
}); | ||
|
||
const input = getByPlaceholderText('Select category'); | ||
|
||
expect(input).toBeVisible(); | ||
expect(input).toBeEnabled(); | ||
}); | ||
|
||
it('should allow the user to select a category', async () => { | ||
const { | ||
getByLabelText, | ||
getByPlaceholderText, | ||
getByText, | ||
} = renderWithThemeAndHookFormContext({ | ||
component: <Marketplace />, | ||
}); | ||
|
||
const select = getByPlaceholderText('Select category'); | ||
|
||
await userEvent.click(select); | ||
|
||
// Verify all categories are rendered in the dropdown list | ||
for (const category of uniqueCategories) { | ||
expect(getByText(category)).toBeVisible(); | ||
} | ||
|
||
// Select a category | ||
await userEvent.click(getByText('Databases')); | ||
|
||
// Verify value updates | ||
expect(select).toHaveDisplayValue('Databases'); | ||
|
||
// Verify the category can be cleared | ||
const clearButton = getByLabelText('Clear'); | ||
|
||
await userEvent.click(clearButton); | ||
|
||
expect(select).toHaveDisplayValue(''); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/manager/src/features/Linodes/LinodeCreatev2/Tabs/Marketplace/Marketplace.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
|
||
import { Autocomplete } from 'src/components/Autocomplete/Autocomplete'; | ||
import { DebouncedSearchTextField } from 'src/components/DebouncedSearchTextField'; | ||
import { Paper } from 'src/components/Paper'; | ||
import { Stack } from 'src/components/Stack'; | ||
import { Typography } from 'src/components/Typography'; | ||
|
||
import { categoryOptions } from './utilities'; | ||
|
||
export const Marketplace = () => { | ||
return ( | ||
<Paper> | ||
<Stack spacing={2}> | ||
<Typography variant="h2">Select an App</Typography> | ||
<Stack direction="row" flexWrap="wrap" gap={1}> | ||
<DebouncedSearchTextField | ||
InputProps={{ sx: { maxWidth: 'unset !important' } }} | ||
containerProps={{ flexGrow: 1 }} | ||
fullWidth | ||
hideLabel | ||
label="Search marketplace" | ||
noMarginTop | ||
placeholder="Search for app name" | ||
/> | ||
<Autocomplete | ||
textFieldProps={{ | ||
containerProps: { sx: { minWidth: 250 } }, | ||
hideLabel: true, | ||
}} | ||
label="Select category" | ||
options={categoryOptions} | ||
placeholder="Select category" | ||
/> | ||
</Stack> | ||
</Stack> | ||
</Paper> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/manager/src/features/Linodes/LinodeCreatev2/Tabs/Marketplace/utilities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { oneClickApps } from 'src/features/OneClickApps/oneClickApps'; | ||
|
||
/** | ||
* Get all categories from our marketplace apps list so | ||
* we can generate a dynamic list of category options. | ||
*/ | ||
const categories = oneClickApps.reduce((acc, app) => { | ||
return [...acc, ...app.categories]; | ||
}, []); | ||
|
||
export const uniqueCategories = Array.from(new Set(categories)); | ||
|
||
/** | ||
* A list of unique categories to be shown in a Select/Autocomplete | ||
*/ | ||
export const categoryOptions = uniqueCategories.map((category) => ({ | ||
label: category, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix the slight height discrepancy that has always existed between these two inputs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try taking a look, but if I can't figure it our cleanly, I'll make a ticket for this