MCPcopy
hub / github.com/autobrr/qui / getTranslatedOperatorsForField

Function getTranslatedOperatorsForField

web/src/components/query-builder/constants.ts:432–446  ·  view source on GitHub ↗
(field: string, t: TFunction)

Source from the content-addressed store, hash-verified

430
431/** Get translated operators for a field, preserving the original structure */
432export function getTranslatedOperatorsForField(field: string, t: TFunction): { value: string; label: string }[] {
433 const ops = getOperatorsForField(field);
434 return ops.map((op) => {
435 // Symbolic operators (=, !=, >, >=, <, <=) stay as-is
436 if (/^[^a-zA-Z]/.test(op.label)) return op;
437 const key = OPERATOR_LABEL_KEYS[op.value];
438 if (!key) return op;
439 // "is" / "is not" share keys with equals/notEquals for state/boolean types but have different labels
440 const type = getFieldType(field);
441 if ((type === "state" || type === "trackerStatus" || type === "boolean" || type === "hardlinkScope") && (op.value === "EQUAL" || op.value === "NOT_EQUAL")) {
442 return { value: op.value, label: t(`queryBuilder.operators.${op.value === "EQUAL" ? "is" : "isNot"}`, { defaultValue: op.label }) };
443 }
444 return { value: op.value, label: t(`queryBuilder.operators.${key}`, { defaultValue: op.label }) };
445 });
446}
447
448/** Get translated torrent states */
449export function getTranslatedTorrentStates(t: TFunction): { value: string; label: string }[] {

Callers 1

LeafConditionFunction · 0.90

Calls 2

getOperatorsForFieldFunction · 0.85
getFieldTypeFunction · 0.85

Tested by

no test coverage detected