diff --git a/assets/javascripts/discourse/chat-route-map.js.es6 b/assets/javascripts/discourse/chat-route-map.js.es6 new file mode 100644 index 0000000..9458f36 --- /dev/null +++ b/assets/javascripts/discourse/chat-route-map.js.es6 @@ -0,0 +1,7 @@ +export default { + resource: 'admin.adminPlugins', + path: '/plugins', + map() { + this.route('chat'); + } +}; \ No newline at end of file diff --git a/assets/javascripts/discourse/controllers/admin-plugins-chat.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-chat.js.es6 new file mode 100644 index 0000000..4ee344f --- /dev/null +++ b/assets/javascripts/discourse/controllers/admin-plugins-chat.js.es6 @@ -0,0 +1,3 @@ +export default Ember.Controller.extend({ + +}); \ No newline at end of file diff --git a/assets/javascripts/discourse/routes/admin-plugins-chat.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-chat.js.es6 new file mode 100644 index 0000000..7212c76 --- /dev/null +++ b/assets/javascripts/discourse/routes/admin-plugins-chat.js.es6 @@ -0,0 +1,9 @@ +import { ajax } from 'discourse/lib/ajax'; + +export default Discourse.Route.extend({ + model() { + return ajax("/chat/list-integrations.json").then(result => { + return result.chat; + }); + } +}); diff --git a/assets/javascripts/discourse/templates/admin/plugins-chat.hbs b/assets/javascripts/discourse/templates/admin/plugins-chat.hbs new file mode 100644 index 0000000..8669772 --- /dev/null +++ b/assets/javascripts/discourse/templates/admin/plugins-chat.hbs @@ -0,0 +1,12 @@ +
+
+
+ + +
+
+
\ No newline at end of file diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 6072116..6cafab4 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1,4 +1,10 @@ en: js: - discourse_chat: - \ No newline at end of file + chat: + menu_title: "Chat Integrations" + + integration: + telegram: + title: "Telegram" + slack: + title: "Slack" \ No newline at end of file diff --git a/lib/integration.rb b/lib/integration.rb new file mode 100644 index 0000000..58cce36 --- /dev/null +++ b/lib/integration.rb @@ -0,0 +1,12 @@ +module DiscourseChat + module Integration + def self.integrations + constants.select do |constant| + constant.to_s =~ /Integration$/ + end.map(&method(:const_get)) + end + end +end + +require_relative "integration/slack/slack_integration.rb" +require_relative "integration/telegram/telegram_integration.rb" \ No newline at end of file diff --git a/lib/integration/slack/slack_integration.rb b/lib/integration/slack/slack_integration.rb new file mode 100644 index 0000000..98a501d --- /dev/null +++ b/lib/integration/slack/slack_integration.rb @@ -0,0 +1,7 @@ +module DiscourseChat + module Integration + module SlackIntegration + INTEGRATION_NAME = "slack".freeze + end + end +end \ No newline at end of file diff --git a/lib/integration/telegram/telegram_integration.rb b/lib/integration/telegram/telegram_integration.rb new file mode 100644 index 0000000..380579a --- /dev/null +++ b/lib/integration/telegram/telegram_integration.rb @@ -0,0 +1,7 @@ +module DiscourseChat + module Integration + module TelegramIntegration + INTEGRATION_NAME = "telegram".freeze + end + end +end \ No newline at end of file diff --git a/plugin.rb b/plugin.rb index 6943aad..3bd2042 100644 --- a/plugin.rb +++ b/plugin.rb @@ -15,4 +15,33 @@ after_initialize do isolate_namespace DiscourseChat end end + + require_relative "lib/integration" + + class ::DiscourseChat::ChatController < ::ApplicationController + requires_plugin DiscourseChat::PLUGIN_NAME + + def list_integrations + render json: ::DiscourseChat::Integration.integrations.map {|x| x::INTEGRATION_NAME} + end + + end + + require_dependency 'admin_constraint' + + + add_admin_route 'chat.menu_title', 'chat' + + DiscourseChat::Engine.routes.draw do + get "/list-integrations" => "chat#list_integrations", constraints: AdminConstraint.new + end + + Discourse::Application.routes.prepend do + mount ::DiscourseChat::Engine, at: "/chat" + end + + Discourse::Application.routes.append do + get '/admin/plugins/chat' => 'admin/plugins#index', constraints: StaffConstraint.new + end + end