Skip to content

Commit

Permalink
search source feature toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Feb 19, 2024
1 parent ba2ac19 commit b02bc91
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
10 changes: 6 additions & 4 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@
->addSortField('bestAnswerCount'),

(new Extend\Settings())
->default('fof-best-answer.schedule_on_one_server', false)
->default('fof-best-answer.stop_overnight', false)
->default('fof-best-answer.store_log_output', false)
->default('fof-best-answer.enabled-tags', '[]')
->default('fof-best-answer.search.solution_search', true)
->serializeToForum('canSelectBestAnswerOwnPost', 'fof-best-answer.allow_select_own_post', 'boolVal')
->serializeToForum('useAlternativeBestAnswerUi', 'fof-best-answer.use_alternative_ui', 'boolVal')
->serializeToForum('showBestAnswerFilterUi', 'fof-best-answer.show_filter_dropdown', 'boolVal')
->serializeToForum('fof-best-answer.show_max_lines', 'fof-best-answer.show_max_lines', 'intVal')
->default('fof-best-answer.schedule_on_one_server', false)
->default('fof-best-answer.stop_overnight', false)
->default('fof-best-answer.store_log_output', false)
->default('fof-best-answer.enabled-tags', '[]'),
->serializeToForum('solutionSearchEnabled', 'fof-best-answer.search.solution_search', 'boolVal'),

(new Extend\ApiController(ShowDiscussionController::class))
->addInclude(['bestAnswerPost', 'bestAnswerUser'])
Expand Down
12 changes: 11 additions & 1 deletion js/src/admin/components/BestAnswerSettings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import app from 'flarum/admin/app';
import ExtensionPage from 'flarum/admin/components/ExtensionPage';
import ExtensionPage, { ExtensionPageAttrs } from 'flarum/admin/components/ExtensionPage';
import Button from 'flarum/common/components/Button';
import Link from 'flarum/common/components/Link';

Expand Down Expand Up @@ -115,6 +115,16 @@ export default class BestAnswerSettings extends ExtensionPage {
})}
</div>
<hr />
<div className="Search">
<h3>{app.translator.trans('fof-best-answer.admin.settings.label.search')}</h3>
{this.buildSettingComponent({
type: 'boolean',
setting: 'fof-best-answer.search.solution_search',
label: app.translator.trans('fof-best-answer.admin.settings.solution_search'),
help: app.translator.trans('fof-best-answer.admin.settings.solution_search_help'),
})}
</div>
<hr />
<div className="Reminders">
<h3>{app.translator.trans('fof-best-answer.admin.settings.label.reminders')}</h3>
<p className="helpText">
Expand Down
5 changes: 4 additions & 1 deletion js/src/forum/extenders/extendSearch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import ItemList from 'flarum/common/utils/ItemList';
import Search, { SearchSource } from 'flarum/forum/components/Search';
import SolutionSearchSource from '../components/SolutionSearchSource';

export default function extendSearch() {
extend(Search.prototype, 'sourceItems', function (items: ItemList<SearchSource>) {
items.add('solution', new SolutionSearchSource(), 110);
if (app.forum.attribute<boolean>('solutionSearchEnabled')) {
items.add('solution', new SolutionSearchSource(), 110);
}
});
}
3 changes: 3 additions & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fof-best-answer:
tags: Best Answer Tags
general: General
reminders: Reminders
search: Search
advanced: Advanced
reminders_notice: For reminders to function, you must have set up the Flarum scheduler correctly.
allow_select_own_post: Select own post
Expand All @@ -34,6 +35,8 @@ fof-best-answer:
remind_tags_help: Select which tags, if any, to send reminders for. Reminders will only be sent for discussions with these tags.
tags_info: |
When a tag is Best Answer enabled, assign permissions to each user group that may set answers (own discussion, any discussion). Permissions may be assigned globally (for any Best Answer anabled tag), or on a per tag basis.
solution_search: Solution search
solution_search_help: Enable the ability to search for discussions with Best Answers
edit_tag:
qna_label: Enable Best Answers to be set in this tag
reminders: Send reminders to set a Best Answer for discussions in this tag
Expand Down

0 comments on commit b02bc91

Please sign in to comment.