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
|
@ -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:
|
||||
js:
|
||||
discourse_chat:
|
||||
chat:
|
||||
menu_title: "Chat Integrations"
|
||||
|
||||
integration:
|
||||
telegram:
|
||||
title: "Telegram"
|
||||
slack:
|
||||
title: "Slack"
|
|
@ -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"
|
|
@ -0,0 +1,7 @@
|
|||
module DiscourseChat
|
||||
module Integration
|
||||
module SlackIntegration
|
||||
INTEGRATION_NAME = "slack".freeze
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue