Skip to content

Add Quick Filter for Unhealthy Resources #2544

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useField } from "formik";
import { Toggle } from "@flanksource-ui/ui/FormControls/Toggle";

export function ConfigUnhealthyToggle() {
const [healthField, healthMeta, healthHelpers] = useField("health");

Check warning on line 5 in src/components/Configs/ConfigsListFilters/ConfigUnhealthyToggle.tsx

View workflow job for this annotation

GitHub Actions / eslint

'healthMeta' is assigned a value but never used
const [unhealthyField] = useField({

Check warning on line 6 in src/components/Configs/ConfigsListFilters/ConfigUnhealthyToggle.tsx

View workflow job for this annotation

GitHub Actions / eslint

'unhealthyField' is assigned a value but never used
name: "showUnhealthy"
});

const handleToggle = (checked: boolean) => {
if (checked) {
// When toggled on, set the health filter to show unhealthy and warning resources
healthHelpers.setValue("unhealthy:1,warning:1");
} else {
// When toggled off, clear the health filter
healthHelpers.setValue(undefined);
}
};

return (
<Toggle
className="mr-2 flex items-center"
label="Unhealthy Only"
hint="Show only unhealthy resources"
value={
// Check if we're filtering specifically for unhealthy and warning statuses
healthField.value === "unhealthy:1,warning:1" ||
healthField.value === "warning:1,unhealthy:1"
}
onChange={handleToggle}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ConfigHealthyDropdown } from "./ConfigHealthyDropdown";
import { ConfigLabelsDropdown } from "./ConfigLabelsDropdown";
import { ConfigStatusDropdown } from "./ConfigStatusDropdown";
import { ConfigTypesDropdown } from "./ConfigTypesDropdown";
import { ConfigUnhealthyToggle } from "./ConfigUnhealthyToggle";

export default function ConfigsListFilters() {
return (
Expand All @@ -20,6 +21,9 @@ export default function ConfigsListFilters() {
]}
>
<div className="mr-4 flex flex-wrap items-center gap-2">
{/* Add the new quick filter for unhealthy resources */}
<ConfigUnhealthyToggle />

<ConfigTypesDropdown />

<ConfigGroupByDropdown />
Expand All @@ -37,4 +41,4 @@ export default function ConfigsListFilters() {
</div>
</FormikFilterForm>
);
}
}
Loading