export function updateParamsFromFilterValue()

in experimenter/experimenter/nimbus-ui/src/components/PageHome/filterExperiments.ts [212:294]


export function updateParamsFromFilterValue(
  updateSearchParams: UpdateSearchParams,
  filterValue: FilterValue,
) {
  updateSearchParams((params) => {
    for (const key of filterValueKeys) {
      params.delete(key);
      let values;
      // Verbose switch that seems to make types happier
      switch (key) {
        case "owners":
          values = indexFilterOptions<"owners">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "applications":
          values = indexFilterOptions<"applications">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "allFeatureConfigs":
          values = indexFilterOptions<"allFeatureConfigs">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "firefoxVersions":
          values = indexFilterOptions<"firefoxVersions">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "channels":
          values = indexFilterOptions<"channels">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "types":
          values = indexFilterOptions<"types">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "projects":
          values = indexFilterOptions<"projects">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "targetingConfigs":
          values = indexFilterOptions<"targetingConfigs">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "takeaways":
          values = indexFilterOptions<"takeaways">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "qaStatus":
          values = indexFilterOptions<"qaStatus">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
        case "subscribers":
          values = indexFilterOptions<"subscribers">(
            filterValue[key],
            optionIndexKeys[key],
          );
          break;
      }
      if (values && values.length) {
        params.set(key, values.join(","));
      }
    }
  });
}