mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-12 16:11:32 +08:00

* chore: added jsx-runtime plugin in eslint tsconfig Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * chore: updated react imports Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * chore: renamed redux dispatch Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> * fix: build is fixed --------- Signed-off-by: GermaVinsmoke <vaibhav1180@gmail.com> Co-authored-by: Palash Gupta <palashgdev@gmail.com>
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import {
|
|
CaretDownFilled,
|
|
CaretUpFilled,
|
|
QuestionCircleFilled,
|
|
QuestionCircleOutlined,
|
|
} from '@ant-design/icons';
|
|
import { Dropdown, Space } from 'antd';
|
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
|
import { useMemo, useState } from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import { AppState } from 'store/reducers';
|
|
import { ConfigProps } from 'types/api/dynamicConfigs/getDynamicConfigs';
|
|
import AppReducer from 'types/reducer/app';
|
|
|
|
import HelpToolTip from './Config';
|
|
|
|
function DynamicConfigDropdown({
|
|
frontendId,
|
|
}: DynamicConfigDropdownProps): JSX.Element {
|
|
const { configs } = useSelector<AppState, AppReducer>((state) => state.app);
|
|
const isDarkMode = useIsDarkMode();
|
|
const [isHelpDropDownOpen, setIsHelpDropDownOpen] = useState<boolean>(false);
|
|
|
|
const config = useMemo(
|
|
() =>
|
|
Object.values(configs).find(
|
|
(config) => config.frontendPositionId === frontendId,
|
|
),
|
|
[frontendId, configs],
|
|
);
|
|
|
|
const onToggleHandler = (): void => {
|
|
setIsHelpDropDownOpen(!isHelpDropDownOpen);
|
|
};
|
|
|
|
const menu = useMemo(
|
|
() => ({
|
|
items: [
|
|
{
|
|
key: '1',
|
|
label: <HelpToolTip config={config as ConfigProps} />,
|
|
},
|
|
],
|
|
}),
|
|
[config],
|
|
);
|
|
|
|
if (!config) {
|
|
return <div />;
|
|
}
|
|
|
|
const Icon = isDarkMode ? QuestionCircleOutlined : QuestionCircleFilled;
|
|
const DropDownIcon = isHelpDropDownOpen ? CaretUpFilled : CaretDownFilled;
|
|
|
|
return (
|
|
<Dropdown
|
|
onOpenChange={onToggleHandler}
|
|
trigger={['click']}
|
|
menu={menu}
|
|
open={isHelpDropDownOpen}
|
|
>
|
|
<Space align="center">
|
|
<Icon
|
|
style={{ fontSize: 26, color: 'white', paddingTop: 26, cursor: 'pointer' }}
|
|
/>
|
|
<DropDownIcon style={{ color: 'white' }} />
|
|
</Space>
|
|
</Dropdown>
|
|
);
|
|
}
|
|
|
|
interface DynamicConfigDropdownProps {
|
|
frontendId: string;
|
|
}
|
|
|
|
export default DynamicConfigDropdown;
|