Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.9)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.0.1)
Expand All @@ -22,34 +24,42 @@ GEM
drb (2.2.3)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.18.0)
json (2.19.1)
json-schema (6.2.0)
addressable (~> 2.8)
bigdecimal (>= 3.1, < 5)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.7.0)
minitest (6.0.1)
mcp (0.8.0)
json-schema (>= 4.1)
minitest (6.0.2)
drb (~> 2.0)
prism (~> 1.5)
parallel (1.27.0)
parser (3.3.10.1)
parser (3.3.10.2)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (1.8.0)
prism (1.9.0)
public_suffix (7.0.5)
racc (1.8.1)
rack (3.2.5)
rainbow (3.1.1)
regexp_parser (2.11.3)
rubocop (1.84.0)
rubocop (1.85.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
mcp (~> 0.6)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.0)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-capybara (2.22.1)
Expand Down Expand Up @@ -101,4 +111,4 @@ DEPENDENCIES
syntax_tree

BUNDLED WITH
4.0.4
4.0.8
10 changes: 6 additions & 4 deletions assets/javascripts/discourse/components/docs-category.gjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable ember/no-classic-components */
import Component from "@ember/component";
import { on } from "@ember/modifier";
import { computed } from "@ember/object";
import { tagName } from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";
import discourseComputed from "discourse/lib/decorators";

@tagName("")
export default class DocsCategory extends Component {
@discourseComputed("category")
categoryName(category) {
return this.site.categories.find((item) => item.id === category.id)?.name;
@computed("category")
get categoryName() {
return this.site.categories.find((item) => item.id === this.category.id)
?.name;
}

<template>
Expand Down
1 change: 1 addition & 0 deletions assets/javascripts/discourse/components/docs-search.gjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable ember/no-classic-components, ember/require-tagless-components */
import Component, { Input } from "@ember/component";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
Expand Down
1 change: 1 addition & 0 deletions assets/javascripts/discourse/components/docs-tag.gjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable ember/no-classic-components */
import Component from "@ember/component";
import { on } from "@ember/modifier";
import { tagName } from "@ember-decorators/component";
Expand Down
8 changes: 5 additions & 3 deletions assets/javascripts/discourse/components/docs-topic.gjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable ember/no-classic-components, ember/require-tagless-components */
import Component from "@ember/component";
import { computed } from "@ember/object";
import { reads } from "@ember/object/computed";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
Expand All @@ -8,7 +10,7 @@ import PluginOutlet from "discourse/components/plugin-outlet";
import Post from "discourse/components/post";
import icon from "discourse/helpers/d-icon";
import discourseDebounce from "discourse/lib/debounce";
import computed, { bind } from "discourse/lib/decorators";
import { bind } from "discourse/lib/decorators";
import transformPost from "discourse/lib/transform-post";
import { i18n } from "discourse-i18n";

Expand All @@ -20,12 +22,12 @@ export default class DocsTopic extends Component {
@reads("post.cooked") originalPostContent;

@computed("currentUser", "model")
post() {
get post() {
return transformPost(this.currentUser, this.site, this.model);
}

@computed("topic", "topic.post_stream")
model() {
get model() {
const post = this.store.createRecord(
"post",
this.topic.post_stream?.posts[0]
Expand Down
150 changes: 80 additions & 70 deletions assets/javascripts/discourse/controllers/docs/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Controller, { inject as controller } from "@ember/controller";
import { action } from "@ember/object";
import { action, computed } from "@ember/object";
import { alias, equal, gt, readOnly } from "@ember/object/computed";
import { getOwner } from "@ember/owner";
import { htmlSafe } from "@ember/template";
import { on } from "@ember-decorators/object";
import discourseComputed from "discourse/lib/decorators";
import getURL from "discourse/lib/get-url";
import { i18n } from "discourse-i18n";
import Docs from "discourse/plugins/discourse-docs/discourse/models/docs";
Expand Down Expand Up @@ -73,13 +72,15 @@ export default class DocsIndexController extends Controller {
});
}

@discourseComputed("categories", "categorySort", "categoryFilter")
sortedCategories(categories, categorySort, filter) {
let { type, direction } = categorySort;
@computed("categories", "categorySort", "categoryFilter")
get sortedCategories() {
let { type, direction } = this.categorySort;
let categories;

if (type === "numeric") {
categories = categories.sort((a, b) => a.count - b.count);
categories = this.categories.sort((a, b) => a.count - b.count);
} else {
categories = categories.sort((a, b) => {
categories = this.categories.sort((a, b) => {
const first = this.site.categories
.find((item) => item.id === a.id)
.name.toLowerCase(),
Expand All @@ -100,41 +101,50 @@ export default class DocsIndexController extends Controller {
(item) => item.id === category.id
);
return (
categoryData.name.toLowerCase().indexOf(filter.toLowerCase()) > -1 ||
(categoryData.description_excerpt &&
categoryData.description_excerpt
.toLowerCase()
.indexOf(filter.toLowerCase()) > -1)
categoryData.name
.toLowerCase()
.includes(this.categoryFilter.toLowerCase()) ||
categoryData.description_excerpt
?.toLowerCase()
.includes(this.categoryFilter.toLowerCase())
);
});
}

return categories;
}

@discourseComputed("categorySort")
categorySortNumericIcon(catSort) {
if (catSort.type === "numeric" && catSort.direction === "asc") {
@computed("categorySort")
get categorySortNumericIcon() {
if (
this.categorySort.type === "numeric" &&
this.categorySort.direction === "asc"
) {
return "arrow-down-1-9";
}
return "arrow-up-1-9";
}

@discourseComputed("categorySort")
categorySortAlphaIcon(catSort) {
if (catSort.type === "alpha" && catSort.direction === "asc") {
@computed("categorySort")
get categorySortAlphaIcon() {
if (
this.categorySort.type === "alpha" &&
this.categorySort.direction === "asc"
) {
return "arrow-down-a-z";
}
return "arrow-up-a-z";
}

@discourseComputed("tags", "tagSort", "tagFilter")
sortedTags(tags, tagSort, filter) {
let { type, direction } = tagSort;
@computed("tags", "tagSort", "tagFilter")
get sortedTags() {
let { type, direction } = this.tagSort;
let tags;

if (type === "numeric") {
tags = tags.sort((a, b) => a.count - b.count);
tags = this.tags.sort((a, b) => a.count - b.count);
} else {
tags = tags.sort((a, b) => {
tags = this.tags.sort((a, b) => {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
});
}
Expand All @@ -145,17 +155,17 @@ export default class DocsIndexController extends Controller {

if (this.showTagFilter) {
return tags.filter((tag) => {
return tag.name.toLowerCase().indexOf(filter.toLowerCase()) > -1;
return tag.name.toLowerCase().includes(this.tagFilter.toLowerCase());
});
}

return tags;
}

@discourseComputed("tagGroups", "tagSort", "tagFilter")
sortedTagGroups(tagGroups, tagSort, filter) {
let { type, direction } = tagSort;
let sortedTagGroups = [...tagGroups];
@computed("tagGroups", "tagSort", "tagFilter")
get sortedTagGroups() {
let { type, direction } = this.tagSort;
let sortedTagGroups = [...(this.tagGroups || [])];

if (type === "numeric") {
sortedTagGroups.forEach((group) => {
Expand All @@ -178,78 +188,78 @@ export default class DocsIndexController extends Controller {

if (this.showTagFilter) {
return sortedTagGroups.filter((tagGroup) =>
tagGroup.name.toLowerCase().includes(filter.toLowerCase())
tagGroup.name.toLowerCase().includes(this.tagFilter.toLowerCase())
);
}

return sortedTagGroups;
}

@discourseComputed("tagSort")
tagSortNumericIcon(tagSort) {
if (tagSort.type === "numeric" && tagSort.direction === "asc") {
@computed("tagSort")
get tagSortNumericIcon() {
if (this.tagSort.type === "numeric" && this.tagSort.direction === "asc") {
return "arrow-down-1-9";
}
return "arrow-up-1-9";
}

@discourseComputed("tagSort")
tagSortAlphaIcon(tagSort) {
if (tagSort.type === "alpha" && tagSort.direction === "asc") {
@computed("tagSort")
get tagSortAlphaIcon() {
if (this.tagSort.type === "alpha" && this.tagSort.direction === "asc") {
return "arrow-down-a-z";
}
return "arrow-up-a-z";
}

@discourseComputed("topics", "isSearching", "filterSolved")
noContent(topics, isSearching, filterSolved) {
const filtered = isSearching || filterSolved;
@computed("topics", "isSearching", "filterSolved")
get noContent() {
const filtered = this.isSearching || this.filterSolved;
return this.topicCount === 0 && !filtered;
}

@discourseComputed("loadMoreUrl")
canLoadMore(loadMoreUrl) {
return loadMoreUrl === null ? false : true;
@computed("loadMoreUrl")
get canLoadMore() {
return this.loadMoreUrl === null ? false : true;
}

@discourseComputed("searchTerm")
isSearching(searchTerm) {
return !!searchTerm;
@computed("searchTerm")
get isSearching() {
return !!this.searchTerm;
}

@discourseComputed("isSearching", "filterSolved")
isSearchingOrFiltered(isSearching, filterSolved) {
return isSearching || filterSolved;
@computed("isSearching", "filterSolved")
get isSearchingOrFiltered() {
return this.isSearching || this.filterSolved;
}

@discourseComputed
canFilterSolved() {
@computed
get canFilterSolved() {
return (
this.siteSettings.solved_enabled &&
this.siteSettings.docs_add_solved_filter
);
}

@discourseComputed("filterTags")
filtered(filterTags) {
return !!filterTags;
@computed("filterTags")
get filtered() {
return !!this.filterTags;
}

@discourseComputed("siteSettings.tagging_enabled", "shouldShowTagsByGroup")
shouldShowTags(tagging_enabled, shouldShowTagsByGroup) {
return tagging_enabled && !shouldShowTagsByGroup;
@computed("siteSettings.tagging_enabled", "shouldShowTagsByGroup")
get shouldShowTags() {
return this.siteSettings?.tagging_enabled && !this.shouldShowTagsByGroup;
}

@discourseComputed(
"siteSettings.show_tags_by_group",
"siteSettings.docs_tag_groups"
)
shouldShowTagsByGroup(show_tags_by_group, docs_tag_groups) {
return show_tags_by_group && Boolean(docs_tag_groups);
@computed("siteSettings.show_tags_by_group", "siteSettings.docs_tag_groups")
get shouldShowTagsByGroup() {
return (
this.siteSettings?.show_tags_by_group &&
Boolean(this.siteSettings?.docs_tag_groups)
);
}

@discourseComputed()
emptyState() {
@computed()
get emptyState() {
let body = i18n("docs.no_docs.body");
if (this.docsCategoriesAndTags.length) {
body += i18n("docs.no_docs.to_include_topic_in_docs");
Expand All @@ -269,13 +279,13 @@ export default class DocsIndexController extends Controller {
};
}

@discourseComputed("docsCategories", "docsTags")
docsCategoriesAndTags(docsCategories, docsTags) {
return docsCategories.concat(docsTags);
@computed("docsCategories", "docsTags")
get docsCategoriesAndTags() {
return this.docsCategories.concat(this.docsTags);
}

@discourseComputed()
docsCategories() {
@computed()
get docsCategories() {
if (!this.siteSettings.docs_categories) {
return [];
}
Expand All @@ -289,8 +299,8 @@ export default class DocsIndexController extends Controller {
.filter(Boolean);
}

@discourseComputed()
docsTags() {
@computed()
get docsTags() {
if (!this.siteSettings.docs_tags) {
return [];
}
Expand Down
Loading