DEV: Move admin namespace (#87)

This commit is contained in:
Mark VanLandingham 2021-08-26 08:52:53 -05:00 committed by GitHub
parent e34998ed7d
commit a8b7e9631b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 63 additions and 57 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
Discourse::Application.routes.append do Discourse::Application.routes.append do
mount ::DiscourseChatIntegration::AdminEngine, at: '/admin/plugins/chat', constraints: AdminConstraint.new mount ::DiscourseChatIntegration::AdminEngine, at: '/admin/plugins/chat-integration', constraints: AdminConstraint.new
mount ::DiscourseChatIntegration::PublicEngine, at: '/chat-transcript/', as: 'chat-transcript' mount ::DiscourseChatIntegration::PublicEngine, at: '/chat-transcript/', as: 'chat-transcript'
mount ::DiscourseChatIntegration::Provider::HookEngine, at: '/chat-integration/' mount ::DiscourseChatIntegration::Provider::HookEngine, at: '/chat-integration/'

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from "admin/adapters/build-plugin"; import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter("chat"); export default buildPluginAdapter("chat-integration");

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from "admin/adapters/build-plugin"; import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter("chat"); export default buildPluginAdapter("chat-integration");

View File

@ -1,3 +1,3 @@
import buildPluginAdapter from "admin/adapters/build-plugin"; import buildPluginAdapter from "admin/adapters/build-plugin";
export default buildPluginAdapter("chat"); export default buildPluginAdapter("chat-integration");

View File

@ -2,7 +2,7 @@ export default {
resource: "admin.adminPlugins", resource: "admin.adminPlugins",
path: "/plugins", path: "/plugins",
map() { map() {
this.route("chat", function () { this.route("chat-integration", function () {
this.route("provider", { path: "/:provider" }); this.route("provider", { path: "/:provider" });
}); });
}, },

View File

@ -29,7 +29,7 @@ export default Ember.Controller.extend({
provider: this.get("model.provider"), provider: this.get("model.provider"),
}; };
showModal("admin-plugins-chat-edit-channel", { showModal("admin-plugins-chat-integration-edit-channel", {
model, model,
admin: true, admin: true,
}); });
@ -43,7 +43,7 @@ export default Ember.Controller.extend({
provider: this.get("model.provider"), provider: this.get("model.provider"),
}; };
showModal("admin-plugins-chat-edit-channel", { showModal("admin-plugins-chat-integration-edit-channel", {
model, model,
admin: true, admin: true,
}); });
@ -51,7 +51,7 @@ export default Ember.Controller.extend({
testChannel(channel) { testChannel(channel) {
this.set("modalShowing", true); this.set("modalShowing", true);
showModal("admin-plugins-chat-test", { showModal("admin-plugins-chat-integration-test", {
model: { channel }, model: { channel },
admin: true, admin: true,
}); });
@ -70,7 +70,10 @@ export default Ember.Controller.extend({
groups: this.get("model.groups"), groups: this.get("model.groups"),
}; };
showModal("admin-plugins-chat-edit-rule", { model, admin: true }); showModal("admin-plugins-chat-integration-edit-rule", {
model,
admin: true,
});
}, },
editRuleWithChannel(rule, channel) { editRuleWithChannel(rule, channel) {
@ -83,13 +86,16 @@ export default Ember.Controller.extend({
groups: this.get("model.groups"), groups: this.get("model.groups"),
}; };
showModal("admin-plugins-chat-edit-rule", { model, admin: true }); showModal("admin-plugins-chat-integration-edit-rule", {
model,
admin: true,
});
}, },
showError(channel) { showError(channel) {
this.set("modalShowing", true); this.set("modalShowing", true);
showModal("admin-plugins-chat-channel-error", { showModal("admin-plugins-chat-integration-channel-error", {
model: channel, model: channel,
admin: true, admin: true,
}); });

View File

@ -28,7 +28,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
} }
this.set("loading", true); this.set("loading", true);
ajax("/admin/plugins/chat/test", { ajax("/admin/plugins/chat-integration/test", {
data: { data: {
channel_id: this.get("model.channel.id"), channel_id: this.get("model.channel.id"),
topic_id: this.get("model.topic_id"), topic_id: this.get("model.topic_id"),

View File

@ -4,7 +4,7 @@ export default DiscourseRoute.extend({
afterModel(model) { afterModel(model) {
if (model.totalRows > 0) { if (model.totalRows > 0) {
this.transitionTo( this.transitionTo(
"adminPlugins.chat.provider", "adminPlugins.chat-integration.provider",
model.get("firstObject").name model.get("firstObject").name
); );
} }

View File

@ -5,7 +5,7 @@ export default DiscourseRoute.extend({
model(params) { model(params) {
return Ember.RSVP.hash({ return Ember.RSVP.hash({
channels: this.store.findAll("channel", { provider: params.provider }), channels: this.store.findAll("channel", { provider: params.provider }),
provider: this.modelFor("admin-plugins-chat").findBy( provider: this.modelFor("admin-plugins-chat-integration").findBy(
"id", "id",
params.provider params.provider
), ),

View File

@ -4,7 +4,7 @@
<ul class="nav nav-pills"> <ul class="nav nav-pills">
{{#each model as |provider|}} {{#each model as |provider|}}
{{nav-item {{nav-item
route="adminPlugins.chat.provider" route="adminPlugins.chat-integration.provider"
routeParam=provider.name routeParam=provider.name
label=(concat "chat_integration.provider." provider.name ".title") label=(concat "chat_integration.provider." provider.name ".title")
}} }}

View File

@ -25,7 +25,7 @@ after_initialize do
Jobs.enqueue_in(time, :notify_chats, post_id: post.id) Jobs.enqueue_in(time, :notify_chats, post_id: post.id)
end end
add_admin_route 'chat_integration.menu_title', 'chat' add_admin_route 'chat_integration.menu_title', 'chat-integration'
AdminDashboardData.add_problem_check do AdminDashboardData.add_problem_check do
error = false error = false

View File

@ -37,7 +37,7 @@ describe 'Chat Controller', type: :request do
end end
describe 'listing providers' do describe 'listing providers' do
include_examples 'admin constraints', 'get', '/admin/plugins/chat/providers.json' include_examples 'admin constraints', 'get', '/admin/plugins/chat-integration/providers.json'
context 'when signed in as an admin' do context 'when signed in as an admin' do
before do before do
@ -45,7 +45,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should return the right response' do it 'should return the right response' do
get '/admin/plugins/chat/providers.json' get '/admin/plugins/chat-integration/providers.json'
expect(response.status).to eq(200) expect(response.status).to eq(200)
@ -63,7 +63,7 @@ describe 'Chat Controller', type: :request do
end end
describe 'testing channels' do describe 'testing channels' do
include_examples 'admin constraints', 'get', '/admin/plugins/chat/test.json' include_examples 'admin constraints', 'get', '/admin/plugins/chat-integration/test.json'
context 'when signed in as an admin' do context 'when signed in as an admin' do
before do before do
@ -71,7 +71,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should return the right response' do it 'should return the right response' do
post '/admin/plugins/chat/test.json', params: { post '/admin/plugins/chat-integration/test.json', params: {
channel_id: channel.id, topic_id: topic.id channel_id: channel.id, topic_id: topic.id
} }
@ -79,7 +79,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid channel' do it 'should fail for invalid channel' do
post '/admin/plugins/chat/test.json', params: { post '/admin/plugins/chat-integration/test.json', params: {
channel_id: 999, topic_id: topic.id channel_id: 999, topic_id: topic.id
} }
@ -89,7 +89,7 @@ describe 'Chat Controller', type: :request do
end end
describe 'viewing channels' do describe 'viewing channels' do
include_examples 'admin constraints', 'get', '/admin/plugins/chat/channels.json' include_examples 'admin constraints', 'get', '/admin/plugins/chat-integration/channels.json'
context 'when signed in as an admin' do context 'when signed in as an admin' do
before do before do
@ -104,7 +104,7 @@ describe 'Chat Controller', type: :request do
tags: [tag.name] tags: [tag.name]
) )
get '/admin/plugins/chat/channels.json', params: { provider: 'dummy' } get '/admin/plugins/chat-integration/channels.json', params: { provider: 'dummy' }
expect(response.status).to eq(200) expect(response.status).to eq(200)
@ -123,7 +123,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid provider' do it 'should fail for invalid provider' do
get '/admin/plugins/chat/channels.json', params: { provider: 'someprovider' } get '/admin/plugins/chat-integration/channels.json', params: { provider: 'someprovider' }
expect(response.status).to eq(400) expect(response.status).to eq(400)
end end
@ -131,7 +131,7 @@ describe 'Chat Controller', type: :request do
end end
describe 'adding a channel' do describe 'adding a channel' do
include_examples 'admin constraints', 'post', '/admin/plugins/chat/channels.json' include_examples 'admin constraints', 'post', '/admin/plugins/chat-integration/channels.json'
context 'as an admin' do context 'as an admin' do
@ -140,7 +140,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able to add a new channel' do it 'should be able to add a new channel' do
post '/admin/plugins/chat/channels.json', params: { post '/admin/plugins/chat-integration/channels.json', params: {
channel: { channel: {
provider: 'dummy', provider: 'dummy',
data: {} data: {}
@ -155,7 +155,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid params' do it 'should fail for invalid params' do
post '/admin/plugins/chat/channels.json', params: { post '/admin/plugins/chat-integration/channels.json', params: {
channel: { channel: {
provider: 'dummy2', provider: 'dummy2',
data: { val: 'something with whitespace' } data: { val: 'something with whitespace' }
@ -170,7 +170,7 @@ describe 'Chat Controller', type: :request do
describe 'updating a channel' do describe 'updating a channel' do
let(:channel) { DiscourseChatIntegration::Channel.create(provider: 'dummy2', data: { val: "something" }) } let(:channel) { DiscourseChatIntegration::Channel.create(provider: 'dummy2', data: { val: "something" }) }
include_examples 'admin constraints', 'put', "/admin/plugins/chat/channels/1.json" include_examples 'admin constraints', 'put', "/admin/plugins/chat-integration/channels/1.json"
context 'as an admin' do context 'as an admin' do
@ -179,7 +179,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able update a channel' do it 'should be able update a channel' do
put "/admin/plugins/chat/channels/#{channel.id}.json", params: { put "/admin/plugins/chat-integration/channels/#{channel.id}.json", params: {
channel: { channel: {
data: { val: "something-else" } data: { val: "something-else" }
} }
@ -192,7 +192,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid params' do it 'should fail for invalid params' do
put "/admin/plugins/chat/channels/#{channel.id}.json", params: { put "/admin/plugins/chat-integration/channels/#{channel.id}.json", params: {
channel: { channel: {
data: { val: "something with whitespace" } data: { val: "something with whitespace" }
} }
@ -206,7 +206,7 @@ describe 'Chat Controller', type: :request do
describe 'deleting a channel' do describe 'deleting a channel' do
let(:channel) { DiscourseChatIntegration::Channel.create(provider: 'dummy', data: {}) } let(:channel) { DiscourseChatIntegration::Channel.create(provider: 'dummy', data: {}) }
include_examples 'admin constraints', 'delete', "/admin/plugins/chat/channels/1.json" include_examples 'admin constraints', 'delete', "/admin/plugins/chat-integration/channels/1.json"
context 'as an admin' do context 'as an admin' do
@ -215,7 +215,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able delete a channel' do it 'should be able delete a channel' do
delete "/admin/plugins/chat/channels/#{channel.id}.json" delete "/admin/plugins/chat-integration/channels/#{channel.id}.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseChatIntegration::Channel.all.size).to eq(0) expect(DiscourseChatIntegration::Channel.all.size).to eq(0)
@ -224,7 +224,7 @@ describe 'Chat Controller', type: :request do
end end
describe 'adding a rule' do describe 'adding a rule' do
include_examples 'admin constraints', 'put', '/admin/plugins/chat/rules.json' include_examples 'admin constraints', 'put', '/admin/plugins/chat-integration/rules.json'
context 'as an admin' do context 'as an admin' do
@ -233,7 +233,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able to add a new rule' do it 'should be able to add a new rule' do
post '/admin/plugins/chat/rules.json', params: { post '/admin/plugins/chat-integration/rules.json', params: {
rule: { rule: {
channel_id: channel.id, channel_id: channel.id,
category_id: category.id, category_id: category.id,
@ -254,7 +254,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid params' do it 'should fail for invalid params' do
post '/admin/plugins/chat/rules.json', params: { post '/admin/plugins/chat-integration/rules.json', params: {
rule: { rule: {
channel_id: channel.id, channel_id: channel.id,
category_id: category.id, category_id: category.id,
@ -271,7 +271,7 @@ describe 'Chat Controller', type: :request do
describe 'updating a rule' do describe 'updating a rule' do
let(:rule) { DiscourseChatIntegration::Rule.create(channel: channel, filter: 'follow', category_id: category.id, tags: [tag.name]) } let(:rule) { DiscourseChatIntegration::Rule.create(channel: channel, filter: 'follow', category_id: category.id, tags: [tag.name]) }
include_examples 'admin constraints', 'put', "/admin/plugins/chat/rules/1.json" include_examples 'admin constraints', 'put', "/admin/plugins/chat-integration/rules/1.json"
context 'as an admin' do context 'as an admin' do
@ -280,7 +280,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able update a rule' do it 'should be able update a rule' do
put "/admin/plugins/chat/rules/#{rule.id}.json", params: { put "/admin/plugins/chat-integration/rules/#{rule.id}.json", params: {
rule: { rule: {
channel_id: channel.id, channel_id: channel.id,
category_id: category2.id, category_id: category2.id,
@ -296,7 +296,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should fail for invalid params' do it 'should fail for invalid params' do
put "/admin/plugins/chat/rules/#{rule.id}.json", params: { put "/admin/plugins/chat-integration/rules/#{rule.id}.json", params: {
rule: { rule: {
channel_id: channel.id, channel_id: channel.id,
category_id: category.id, category_id: category.id,
@ -320,7 +320,7 @@ describe 'Chat Controller', type: :request do
) )
end end
include_examples 'admin constraints', 'delete', "/admin/plugins/chat/rules/1.json" include_examples 'admin constraints', 'delete', "/admin/plugins/chat-integration/rules/1.json"
context 'as an admin' do context 'as an admin' do
@ -329,7 +329,7 @@ describe 'Chat Controller', type: :request do
end end
it 'should be able delete a rule' do it 'should be able delete a rule' do
delete "/admin/plugins/chat/rules/#{rule.id}.json" delete "/admin/plugins/chat-integration/rules/#{rule.id}.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseChatIntegration::Rule.all.size).to eq(0) expect(DiscourseChatIntegration::Rule.all.size).to eq(0)

View File

@ -16,7 +16,7 @@ acceptance("Chat Integration", function (needs) {
]; ];
}; };
server.get("/admin/plugins/chat/providers", () => { server.get("/admin/plugins/chat-integration/providers", () => {
return jsonResponse({ return jsonResponse({
providers: [ providers: [
{ {
@ -28,7 +28,7 @@ acceptance("Chat Integration", function (needs) {
}); });
}); });
server.get("/admin/plugins/chat/channels", () => { server.get("/admin/plugins/chat-integration/channels", () => {
return jsonResponse({ return jsonResponse({
channels: [ channels: [
{ {
@ -52,31 +52,31 @@ acceptance("Chat Integration", function (needs) {
}); });
}); });
server.post("/admin/plugins/chat/channels", () => { server.post("/admin/plugins/chat-integration/channels", () => {
return response({}); return response({});
}); });
server.put("/admin/plugins/chat/channels/:id", () => { server.put("/admin/plugins/chat-integration/channels/:id", () => {
return response({}); return response({});
}); });
server.delete("/admin/plugins/chat/channels/:id", () => { server.delete("/admin/plugins/chat-integration/channels/:id", () => {
return response({}); return response({});
}); });
server.post("/admin/plugins/chat/rules", () => { server.post("/admin/plugins/chat-integration/rules", () => {
return response({}); return response({});
}); });
server.put("/admin/plugins/chat/rules/:id", () => { server.put("/admin/plugins/chat-integration/rules/:id", () => {
return response({}); return response({});
}); });
server.delete("/admin/plugins/chat/rules/:id", () => { server.delete("/admin/plugins/chat-integration/rules/:id", () => {
return response({}); return response({});
}); });
server.post("/admin/plugins/chat/test", () => { server.post("/admin/plugins/chat-integration/test", () => {
return response({}); return response({});
}); });
@ -86,7 +86,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Rules load successfully", async (assert) => { test("Rules load successfully", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
assert.ok( assert.ok(
exists("#admin-plugin-chat table"), exists("#admin-plugin-chat table"),
@ -101,7 +101,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Create channel works", async (assert) => { test("Create channel works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
await click("#create-channel"); await click("#create-channel");
assert.ok( assert.ok(
@ -129,7 +129,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Edit channel works", async (assert) => { test("Edit channel works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
await click(".channel-header button:first"); await click(".channel-header button:first");
assert.ok( assert.ok(
@ -162,7 +162,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Create rule works", async (assert) => { test("Create rule works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
assert.ok( assert.ok(
exists(".channel-footer button:first"), exists(".channel-footer button:first"),
@ -186,7 +186,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Edit rule works", async (assert) => { test("Edit rule works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
assert.ok(exists(".edit:first"), "edit button is displayed"); assert.ok(exists(".edit:first"), "edit button is displayed");
@ -210,7 +210,7 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Delete channel works", async (assert) => { test("Delete channel works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
assert.ok(exists(".channel-header button:last"), "delete button exists"); assert.ok(exists(".channel-header button:last"), "delete button exists");
await click(".channel-header button:last"); await click(".channel-header button:last");
@ -222,14 +222,14 @@ acceptance("Chat Integration", function (needs) {
}); });
test("Delete rule works", async (assert) => { test("Delete rule works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
assert.ok(exists(".delete:first")); assert.ok(exists(".delete:first"));
await click(".delete:first"); await click(".delete:first");
}); });
test("Test channel works", async (assert) => { test("Test channel works", async (assert) => {
await visit("/admin/plugins/chat"); await visit("/admin/plugins/chat-integration");
await click(".btn-chat-test"); await click(".btn-chat-test");