UX: Move watched words to the Logs section of admin

This commit is contained in:
Neil Lalonde 2017-07-31 17:06:26 -04:00
parent ce27783da4
commit ec85b41078
9 changed files with 23 additions and 25 deletions

View File

@ -4,7 +4,7 @@ import UploadMixin from "discourse/mixins/upload";
export default Em.Component.extend(UploadMixin, {
type: 'csv',
classNames: 'watched-words-uploader',
uploadUrl: '/admin/watched_words/upload',
uploadUrl: '/admin/logs/watched_words/upload',
addDisabled: Em.computed.alias("uploading"),
validateUploadedFilesOptions() {

View File

@ -2,7 +2,7 @@ import { ajax } from 'discourse/lib/ajax';
const WatchedWord = Discourse.Model.extend({
save() {
return ajax("/admin/watched_words" + (this.id ? '/' + this.id : '') + ".json", {
return ajax("/admin/logs/watched_words" + (this.id ? '/' + this.id : '') + ".json", {
type: this.id ? 'PUT' : 'POST',
data: {word: this.get('word'), action_key: this.get('action')},
dataType: 'json'
@ -10,13 +10,13 @@ const WatchedWord = Discourse.Model.extend({
},
destroy() {
return ajax("/admin/watched_words/" + this.get('id') + ".json", {type: 'DELETE'});
return ajax("/admin/logs/watched_words/" + this.get('id') + ".json", {type: 'DELETE'});
}
});
WatchedWord.reopenClass({
findAll() {
return ajax("/admin/watched_words").then(function (list) {
return ajax("/admin/logs/watched_words").then(function (list) {
const actions = {};
list.words.forEach(s => {
if (!actions[s.action]) { actions[s.action] = []; }

View File

@ -62,6 +62,10 @@ export default function() {
this.route('screenedEmails', { path: '/screened_emails' });
this.route('screenedIpAddresses', { path: '/screened_ip_addresses' });
this.route('screenedUrls', { path: '/screened_urls' });
this.route('adminWatchedWords', { path: '/watched_words', resetNamespace: true}, function() {
this.route('index', { path: '/' } );
this.route('action', { path: '/action/:action_id' } );
});
});
this.route('adminGroups', { path: '/groups', resetNamespace: true }, function() {
@ -90,10 +94,5 @@ export default function() {
this.route('adminPlugins', { path: '/plugins', resetNamespace: true }, function() {
this.route('index', { path: '/' });
});
this.route('adminWatchedWords', { path: '/watched_words', resetNamespace: true}, function() {
this.route('index', { path: '/' } );
this.route('action', { path: '/action/:action_id' } );
});
});
};

View File

@ -22,7 +22,6 @@
{{nav-item route='adminApi' label='admin.api.title'}}
{{nav-item route='admin.backups' label='admin.backups.title'}}
{{/if}}
{{nav-item route='adminWatchedWords' label='admin.watched_words.title'}}
{{nav-item route='adminPlugins' label='admin.plugins.title'}}
{{plugin-outlet name="admin-menu" connectorTagName="li"}}
</ul>

View File

@ -3,6 +3,7 @@
{{nav-item route='adminLogs.screenedEmails' label='admin.logs.screened_emails.title'}}
{{nav-item route='adminLogs.screenedIpAddresses' label='admin.logs.screened_ips.title'}}
{{nav-item route='adminLogs.screenedUrls' label='admin.logs.screened_urls.title'}}
{{nav-item route='adminWatchedWords' label='admin.watched_words.title'}}
{{#if currentUser.admin}}
{{nav-item path='/logs' label='admin.logs.logster.title'}}
{{/if}}

View File

@ -168,6 +168,12 @@ Discourse::Application.routes.draw do
end
end
resources :screened_urls, only: [:index]
resources :watched_words, only: [:index, :create, :update, :destroy] do
collection do
get "action/:id" => "watched_words#index"
end
end
post "watched_words/upload" => "watched_words#upload"
end
get "/logs" => "staff_action_logs#index"
@ -268,13 +274,6 @@ Discourse::Application.routes.draw do
get "memory_stats" => "diagnostics#memory_stats", constraints: AdminConstraint.new
get "dump_heap" => "diagnostics#dump_heap", constraints: AdminConstraint.new
get "dump_statement_cache" => "diagnostics#dump_statement_cache", constraints: AdminConstraint.new
resources :watched_words, only: [:index, :create, :update, :destroy], constraints: AdminConstraint.new do
collection do
get "action/:id" => "watched_words#index"
end
end
post "watched_words/upload" => "watched_words#upload"
end # admin namespace
get "email_preferences" => "email#preferences_redirect", :as => "email_preferences_redirect"

View File

@ -2,7 +2,7 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Watched Words", { loggedIn: true });
QUnit.test("list words in groups", assert => {
visit("/admin/watched_words/action/block");
visit("/admin/logs/watched_words/action/block");
andThen(() => {
assert.ok(exists('.watched-words-list'));
assert.ok(!exists('.watched-words-list .watched-word'), "Don't show bad words by default.");
@ -31,7 +31,7 @@ QUnit.test("list words in groups", assert => {
});
QUnit.test("add words", assert => {
visit("/admin/watched_words/action/block");
visit("/admin/logs/watched_words/action/block");
andThen(() => {
click('.show-words-checkbox');
fillIn('.watched-word-form input', 'poutine');
@ -49,7 +49,7 @@ QUnit.test("add words", assert => {
});
QUnit.test("remove words", assert => {
visit("/admin/watched_words/action/block");
visit("/admin/logs/watched_words/action/block");
click('.show-words-checkbox');
let word = null;

View File

@ -1,5 +1,5 @@
export default {
"/admin/watched_words.json": {
"/admin/logs/watched_words.json": {
"actions": ["block", "censor", "require_approval", "flag"],
"words": [
{id: 1, word: "liquorice", action: "block"},

View File

@ -334,12 +334,12 @@ export default function() {
this.post('/admin/badges', success);
this.delete('/admin/badges/:id', success);
this.get('/admin/watched_words', () => {
return response(200, fixturesByUrl['/admin/watched_words.json']);
this.get('/admin/logs/watched_words', () => {
return response(200, fixturesByUrl['/admin/logs/watched_words.json']);
});
this.delete('/admin/watched_words/:id.json', success);
this.delete('/admin/logs/watched_words/:id.json', success);
this.post('/admin/watched_words.json', request => {
this.post('/admin/logs/watched_words.json', request => {
const result = parsePostData(request.requestBody);
result.id = new Date().getTime();
return response(200, result);