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
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::Provider::HookEngine, at: '/chat-integration/'

View File

@ -1,3 +1,3 @@
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";
export default buildPluginAdapter("chat");
export default buildPluginAdapter("chat-integration");

View File

@ -1,3 +1,3 @@
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",
path: "/plugins",
map() {
this.route("chat", function () {
this.route("chat-integration", function () {
this.route("provider", { path: "/:provider" });
});
},

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
<ul class="nav nav-pills">
{{#each model as |provider|}}
{{nav-item
route="adminPlugins.chat.provider"
route="adminPlugins.chat-integration.provider"
routeParam=provider.name
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)
end
add_admin_route 'chat_integration.menu_title', 'chat'
add_admin_route 'chat_integration.menu_title', 'chat-integration'
AdminDashboardData.add_problem_check do
error = false

View File

@ -37,7 +37,7 @@ describe 'Chat Controller', type: :request do
end
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
before do
@ -45,7 +45,7 @@ describe 'Chat Controller', type: :request do
end
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)
@ -63,7 +63,7 @@ describe 'Chat Controller', type: :request do
end
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
before do
@ -71,7 +71,7 @@ describe 'Chat Controller', type: :request do
end
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
}
@ -79,7 +79,7 @@ describe 'Chat Controller', type: :request do
end
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
}
@ -89,7 +89,7 @@ describe 'Chat Controller', type: :request do
end
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
before do
@ -104,7 +104,7 @@ describe 'Chat Controller', type: :request do
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)
@ -123,7 +123,7 @@ describe 'Chat Controller', type: :request do
end
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)
end
@ -131,7 +131,7 @@ describe 'Chat Controller', type: :request do
end
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
@ -140,7 +140,7 @@ describe 'Chat Controller', type: :request do
end
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: {
provider: 'dummy',
data: {}
@ -155,7 +155,7 @@ describe 'Chat Controller', type: :request do
end
it 'should fail for invalid params' do
post '/admin/plugins/chat/channels.json', params: {
post '/admin/plugins/chat-integration/channels.json', params: {
channel: {
provider: 'dummy2',
data: { val: 'something with whitespace' }
@ -170,7 +170,7 @@ describe 'Chat Controller', type: :request do
describe 'updating a channel' do
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
@ -179,7 +179,7 @@ describe 'Chat Controller', type: :request do
end
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: {
data: { val: "something-else" }
}
@ -192,7 +192,7 @@ describe 'Chat Controller', type: :request do
end
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: {
data: { val: "something with whitespace" }
}
@ -206,7 +206,7 @@ describe 'Chat Controller', type: :request do
describe 'deleting a channel' do
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
@ -215,7 +215,7 @@ describe 'Chat Controller', type: :request do
end
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(DiscourseChatIntegration::Channel.all.size).to eq(0)
@ -224,7 +224,7 @@ describe 'Chat Controller', type: :request do
end
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
@ -233,7 +233,7 @@ describe 'Chat Controller', type: :request do
end
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: {
channel_id: channel.id,
category_id: category.id,
@ -254,7 +254,7 @@ describe 'Chat Controller', type: :request do
end
it 'should fail for invalid params' do
post '/admin/plugins/chat/rules.json', params: {
post '/admin/plugins/chat-integration/rules.json', params: {
rule: {
channel_id: channel.id,
category_id: category.id,
@ -271,7 +271,7 @@ describe 'Chat Controller', type: :request do
describe 'updating a rule' do
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
@ -280,7 +280,7 @@ describe 'Chat Controller', type: :request do
end
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: {
channel_id: channel.id,
category_id: category2.id,
@ -296,7 +296,7 @@ describe 'Chat Controller', type: :request do
end
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: {
channel_id: channel.id,
category_id: category.id,
@ -320,7 +320,7 @@ describe 'Chat Controller', type: :request do
)
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
@ -329,7 +329,7 @@ describe 'Chat Controller', type: :request do
end
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(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({
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({
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({});
});
server.put("/admin/plugins/chat/channels/:id", () => {
server.put("/admin/plugins/chat-integration/channels/:id", () => {
return response({});
});
server.delete("/admin/plugins/chat/channels/:id", () => {
server.delete("/admin/plugins/chat-integration/channels/:id", () => {
return response({});
});
server.post("/admin/plugins/chat/rules", () => {
server.post("/admin/plugins/chat-integration/rules", () => {
return response({});
});
server.put("/admin/plugins/chat/rules/:id", () => {
server.put("/admin/plugins/chat-integration/rules/:id", () => {
return response({});
});
server.delete("/admin/plugins/chat/rules/:id", () => {
server.delete("/admin/plugins/chat-integration/rules/:id", () => {
return response({});
});
server.post("/admin/plugins/chat/test", () => {
server.post("/admin/plugins/chat-integration/test", () => {
return response({});
});
@ -86,7 +86,7 @@ acceptance("Chat Integration", function (needs) {
});
test("Rules load successfully", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
assert.ok(
exists("#admin-plugin-chat table"),
@ -101,7 +101,7 @@ acceptance("Chat Integration", function (needs) {
});
test("Create channel works", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
await click("#create-channel");
assert.ok(
@ -129,7 +129,7 @@ acceptance("Chat Integration", function (needs) {
});
test("Edit channel works", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
await click(".channel-header button:first");
assert.ok(
@ -162,7 +162,7 @@ acceptance("Chat Integration", function (needs) {
});
test("Create rule works", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
assert.ok(
exists(".channel-footer button:first"),
@ -186,7 +186,7 @@ acceptance("Chat Integration", function (needs) {
});
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");
@ -210,7 +210,7 @@ acceptance("Chat Integration", function (needs) {
});
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");
await click(".channel-header button:last");
@ -222,14 +222,14 @@ acceptance("Chat Integration", function (needs) {
});
test("Delete rule works", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
assert.ok(exists(".delete:first"));
await click(".delete:first");
});
test("Test channel works", async (assert) => {
await visit("/admin/plugins/chat");
await visit("/admin/plugins/chat-integration");
await click(".btn-chat-test");