Skip to content

Commit

Permalink
FIX: Restore behaviour for displayCategory setting (#44)
Browse files Browse the repository at this point in the history
The ability to restrict the menu item to certain categories was lost in the recent refactoring. This restores it, and updates things to use core's new 'discovery' service.
  • Loading branch information
davidtaylorhq committed Dec 22, 2023
1 parent 6ae7437 commit 8d92616
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
19 changes: 11 additions & 8 deletions javascripts/discourse/components/kanban/nav.gjs
Expand Up @@ -2,6 +2,7 @@ import Component from "@glimmer/component";
import { inject as service } from "@ember/service";
import concatClass from "discourse/helpers/concat-class";
import i18n from "discourse-common/helpers/i18n";
import { displayConnector } from "../../lib/kanban-utilities";

export default class KanbanNav extends Component {
@service kanbanManager;
Expand All @@ -19,13 +20,15 @@ export default class KanbanNav extends Component {
}

<template>
<li>
<a
href={{this.href}}
class={{concatClass "kanban-nav" (if this.active "active")}}
>
{{i18n (themePrefix "menu_label")}}
</a>
</li>
{{#if (displayConnector this.kanbanManager.discoveryCategory.slug)}}
<li>
<a
href={{this.href}}
class={{concatClass "kanban-nav" (if this.active "active")}}
>
{{i18n (themePrefix "menu_label")}}
</a>
</li>
{{/if}}
</template>
}
12 changes: 8 additions & 4 deletions javascripts/discourse/services/kanban-manager.js
Expand Up @@ -8,6 +8,7 @@ import buildTagLists from "../lib/kanban-list-builders/tags";

export default class KanbanManager extends Service {
@service router;
@service discovery;

@tracked fullscreen;

Expand Down Expand Up @@ -47,23 +48,26 @@ export default class KanbanManager extends Service {
}

get discoveryTopTags() {
return this.discoveryRouteAttribute("list.topic_list.top_tags");
return this.discovery.currentTopicList?.get("topic_list.top_tags");
}

get discoveryCategory() {
return this.discoveryRouteAttribute("category");
return this.discovery.category;
}

get discoveryTag() {
return this.discoveryRouteAttribute("tag");
return this.discovery.tag;
}

get active() {
return !!this.currentDescriptor;
}

get currentDescriptor() {
return this.discoveryParams && get(this.discoveryParams, "board");
return (
this.discovery.onDiscoveryRoute &&
this.router.currentRoute?.queryParams?.board
);
}

get listDefinitions() {
Expand Down

0 comments on commit 8d92616

Please sign in to comment.