1 import { c } from 'ttag';
3 import { ConditionComparator, ConditionType, FilterStatement } from './interfaces';
4 import type { SelectOption } from './modal/FilterActionsFormFolderRow';
6 export const FILTER_VERSION = 2;
8 export const getConditionTypeLabels = (type: ConditionType) => {
10 case ConditionType.SELECT:
11 return c('Filter modal type').t`Select…`;
12 case ConditionType.SUBJECT:
13 return c('Filter modal type').t`The subject`;
14 case ConditionType.SENDER:
15 return c('Filter modal type').t`The sender`;
16 case ConditionType.RECIPIENT:
17 return c('Filter modal type').t`The recipient`;
18 case ConditionType.ATTACHMENTS:
19 return c('Filter modal type').t`The attachment`;
25 export const getComparatorLabels = (comparator: ConditionComparator) => {
27 case ConditionComparator.CONTAINS:
28 return c('Condition for custom filter').t`contains`;
29 case ConditionComparator.IS:
30 return c('Condition for custom filter').t`is exactly`;
31 case ConditionComparator.STARTS:
32 return c('Condition for custom filter').t`begins with`;
33 case ConditionComparator.ENDS:
34 return c('Condition for custom filter').t`ends with`;
35 case ConditionComparator.MATCHES:
36 return c('Condition for custom filter').t`matches`;
37 case ConditionComparator.DOES_NOT_CONTAIN:
38 return c('Condition for custom filter').t`does not contain`;
39 case ConditionComparator.IS_NOT:
40 return c('Condition for custom filter').t`is not`;
41 case ConditionComparator.DOES_NOT_START:
42 return c('Condition for custom filter').t`does not begin with`;
43 case ConditionComparator.DOES_NOT_END:
44 return c('Condition for custom filter').t`does not end with`;
45 case ConditionComparator.DOES_NOT_MATCH:
46 return c('Condition for custom filter').t`does not match`;
52 export const getOperatorLabels = (statement: FilterStatement) => {
54 case FilterStatement.ALL:
55 return c('Filter modal operators').t`All conditions must be fulfilled (AND)`;
56 case FilterStatement.ANY:
57 return c('Filter modal operators').t`One condition must be fulfilled (OR)`;
63 export const TYPES = [
65 label: getConditionTypeLabels(ConditionType.SELECT),
66 value: ConditionType.SELECT,
69 label: getConditionTypeLabels(ConditionType.SUBJECT),
70 value: ConditionType.SUBJECT,
73 label: getConditionTypeLabels(ConditionType.SENDER),
74 value: ConditionType.SENDER,
77 label: getConditionTypeLabels(ConditionType.RECIPIENT),
78 value: ConditionType.RECIPIENT,
81 label: getConditionTypeLabels(ConditionType.ATTACHMENTS),
82 value: ConditionType.ATTACHMENTS,
86 export const COMPARATORS = [
88 label: getComparatorLabels(ConditionComparator.CONTAINS),
89 value: ConditionComparator.CONTAINS,
92 label: getComparatorLabels(ConditionComparator.IS),
93 value: ConditionComparator.IS,
96 label: getComparatorLabels(ConditionComparator.STARTS),
97 value: ConditionComparator.STARTS,
100 label: getComparatorLabels(ConditionComparator.ENDS),
101 value: ConditionComparator.ENDS,
104 label: getComparatorLabels(ConditionComparator.MATCHES),
105 value: ConditionComparator.MATCHES,
108 label: getComparatorLabels(ConditionComparator.DOES_NOT_CONTAIN),
109 value: ConditionComparator.DOES_NOT_CONTAIN,
112 label: getComparatorLabels(ConditionComparator.IS_NOT),
113 value: ConditionComparator.IS_NOT,
116 label: getComparatorLabels(ConditionComparator.DOES_NOT_START),
117 value: ConditionComparator.DOES_NOT_START,
120 label: getComparatorLabels(ConditionComparator.DOES_NOT_END),
121 value: ConditionComparator.DOES_NOT_END,
124 label: getComparatorLabels(ConditionComparator.DOES_NOT_MATCH),
125 value: ConditionComparator.DOES_NOT_MATCH,
129 export const OPERATORS = [
131 label: getOperatorLabels(FilterStatement.ALL),
132 value: FilterStatement.ALL,
135 label: getOperatorLabels(FilterStatement.ANY),
136 value: FilterStatement.ANY,
140 export const noFolderValue = '';
141 export const noFolderOption = {
143 text: c('Filter Actions').t`Do not move`,
144 value: noFolderValue,
147 export const getDefaultFolders = () => {
150 group: c('Option group').t`Move to...`,
151 text: c('Filter Actions').t`Select a folder`,
156 group: c('Option group').t`Default folders`,
157 text: c('Filter Actions').t`Archive`,
161 group: c('Option group').t`Default folders`,
162 text: c('Filter Actions').t`Inbox`,
166 group: c('Option group').t`Default folders`,
167 text: c('Filter Actions').t`Spam`,
171 group: c('Option group').t`Default folders`,
172 text: c('Filter Actions').t`Trash`,
178 export const getDefaultFolderOptions = () => {
182 text: c('Option group').t`Default folders`,
186 text: c('Filter Actions').t`Archive`,
191 text: c('Filter Actions').t`Inbox - Default`,
196 text: c('Filter Actions').t`Spam`,
201 text: c('Filter Actions').t`Trash`,