mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
narrow-filter: Update Filter.describe_is_operator for "resolved".
Updates `Filter.describe_is_operator` to use switch/case instead of if/else and adds case for "is:resolved" narrow so that it is not shown as invalid when used with other search narrow filters.
This commit is contained in:
committed by
Tim Abbott
parent
982a37aece
commit
b821c90f44
@@ -999,14 +999,20 @@ export class Filter {
|
|||||||
static describe_is_operator(operator) {
|
static describe_is_operator(operator) {
|
||||||
const verb = operator.negated ? "exclude " : "";
|
const verb = operator.negated ? "exclude " : "";
|
||||||
const operand = operator.operand;
|
const operand = operator.operand;
|
||||||
const operand_list = ["starred", "alerted", "unread"];
|
|
||||||
if (operand_list.includes(operand)) {
|
switch (operand) {
|
||||||
return verb + operand + " messages";
|
case "starred":
|
||||||
} else if (operand === "mentioned") {
|
case "alerted":
|
||||||
return verb + "@-mentions";
|
case "unread":
|
||||||
} else if (operand === "private") {
|
return verb + operand + " messages";
|
||||||
return verb + "direct messages";
|
case "mentioned":
|
||||||
|
return verb + "@-mentions";
|
||||||
|
case "private":
|
||||||
|
return verb + "direct messages";
|
||||||
|
case "resolved":
|
||||||
|
return verb + "topics marked as resolved";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "invalid " + operand + " operand for is operator";
|
return "invalid " + operand + " operand for is operator";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1157,6 +1157,10 @@ test("describe", () => {
|
|||||||
string = "alerted messages";
|
string = "alerted messages";
|
||||||
assert.equal(Filter.describe(narrow), string);
|
assert.equal(Filter.describe(narrow), string);
|
||||||
|
|
||||||
|
narrow = [{operator: "is", operand: "resolved"}];
|
||||||
|
string = "topics marked as resolved";
|
||||||
|
assert.equal(Filter.describe(narrow), string);
|
||||||
|
|
||||||
narrow = [{operator: "is", operand: "something_we_do_not_support"}];
|
narrow = [{operator: "is", operand: "something_we_do_not_support"}];
|
||||||
string = "invalid something_we_do_not_support operand for is operator";
|
string = "invalid something_we_do_not_support operand for is operator";
|
||||||
assert.equal(Filter.describe(narrow), string);
|
assert.equal(Filter.describe(narrow), string);
|
||||||
|
|||||||
Reference in New Issue
Block a user