import React, { FC } from "react"; import Creatable from "react-select/creatable"; import { GroupTypeBase, SelectComponentsConfig } from "react-select"; import { useFetchGet } from "Hooks/useFetchGet"; import { FormatBackendURI } from "Stores/AlertStore"; import { Settings } from "Stores/Settings"; import { ThemeContext } from "Components/Theme"; import { NewLabelName, StringToOption, OptionT } from "Common/Select"; const disabledLabel = "Disable multi-grid"; const valueToOption = (v: string) => ({ label: v ? v : disabledLabel, value: v, }); const staticValues = [ { label: disabledLabel, value: "" }, { label: "@alertmanager", value: "@alertmanager" }, { label: "@cluster", value: "@cluster" }, { label: "@receiver", value: "@receiver" }, ]; const GridLabelName: FC<{ settingsStore: Settings; isOpen?: boolean | undefined; selectComponents?: | Partial>> | undefined; }> = ({ settingsStore, isOpen = undefined, selectComponents = undefined }) => { const { response } = useFetchGet( FormatBackendURI(`labelNames.json`) ); const context = React.useContext(ThemeContext); return ( StringToOption(value)), ] : staticValues } onChange={(option) => { settingsStore.multiGridConfig.config.gridLabel = (option as OptionT).value; }} menuIsOpen={isOpen} components={selectComponents} /> ); }; export { GridLabelName };