-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2077cd5
commit 7927cac
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/components/Notifications/Filters/NotificationFilterBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import FormikFilterForm from "../../Forms/FormikFilterForm"; | ||
import NotificationResourceTypeDropdown from "./NotificationResourceTypeDropdown"; | ||
import NotificationStatusDropdown from "./NotificationStatusDropdown"; | ||
|
||
export default function NotificationFilterBar() { | ||
return ( | ||
<FormikFilterForm | ||
paramsToReset={["pageIndex", "pageSize"]} | ||
filterFields={["status", "resource_type"]} | ||
> | ||
<div className="flex flex-row gap-2 py-3"> | ||
<NotificationStatusDropdown /> | ||
<NotificationResourceTypeDropdown /> | ||
</div> | ||
</FormikFilterForm> | ||
); | ||
} |
50 changes: 50 additions & 0 deletions
50
src/components/Notifications/Filters/NotificationResourceTypeDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import TristateReactSelect, { | ||
TriStateOptions | ||
} from "@flanksource-ui/ui/Dropdowns/TristateReactSelect"; | ||
import { useField } from "formik"; | ||
|
||
export const jobHistoryResourceTypes: TriStateOptions[] = [ | ||
{ | ||
label: "Canary", | ||
value: "canary", | ||
id: "canary" | ||
}, | ||
{ | ||
label: "Check", | ||
value: "check", | ||
id: "check" | ||
}, | ||
{ | ||
label: "Component", | ||
value: "component", | ||
id: "component" | ||
}, | ||
{ | ||
label: "Catalog", | ||
value: "catalog", | ||
id: "catalog" | ||
} | ||
].sort((a, b) => a.label.localeCompare(b.label)); | ||
|
||
export default function NotificationResourceTypeDropdown() { | ||
const [field] = useField({ | ||
name: "resource_type" | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<TristateReactSelect | ||
value={field.value} | ||
options={jobHistoryResourceTypes} | ||
onChange={(val) => { | ||
if (val && val !== "All") { | ||
field.onChange({ target: { value: val, name: field.name } }); | ||
} else { | ||
field.onChange({ target: { value: undefined, name: field.name } }); | ||
} | ||
}} | ||
label="Resource Type" | ||
/> | ||
</div> | ||
); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/components/Notifications/Filters/NotificationStatusDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import TristateReactSelect, { | ||
TriStateOptions | ||
} from "@flanksource-ui/ui/Dropdowns/TristateReactSelect"; | ||
import { useField } from "formik"; | ||
|
||
const statusOptions: Record<string, TriStateOptions> = { | ||
running: { | ||
id: "sent", | ||
label: "Sent", | ||
value: "Sent" | ||
}, | ||
failed: { | ||
id: "failed", | ||
label: "Failed", | ||
value: "Failed" | ||
}, | ||
silenced: { | ||
id: "silenced", | ||
label: "Silenced", | ||
value: "Silenced" | ||
}, | ||
repeated: { | ||
id: "repeated", | ||
label: "Repeated", | ||
value: "Repeated" | ||
} | ||
}; | ||
|
||
export default function NotificationStatusDropdown() { | ||
const [field] = useField({ | ||
name: "status", | ||
id: "status" | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<TristateReactSelect | ||
value={field.value} | ||
options={Object.values(statusOptions)} | ||
onChange={(val) => { | ||
if (val && val !== "All") { | ||
field.onChange({ target: { value: val, name: field.name } }); | ||
} else { | ||
field.onChange({ target: { value: undefined, name: field.name } }); | ||
} | ||
}} | ||
label="Status" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters