MCPcopy Create free account
hub / github.com/coder/coder / useActionFilterMenu

Function useActionFilterMenu

site/src/pages/AuditPage/AuditFilter.tsx:88–111  ·  view source on GitHub ↗
({
	value,
	onChange,
}: Pick<UseFilterMenuOptions, "value" | "onChange">)

Source from the content-addressed store, hash-verified

86};
87
88export const useActionFilterMenu = ({
89 value,
90 onChange,
91}: Pick<UseFilterMenuOptions, "value" | "onChange">) => {
92 const actionOptions: SelectFilterOption[] = AuditActions
93 // TODO(ethanndickson): Logs with these action types are no longer produced.
94 // Until we remove them from the database and API, we shouldn't suggest them
95 // in the filter dropdown.
96 .filter(
97 (action) => !["connect", "disconnect", "open", "close"].includes(action),
98 )
99 .map((action) => ({
100 value: action,
101 label: capitalize(action),
102 }));
103 return useFilterMenu({
104 onChange,
105 value,
106 id: "status",
107 getSelectedOption: async () =>
108 actionOptions.find((option) => option.value === value) ?? null,
109 getOptions: async () => actionOptions,
110 });
111};
112
113type ActionFilterMenu = ReturnType<typeof useActionFilterMenu>;
114

Callers 1

AuditPageFunction · 0.90

Calls 4

useFilterMenuFunction · 0.90
capitalizeFunction · 0.85
filterMethod · 0.80
findMethod · 0.80

Tested by

no test coverage detected