mirror of https://github.com/zulip/zulip.git
integrations: Convert CATEGORIES from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
230b701acc
commit
9b1f55c020
|
@ -6,7 +6,7 @@ import { path_parts } from './landing-page';
|
|||
// these constants are populated immediately with data from the DOM on page load
|
||||
// name -> display name
|
||||
const INTEGRATIONS = new Map();
|
||||
const CATEGORIES = {};
|
||||
const CATEGORIES = new Map();
|
||||
|
||||
function load_data() {
|
||||
$('.integration-lozenge').toArray().forEach(function (integration) {
|
||||
|
@ -23,7 +23,7 @@ function load_data() {
|
|||
const display_name = $(category).text().trim();
|
||||
|
||||
if (display_name && name) {
|
||||
CATEGORIES[name] = display_name;
|
||||
CATEGORIES.set(name, display_name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ function update_categories() {
|
|||
if (state.category === INITIAL_STATE.category) {
|
||||
$dropdown_label.text(i18n.t('Filter by category'));
|
||||
} else {
|
||||
$dropdown_label.text(CATEGORIES[state.category]);
|
||||
$dropdown_label.text(CATEGORIES.get(state.category));
|
||||
}
|
||||
|
||||
$('.integration-lozenges').animate(
|
||||
|
@ -115,7 +115,7 @@ const update_integrations = _.debounce(function () {
|
|||
const display_name = INTEGRATIONS.get($integration.data('name'));
|
||||
const display =
|
||||
common.phrase_match(state.query, display_name) &&
|
||||
($integration.data('categories').includes(CATEGORIES[state.category]) ||
|
||||
($integration.data('categories').includes(CATEGORIES.get(state.category)) ||
|
||||
state.category === 'all');
|
||||
|
||||
if (display) {
|
||||
|
@ -147,11 +147,11 @@ function hide_catalog_show_integration() {
|
|||
$('#integration-instructions-group .categories .integration-category').remove();
|
||||
categories.forEach(function (category) {
|
||||
let link;
|
||||
Object.keys(CATEGORIES).forEach(function (name) {
|
||||
if (CATEGORIES[name] === category) {
|
||||
for (const [name, display_name] of CATEGORIES) {
|
||||
if (display_name === category) {
|
||||
link = name;
|
||||
}
|
||||
});
|
||||
}
|
||||
const category_el = $('<a></a>')
|
||||
.attr('href', '/integrations/' + link)
|
||||
.append('<h3 class="integration-category"></h3>');
|
||||
|
@ -234,7 +234,7 @@ function get_state_from_path() {
|
|||
const parts = path_parts();
|
||||
if (parts[1] === 'doc' && INTEGRATIONS.get(parts[2])) {
|
||||
result.integration = parts[2];
|
||||
} else if (CATEGORIES[parts[1]]) {
|
||||
} else if (CATEGORIES.has(parts[1])) {
|
||||
result.category = parts[1];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue