From 50511a5fec4355e61307fbd3e72cfe1c024b0bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Sis=C3=A1k?= <86593861+dzsak@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:16:38 +0200 Subject: [PATCH] Feature: Searchbar on Kustomizations/HelmReleases/Source view (#83) --- web/src/App.js | 29 ++------------ web/src/FilterBar.js | 44 +++++++++++++++++---- web/src/HelmReleases.jsx | 15 ++++---- web/src/Kustomizations.jsx | 15 ++++---- web/src/Sources.jsx | 15 ++++---- web/src/utils.js | 79 ++++++++++++++++++++++---------------- 6 files changed, 108 insertions(+), 89 deletions(-) diff --git a/web/src/App.js b/web/src/App.js index 78e4f27..85fa9a5 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -38,27 +38,6 @@ function App() { localStorage.setItem("filters", JSON.stringify(filters)); }, [filters]); - const addFilter = (filter) => { - setFilters([...filters, filter]); - } - - const filterValueByProperty = (property) => { - const filter = filters.find(f => f.property === property) - if (!filter) { - return "" - } - - return filter.value - } - - const deleteFilter = (filter) => { - setFilters(filters.filter(f => f.property !== filter.property)) - } - - const resetFilters = () => { - setFilters([]) - } - return ( <> @@ -66,12 +45,10 @@ function App() {
-
diff --git a/web/src/FilterBar.js b/web/src/FilterBar.js index bbc7358..066d3c4 100644 --- a/web/src/FilterBar.js +++ b/web/src/FilterBar.js @@ -1,7 +1,28 @@ import React, { useState, useRef, useEffect } from 'react'; import { FunnelIcon, XMarkIcon } from '@heroicons/react/24/outline' -function FilterBar({ filters, addFilter, deleteFilter, resetFilters, filterValueByProperty }) { +function FilterBar({ properties = [], filters, change }) { + const addFilter = (filter) => { + change([...filters, filter]); + } + + const filterValueByProperty = (property) => { + const filter = filters.find(f => f.property === property) + if (!filter) { + return "" + } + + return filter.value + } + + const deleteFilter = (filter) => { + change(filters.filter(f => f.property !== filter.property)) + } + + const resetFilters = () => { + change([]) + } + return (
@@ -10,7 +31,7 @@ function FilterBar({ filters, addFilter, deleteFilter, resetFilters, filterValue {filters.map(filter => ( ))} - +
  @@ -29,7 +50,7 @@ function Filter(props) { const { filter } = props; return (