Skip to content

Commit

Permalink
[MI-3457]: Added a Include or Empty filter for subscription (#66) (#…
Browse files Browse the repository at this point in the history
…968)

* [MI-3457]: Added include_or_empty filter to subscription

* [MI-3457]: Removed a extra line from subscribe.go

* [MI-3457]: Formatted the code in subscribe.go

* [MI-3457]: Fixed the testcases for channel_subscription_filter

* [MI-3457]: Fixed the formatting of server/subscribe.go

* [MI-3457]: Improved the message in dropdown
  • Loading branch information
Kshitij-Katiyar authored Sep 18, 2024
1 parent d645699 commit ac41da4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions server/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (
const (
JiraSubscriptionsKey = "jirasub"

FilterIncludeAny = "include_any"
FilterIncludeAll = "include_all"
FilterExcludeAny = "exclude_any"
FilterEmpty = "empty"
FilterIncludeAny = "include_any"
FilterIncludeAll = "include_all"
FilterExcludeAny = "exclude_any"
FilterEmpty = "empty"
FilterIncludeOrEmpty = "include_or_empty"

MaxSubscriptionNameLength = 100
)
Expand Down Expand Up @@ -192,7 +193,8 @@ func isValidFieldInclusion(field FieldFilter, value StringSet, inclusion string)
if (inclusion == FilterIncludeAny && !containsAny) ||
(inclusion == FilterIncludeAll && !containsAll) ||
(inclusion == FilterExcludeAny && containsAny) ||
(inclusion == FilterEmpty && value.Len() > 0) {
(inclusion == FilterEmpty && value.Len() > 0) ||
(inclusion == FilterIncludeOrEmpty && !containsAny && value.Len() > 0) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ exports[`components/ChannelSubscriptionFilter should match snapshot 1`] = `
"label": "Empty",
"value": "empty",
},
Object {
"label": "Include or Empty",
"value": "include_or_empty",
},
]
}
removeValidate={[MockFunction]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ export default class ChannelSubscriptionFilter extends React.PureComponent<Props
case FilterFieldInclusion.EMPTY:
subtext = 'Includes when the value is empty';
break;
case FilterFieldInclusion.INCLUDE_OR_EMPTY:
subtext = 'Includes the specified values or when the value is empty';
break;
}

return (
Expand Down Expand Up @@ -202,6 +205,7 @@ export default class ChannelSubscriptionFilter extends React.PureComponent<Props
{label: 'Include All', value: FilterFieldInclusion.INCLUDE_ALL},
{label: 'Exclude', value: FilterFieldInclusion.EXCLUDE_ANY},
{label: 'Empty', value: FilterFieldInclusion.EMPTY},
{label: 'Include or Empty', value: FilterFieldInclusion.INCLUDE_OR_EMPTY},
];

if (isSecurityLevelField(field) && value.inclusion !== FilterFieldInclusion.EXCLUDE_ANY && this.props.securityLevelEmptyForJiraSubscriptions) {
Expand Down
1 change: 1 addition & 0 deletions webapp/src/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export enum FilterFieldInclusion {
INCLUDE_ALL = 'include_all',
EXCLUDE_ANY = 'exclude_any',
EMPTY = 'empty',
INCLUDE_OR_EMPTY = 'include_or_empty',
}

export type FilterValue = {
Expand Down

0 comments on commit ac41da4

Please sign in to comment.