Skip to content

Commit

Permalink
relocate metric source field (#437)
Browse files Browse the repository at this point in the history
* metric source comp

* screens

* screens after merge master

* link const

---------

Co-authored-by: Eduard Zaidler <zaidler@skbkontur.ru>
  • Loading branch information
EduardZaydler and Eduard Zaidler authored Oct 6, 2023
1 parent a5880f6 commit 966a9e6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
Binary file modified .creevey/images/ContactList/invalid item/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/Components/TriggerEditForm/MetricSourceSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import { Gapped, Radio, RadioGroup } from "@skbkontur/react-ui";
import TriggerSource from "../../Domain/Trigger";
import { Link } from "@skbkontur/react-ui/components/Link";

interface Props {
triggerSource?: TriggerSource;
onSourceChange: (value: TriggerSource) => void;
}

const remoteTriggerLink =
"http://moira.readthedocs.io/en/latest/user_guide/advanced.html#data-source";

export const MetricSourceSelect: React.FC<Props> = ({ triggerSource, onSourceChange }) => {
return (
<RadioGroup<TriggerSource>
name="data-source"
defaultValue={triggerSource}
onValueChange={onSourceChange}
>
<Gapped vertical gap={10}>
<Radio value={TriggerSource.GRAPHITE_LOCAL}> Local (default)</Radio>
<Radio value={TriggerSource.GRAPHITE_REMOTE}>
Graphite Remote. Be careful, it may cause&nbsp;
<Link href={remoteTriggerLink}>extra load</Link>
</Radio>
<Radio value={TriggerSource.PROMETHEUS_REMOTE}> Prometheus Remote </Radio>
</Gapped>
</RadioGroup>
);
};
49 changes: 13 additions & 36 deletions src/Components/TriggerEditForm/TriggerEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ import { Remarkable } from "remarkable";
import { sanitize } from "dompurify";
import RemoveIcon from "@skbkontur/react-icons/Remove";
import AddIcon from "@skbkontur/react-icons/Add";
import {
RadioGroup,
Radio,
Checkbox,
Gapped,
Input,
Textarea,
Button,
Link,
Tabs,
} from "@skbkontur/react-ui";
import { Checkbox, Input, Textarea, Button, Tabs } from "@skbkontur/react-ui";
import { RowStack, Fill, Fit } from "@skbkontur/react-stack-layout";
import {
DEFAULT_TRIGGER_TTL,
Expand All @@ -36,6 +26,8 @@ import CodeRef from "../CodeRef/CodeRef";
import HighlightInput from "../HighlightInput/HighlightInput";
import HelpTooltip from "../HelpTooltip/HelpTooltip";
import EditDescriptionHelp from "./EditDescritionHelp";
import { MetricSourceSelect } from "./MetricSourceSelect";

import classNames from "classnames/bind";

import styles from "./TriggerEditForm.less";
Expand Down Expand Up @@ -183,6 +175,16 @@ export default class TriggerEditForm extends React.Component<Props, State> {
/>
)}
</FormRow>
{remoteAllowed && (
<FormRow label="Data source" singleLineControlGroup>
<MetricSourceSelect
triggerSource={triggerSource}
onSourceChange={(value: TriggerSource) =>
onChange({ trigger_source: value })
}
/>
</FormRow>
)}
<FormRow label="Target" useTopAlignForLabel>
{targets?.map((x, i) => (
<div key={`target-${i}`} className={cn("target")}>
Expand Down Expand Up @@ -311,31 +313,6 @@ export default class TriggerEditForm extends React.Component<Props, State> {
/>
</ValidationWrapperV1>
</FormRow>
{remoteAllowed && (
<FormRow label="Data source" singleLineControlGroup>
<RadioGroup<TriggerSource>
name="data-source"
defaultValue={triggerSource}
onValueChange={(value: TriggerSource) =>
onChange({ trigger_source: value })
}
>
<Gapped vertical gap={10}>
<Radio value={TriggerSource.GRAPHITE_LOCAL}> Local (default)</Radio>
<Radio value={TriggerSource.GRAPHITE_REMOTE}>
Graphite Remote. Be careful, it may cause&nbsp;
<Link href="http://moira.readthedocs.io/en/latest/user_guide/advanced.html#data-source">
extra load
</Link>
</Radio>
<Radio value={TriggerSource.PROMETHEUS_REMOTE}>
{" "}
Prometheus Remote{" "}
</Radio>
</Gapped>
</RadioGroup>
</FormRow>
)}
</Form>
);
}
Expand Down

0 comments on commit 966a9e6

Please sign in to comment.