mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-07-05 05:32:10 +00:00
Created basic system to allow multiple integrations to register themselves, creating a separate tab in the admin interface for each one.
This commit is contained in:
parent
3e3a309c44
commit
3967e2cd91
7
assets/javascripts/discourse/chat-route-map.js.es6
Normal file
7
assets/javascripts/discourse/chat-route-map.js.es6
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
resource: 'admin.adminPlugins',
|
||||||
|
path: '/plugins',
|
||||||
|
map() {
|
||||||
|
this.route('chat');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,3 @@
|
|||||||
|
export default Ember.Controller.extend({
|
||||||
|
|
||||||
|
});
|
@ -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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,12 @@
|
|||||||
|
<div class='admin-chat'>
|
||||||
|
<div class="admin-controls">
|
||||||
|
<div class="span15">
|
||||||
|
|
||||||
|
<ul class="nav nav-pills">
|
||||||
|
{{#each model as |provider|}}
|
||||||
|
{{nav-item label=(concat 'chat.integration.' provider '.title')}}
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,4 +1,10 @@
|
|||||||
en:
|
en:
|
||||||
js:
|
js:
|
||||||
discourse_chat:
|
chat:
|
||||||
|
menu_title: "Chat Integrations"
|
||||||
|
|
||||||
|
integration:
|
||||||
|
telegram:
|
||||||
|
title: "Telegram"
|
||||||
|
slack:
|
||||||
|
title: "Slack"
|
12
lib/integration.rb
Normal file
12
lib/integration.rb
Normal file
@ -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"
|
7
lib/integration/slack/slack_integration.rb
Normal file
7
lib/integration/slack/slack_integration.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module DiscourseChat
|
||||||
|
module Integration
|
||||||
|
module SlackIntegration
|
||||||
|
INTEGRATION_NAME = "slack".freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
7
lib/integration/telegram/telegram_integration.rb
Normal file
7
lib/integration/telegram/telegram_integration.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module DiscourseChat
|
||||||
|
module Integration
|
||||||
|
module TelegramIntegration
|
||||||
|
INTEGRATION_NAME = "telegram".freeze
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
29
plugin.rb
29
plugin.rb
@ -15,4 +15,33 @@ after_initialize do
|
|||||||
isolate_namespace DiscourseChat
|
isolate_namespace DiscourseChat
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user