1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/frontend/src/utils/operatorsForContext.ts
olav f33ca9db4b feat: expand constraint operator descriptions (2) (#858)
* refactor: remove pre-CO constraints list

* refactor: improve constraints dropdown order

* refactor: simplify prop value

* refactor: add missing space around parameter names

* refactor: remove constraint accordion box shadow

* refactor: show operator descriptions in constraints accordion

* refactor: show operator descriptions in constraints dropdown

* refactor: use ConstraintAccordionList in FeatureOverviewExecution

* refactor: add separators between operators in constraints dropdown

* refactor: remove unnecessary comment
2022-04-07 10:31:06 +02:00

25 lines
651 B
TypeScript

import { allOperators, dateOperators, Operator } from 'constants/operators';
import { oneOf } from 'utils/oneOf';
export const CURRENT_TIME_CONTEXT_FIELD = 'currentTime';
export const operatorsForContext = (contextName: string): Operator[] => {
return allOperators.filter(operator => {
if (
oneOf(dateOperators, operator) &&
contextName !== CURRENT_TIME_CONTEXT_FIELD
) {
return false;
}
if (
!oneOf(dateOperators, operator) &&
contextName === CURRENT_TIME_CONTEXT_FIELD
) {
return false;
}
return true;
});
};