-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add connection item display and fix types for icons
- Loading branch information
1 parent
2f6ab9a
commit 82a3629
Showing
3 changed files
with
33 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Icon } from "@flanksource-ui/ui/Icons/Icon"; | ||
import { useMemo } from "react"; | ||
import { Connection } from "./ConnectionFormModal"; | ||
import { connectionTypes } from "./connectionTypes"; | ||
|
||
type ConnectionIconProps = { | ||
connection: Pick<Connection, "type" | "name" | "id">; | ||
showLabel?: boolean; | ||
}; | ||
export default function ConnectionIcon({ | ||
connection, | ||
showLabel = false | ||
}: ConnectionIconProps) { | ||
const icon = useMemo(() => { | ||
return connectionTypes.find((item) => item.value === connection.type)?.icon; | ||
}, [connection.type]); | ||
|
||
return ( | ||
<div className="flex flex-row items-center gap-1"> | ||
{typeof icon === "string" ? ( | ||
<Icon name={icon} className="h-5" /> | ||
) : ( | ||
// if not a string, it's a react component | ||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
icon && <>{icon}</> | ||
)} | ||
{showLabel && <span>{connection.name}</span>} | ||
</div> | ||
); | ||
} |
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