-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract search and add to ads (#38192)
## Description Extract search and add to ADS. Fixes [#37888](#37888) ## Automation /ok-to-test tags="@tag.IDE, @tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12407865393> > Commit: dce12fb > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12407865393&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.IDE, @tag.Sanity` > Spec: > <hr>Thu, 19 Dec 2024 07:44:13 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced the `SearchAndAdd` component for enhanced search and add functionality. - Added a new Storybook story for the `SearchAndAdd` component, providing visual documentation and interaction examples. - **Bug Fixes** - Replaced the deprecated `AddAndSearchbar` component with `SearchAndAdd` in relevant areas of the application. - **Documentation** - Enhanced documentation for the `SearchAndAdd` component through Storybook. - **Chores** - Updated import statements to reflect the new component structure and removed obsolete components. - Modified locators to use data attributes for improved element identification in tests. - Added specific identifiers for testing frameworks to enhance testability of components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
ad810c0
commit 68264f1
Showing
12 changed files
with
124 additions
and
41 deletions.
There are no files selected for viewing
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
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
38 changes: 38 additions & 0 deletions
38
...ages/design-system/ads/src/Templates/EntityExplorer/SearchAndAdd/SearchAndAdd.stories.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,38 @@ | ||
/* eslint-disable no-console */ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { SearchAndAdd, type SearchAndAddProps } from "."; | ||
|
||
const meta: Meta<typeof SearchAndAdd> = { | ||
title: "ADS/Templates/Entity Explorer/Search And Add", | ||
component: SearchAndAdd, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template = (props: SearchAndAddProps) => { | ||
const { onAdd, onSearch, placeholder, showAddButton = true } = props; | ||
|
||
return ( | ||
<div style={{ width: 250 }}> | ||
<SearchAndAdd | ||
{...{ | ||
onAdd, | ||
onSearch, | ||
showAddButton, | ||
placeholder, | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export const Basic = Template.bind({}) as StoryObj; | ||
|
||
Basic.args = { | ||
onAdd: () => console.log("Add clicked"), | ||
onSearch: (searchTerm: string) => console.log(searchTerm), | ||
placeholder: "Search", | ||
showAddButton: true, | ||
}; |
16 changes: 16 additions & 0 deletions
16
...kages/design-system/ads/src/Templates/EntityExplorer/SearchAndAdd/SearchAndAdd.styles.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,16 @@ | ||
import styled from "styled-components"; | ||
|
||
import { Button } from "@appsmith/ads"; | ||
|
||
export const Root = styled.div` | ||
display: flex; | ||
gap: var(--ads-v2-spaces-3); | ||
width: 100%; | ||
`; | ||
|
||
export const SquareButton = styled(Button)` | ||
&& { | ||
max-width: 24px; | ||
min-width: 24px; | ||
} | ||
`; |
43 changes: 43 additions & 0 deletions
43
...ent/packages/design-system/ads/src/Templates/EntityExplorer/SearchAndAdd/SearchAndAdd.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,43 @@ | ||
import React, { forwardRef } from "react"; | ||
|
||
import { SearchInput } from "@appsmith/ads"; | ||
import * as Styles from "./SearchAndAdd.styles"; | ||
import type { SearchAndAddProps } from "./SearchAndAdd.types"; | ||
|
||
export const SearchAndAdd = forwardRef<HTMLInputElement, SearchAndAddProps>( | ||
(props, ref) => { | ||
const { | ||
onAdd, | ||
onSearch, | ||
placeholder, | ||
searchTerm = "", | ||
showAddButton, | ||
} = props; | ||
|
||
return ( | ||
<Styles.Root> | ||
<SearchInput | ||
data-testid="t--search-input" | ||
onChange={onSearch} | ||
placeholder={placeholder} | ||
ref={ref} | ||
size="sm" | ||
value={searchTerm} | ||
/> | ||
{showAddButton && ( | ||
<Styles.SquareButton | ||
aria-label="Add" | ||
data-testid="t--add-item" | ||
isIconButton | ||
kind="secondary" | ||
onClick={onAdd} | ||
size="sm" | ||
startIcon="add-line" | ||
/> | ||
)} | ||
</Styles.Root> | ||
); | ||
}, | ||
); | ||
|
||
SearchAndAdd.displayName = "SearchAndAdd"; |
12 changes: 12 additions & 0 deletions
12
...ackages/design-system/ads/src/Templates/EntityExplorer/SearchAndAdd/SearchAndAdd.types.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,12 @@ | ||
export interface SearchAndAddProps { | ||
/** Placeholder text for search input. */ | ||
placeholder?: string; | ||
/** Value for search input in controlled mode. */ | ||
searchTerm?: string; | ||
/** Callback to be called when add button is clicked. */ | ||
onAdd?: () => void; | ||
/** Callback to be called when search input value changes. */ | ||
onSearch?: (searchTerm: string) => void; | ||
/** Whether to show the add button. Allows to hide the button for users with insufficient access privileges. */ | ||
showAddButton: boolean; | ||
} |
2 changes: 2 additions & 0 deletions
2
app/client/packages/design-system/ads/src/Templates/EntityExplorer/SearchAndAdd/index.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,2 @@ | ||
export { SearchAndAdd } from "./SearchAndAdd"; | ||
export * from "./SearchAndAdd.types"; |
1 change: 1 addition & 0 deletions
1
app/client/packages/design-system/ads/src/Templates/EntityExplorer/index.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { ListItemContainer, ListHeaderContainer } from "./styles"; | ||
export { ListWithHeader } from "./ListWithHeader"; | ||
export { EditorSegments } from "./EditorSegments"; | ||
export * from "./SearchAndAdd"; |
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
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
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
29 changes: 0 additions & 29 deletions
29
app/client/src/pages/Editor/IDE/EditorPane/components/AddAndSearchbar.tsx
This file was deleted.
Oops, something went wrong.