From 22e1c7c05eb561db0a300001a72ec84e15b3becd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Tue, 12 May 2020 13:18:35 +0100 Subject: [PATCH] fix(ui): drop unused MultiSelect component --- ui/src/Components/MultiSelect/index.js | 22 -- .../SilenceModal/AlertManagerInput/index.js | 2 +- .../SilenceMatch/LabelNameInput.js | 2 +- .../SilenceMatch/LabelValueInput.js | 2 +- .../ReactSelect.test.js} | 48 +---- .../__snapshots__/ReactSelect.test.js.snap} | 190 ++++-------------- .../__snapshots__/index.test.js.snap} | 0 .../index.js} | 0 .../index.test.js} | 2 +- 9 files changed, 57 insertions(+), 211 deletions(-) delete mode 100644 ui/src/Components/MultiSelect/index.js rename ui/src/Components/{MultiSelect/index.test.js => Theme/ReactSelect.test.js} (55%) rename ui/src/Components/{MultiSelect/__snapshots__/index.test.js.snap => Theme/__snapshots__/ReactSelect.test.js.snap} (56%) rename ui/src/Components/{MultiSelect/__snapshots__/ValidationError.test.js.snap => ValidationError/__snapshots__/index.test.js.snap} (100%) rename ui/src/Components/{MultiSelect/ValidationError.js => ValidationError/index.js} (100%) rename ui/src/Components/{MultiSelect/ValidationError.test.js => ValidationError/index.test.js} (84%) diff --git a/ui/src/Components/MultiSelect/index.js b/ui/src/Components/MultiSelect/index.js deleted file mode 100644 index 9e9bf2e94..000000000 --- a/ui/src/Components/MultiSelect/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from "react"; - -import Creatable from "react-select/creatable"; - -import { ThemeContext } from "Components/Theme"; - -class MultiSelect extends Creatable { - renderProps = () => ({}); - - render() { - return ( - - ); - } -} -MultiSelect.contextType = ThemeContext; - -export { MultiSelect }; diff --git a/ui/src/Components/SilenceModal/AlertManagerInput/index.js b/ui/src/Components/SilenceModal/AlertManagerInput/index.js index 8a5bf751b..65d56e9ed 100644 --- a/ui/src/Components/SilenceModal/AlertManagerInput/index.js +++ b/ui/src/Components/SilenceModal/AlertManagerInput/index.js @@ -12,7 +12,7 @@ import { AlertmanagerClustersToOption, } from "Stores/SilenceFormStore"; import { ThemeContext } from "Components/Theme"; -import { ValidationError } from "Components/MultiSelect/ValidationError"; +import { ValidationError } from "Components/ValidationError"; const AlertManagerInput = ({ alertStore, silenceFormStore }) => { useEffect(() => { diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelNameInput.js b/ui/src/Components/SilenceModal/SilenceMatch/LabelNameInput.js index 83edbb7ae..d99b390f5 100644 --- a/ui/src/Components/SilenceModal/SilenceMatch/LabelNameInput.js +++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelNameInput.js @@ -6,7 +6,7 @@ import Creatable from "react-select/creatable"; import { SilenceFormMatcher } from "Models/SilenceForm"; import { FormatBackendURI } from "Stores/AlertStore"; import { useFetchGet } from "Hooks/useFetchGet"; -import { ValidationError } from "Components/MultiSelect/ValidationError"; +import { ValidationError } from "Components/ValidationError"; import { ThemeContext } from "Components/Theme"; const LabelNameInput = ({ matcher, isValid }) => { diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js index f1a1d9f2f..43cfb0c06 100644 --- a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js +++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.js @@ -13,7 +13,7 @@ import { FormatBackendURI } from "Stores/AlertStore"; import { SilenceFormStore } from "Stores/SilenceFormStore"; import { SilenceFormMatcher } from "Models/SilenceForm"; import { useFetchGet } from "Hooks/useFetchGet"; -import { ValidationError } from "Components/MultiSelect/ValidationError"; +import { ValidationError } from "Components/ValidationError"; import { ThemeContext } from "Components/Theme"; import { MatchCounter } from "./MatchCounter"; diff --git a/ui/src/Components/MultiSelect/index.test.js b/ui/src/Components/Theme/ReactSelect.test.js similarity index 55% rename from ui/src/Components/MultiSelect/index.test.js rename to ui/src/Components/Theme/ReactSelect.test.js index b82eaf769..e3dc01f3d 100644 --- a/ui/src/Components/MultiSelect/index.test.js +++ b/ui/src/Components/Theme/ReactSelect.test.js @@ -4,65 +4,35 @@ import { mount } from "enzyme"; import toDiffableHtml from "diffable-html"; -import { ThemeContext } from "Components/Theme"; +import Select from "react-select"; + import { ReactSelectColors, ReactSelectStyles, } from "Components/Theme/ReactSelect"; -import { MultiSelect } from "."; const Option = (value) => ({ label: value, value: value }); -const Wrapped = (component) => ( - - {component} - +const ThemedSelect = (props) => ( + -
-
- - - -
- - -
- - - - -
-
- - -" -`; - exports[` matches snapshot when focused 1`] = ` "
@@ -64,19 +13,19 @@ exports[` matches snapshot when focused 1`] = `   0 results available. Select is focused ,type to refine list, press Down to open the menu,

-
-
-
+
+
+
Select...
-
matches snapshot when focused 1`] = `
-
- +
+
matches snapshot when focused 1`] = ` exports[` matches snapshot with a value 1`] = ` "
-
-
-
+
+
+
foo
-
matches snapshot with a value 1`] = `
-
- +
+
- - - - -
-
-
-
-" -`; - -exports[` matches snapshot with defaults 1`] = ` -" -
-
-
-
- Select... -
-
-
- -
-
-
-
-
-
- - -
matches snapshot with defaults 1`] = ` exports[` matches snapshot with isDisabled=true 1`] = ` " -
-
-
-
+
+
+
+
foo
-
matches snapshot with isDisabled=true 1`]
-
- +
+
matches snapshot with isDisabled=true 1`] exports[` matches snapshot with isMulti=true 1`] = ` "
-
-
-
+
+
+
Select...
-
matches snapshot with isMulti=true 1`] = `
-
- +
+
matches snapshot with isMulti=true 1`] = ` exports[` matches snapshot with isMulti=true and a value 1`] = ` "
-
-
-
-
+
+
+
+
foo
-
+
matches snapshot with isMulti=true and a v
-
matches snapshot with isMulti=true and a v
-
+
matches snapshot with isMulti=true and a v
- +
", () => { it("matches snapshot", () => {