-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup StatusIcon component states (#12039)
* Start cleanup of StatusIcon component and add unit test * Update StatusIcon booleans to use single status prop * Update AllConnectionStatusCell component to use configuration-based rendering. * Cleanup code bsed on PR review
- Loading branch information
Showing
11 changed files
with
154 additions
and
142 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
interface Props { | ||
color?: string; | ||
title?: string; | ||
} | ||
|
||
const PauseIcon = ({ color = "currentColor", title }: Props): JSX.Element => ( | ||
<svg width="6" height="11" viewBox="0 0 6 11" fill="none" role="img" data-icon="pause"> | ||
{title && <title>{title}</title>} | ||
<line x1="1" y1="1.5" x2="1" y2="10.5" stroke={color} strokeWidth="2" /> | ||
<line x1="5" y1="1.5" x2="5" y2="10.5" stroke={color} strokeWidth="2" /> | ||
</svg> | ||
); | ||
|
||
export default PauseIcon; |
39 changes: 39 additions & 0 deletions
39
airbyte-webapp/src/components/StatusIcon/StatusIcon.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,39 @@ | ||
import { render } from "@testing-library/react"; | ||
|
||
import StatusIcon, { StatusIconStatus } from "./StatusIcon"; | ||
|
||
describe("<StatusIcon />", () => { | ||
test("renders with title and default icon", () => { | ||
const title = "Pulpo"; | ||
const value = 888; | ||
|
||
const component = render(<StatusIcon title={title} value={value} />); | ||
|
||
expect(component.getByTitle(title)).toBeDefined(); | ||
expect(component.getByRole("img")).toHaveAttribute("data-icon", "times"); | ||
expect(component.getByText(`${value}`)).toBeDefined(); | ||
}); | ||
|
||
const statusCases: { status: StatusIconStatus; icon: string }[] = [ | ||
{ status: "success", icon: "check" }, | ||
{ status: "inactive", icon: "pause" }, | ||
{ status: "empty", icon: "ban" }, | ||
{ status: "warning", icon: "exclamation-triangle" }, | ||
]; | ||
|
||
test.each(statusCases)("renders $status status", ({ status, icon }) => { | ||
const title = `Status is ${status}`; | ||
const value = 888; | ||
const props = { | ||
title, | ||
value, | ||
status, | ||
}; | ||
|
||
const component = render(<StatusIcon {...props} />); | ||
|
||
expect(component.getByTitle(title)).toBeDefined(); | ||
expect(component.getByRole("img")).toHaveAttribute("data-icon", icon); | ||
expect(component.getByText(`${value}`)).toBeDefined(); | ||
}); | ||
}); |
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
8 changes: 0 additions & 8 deletions
8
airbyte-webapp/src/components/StatusIcon/components/Pause.tsx
This file was deleted.
Oops, something went wrong.
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.