2022-03-03 10:56:53 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
2023-01-23 03:50:47 +00:00
|
|
|
import { getTypographyByKey } from "design-system-old";
|
2022-03-03 10:56:53 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import { useSelector } from "react-redux";
|
2022-08-24 12:16:32 +00:00
|
|
|
import { AppState } from "@appsmith/reducers";
|
2022-09-02 13:17:17 +00:00
|
|
|
import { getDefaultPlugin } from "selectors/entitiesSelector";
|
2022-03-03 10:56:53 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
|
|
|
|
const StyledDatasourceChip = styled.div`
|
|
|
|
|
background-color: rgba(248, 248, 248, 0.5);
|
|
|
|
|
border: 1px solid ${Colors.MERCURY_2};
|
|
|
|
|
padding: ${(props) =>
|
|
|
|
|
`${props.theme.spaces[1]}px ${props.theme.spaces[3]}px`};
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
.image {
|
|
|
|
|
height: 15px;
|
|
|
|
|
width: 15px;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
}
|
|
|
|
|
span {
|
|
|
|
|
margin-left: ${(props) => props.theme.spaces[2]}px;
|
2022-11-16 04:32:00 +00:00
|
|
|
${getTypographyByKey("h6")}
|
2022-03-03 10:56:53 +00:00
|
|
|
letter-spacing: -0.221538px;
|
|
|
|
|
color: var(--appsmith-color-black-900);
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
interface DatasourceChipProps {
|
|
|
|
|
className?: string;
|
|
|
|
|
pluginPackageName: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DatasourceChip(props: DatasourceChipProps) {
|
|
|
|
|
const plugin = useSelector((state: AppState) =>
|
2022-09-02 13:17:17 +00:00
|
|
|
getDefaultPlugin(state, props.pluginPackageName),
|
2022-03-03 10:56:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!plugin) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<StyledDatasourceChip className={props.className}>
|
|
|
|
|
<img className="image" src={plugin.iconLocation} />
|
|
|
|
|
<span>{plugin.name}</span>
|
|
|
|
|
</StyledDatasourceChip>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DatasourceChip;
|