Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relocate metric source field #437

Merged
merged 5 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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