filter: Rename describe to search_description_as_html.

Changing this since wobbly naming on HTML variables is dangerous.
This commit is contained in:
Evy Kassirer 2023-06-26 11:11:17 -07:00 committed by GitHub
parent 466db56118
commit adcf088740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 22 deletions

View File

@ -1104,7 +1104,7 @@ export class Filter {
return [...parts, ...more_parts].join(", "); return [...parts, ...more_parts].join(", ");
} }
static describe(operators) { static search_description_as_html(operators) {
return Handlebars.Utils.escapeExpression(Filter.describe_unescaped(operators)); return Handlebars.Utils.escapeExpression(Filter.describe_unescaped(operators));
} }

View File

@ -61,7 +61,7 @@ function check_validity(last, operators, valid, invalid) {
function format_as_suggestion(terms) { function format_as_suggestion(terms) {
return { return {
description_html: Filter.describe(terms), description_html: Filter.search_description_as_html(terms),
search_string: Filter.unparse(terms), search_string: Filter.unparse(terms),
}; };
} }

View File

@ -1162,114 +1162,114 @@ test("describe", () => {
narrow = [{operator: "streams", operand: "public"}]; narrow = [{operator: "streams", operand: "public"}];
string = "streams public"; string = "streams public";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "streams", operand: "public", negated: true}]; narrow = [{operator: "streams", operand: "public", negated: true}];
string = "exclude streams public"; string = "exclude streams public";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
{operator: "is", operand: "starred"}, {operator: "is", operand: "starred"},
]; ];
string = "stream devel, starred messages"; string = "stream devel, starred messages";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "river"}, {operator: "stream", operand: "river"},
{operator: "is", operand: "unread"}, {operator: "is", operand: "unread"},
]; ];
string = "stream river, unread messages"; string = "stream river, unread messages";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
{operator: "topic", operand: "JS"}, {operator: "topic", operand: "JS"},
]; ];
string = "stream devel > JS"; string = "stream devel > JS";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "is", operand: "dm"}, {operator: "is", operand: "dm"},
{operator: "search", operand: "lunch"}, {operator: "search", operand: "lunch"},
]; ];
string = "direct messages, search for lunch"; string = "direct messages, search for lunch";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "id", operand: 99}]; narrow = [{operator: "id", operand: 99}];
string = "message ID 99"; string = "message ID 99";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "in", operand: "home"}]; narrow = [{operator: "in", operand: "home"}];
string = "messages in home"; string = "messages in home";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "is", operand: "mentioned"}]; narrow = [{operator: "is", operand: "mentioned"}];
string = "@-mentions"; string = "@-mentions";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "is", operand: "alerted"}]; narrow = [{operator: "is", operand: "alerted"}];
string = "alerted messages"; string = "alerted messages";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [{operator: "is", operand: "resolved"}]; narrow = [{operator: "is", operand: "resolved"}];
string = "topics marked as resolved"; string = "topics marked as resolved";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(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.search_description_as_html(narrow), string);
// this should be unreachable, but just in case // this should be unreachable, but just in case
narrow = [{operator: "bogus", operand: "foo"}]; narrow = [{operator: "bogus", operand: "foo"}];
string = "unknown operator"; string = "unknown operator";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
{operator: "topic", operand: "JS", negated: true}, {operator: "topic", operand: "JS", negated: true},
]; ];
string = "stream devel, exclude topic JS"; string = "stream devel, exclude topic JS";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "is", operand: "dm"}, {operator: "is", operand: "dm"},
{operator: "search", operand: "lunch", negated: true}, {operator: "search", operand: "lunch", negated: true},
]; ];
string = "direct messages, exclude lunch"; string = "direct messages, exclude lunch";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
{operator: "is", operand: "starred", negated: true}, {operator: "is", operand: "starred", negated: true},
]; ];
string = "stream devel, exclude starred messages"; string = "stream devel, exclude starred messages";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
{operator: "has", operand: "image", negated: true}, {operator: "has", operand: "image", negated: true},
]; ];
string = "stream devel, exclude messages with one or more image"; string = "stream devel, exclude messages with one or more image";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "has", operand: "abc", negated: true}, {operator: "has", operand: "abc", negated: true},
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
]; ];
string = "invalid abc operand for has operator, stream devel"; string = "invalid abc operand for has operator, stream devel";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = [ narrow = [
{operator: "has", operand: "image", negated: true}, {operator: "has", operand: "image", negated: true},
{operator: "stream", operand: "devel"}, {operator: "stream", operand: "devel"},
]; ];
string = "exclude messages with one or more image, stream devel"; string = "exclude messages with one or more image, stream devel";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
narrow = []; narrow = [];
string = "all messages"; string = "all messages";
assert.equal(Filter.describe(narrow), string); assert.equal(Filter.search_description_as_html(narrow), string);
}); });
test("can_bucket_by", () => { test("can_bucket_by", () => {