state-hub/dashboard/src/components/workplan-search.js
tegwick b5747d1104
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
feat(dashboard): text filter for Overview workplans chart
Add a search field next to the Workplans by Repository mode selector so
operators can narrow large lists by title, repo, domain, filename, or owner.
2026-07-22 01:22:22 +02:00

22 lines
705 B
JavaScript

/**
* Case-insensitive substring match for Overview "Workplans by Repository".
* Matches title, repo, domain, filename, owner, and id.
*
* @param {object} workplan Row from overview workplan_rows
* @param {string} query Free-text filter
* @returns {boolean}
*/
export function workplanMatchesSearch(workplan, query) {
const q = String(query ?? "").trim().toLowerCase();
if (!q) return true;
if (!workplan || typeof workplan !== "object") return false;
const haystack = [
workplan.title,
workplan.repo_label,
workplan.domain,
workplan.workplan_filename,
workplan.owner,
workplan.id,
].filter(Boolean).join("\n").toLowerCase();
return haystack.includes(q);
}