Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
import type { SearchAttributeFilter } from '$lib/models/search-attribute-filters';
import { isWorkflowStatusType } from '$lib/models/workflow-status';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import { formatDate } from '$lib/utilities/format-date';
import {
isContains,
isNullConditional,
isStartsWith,
} from '$lib/utilities/is';
import { isNullConditional, isStartsWith } from '$lib/utilities/is';
import {
formatDateTimeRange,
Expand Down Expand Up @@ -110,7 +116,9 @@
{:else}
{isStartsWith(conditional)
? translate('common.starts-with').toLocaleLowerCase()
: conditional}
: isContains(conditional)
? translate('common.contains').toLocaleLowerCase()
: conditional}
{isTextFilter(workflowFilter) ? `"${value}"` : value}
{/if}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
{ value: '=', label: translate('common.equal-to') },
{ value: '!=', label: translate('common.not-equal-to') },
...($prefixSearchEnabled && $filter.type === SEARCH_ATTRIBUTE_TYPE.KEYWORD
? [{ value: 'STARTS_WITH', label: translate('common.starts-with') }]
? [
{ value: 'STARTS_WITH', label: translate('common.starts-with') },
{ value: 'CONTAINS', label: translate('common.contains') },
]
: []),
];
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
label: translate('common.starts-with'),
id: 'starts-with',
},
{
value: 'CONTAINS',
label: translate('common.contains'),
id: 'contains',
},
...defaultConditionOptions,
];

Expand Down Expand Up @@ -154,7 +159,9 @@
const conditionText =
conditional === 'STARTS_WITH'
? translate('common.starts-with').toLowerCase()
: conditional;
: conditional === 'CONTAINS'
? translate('common.contains').toLowerCase()
: conditional;
return `${attribute} ${conditionText}`;
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/i18n/locales/en/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const Strings = {
between: 'Between',
'in-last': 'In Last',
'starts-with': 'Starts with',
contains: 'Contains',
equals: 'Equals',
'greater-than': 'Greater Than',
'greater-than-or-equal-to': 'Greater than or equal to',
Expand Down
7 changes: 7 additions & 0 deletions src/lib/utilities/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const operators = [
'(',
')',
'starts_with',
'contains',
] as const;

const conditionals = [
Expand All @@ -57,6 +58,7 @@ const conditionals = [
'<',
'!',
'starts_with',
'contains',
'is',
'is not',
'in',
Expand Down Expand Up @@ -186,6 +188,11 @@ export const isStartsWith = (x: unknown) => {
return x.toLocaleLowerCase() === 'starts_with';
};

export const isContains = (x: unknown) => {
if (!isString(x)) return false;
return x.toLocaleLowerCase() === 'contains';
};

export const isInConditional = (x: unknown) => {
if (!isString(x)) return false;

Expand Down
15 changes: 14 additions & 1 deletion src/lib/utilities/query/filter-workflow-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
type SearchAttributeType,
} from '$lib/types/workflows';

import { isInConditional, isNullConditional, isStartsWith } from '../is';
import {
isContains,
isInConditional,
isNullConditional,
isStartsWith,
} from '../is';
import { isDuration, isDurationString, toDate, tomorrow } from '../to-duration';

export type QueryKey =
Expand Down Expand Up @@ -105,6 +110,14 @@ const toFilterQueryStatement = (
})}`;
}

if (isContains(conditional)) {
return `\`${queryKey}\` ${conditional} ${formatValue({
value,
type,
conditional,
})}`;
}

return `\`${queryKey}\`${conditional}${formatValue({
value,
type,
Expand Down