From bf113f47b0db6a6d984976d6869239ee88e68992 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Feb 2017 12:20:01 -0500 Subject: [PATCH] FEATURE: add solved enabled key --- .../initializers/extend-for-solved-button.js.es6 | 9 +++++++-- config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ plugin.rb | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 index c19beaf..375471b 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 @@ -173,9 +173,14 @@ function initializeWithApi(api) { }); if (api.registerConnectorClass) { + api.registerConnectorClass('user-activity-bottom', 'solved-list', { + shouldRender(args, component) { + return component.siteSettings.solved_enabled; + }, + }); api.registerConnectorClass('user-summary-stat', 'solved-count', { - shouldRender(args) { - return args.model.solved_count > 0; + shouldRender(args, component) { + return component.siteSettings.solved_enabled && args.model.solved_count > 0; }, setupComponent() { this.set('classNames', ['linked-stat']); diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 787b6dc..2ac8d35 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,5 +1,6 @@ en: site_settings: + solved_enabled: "Enable solved plugin, allow users to select solutions for topics" allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)" accept_all_solutions_trust_level: "Minimum trust level required to accept solutions on any topic (even when not OP)" reports: diff --git a/config/settings.yml b/config/settings.yml index 9f46b5c..20e2d68 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -1,4 +1,7 @@ plugins: + solved_enabled: + default: true + client: true allow_solved_on_all_topics: default: false client: true diff --git a/plugin.rb b/plugin.rb index 9a048bd..65dd583 100644 --- a/plugin.rb +++ b/plugin.rb @@ -3,6 +3,8 @@ # version: 0.1 # authors: Sam Saffron +enabled_site_setting :solved_enabled + PLUGIN_NAME = "discourse_solved".freeze register_asset 'stylesheets/solutions.scss'