mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
integrations: Properly pass data-categories as a JSON array.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
77cac403ee
commit
801e267e00
@@ -107,7 +107,7 @@
|
|||||||
class="integration-lozenge integration-{{ integration.name }} legacy"{% else %}
|
class="integration-lozenge integration-{{ integration.name }} legacy"{% else %}
|
||||||
class="integration-lozenge integration-{{ integration.name }}"
|
class="integration-lozenge integration-{{ integration.name }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
data-categories="{{ integration.categories }}"
|
data-categories='{{ integration.get_translated_categories()|tojson }}'
|
||||||
data-name="{{ integration.name }}">
|
data-name="{{ integration.name }}">
|
||||||
<img class="integration-logo" src="{{ integration.logo_url }}"
|
<img class="integration-logo" src="{{ integration.logo_url }}"
|
||||||
alt="{{ integration.display_name }} logo"/>
|
alt="{{ integration.display_name }} logo"/>
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ const update_integrations = _.debounce(() => {
|
|||||||
const display_name = INTEGRATIONS.get($integration.attr("data-name"));
|
const display_name = INTEGRATIONS.get($integration.attr("data-name"));
|
||||||
const display =
|
const display =
|
||||||
common.phrase_match(state.query, display_name) &&
|
common.phrase_match(state.query, display_name) &&
|
||||||
($integration.attr("data-categories").includes(CATEGORIES.get(state.category)) ||
|
(JSON.parse($integration.attr("data-categories")).includes(
|
||||||
|
CATEGORIES.get(state.category),
|
||||||
|
) ||
|
||||||
state.category === "all");
|
state.category === "all");
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
@@ -140,11 +142,9 @@ function hide_catalog_show_integration() {
|
|||||||
).clone(false);
|
).clone(false);
|
||||||
$lozenge_icon.removeClass("legacy");
|
$lozenge_icon.removeClass("legacy");
|
||||||
|
|
||||||
const categories = $(`.integration-${CSS.escape(state.integration)}`)
|
const categories = JSON.parse(
|
||||||
.attr("data-categories")
|
$(`.integration-${CSS.escape(state.integration)}`).attr("data-categories"),
|
||||||
.slice(1, -1)
|
);
|
||||||
.split(",")
|
|
||||||
.map((category) => category.trim().slice(1, -1));
|
|
||||||
|
|
||||||
function show_integration(doc) {
|
function show_integration(doc) {
|
||||||
$("#integration-instructions-group .name").text(INTEGRATIONS.get(state.integration));
|
$("#integration-instructions-group .name").text(INTEGRATIONS.get(state.integration));
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ class Integration:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_translated_categories(self) -> list[str]:
|
||||||
|
return [str(category) for category in self.categories]
|
||||||
|
|
||||||
|
|
||||||
class BotIntegration(Integration):
|
class BotIntegration(Integration):
|
||||||
DEFAULT_LOGO_STATIC_PATH_PNG = "generated/bots/{name}/logo.png"
|
DEFAULT_LOGO_STATIC_PATH_PNG = "generated/bots/{name}/logo.png"
|
||||||
|
|||||||
Reference in New Issue
Block a user