Version bump

This commit is contained in:
Neil Lalonde 2019-05-30 13:47:44 -04:00
commit 9a9b0a6847
4761 changed files with 51696 additions and 36248 deletions

View File

@ -5,7 +5,7 @@
"es6": true,
"jasmine": true,
"mocha": true,
"node": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 7,
@ -20,6 +20,8 @@
"Blob": true,
"bootbox": true,
"click": true,
"waitUntil": true,
"getSettledState": true,
"collapseSelectKit": true,
"controllerFor": true,
"count": true,
@ -57,6 +59,8 @@
"selectKitSelectRowByIndex": true,
"selectKitSelectRowByName": true,
"selectKitSelectRowByValue": true,
"setTextareaSelection": true,
"getTextareaSelection": true,
"sinon": true,
"test": true,
"triggerEvent": true,
@ -99,7 +103,7 @@
"semi": 2,
"strict": 0,
"valid-typeof": 2,
"wrap-iife": [2, "inside"],
"wrap-iife": [2, "inside"]
},
"parser": "babel-eslint"
}

View File

@ -2,4 +2,5 @@ app/assets/stylesheets/vendor/
plugins/**/assets/stylesheets/vendor/
package.json
config/locales/**/*.yml
!config/locales/**/*.en.yml
!config/locales/**/*.en*.yml
script/import_scripts/**/*.yml

View File

@ -12,6 +12,9 @@ AllCops:
Style/AndOr:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:

View File

@ -1 +1 @@
2.5.3
2.6.1

View File

@ -34,7 +34,7 @@ matrix:
fast_finish: true
rvm:
- 2.6.2
- 2.6.3
services:
- redis-server
@ -75,7 +75,7 @@ script:
bash -c "
if [ '$RUN_LINT' == '1' ]; then
bundle exec rubocop --parallel && \
bundle exec danger && \
yarn prettier --list-different "app/assets/stylesheets/**/*.scss" "app/assets/javascripts/**/*.es6" "test/javascripts/**/*.es6"
yarn eslint --ext .es6 app/assets/javascripts && \
yarn eslint --ext .es6 test/javascripts && \
yarn eslint --ext .es6 plugins/**/assets/javascripts && \

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Install development dependencies on Mac OS X using Homebrew (http://mxcl.github.com/homebrew)
# you probably already have git installed; ensure that it is the latest version

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
if github.pr_json && (github.pr_json["additions"] || 0) > 250 || (github.pr_json["deletions"] || 0) > 250
warn("This pull request is big! We prefer smaller PRs whenever possible, as they are easier to review. Can this be split into a few smaller PRs?")
end
@ -11,8 +13,8 @@ This PR doesn't match our required code formatting standards, as enforced by pre
})
end
locales_changes = git.modified_files.grep(/config\/locales/)
has_non_en_locales_changes = locales_changes.grep_v(/config\/locales\/(client|server)\.en\.yml/).any?
locales_changes = git.modified_files.grep(%r{config/locales})
has_non_en_locales_changes = locales_changes.grep_v(%r{config/locales/(?:client|server)\.(?:en|en_US)\.yml}).any?
if locales_changes.any? && has_non_en_locales_changes
fail("Please submit your non-English translation updates via [Transifex](https://www.transifex.com/discourse/discourse-org/). You can read more on how to contribute translations [here](https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882).")

11
Gemfile
View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
# if there is a super emergency and rubygems is playing up, try
#source 'http://production.cf.rubygems.org'
@ -44,12 +46,12 @@ gem 'redis-namespace'
gem 'active_model_serializers', '~> 0.8.3'
gem 'onebox', '1.8.86'
gem 'onebox', '1.8.90'
gem 'http_accept_language', '~>2.0.5', require: false
gem 'ember-rails', '0.18.5'
gem 'discourse-ember-source', '~> 3.7.0'
gem 'discourse-ember-source', '~> 3.8.0'
gem 'ember-handlebars-template', '0.8.0'
gem 'barber'
@ -87,7 +89,9 @@ gem 'omniauth-github'
gem 'omniauth-oauth2', require: false
gem 'omniauth-google-oauth2'
# pinned until we test verified email change in the gem
gem 'omniauth-google-oauth2', '0.6.0'
gem 'oj'
gem 'pg'
gem 'mini_sql'
@ -120,7 +124,6 @@ group :test do
gem 'webmock', require: false
gem 'fakeweb', '~> 1.3.0', require: false
gem 'minitest', require: false
gem 'danger'
gem 'simplecov', require: false
gem "test-prof"
end

View File

@ -38,77 +38,59 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
annotate (2.7.4)
activerecord (>= 3.2, < 6.0)
annotate (2.7.5)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 13.0)
arel (9.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
aws-partitions (1.138.0)
aws-sdk-core (3.46.1)
aws-eventstream (~> 1.0)
aws-eventstream (1.0.3)
aws-partitions (1.154.0)
aws-sdk-core (3.48.6)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.13.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.30.1)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sdk-kms (1.17.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.36.1)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sdk-sns (1.9.0)
aws-sdk-core (~> 3, >= 3.39.0)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.3)
barber (0.12.0)
aws-sdk-sns (1.13.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.0)
aws-eventstream (~> 1.0, >= 1.0.2)
barber (0.12.2)
ember-source (>= 1.0, < 3.1)
execjs (>= 1.2, < 3)
better_errors (2.5.0)
better_errors (2.5.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bootsnap (1.3.2)
bootsnap (1.4.4)
msgpack (~> 1.0)
builder (3.2.3)
bullet (5.9.0)
bullet (6.0.0)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (10.0.2)
byebug (11.0.1)
certified (1.0.0)
chunky_png (1.3.11)
claide (1.0.2)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
coderay (1.1.2)
colored2 (3.1.2)
concurrent-ruby (1.1.5)
connection_pool (2.2.2)
cork (0.3.0)
colored2 (~> 3.1)
cppjieba_rb (0.3.3)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.4)
danger (5.13.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 1.0)
git (~> 1.5)
kramdown (~> 1.5)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
debug_inspector (0.0.3)
diff-lcs (1.3)
discourse-ember-source (3.7.0.2)
discourse-ember-source (3.8.0.1)
discourse_image_optim (0.26.2)
exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0)
@ -131,15 +113,13 @@ GEM
railties (>= 3.1)
ember-source (2.18.2)
erubi (1.8.0)
excon (0.62.0)
excon (0.64.0)
execjs (2.7.0)
exifr (1.3.5)
exifr (1.3.6)
fabrication (2.20.1)
fakeweb (1.3.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
fast_blank (1.0.0)
fast_xor (1.1.3)
rake
@ -150,11 +130,10 @@ GEM
flamegraph (0.9.5)
fspath (3.1.0)
gc_tracer (1.5.1)
git (1.5.0)
globalid (0.4.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
guess_html_encoding (0.0.11)
hashdiff (0.3.7)
hashdiff (0.3.9)
hashie (3.6.0)
highline (1.7.10)
hiredis (0.6.3)
@ -164,7 +143,7 @@ GEM
i18n (1.6.0)
concurrent-ruby (~> 1.0)
image_size (1.5.0)
in_threads (1.5.0)
in_threads (1.5.1)
jaro_winkler (1.5.2)
jmespath (1.4.0)
jquery-rails (4.3.3)
@ -174,13 +153,12 @@ GEM
json (2.2.0)
jwt (2.1.0)
kgio (2.11.2)
kramdown (1.17.0)
libv8 (6.7.288.46.1)
libv8 (7.3.492.27.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lograge (0.10.0)
lograge (0.11.0)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
@ -196,32 +174,30 @@ GEM
mail (2.7.1)
mini_mime (>= 0.1.1)
maxminddb (0.1.22)
memory_profiler (0.9.12)
memory_profiler (0.9.13)
message_bus (2.2.0)
rack (>= 1.1.3)
metaclass (0.0.4)
method_source (0.8.2)
method_source (0.9.2)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
mini_racer (0.2.4)
libv8 (>= 6.3)
mini_scheduler (0.9.1)
mini_racer (0.2.6)
libv8 (>= 6.9.411)
mini_scheduler (0.9.2)
sidekiq
mini_sql (0.2.1)
mini_sql (0.2.2)
mini_suffix (0.3.0)
ffi (~> 1.9)
minitest (5.11.3)
mocha (1.5.0)
mocha (1.8.0)
metaclass (~> 0.0.1)
mock_redis (0.18.0)
mock_redis (0.19.0)
moneta (1.1.1)
msgpack (1.2.6)
msgpack (1.2.10)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
mustache (1.1.0)
nap (1.1.0)
no_proxy_fix (0.1.2)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)
nokogumbo (2.0.1)
@ -233,9 +209,7 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
octokit (4.13.0)
sawyer (~> 0.8.0, >= 0.5.3)
oj (3.7.8)
oj (3.7.12)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
@ -263,38 +237,35 @@ GEM
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
onebox (1.8.86)
onebox (1.8.90)
htmlentities (~> 4.3)
moneta (~> 1.0)
multi_json (~> 1.11)
mustache
nokogiri (~> 1.7)
sanitize
open4 (1.3.4)
openid-redis-store (0.0.2)
redis
ruby-openid
optimist (3.0.0)
parallel (1.13.0)
parallel (1.17.0)
parallel_tests (2.28.0)
parallel
parser (2.6.0.0)
parser (2.6.3.0)
ast (~> 2.4.0)
pg (1.1.4)
powerpack (0.1.2)
progress (3.5.0)
pry (0.10.4)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-nav (0.2.4)
pry (>= 0.9.10, < 0.11.0)
pry-rails (0.3.6)
method_source (~> 0.9.0)
pry-nav (0.3.0)
pry (>= 0.9.10, < 0.13.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (3.0.3)
puma (3.12.0)
puma (3.12.1)
r2 (0.2.7)
rack (2.0.6)
rack (2.0.7)
rack-mini-profiler (1.0.2)
rack (>= 1.2.0)
rack-openid (1.3.1)
@ -309,9 +280,9 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails_multisite (2.0.6)
activerecord (> 4.2, < 6)
railties (> 4.2, < 6)
rails_multisite (2.0.7)
activerecord (> 4.2, < 7)
railties (> 4.2, < 7)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
@ -321,7 +292,7 @@ GEM
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.2)
rake-compiler (1.0.4)
rake-compiler (1.0.7)
rake
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
@ -336,43 +307,42 @@ GEM
redis (>= 3.0.4)
request_store (1.4.1)
rack (>= 1.4)
rinku (2.0.4)
rinku (2.0.6)
rotp (3.3.1)
rqrcode (0.10.1)
chunky_png (~> 1.0)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (~> 3.8.0)
rspec-html-matchers (0.9.1)
nokogiri (~> 1)
rspec (>= 3.0.0.a, < 4)
rspec-mocks (3.7.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rtlit (0.0.5)
rubocop (0.63.1)
rubocop (0.69.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
unicode-display_width (>= 1.4.0, < 1.7)
ruby-openid (2.7.0)
ruby-prof (0.17.0)
ruby-progressbar (1.10.0)
@ -380,7 +350,7 @@ GEM
guess_html_encoding (>= 0.0.4)
nokogiri (>= 1.6.0)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
safe_yaml (1.0.5)
sanitize (5.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
@ -388,21 +358,18 @@ GEM
sassc (2.0.1)
ffi (~> 1.9)
rake
sassc-rails (2.1.0)
sassc-rails (2.1.1)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
seed-fu (2.3.9)
activerecord (>= 3.1)
activesupport (>= 3.1)
shoulda-matchers (3.1.3)
activesupport (>= 4.0.0)
sidekiq (5.2.5)
sidekiq (5.2.7)
connection_pool (~> 2.2, >= 2.2.2)
rack (>= 1.5.0)
rack-protection (>= 1.5.0)
@ -412,7 +379,6 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slop (3.6.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
@ -420,31 +386,29 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkey (1.9.0)
sshkey (2.0.0)
stackprof (0.2.12)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
test-prof (0.8.0)
test-prof (0.9.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
tilt (2.0.9)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unicorn (5.4.1)
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
unicorn (5.5.1)
kgio (~> 2.6)
raindrops (~> 0.7)
uniform_notifier (1.12.1)
webmock (3.4.2)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
webpush (0.3.6)
webpush (0.3.8)
hkdf (~> 0.2)
jwt (~> 2.0)
@ -471,8 +435,7 @@ DEPENDENCIES
certified
colored2
cppjieba_rb
danger
discourse-ember-source (~> 3.7.0)
discourse-ember-source (~> 3.8.0)
discourse_image_optim
email_reply_trimmer (~> 0.1)
ember-handlebars-template (= 0.8.0)
@ -516,12 +479,12 @@ DEPENDENCIES
omniauth
omniauth-facebook
omniauth-github
omniauth-google-oauth2
omniauth-google-oauth2 (= 0.6.0)
omniauth-instagram
omniauth-oauth2
omniauth-openid
omniauth-twitter
onebox (= 1.8.86)
onebox (= 1.8.90)
openid-redis-store
parallel_tests
pg

View File

@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

View File

@ -10,7 +10,7 @@ export default Ember.Component.extend({
@observes("editorId")
editorIdChanged() {
if (this.get("autofocus")) {
if (this.autofocus) {
this.send("focus");
}
},
@ -18,14 +18,14 @@ export default Ember.Component.extend({
@observes("content")
contentChanged() {
if (this._editor && !this._skipContentChangeEvent) {
this._editor.getSession().setValue(this.get("content"));
this._editor.getSession().setValue(this.content);
}
},
@observes("mode")
modeChanged() {
if (this._editor && !this._skipContentChangeEvent) {
this._editor.getSession().setMode("ace/mode/" + this.get("mode"));
this._editor.getSession().setMode("ace/mode/" + this.mode);
}
},
@ -37,7 +37,7 @@ export default Ember.Component.extend({
changeDisabledState() {
const editor = this._editor;
if (editor) {
const disabled = this.get("disabled");
const disabled = this.disabled;
editor.setOptions({
readOnly: disabled,
highlightActiveLine: !disabled,
@ -79,7 +79,7 @@ export default Ember.Component.extend({
editor.setTheme("ace/theme/chrome");
editor.setShowPrintMargin(false);
editor.setOptions({ fontSize: "14px" });
editor.getSession().setMode("ace/mode/" + this.get("mode"));
editor.getSession().setMode("ace/mode/" + this.mode);
editor.on("change", () => {
this._skipContentChangeEvent = true;
this.set("content", editor.getSession().getValue());
@ -103,7 +103,7 @@ export default Ember.Component.extend({
this.appEvents.on("ace:resize", this, "resize");
}
if (this.get("autofocus")) {
if (this.autofocus) {
this.send("focus");
}
});

View File

@ -25,7 +25,7 @@ export default Ember.Component.extend(
@on("init")
@observes("logs.[]")
_resetFormattedLogs() {
if (this.get("logs").length === 0) {
if (this.logs.length === 0) {
this._reset(); // reset the cached logs whenever the model is reset
this.rerenderBuffer();
}
@ -34,12 +34,12 @@ export default Ember.Component.extend(
@on("init")
@observes("logs.[]")
_updateFormattedLogs: debounce(function() {
const logs = this.get("logs");
const logs = this.logs;
if (logs.length === 0) return;
// do the log formatting only once for HELLish performance
let formattedLogs = this.get("formattedLogs");
for (let i = this.get("index"), length = logs.length; i < length; i++) {
let formattedLogs = this.formattedLogs;
for (let i = this.index, length = logs.length; i < length; i++) {
const date = logs[i].get("timestamp"),
message = escapeExpression(logs[i].get("message"));
formattedLogs += "[" + date + "] " + message + "\n";
@ -56,7 +56,7 @@ export default Ember.Component.extend(
}, 150),
buildBuffer(buffer) {
const formattedLogs = this.get("formattedLogs");
const formattedLogs = this.formattedLogs;
if (formattedLogs && formattedLogs.length > 0) {
buffer.push("<pre>");
buffer.push(formattedLogs);

View File

@ -8,27 +8,25 @@ export default Ember.Component.extend(
rerenderTriggers: ["order", "ascending"],
buildBuffer(buffer) {
const icon = this.get("icon");
const icon = this.icon;
if (icon) {
buffer.push(iconHTML(icon));
}
buffer.push(I18n.t(this.get("i18nKey")));
buffer.push(I18n.t(this.i18nKey));
if (this.get("field") === this.get("order")) {
buffer.push(
iconHTML(this.get("ascending") ? "chevron-up" : "chevron-down")
);
if (this.field === this.order) {
buffer.push(iconHTML(this.ascending ? "chevron-up" : "chevron-down"));
}
},
click() {
const currentOrder = this.get("order");
const field = this.get("field");
const currentOrder = this.order;
const field = this.field;
if (currentOrder === field) {
this.set("ascending", this.get("ascending") ? null : true);
this.set("ascending", this.ascending ? null : true);
} else {
this.setProperties({ order: field, ascending: null });
}

View File

@ -11,13 +11,13 @@ export default Ember.Component.extend({
actions: {
edit() {
this.set("buffer", this.get("value"));
this.set("buffer", this.value);
this.toggleProperty("editing");
},
save() {
// Action has to toggle 'editing' property.
this.action(this.get("buffer"));
this.action(this.buffer);
}
}
});

View File

@ -6,7 +6,7 @@ export default Ember.Component.extend({
refreshChart() {
const ctx = this.$()[0].getContext("2d");
const model = this.get("model");
const model = this.model;
const rawData = this.get("model.data");
var data = {
@ -15,16 +15,14 @@ export default Ember.Component.extend({
{
data: rawData.map(r => r.y),
label: model.get("title"),
backgroundColor: `rgba(200,220,240,${
this.get("type") === "bar" ? 1 : 0.3
})`,
backgroundColor: `rgba(200,220,240,${this.type === "bar" ? 1 : 0.3})`,
borderColor: "#08C"
}
]
};
const config = {
type: this.get("type"),
type: this.type,
data: data,
options: {
responsive: true,

View File

@ -35,7 +35,7 @@ export default Ember.Component.extend({
_scheduleChartRendering() {
Ember.run.schedule("afterRender", () => {
this._renderChart(this.get("model"), this.$(".chart-canvas"));
this._renderChart(this.model, this.$(".chart-canvas"));
});
},

View File

@ -33,7 +33,7 @@ export default Ember.Component.extend({
_scheduleChartRendering() {
Ember.run.schedule("afterRender", () => {
this._renderChart(this.get("model"), this.$(".chart-canvas"));
this._renderChart(this.model, this.$(".chart-canvas"));
});
},
@ -114,6 +114,7 @@ export default Ember.Component.extend({
display: true,
gridLines: { display: false },
type: "time",
offset: true,
time: {
parser: "YYYY-MM-DD",
minUnit: "day"

View File

@ -134,8 +134,8 @@ export default Ember.Component.extend({
},
sortByLabel(label) {
if (this.get("sortLabel") === label) {
this.set("sortDirection", this.get("sortDirection") === 1 ? -1 : 1);
if (this.sortLabel === label) {
this.set("sortDirection", this.sortDirection === 1 ? -1 : 1);
} else {
this.set("sortLabel", label);
}

View File

@ -1,7 +1,7 @@
import ReportLoader from "discourse/lib/reports-loader";
import Category from "discourse/models/category";
import { exportEntity } from "discourse/lib/export-csv";
import { outputExportResult } from "discourse/lib/export-result";
import { isNumeric } from "discourse/lib/utilities";
import { SCHEMA_VERSION, default as Report } from "admin/models/report";
import computed from "ember-addons/ember-computed-decorators";
@ -50,21 +50,15 @@ export default Ember.Component.extend({
filters: null,
startDate: null,
endDate: null,
category: null,
groupId: null,
filter: null,
showTrend: false,
showHeader: true,
showTitle: true,
showFilteringUI: false,
showCategoryOptions: Ember.computed.alias("model.category_filtering"),
showDatesOptions: Ember.computed.alias("model.dates_filtering"),
showGroupOptions: Ember.computed.alias("model.group_filtering"),
showExport: Ember.computed.not("model.onlyTable"),
showRefresh: Ember.computed.or(
"showCategoryOptions",
"showDatesOptions",
"showGroupOptions"
"model.available_filters.length"
),
shouldDisplayTrend: Ember.computed.and("showTrend", "model.prev_period"),
@ -74,26 +68,15 @@ export default Ember.Component.extend({
this._reports = [];
},
startDate: Ember.computed.reads("filters.startDate"),
endDate: Ember.computed.reads("filters.endDate"),
didReceiveAttrs() {
this._super(...arguments);
const state = this.get("filters") || {};
this.setProperties({
category: Category.findById(state.categoryId),
groupId: state.groupId,
filter: state.filter,
startDate: state.startDate,
endDate: state.endDate
});
if (this.get("report")) {
this._renderReport(
this.get("report"),
this.get("forcedModes"),
this.get("currentMode")
);
} else if (this.get("dataSourceName")) {
if (this.report) {
this._renderReport(this.report, this.forcedModes, this.currentMode);
} else if (this.dataSourceName) {
this._fetchReport();
}
},
@ -125,8 +108,6 @@ export default Ember.Component.extend({
return displayedModesLength > 1;
},
categoryId: Ember.computed.alias("category.id"),
@computed("currentMode", "model.modes", "forcedModes")
displayedModes(currentMode, reportModes, forcedModes) {
const modes = forcedModes ? forcedModes.split(",") : reportModes;
@ -143,35 +124,11 @@ export default Ember.Component.extend({
});
},
@computed()
groupOptions() {
const arr = [
{ name: I18n.t("admin.dashboard.reports.groups"), value: "all" }
];
return arr.concat(
(this.site.groups || []).map(i => {
return { name: i["name"], value: i["id"] };
})
);
},
@computed("currentMode")
modeComponent(currentMode) {
return `admin-report-${currentMode}`;
},
@computed("model.filter_options")
filterOptions(options) {
if (options) {
return options.map(option => {
if (option.allowAny) {
option.choices.unshift(I18n.t("admin.dashboard.report_filter_any"));
}
return option;
});
}
},
@computed("startDate")
normalizedStartDate(startDate) {
return startDate && typeof startDate.isValid === "function"
@ -198,25 +155,25 @@ export default Ember.Component.extend({
@computed(
"dataSourceName",
"categoryId",
"groupId",
"filter",
"normalizedStartDate",
"normalizedEndDate"
"normalizedEndDate",
"filters.customFilters"
)
reportKey(dataSourceName, categoryId, groupId, filter, startDate, endDate) {
reportKey(dataSourceName, startDate, endDate, customFilters) {
if (!dataSourceName || !startDate || !endDate) return null;
let reportKey = "reports:";
reportKey += [
dataSourceName,
categoryId,
startDate.replace(/-/g, ""),
endDate.replace(/-/g, ""),
groupId,
filter,
"[:prev_period]",
this.get("reportOptions.table.limit"),
customFilters
? JSON.stringify(customFilters, (key, value) =>
isNumeric(value) ? value.toString() : value
)
: null,
SCHEMA_VERSION
]
.filter(x => x)
@ -227,49 +184,41 @@ export default Ember.Component.extend({
},
actions: {
filter(filterOptionId, value) {
let params = [];
let paramPairs = {};
let newParams = [];
applyFilter(id, value) {
let customFilters = this.get("filters.customFilters") || {};
if (this.get("filter")) {
const filter = this.get("filter").slice(1, -1);
params = filter.split("&") || [];
params.map(p => {
const pair = p.split("=");
paramPairs[pair[0]] = pair[1];
});
if (typeof value === "undefined") {
delete customFilters[id];
} else {
customFilters[id] = value;
}
paramPairs[filterOptionId] = value;
Object.keys(paramPairs).forEach(key => {
if (paramPairs[key] !== I18n.t("admin.dashboard.report_filter_any")) {
newParams.push(`${key}=${paramPairs[key]}`);
}
this.attrs.onRefresh({
type: this.get("model.type"),
startDate: this.startDate,
endDate: this.endDate,
filters: customFilters
});
this.set("filter", `[${newParams.join("&")}]`);
},
refreshReport() {
this.attrs.onRefresh({
categoryId: this.get("categoryId"),
groupId: this.get("groupId"),
filter: this.get("filter"),
startDate: this.get("startDate"),
endDate: this.get("endDate")
type: this.get("model.type"),
startDate: this.startDate,
endDate: this.endDate,
filters: this.get("filters.customFilters")
});
},
exportCsv() {
const customFilters = this.get("filters.customFilters") || {};
exportEntity("report", {
name: this.get("model.type"),
start_date: this.get("startDate"),
end_date: this.get("endDate"),
category_id:
this.get("categoryId") === "all" ? undefined : this.get("categoryId"),
group_id:
this.get("groupId") === "all" ? undefined : this.get("groupId")
start_date: this.startDate,
end_date: this.endDate,
category_id: customFilters.category,
group_id: customFilters.group
}).then(outputExportResult);
},
@ -296,16 +245,16 @@ export default Ember.Component.extend({
const sort = r => {
if (r.length > 1) {
return r.findBy("type", this.get("dataSourceName"));
return r.findBy("type", this.dataSourceName);
} else {
return r;
}
};
if (!this.get("startDate") || !this.get("endDate")) {
if (!this.startDate || !this.endDate) {
report = sort(filteredReports)[0];
} else {
const reportKey = this.get("reportKey");
const reportKey = this.reportKey;
report = sort(
filteredReports.filter(r => r.report_key.includes(reportKey))
@ -318,11 +267,7 @@ export default Ember.Component.extend({
this.set("showFilteringUI", false);
}
this._renderReport(
report,
this.get("forcedModes"),
this.get("currentMode")
);
this._renderReport(report, this.forcedModes, this.currentMode);
},
_renderReport(report, forcedModes, currentMode) {
@ -364,41 +309,33 @@ export default Ember.Component.extend({
}
};
ReportLoader.enqueue(this.get("dataSourceName"), payload.data, callback);
ReportLoader.enqueue(this.dataSourceName, payload.data, callback);
});
},
_buildPayload(facets) {
let payload = { data: { cache: true, facets } };
if (this.get("startDate")) {
if (this.startDate) {
payload.data.start_date = moment
.utc(this.get("startDate"), "YYYY-MM-DD")
.utc(this.startDate, "YYYY-MM-DD")
.toISOString();
}
if (this.get("endDate")) {
if (this.endDate) {
payload.data.end_date = moment
.utc(this.get("endDate"), "YYYY-MM-DD")
.utc(this.endDate, "YYYY-MM-DD")
.toISOString();
}
if (this.get("groupId") && this.get("groupId") !== "all") {
payload.data.group_id = this.get("groupId");
}
if (this.get("categoryId") && this.get("categoryId") !== "all") {
payload.data.category_id = this.get("categoryId");
}
if (this.get("filter") && this.get("filter") !== "all") {
payload.data.filter = this.get("filter");
}
if (this.get("reportOptions.table.limit")) {
payload.data.limit = this.get("reportOptions.table.limit");
}
if (this.get("filters.customFilters")) {
payload.data.filters = this.get("filters.customFilters");
}
return payload;
},
@ -443,8 +380,8 @@ export default Ember.Component.extend({
Report.fillMissingDates(jsonReport, {
filledField: "prevChartData",
dataField: "prev_data",
starDate: jsonReport.prev_start_date,
endDate: jsonReport.prev_end_date
starDate: jsonReport.prev_startDate,
endDate: jsonReport.prev_endDate
});
if (jsonReport.prevChartData && jsonReport.prevChartData.length > 40) {

View File

@ -56,7 +56,7 @@ export default Ember.Component.extend({
@computed("currentTargetName", "fieldName", "theme.theme_fields.@each.error")
error(target, fieldName) {
return this.get("theme").getError(target, fieldName);
return this.theme.getError(target, fieldName);
},
actions: {
@ -75,9 +75,9 @@ export default Ember.Component.extend({
addField(name) {
if (!name) return;
name = name.replace(/[^a-zA-Z0-9-_/]/g, "");
this.get("theme").setField(this.get("currentTargetName"), name, "");
this.theme.setField(this.currentTargetName, name, "");
this.setProperties({ newFieldName: "", addingField: false });
this.fieldAdded(this.get("currentTargetName"), name);
this.fieldAdded(this.currentTargetName, name);
},
toggleMaximize: function() {

View File

@ -26,7 +26,7 @@ export default Ember.Component.extend(bufferedProperty("userField"), {
@on("didInsertElement")
@observes("editing")
_focusOnEdit() {
if (this.get("editing")) {
if (this.editing) {
Ember.run.scheduleOnce("afterRender", this, "_focusName");
}
},
@ -66,7 +66,7 @@ export default Ember.Component.extend(bufferedProperty("userField"), {
actions: {
save() {
const buffered = this.get("buffered");
const buffered = this.buffered;
const attrs = buffered.getProperties(
"name",
"description",
@ -78,7 +78,7 @@ export default Ember.Component.extend(bufferedProperty("userField"), {
"options"
);
this.get("userField")
this.userField
.save(attrs)
.then(() => {
this.set("editing", false);
@ -94,7 +94,7 @@ export default Ember.Component.extend(bufferedProperty("userField"), {
cancel() {
const id = this.get("userField.id");
if (Ember.isEmpty(id)) {
this.destroyAction(this.get("userField"));
this.destroyAction(this.userField);
} else {
this.rollbackBuffer();
this.set("editing", false);

View File

@ -11,10 +11,10 @@ export default Ember.Component.extend(
},
click() {
this.get("word")
this.word
.destroy()
.then(() => {
this.action(this.get("word"));
this.action(this.word);
})
.catch(e => {
bootbox.alert(

View File

@ -25,8 +25,8 @@ export default Ember.Component.extend({
return eventTypeExists;
},
set(value, eventTypeExists) {
const type = this.get("type");
const model = this.get("model");
const type = this.type;
const model = this.model;
// add an association when not exists
if (value !== eventTypeExists) {
if (value) {

View File

@ -33,14 +33,14 @@ export default Ember.Component.extend({
@computed("expandDetails")
expandRequestIcon(expandDetails) {
return expandDetails === this.get("expandDetailsRequestKey")
return expandDetails === this.expandDetailsRequestKey
? "ellipsis-h"
: "ellipsis-v";
},
@computed("expandDetails")
expandResponseIcon(expandDetails) {
return expandDetails === this.get("expandDetailsResponseKey")
return expandDetails === this.expandDetailsResponseKey
? "ellipsis-h"
: "ellipsis-v";
},
@ -69,9 +69,9 @@ export default Ember.Component.extend({
},
toggleRequest() {
const expandDetailsKey = this.get("expandDetailsRequestKey");
const expandDetailsKey = this.expandDetailsRequestKey;
if (this.get("expandDetails") !== expandDetailsKey) {
if (this.expandDetails !== expandDetailsKey) {
let headers = _.extend(
{
"Request URL": this.get("model.request_url"),
@ -91,9 +91,9 @@ export default Ember.Component.extend({
},
toggleResponse() {
const expandDetailsKey = this.get("expandDetailsResponseKey");
const expandDetailsKey = this.expandDetailsResponseKey;
if (this.get("expandDetails") !== expandDetailsKey) {
if (this.expandDetails !== expandDetailsKey) {
this.setProperties({
headers: plainJSON(this.get("model.response_headers")),
body: this.get("model.response_body"),

View File

@ -23,7 +23,7 @@ export default Ember.Component.extend(
},
buildBuffer(buffer) {
buffer.push(iconHTML(this.get("icon"), { class: this.get("class") }));
buffer.push(iconHTML(this.icon, { class: this.class }));
buffer.push(
I18n.t(`admin.web_hooks.delivery_status.${this.get("status.name")}`)
);

View File

@ -10,21 +10,21 @@ import { default as loadScript, loadCSS } from "discourse/lib/load-script";
export default Ember.Component.extend({
classNames: ["color-picker"],
hexValueChanged: function() {
var hex = this.get("hexValue");
var hex = this.hexValue;
let $text = this.$("input.hex-input");
if (this.get("valid")) {
if (this.valid) {
$text.attr(
"style",
"color: " +
(this.get("brightnessValue") > 125 ? "black" : "white") +
(this.brightnessValue > 125 ? "black" : "white") +
"; background-color: #" +
hex +
";"
);
if (this.get("pickerLoaded")) {
this.$(".picker").spectrum({ color: "#" + this.get("hexValue") });
if (this.pickerLoaded) {
this.$(".picker").spectrum({ color: "#" + this.hexValue });
}
} else {
$text.attr("style", "");
@ -36,7 +36,7 @@ export default Ember.Component.extend({
loadCSS("/javascripts/spectrum.css").then(() => {
Ember.run.schedule("afterRender", () => {
this.$(".picker")
.spectrum({ color: "#" + this.get("hexValue") })
.spectrum({ color: "#" + this.hexValue })
.on("change.spectrum", (me, color) => {
this.set("hexValue", color.toHexString().replace("#", ""));
});

View File

@ -30,26 +30,23 @@ export default Ember.Component.extend(bufferedProperty("host"), {
},
save() {
if (this.get("cantSave")) {
if (this.cantSave) {
return;
}
const props = this.get("buffered").getProperties(
const props = this.buffered.getProperties(
"host",
"path_whitelist",
"class_name"
);
props.category_id = this.get("categoryId");
props.category_id = this.categoryId;
const host = this.get("host");
const host = this.host;
host
.save(props)
.then(() => {
host.set(
"category",
Discourse.Category.findById(this.get("categoryId"))
);
host.set("category", Discourse.Category.findById(this.categoryId));
this.set("editToggled", false);
})
.catch(popupAjaxError);
@ -58,17 +55,15 @@ export default Ember.Component.extend(bufferedProperty("host"), {
delete() {
bootbox.confirm(I18n.t("admin.embedding.confirm_delete"), result => {
if (result) {
this.get("host")
.destroyRecord()
.then(() => {
this.deleteHost(this.get("host"));
});
this.host.destroyRecord().then(() => {
this.deleteHost(this.host);
});
}
});
},
cancel() {
const host = this.get("host");
const host = this.host;
if (host.get("isNew")) {
this.deleteHost(host);
} else {

View File

@ -12,12 +12,12 @@ export default Ember.Component.extend({
init() {
this._super(...arguments);
this.set("checkedInternal", this.get("checked"));
this.set("checkedInternal", this.checked);
},
@observes("checked")
checkedChanged() {
this.set("checkedInternal", this.get("checked"));
this.set("checkedInternal", this.checked);
},
@computed("labelKey")
@ -32,11 +32,11 @@ export default Ember.Component.extend({
actions: {
cancelled() {
this.set("checkedInternal", this.get("checked"));
this.set("checkedInternal", this.checked);
},
finished() {
this.set("checked", this.get("checkedInternal"));
this.set("checked", this.checkedInternal);
this.action();
}
}

View File

@ -18,18 +18,18 @@ export default Ember.Component.extend({
lookup() {
this.set("show", true);
if (!this.get("location")) {
ajax("/admin/users/ip-info", { data: { ip: this.get("ip") } }).then(
location => this.set("location", Ember.Object.create(location))
if (!this.location) {
ajax("/admin/users/ip-info", { data: { ip: this.ip } }).then(location =>
this.set("location", Ember.Object.create(location))
);
}
if (!this.get("other_accounts")) {
if (!this.other_accounts) {
this.set("otherAccountsLoading", true);
const data = {
ip: this.get("ip"),
exclude: this.get("userId"),
ip: this.ip,
exclude: this.userId,
order: "trust_level DESC"
};
@ -51,8 +51,8 @@ export default Ember.Component.extend({
},
copy() {
let text = `IP: ${this.get("ip")}\n`;
const location = this.get("location");
let text = `IP: ${this.ip}\n`;
const location = this.location;
if (location) {
if (location.hostname) {
text += `${I18n.t("ip_lookup.hostname")}: ${location.hostname}\n`;
@ -97,8 +97,8 @@ export default Ember.Component.extend({
ajax("/admin/users/delete-others-with-same-ip.json", {
type: "DELETE",
data: {
ip: this.get("ip"),
exclude: this.get("userId"),
ip: this.ip,
exclude: this.userId,
order: "trust_level DESC"
}
}).then(() => this.send("lookup"));

View File

@ -1,6 +1,7 @@
import computed from "ember-addons/ember-computed-decorators";
const ACTIONS = ["delete", "edit", "none"];
const ACTIONS = ["delete", "delete_replies", "edit", "none"];
export default Ember.Component.extend({
postId: null,
postAction: null,
@ -17,7 +18,7 @@ export default Ember.Component.extend({
actions: {
penaltyChanged() {
let postAction = this.get("postAction");
let postAction = this.postAction;
// If we switch to edit mode, jump to the edit textarea
if (postAction === "edit") {

View File

@ -24,13 +24,13 @@ export default Ember.Component.extend({
actions: {
submit() {
if (!this.get("formSubmitted")) {
if (!this.formSubmitted) {
this.set("formSubmitted", true);
Permalink.create({
url: this.get("url"),
permalink_type: this.get("permalinkType"),
permalink_type_value: this.get("permalink_type_value")
url: this.url,
permalink_type: this.permalinkType,
permalink_type_value: this.permalink_type_value
})
.save()
.then(

View File

@ -0,0 +1,20 @@
import Category from "discourse/models/category";
import { default as computed } from "ember-addons/ember-computed-decorators";
import FilterComponent from "admin/components/report-filters/filter";
export default FilterComponent.extend({
classNames: ["category-filter"],
layoutName: "admin/templates/components/report-filters/category",
@computed("filter.default")
category(categoryId) {
return Category.findById(categoryId);
},
actions: {
onDeselect() {
this.applyFilter(this.get("filter.id"), undefined);
}
}
});

View File

@ -0,0 +1,7 @@
import FilterComponent from "admin/components/report-filters/filter";
export default FilterComponent.extend({
classNames: ["file-extension-filter"],
layoutName: "admin/templates/components/report-filters/file-extension"
});

View File

@ -0,0 +1,7 @@
export default Ember.Component.extend({
actions: {
onChange(value) {
this.applyFilter(this.get("filter.id"), value);
}
}
});

View File

@ -0,0 +1,20 @@
import FilterComponent from "admin/components/report-filters/filter";
import { default as computed } from "ember-addons/ember-computed-decorators";
export default FilterComponent.extend({
classNames: ["group-filter"],
layoutName: "admin/templates/components/report-filters/group",
@computed()
groupOptions() {
return (this.site.groups || []).map(group => {
return { name: group["name"], value: group["id"] };
});
},
@computed("filter.default")
groupId(filterDefault) {
return filterDefault ? parseInt(filterDefault, 10) : null;
}
});

View File

@ -1,5 +1,9 @@
import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
import {
default as computed,
on
} from "ember-addons/ember-computed-decorators";
/*global Resumable:true */
@ -19,113 +23,108 @@ export default Ember.Component.extend(
classNames: ["btn", "ru"],
classNameBindings: ["isUploading"],
attributeBindings: ["translatedTitle:title"],
resumable: null,
isUploading: false,
progress: 0,
rerenderTriggers: ["isUploading", "progress"],
translatedTitle: function() {
const title = this.get("title");
return title ? I18n.t(title) : this.get("text");
}.property("title", "text"),
@on("init")
_initialize() {
this.resumable = new Resumable({
target: Discourse.getURL(this.target),
maxFiles: 1, // only 1 file at a time
headers: {
"X-CSRF-Token": document.querySelector("meta[name='csrf-token']")
.content
}
});
text: function() {
if (this.get("isUploading")) {
return this.get("progress") + " %";
} else {
return this.get("uploadText");
}
}.property("isUploading", "progress"),
this.resumable.on("fileAdded", () => {
// automatically upload the selected file
this.resumable.upload();
buildBuffer(buffer) {
const icon = this.get("isUploading") ? "times" : "upload";
buffer.push(iconHTML(icon));
buffer.push("<span class='ru-label'>" + this.get("text") + "</span>");
buffer.push(
"<span class='ru-progress' style='width:" +
this.get("progress") +
"%'></span>"
// mark as uploading
Ember.run.later(() => this.set("isUploading", true));
});
this.resumable.on("fileProgress", file => {
// update progress
Ember.run.later(() =>
this.set("progress", parseInt(file.progress() * 100, 10))
);
});
this.resumable.on("fileSuccess", file => {
Ember.run.later(() => {
// mark as not uploading anymore
this._reset();
// fire an event to allow the parent route to reload its model
this.success(file.fileName);
});
});
this.resumable.on("fileError", (file, message) => {
Ember.run.later(() => {
// mark as not uploading anymore
this._reset();
// fire an event to allow the parent route to display the error message
this.error(file.fileName, message);
});
});
},
@on("didInsertElement")
_assignBrowse() {
Ember.run.schedule("afterRender", () =>
this.resumable.assignBrowse($(this.element))
);
},
click: function() {
if (this.get("isUploading")) {
@on("willDestroyElement")
_teardown() {
if (this.resumable) {
this.resumable.cancel();
var self = this;
Ember.run.later(function() {
self._reset();
});
this.resumable = null;
}
},
@computed("title", "text")
translatedTitle(title, text) {
return title ? I18n.t(title) : text;
},
@computed("isUploading", "progress")
text(isUploading, progress) {
if (isUploading) {
return progress + " %";
} else {
return this.uploadText;
}
},
buildBuffer(buffer) {
const icon = this.isUploading ? "times" : "upload";
buffer.push(iconHTML(icon));
buffer.push("<span class='ru-label'>" + this.text + "</span>");
buffer.push(
"<span class='ru-progress' style='width:" + this.progress + "%'></span>"
);
},
click() {
if (this.isUploading) {
this.resumable.cancel();
Ember.run.later(() => this._reset());
return false;
} else {
return true;
}
},
_reset: function() {
_reset() {
this.setProperties({ isUploading: false, progress: 0 });
},
_initialize: function() {
this.resumable = new Resumable({
target: Discourse.getURL(this.get("target")),
maxFiles: 1, // only 1 file at a time
headers: {
"X-CSRF-Token": $("meta[name='csrf-token']").attr("content")
}
});
var self = this;
this.resumable.on("fileAdded", function() {
// automatically upload the selected file
self.resumable.upload();
// mark as uploading
Ember.run.later(function() {
self.set("isUploading", true);
});
});
this.resumable.on("fileProgress", function(file) {
// update progress
Ember.run.later(function() {
self.set("progress", parseInt(file.progress() * 100, 10));
});
});
this.resumable.on("fileSuccess", function(file) {
Ember.run.later(function() {
// mark as not uploading anymore
self._reset();
// fire an event to allow the parent route to reload its model
self.success(file.fileName);
});
});
this.resumable.on("fileError", function(file, message) {
Ember.run.later(function() {
// mark as not uploading anymore
self._reset();
// fire an event to allow the parent route to display the error message
self.error(file.fileName, message);
});
});
}.on("init"),
_assignBrowse: function() {
var self = this;
Ember.run.schedule("afterRender", function() {
self.resumable.assignBrowse(self.$());
});
}.on("didInsertElement"),
_teardown: function() {
if (this.resumable) {
this.resumable.cancel();
this.resumable = null;
}
}.on("willDestroyElement")
}
})
);

View File

@ -50,11 +50,11 @@ export default Ember.Component.extend({
actions: {
submit() {
if (!this.get("formSubmitted")) {
if (!this.formSubmitted) {
this.set("formSubmitted", true);
const screenedIpAddress = ScreenedIpAddress.create({
ip_address: this.get("ip_address"),
action_name: this.get("actionName")
ip_address: this.ip_address,
action_name: this.actionName
});
screenedIpAddress
.save()

View File

@ -9,11 +9,11 @@ export default Ember.Component.extend({
@on("didReceiveAttrs")
_setupCollection() {
const values = this.get("values");
const values = this.values;
this.set(
"collection",
this._splitValues(values, this.get("inputDelimiter") || "\n")
this._splitValues(values, this.inputDelimiter || "\n")
);
},
@ -29,9 +29,8 @@ export default Ember.Component.extend({
},
addValue() {
if (this._checkInvalidInput([this.get("newKey"), this.get("newSecret")]))
return;
this._addValue(this.get("newKey"), this.get("newSecret"));
if (this._checkInvalidInput([this.newKey, this.newSecret])) return;
this._addValue(this.newKey, this.newSecret);
this.setProperties({ newKey: "", newSecret: "" });
},
@ -54,18 +53,18 @@ export default Ember.Component.extend({
},
_addValue(value, secret) {
this.get("collection").addObject({ key: value, secret: secret });
this.collection.addObject({ key: value, secret: secret });
this._saveValues();
},
_removeValue(value) {
const collection = this.get("collection");
const collection = this.collection;
collection.removeObject(value);
this._saveValues();
},
_replaceValue(index, newValue, keyName) {
let item = this.get("collection")[index];
let item = this.collection[index];
Ember.set(item, keyName, newValue);
this._saveValues();
@ -74,7 +73,7 @@ export default Ember.Component.extend({
_saveValues() {
this.set(
"values",
this.get("collection")
this.collection
.map(function(elem) {
return `${elem.key}|${elem.secret}`;
})

View File

@ -4,7 +4,7 @@ import SettingComponent from "admin/mixins/setting-component";
export default Ember.Component.extend(BufferedContent, SettingComponent, {
_save() {
const setting = this.get("buffered");
const setting = this.buffered;
return SiteSetting.update(setting.get("setting"), setting.get("value"));
}
});

View File

@ -0,0 +1,8 @@
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
@computed()
groupChoices() {
return this.site.get("groups").map(g => g.name);
}
});

View File

@ -17,18 +17,18 @@ export default Ember.Component.extend({
},
click() {
this.send("edit");
this.editAction(this.siteText);
},
_searchTerm() {
const regex = this.get("searchRegex");
const siteText = this.get("siteText");
const regex = this.searchRegex;
const siteText = this.siteText;
if (regex && siteText) {
const matches = siteText.value.match(new RegExp(regex, "i"));
if (matches) return matches[0];
}
return this.get("term");
return this.term;
}
});

View File

@ -4,7 +4,7 @@ import SettingComponent from "admin/mixins/setting-component";
export default Ember.Component.extend(BufferedContent, SettingComponent, {
layoutName: "admin/templates/components/site-setting",
_save() {
return this.get("model").saveSettings(
return this.model.saveSettings(
this.get("setting.setting"),
this.get("buffered.value")
);

View File

@ -8,7 +8,7 @@ export default Ember.Component.extend(BufferedContent, SettingComponent, {
settingName: Ember.computed.alias("translation.key"),
_save() {
return this.get("model").saveTranslation(
return this.model.saveTranslation(
this.get("translation.key"),
this.get("buffered.value")
);

View File

@ -56,12 +56,12 @@ export default Ember.Component.extend({
"childrenExpanded"
)
children() {
const theme = this.get("theme");
const theme = this.theme;
let children = theme.get("childThemes");
if (theme.get("component") || !children) {
return [];
}
children = this.get("childrenExpanded")
children = this.childrenExpanded
? children
: children.slice(0, MAX_COMPONENTS);
return children.map(t => t.get("name"));

View File

@ -16,7 +16,7 @@ export default Ember.Component.extend({
@computed("themes", "components", "currentTab")
themesList(themes, components) {
if (this.get("themesTabActive")) {
if (this.themesTabActive) {
return themes;
} else {
return components;
@ -30,7 +30,7 @@ export default Ember.Component.extend({
"themesList.@each.default"
)
inactiveThemes(themes) {
if (this.get("componentsTabActive")) {
if (this.componentsTabActive) {
return themes.filter(theme => theme.get("parent_themes.length") <= 0);
}
return themes.filter(
@ -45,7 +45,7 @@ export default Ember.Component.extend({
"themesList.@each.default"
)
activeThemes(themes) {
if (this.get("componentsTabActive")) {
if (this.componentsTabActive) {
return themes.filter(theme => theme.get("parent_themes.length") > 0);
} else {
themes = themes.filter(
@ -63,7 +63,7 @@ export default Ember.Component.extend({
actions: {
changeView(newTab) {
if (newTab !== this.get("currentTab")) {
if (newTab !== this.currentTab) {
this.set("currentTab", newTab);
}
},

View File

@ -15,15 +15,15 @@ export default Ember.Component.extend({
@on("didReceiveAttrs")
_setupCollection() {
const values = this.get("values");
if (this.get("inputType") === "array") {
const values = this.values;
if (this.inputType === "array") {
this.set("collection", values || []);
return;
}
this.set(
"collection",
this._splitValues(values, this.get("inputDelimiter") || "\n")
this._splitValues(values, this.inputDelimiter || "\n")
);
},
@ -33,7 +33,7 @@ export default Ember.Component.extend({
},
keyDown(event) {
if (event.keyCode === 13) this.send("addValue", this.get("newValue"));
if (event.keyCode === 13) this.send("addValue", this.newValue);
},
actions: {
@ -42,7 +42,7 @@ export default Ember.Component.extend({
},
addValue(newValue) {
if (this.get("inputInvalid")) return;
if (this.inputInvalid) return;
this.set("newValue", "");
this._addValue(newValue);
@ -58,31 +58,28 @@ export default Ember.Component.extend({
},
_addValue(value) {
this.get("collection").addObject(value);
this.collection.addObject(value);
this._saveValues();
},
_removeValue(value) {
const collection = this.get("collection");
const collection = this.collection;
collection.removeObject(value);
this._saveValues();
},
_replaceValue(index, newValue) {
this.get("collection").replace(index, 1, [newValue]);
this.collection.replace(index, 1, [newValue]);
this._saveValues();
},
_saveValues() {
if (this.get("inputType") === "array") {
this.set("values", this.get("collection"));
if (this.inputType === "array") {
this.set("values", this.collection);
return;
}
this.set(
"values",
this.get("collection").join(this.get("inputDelimiter") || "\n")
);
this.set("values", this.collection.join(this.inputDelimiter || "\n"));
},
_splitValues(values, delimiter) {

View File

@ -21,17 +21,15 @@ export default Ember.Component.extend({
@observes("word")
removeMessage() {
if (this.get("showMessage") && !Ember.isEmpty(this.get("word"))) {
if (this.showMessage && !Ember.isEmpty(this.word)) {
this.set("showMessage", false);
}
},
@computed("word")
isUniqueWord(word) {
const words = this.get("filteredContent") || [];
const filtered = words.filter(
content => content.action === this.get("actionKey")
);
const words = this.filteredContent || [];
const filtered = words.filter(content => content.action === this.actionKey);
return filtered.every(
content => content.word.toLowerCase() !== word.toLowerCase()
);
@ -39,7 +37,7 @@ export default Ember.Component.extend({
actions: {
submit() {
if (!this.get("isUniqueWord")) {
if (!this.isUniqueWord) {
this.setProperties({
showMessage: true,
message: I18n.t("admin.watched_words.form.exists")
@ -47,12 +45,12 @@ export default Ember.Component.extend({
return;
}
if (!this.get("formSubmitted")) {
if (!this.formSubmitted) {
this.set("formSubmitted", true);
const watchedWord = WatchedWord.create({
word: this.get("word"),
action: this.get("actionKey")
word: this.word,
action: this.actionKey
});
watchedWord

View File

@ -9,7 +9,7 @@ export default Ember.Controller.extend({
actions: {
generateMasterKey() {
ApiKey.generateMasterKey().then(key => this.get("model").pushObject(key));
ApiKey.generateMasterKey().then(key => this.model.pushObject(key));
},
regenerateKey(key) {
@ -32,7 +32,7 @@ export default Ember.Controller.extend({
I18n.t("yes_value"),
result => {
if (result) {
key.revoke().then(() => this.get("model").removeObject(key));
key.revoke().then(() => this.model.removeObject(key));
}
}
);

View File

@ -1,5 +1,10 @@
export default Ember.Controller.extend({
logs: [],
adminBackups: Ember.inject.controller(),
status: Ember.computed.alias("adminBackups.model")
status: Ember.computed.alias("adminBackups.model"),
init() {
this._super(...arguments);
this.logs = [];
}
});

View File

@ -1,6 +1,7 @@
import { popupAjaxError } from "discourse/lib/ajax-error";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import { propertyNotEqual } from "discourse/lib/computed";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(bufferedProperty("model"), {
adminBadges: Ember.inject.controller(),
@ -17,14 +18,13 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
readOnly: Ember.computed.alias("buffered.system"),
showDisplayName: propertyNotEqual("name", "displayName"),
hasQuery: function() {
const bQuery = this.get("buffered.query");
if (bQuery) {
return bQuery.trim().length > 0;
@computed("model.query", "buffered.query")
hasQuery(modelQuery, bufferedQuery) {
if (bufferedQuery) {
return bufferedQuery.trim().length > 0;
}
const mQuery = this.get("model.query");
return mQuery && mQuery.trim().length > 0;
}.property("model.query", "buffered.query"),
return modelQuery && modelQuery.trim().length > 0;
},
_resetSaving: function() {
this.set("saving", false);
@ -33,7 +33,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
actions: {
save() {
if (!this.get("saving")) {
if (!this.saving) {
let fields = [
"allow_title",
"multiple_grant",
@ -54,7 +54,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
];
if (this.get("buffered.system")) {
var protectedFields = this.get("protectedSystemFields") || [];
var protectedFields = this.protectedSystemFields || [];
fields = _.filter(fields, f => !protectedFields.includes(f));
}
@ -72,7 +72,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
];
const data = {};
const buffered = this.get("buffered");
const buffered = this.buffered;
fields.forEach(function(field) {
var d = buffered.get(field);
if (boolFields.includes(field)) {
@ -81,9 +81,9 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
data[field] = d;
});
const newBadge = !this.get("id");
const model = this.get("model");
this.get("model")
const newBadge = !this.id;
const model = this.model;
this.model
.save(data)
.then(() => {
if (newBadge) {
@ -107,7 +107,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
destroy() {
const adminBadges = this.get("adminBadges.model");
const model = this.get("model");
const model = this.model;
if (!model.get("id")) {
this.transitionToRoute("adminBadges.index");

View File

@ -23,7 +23,7 @@ export default Ember.Controller.extend({
$(".table.colors").hide();
let area = $("<textarea id='copy-range'></textarea>");
$(".table.colors").after(area);
area.text(this.get("model").schemeJson());
area.text(this.model.schemeJson());
let range = document.createRange();
range.selectNode(area[0]);
window.getSelection().addRange(range);
@ -51,7 +51,7 @@ export default Ember.Controller.extend({
},
copy() {
var newColorScheme = Ember.copy(this.get("model"), true);
var newColorScheme = Ember.copy(this.model, true);
newColorScheme.set(
"name",
I18n.t("admin.customize.colors.copy_name_prefix") +
@ -59,17 +59,17 @@ export default Ember.Controller.extend({
this.get("model.name")
);
newColorScheme.save().then(() => {
this.get("allColors").pushObject(newColorScheme);
this.allColors.pushObject(newColorScheme);
this.replaceRoute("adminCustomize.colors.show", newColorScheme);
});
},
save: function() {
this.get("model").save();
this.model.save();
},
destroy: function() {
const model = this.get("model");
const model = this.model;
return bootbox.confirm(
I18n.t("admin.customize.colors.delete_confirm"),
I18n.t("no_value"),
@ -77,7 +77,7 @@ export default Ember.Controller.extend({
result => {
if (result) {
model.destroy().then(() => {
this.get("allColors").removeObject(model);
this.allColors.removeObject(model);
this.replaceRoute("adminCustomize.colors");
});
}

View File

@ -4,12 +4,12 @@ import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
@computed("model.@each.id")
baseColorScheme() {
return this.get("model").findBy("is_base", true);
return this.model.findBy("is_base", true);
},
@computed("model.@each.id")
baseColorSchemes() {
return this.get("model").filterBy("is_base", true);
return this.model.filterBy("is_base", true);
},
@computed("baseColorScheme")
@ -23,17 +23,14 @@ export default Ember.Controller.extend({
actions: {
newColorSchemeWithBase(baseKey) {
const base = this.get("baseColorSchemes").findBy(
"base_scheme_id",
baseKey
);
const base = this.baseColorSchemes.findBy("base_scheme_id", baseKey);
const newColorScheme = Ember.copy(base, true);
newColorScheme.setProperties({
name: I18n.t("admin.customize.colors.new_name"),
base_scheme_id: base.get("base_scheme_id")
});
newColorScheme.save().then(() => {
this.get("model").pushObject(newColorScheme);
this.model.pushObject(newColorScheme);
newColorScheme.set("savingStatus", null);
this.replaceRoute("adminCustomize.colors.show", newColorScheme);
});
@ -41,7 +38,7 @@ export default Ember.Controller.extend({
newColorScheme() {
showModal("admin-color-scheme-select-base", {
model: this.get("baseColorSchemes"),
model: this.baseColorSchemes,
admin: true
});
}

View File

@ -1,23 +1,24 @@
import { popupAjaxError } from "discourse/lib/ajax-error";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(bufferedProperty("emailTemplate"), {
saved: false,
hasMultipleSubjects: function() {
const buffered = this.get("buffered");
@computed("buffered")
hasMultipleSubjects(buffered) {
if (buffered.getProperties("subject")["subject"]) {
return false;
} else {
return buffered.getProperties("id")["id"];
}
}.property("buffered"),
},
actions: {
saveChanges() {
this.set("saved", false);
const buffered = this.get("buffered");
this.get("emailTemplate")
const buffered = this.buffered;
this.emailTemplate
.save(buffered.getProperties("subject", "body"))
.then(() => {
this.set("saved", true);
@ -31,10 +32,10 @@ export default Ember.Controller.extend(bufferedProperty("emailTemplate"), {
I18n.t("admin.customize.email_templates.revert_confirm"),
result => {
if (result) {
this.get("emailTemplate")
this.emailTemplate
.revert()
.then(props => {
const buffered = this.get("buffered");
const buffered = this.buffered;
buffered.setProperties(props);
this.commitBuffer();
})

View File

@ -1,6 +1,10 @@
export default Ember.Controller.extend({
titleSorting: ["title"],
emailTemplates: null,
sortedTemplates: Ember.computed.sort("emailTemplates", "titleSorting"),
sortedTemplates: Ember.computed.sort("emailTemplates", "titleSorting")
init() {
this._super(...arguments);
this.titleSorting = ["title"];
}
});

View File

@ -36,37 +36,25 @@ export default Ember.Controller.extend({
actions: {
save() {
this.set("saving", true);
this.get("model")
.saveChanges("theme_fields")
.finally(() => {
this.set("saving", false);
});
this.model.saveChanges("theme_fields").finally(() => {
this.set("saving", false);
});
},
fieldAdded(target, name) {
this.replaceRoute(
this.get("editRouteName"),
this.get("model.id"),
target,
name
);
this.replaceRoute(this.editRouteName, this.get("model.id"), target, name);
},
onlyOverriddenChanged(onlyShowOverridden) {
if (onlyShowOverridden) {
if (
!this.get("model").hasEdited(
this.get("currentTargetName"),
this.get("fieldName")
)
) {
if (!this.model.hasEdited(this.currentTargetName, this.fieldName)) {
let firstTarget = this.get("model.targets").find(t => t.edited);
let firstField = this.get(`model.fields.${firstTarget.name}`).find(
f => f.edited
);
this.replaceRoute(
this.get("editRouteName"),
this.editRouteName,
this.get("model.id"),
firstTarget.name,
firstField.name

View File

@ -100,7 +100,7 @@ export default Ember.Controller.extend({
},
commitSwitchType() {
const model = this.get("model");
const model = this.model;
const newValue = !model.get("component");
model.set("component", newValue);
@ -141,7 +141,7 @@ export default Ember.Controller.extend({
},
transitionToEditRoute() {
this.transitionToRoute(
this.get("editRouteName"),
this.editRouteName,
this.get("model.id"),
"common",
"scss"
@ -154,7 +154,7 @@ export default Ember.Controller.extend({
actions: {
updateToLatest() {
this.set("updatingRemote", true);
this.get("model")
this.model
.updateToLatest()
.catch(popupAjaxError)
.finally(() => {
@ -164,7 +164,7 @@ export default Ember.Controller.extend({
checkForThemeUpdates() {
this.set("updatingRemote", true);
this.get("model")
this.model
.checkForUpdates()
.catch(popupAjaxError)
.finally(() => {
@ -177,7 +177,7 @@ export default Ember.Controller.extend({
},
addUpload(info) {
let model = this.get("model");
let model = this.model;
model.setField("common", info.name, "", info.upload_id, THEME_UPLOAD_VAR);
model.saveChanges("theme_fields").catch(e => popupAjaxError(e));
},
@ -186,23 +186,23 @@ export default Ember.Controller.extend({
this.set("colorSchemeId", this.get("model.color_scheme_id"));
},
changeScheme() {
let schemeId = this.get("colorSchemeId");
let schemeId = this.colorSchemeId;
this.set(
"model.color_scheme_id",
schemeId === null ? null : parseInt(schemeId)
);
this.get("model").saveChanges("color_scheme_id");
this.model.saveChanges("color_scheme_id");
},
startEditingName() {
this.set("oldName", this.get("model.name"));
this.set("editingName", true);
},
cancelEditingName() {
this.set("model.name", this.get("oldName"));
this.set("model.name", this.oldName);
this.set("editingName", false);
},
finishedEditingName() {
this.get("model").saveChanges("name");
this.model.saveChanges("name");
this.set("editingName", false);
},
@ -222,10 +222,10 @@ export default Ember.Controller.extend({
},
applyDefault() {
const model = this.get("model");
const model = this.model;
model.saveChanges("default").then(() => {
if (model.get("default")) {
this.get("allThemes").forEach(theme => {
this.allThemes.forEach(theme => {
if (theme !== model && theme.get("default")) {
theme.set("default", false);
}
@ -235,13 +235,13 @@ export default Ember.Controller.extend({
},
applyUserSelectable() {
this.get("model").saveChanges("user_selectable");
this.model.saveChanges("user_selectable");
},
addChildTheme() {
let themeId = parseInt(this.get("selectedChildThemeId"));
let theme = this.get("allThemes").findBy("id", themeId);
this.get("model").addChildTheme(theme);
let themeId = parseInt(this.selectedChildThemeId);
let theme = this.allThemes.findBy("id", themeId);
this.model.addChildTheme(theme);
},
removeUpload(upload) {
@ -251,26 +251,28 @@ export default Ember.Controller.extend({
I18n.t("yes_value"),
result => {
if (result) {
this.get("model").removeField(upload);
this.model.removeField(upload);
}
}
);
},
removeChildTheme(theme) {
this.get("model").removeChildTheme(theme);
this.model.removeChildTheme(theme);
},
destroy() {
return bootbox.confirm(
I18n.t("admin.customize.delete_confirm"),
I18n.t("admin.customize.delete_confirm", {
theme_name: this.get("model.name")
}),
I18n.t("no_value"),
I18n.t("yes_value"),
result => {
if (result) {
const model = this.get("model");
const model = this.model;
model.destroyRecord().then(() => {
this.get("allThemes").removeObject(model);
this.allThemes.removeObject(model);
this.transitionToRoute("adminCustomizeThemes");
});
}
@ -280,12 +282,12 @@ export default Ember.Controller.extend({
switchType() {
const relatives = this.get("model.component")
? this.get("parentThemes")
? this.parentThemes
: this.get("model.childThemes");
if (relatives && relatives.length > 0) {
const names = relatives.map(relative => relative.get("name"));
bootbox.confirm(
I18n.t(`${this.get("convertKey")}_alert`, {
I18n.t(`${this.convertKey}_alert`, {
relatives: names.join(", ")
}),
I18n.t("no_value"),

View File

@ -6,7 +6,7 @@ import PeriodComputationMixin from "admin/mixins/period-computation";
function staticReport(reportType) {
return function() {
return Ember.makeArray(this.get("reports")).find(
return Ember.makeArray(this.reports).find(
report => report.type === reportType
);
}.property("reports.[]");
@ -27,8 +27,8 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
@computed
activityMetricsFilters() {
return {
startDate: this.get("lastMonth"),
endDate: this.get("today")
startDate: this.lastMonth,
endDate: this.today
};
},
@ -45,7 +45,7 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
startDate: moment()
.subtract(6, "days")
.startOf("day"),
endDate: this.get("today")
endDate: this.today
};
},
@ -55,7 +55,7 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
startDate: moment()
.subtract(1, "month")
.startOf("day"),
endDate: this.get("today")
endDate: this.today
};
},
@ -78,13 +78,13 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
storageReport: staticReport("storage_report"),
fetchDashboard() {
if (this.get("isLoading")) return;
if (this.isLoading) return;
if (
!this.get("dashboardFetchedAt") ||
!this.dashboardFetchedAt ||
moment()
.subtract(30, "minutes")
.toDate() > this.get("dashboardFetchedAt")
.toDate() > this.dashboardFetchedAt
) {
this.set("isLoading", true);
@ -99,7 +99,7 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
});
})
.catch(e => {
this.get("exceptionController").set("thrown", e.jqXHR);
this.exceptionController.set("thrown", e.jqXHR);
this.replaceRoute("exception");
})
.finally(() => this.set("isLoading", false));
@ -111,13 +111,6 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
return { startDate, endDate };
},
@computed("model.attributes.updated_at")
updatedTimestamp(updatedAt) {
return moment(updatedAt)
.tz(moment.tz.guess())
.format("LLL");
},
_reportsForPeriodURL(period) {
return Discourse.getURL(`/admin?period=${period}`);
}

View File

@ -17,13 +17,13 @@ export default Ember.Controller.extend({
},
fetchProblems() {
if (this.get("isLoadingProblems")) return;
if (this.isLoadingProblems) return;
if (
!this.get("problemsFetchedAt") ||
!this.problemsFetchedAt ||
moment()
.subtract(PROBLEMS_CHECK_MINUTES, "minutes")
.toDate() > this.get("problemsFetchedAt")
.toDate() > this.problemsFetchedAt
) {
this._loadProblems();
}
@ -32,13 +32,13 @@ export default Ember.Controller.extend({
fetchDashboard() {
const versionChecks = this.siteSettings.version_checks;
if (this.get("isLoading") || !versionChecks) return;
if (this.isLoading || !versionChecks) return;
if (
!this.get("dashboardFetchedAt") ||
!this.dashboardFetchedAt ||
moment()
.subtract(30, "minutes")
.toDate() > this.get("dashboardFetchedAt")
.toDate() > this.dashboardFetchedAt
) {
this.set("isLoading", true);
@ -55,7 +55,7 @@ export default Ember.Controller.extend({
this.setProperties(properties);
})
.catch(e => {
this.get("exceptionController").set("thrown", e.jqXHR);
this.exceptionController.set("thrown", e.jqXHR);
this.replaceRoute("exception");
})
.finally(() => {

View File

@ -14,7 +14,7 @@ export default Ember.Controller.extend({
ajax("/admin/email/advanced-test", {
type: "POST",
data: { email: this.get("email") }
data: { email: this.email }
})
.then(data => {
this.setProperties({

View File

@ -30,7 +30,7 @@ export default Ember.Controller.extend({
ajax("/admin/email/test", {
type: "POST",
data: { email_address: this.get("testEmailAddress") }
data: { email_address: this.testEmailAddress }
})
.then(response =>
this.set("sentTestEmailMessage", response.sent_test_email_message)

View File

@ -4,7 +4,7 @@ export default Ember.Controller.extend({
loading: false,
loadLogs(sourceModel, loadMore) {
if ((loadMore && this.get("loading")) || this.get("model.allLoaded")) {
if ((loadMore && this.loading) || this.get("model.allLoaded")) {
return;
}
@ -13,14 +13,14 @@ export default Ember.Controller.extend({
sourceModel = sourceModel || EmailLog;
return sourceModel
.findAll(this.get("filter"), loadMore ? this.get("model.length") : null)
.findAll(this.filter, loadMore ? this.get("model.length") : null)
.then(logs => {
if (this.get("model") && loadMore && logs.length < 50) {
this.get("model").set("allLoaded", true);
if (this.model && loadMore && logs.length < 50) {
this.model.set("allLoaded", true);
}
if (this.get("model") && loadMore) {
this.get("model").addObjects(logs);
if (this.model && loadMore) {
this.model.addObjects(logs);
} else {
this.set("model", logs);
}

View File

@ -12,18 +12,18 @@ export default Ember.Controller.extend({
actions: {
refresh() {
const model = this.get("model");
const model = this.model;
this.set("loading", true);
this.set("sentEmail", false);
let username = this.get("username");
let username = this.username;
if (!username) {
username = this.currentUser.get("username");
this.set("username", username);
}
EmailPreview.findDigest(username, this.get("lastSeen")).then(email => {
EmailPreview.findDigest(username, this.lastSeen).then(email => {
model.setProperties(
email.getProperties("html_content", "text_content")
);
@ -39,11 +39,7 @@ export default Ember.Controller.extend({
this.set("sendingEmail", true);
this.set("sentEmail", false);
EmailPreview.sendDigest(
this.get("username"),
this.get("lastSeen"),
this.get("email")
)
EmailPreview.sendDigest(this.username, this.lastSeen, this.email)
.then(result => {
if (result.errors) {
bootbox.alert(result.errors);

View File

@ -32,11 +32,11 @@ export default Ember.Controller.extend({
actions: {
saveChanges() {
const embedding = this.get("embedding");
const embedding = this.embedding;
const updates = embedding.getProperties(embedding.get("fields"));
this.set("saved", false);
this.get("embedding")
this.embedding
.update(updates)
.then(() => this.set("saved", true))
.catch(popupAjaxError);

View File

@ -1,12 +1,17 @@
import { ajax } from "discourse/lib/ajax";
export default Ember.Controller.extend({
sortedEmojis: Ember.computed.sort("model", "emojiSorting"),
emojiSorting: ["name"],
init() {
this._super(...arguments);
this.emojiSorting = ["name"];
},
actions: {
emojiUploaded(emoji) {
emoji.url += "?t=" + new Date().getTime();
this.get("model").pushObject(Ember.Object.create(emoji));
this.model.pushObject(Ember.Object.create(emoji));
},
destroy(emoji) {
@ -19,7 +24,7 @@ export default Ember.Controller.extend({
return ajax("/admin/customize/emojis/" + emoji.get("name"), {
type: "DELETE"
}).then(() => {
this.get("model").removeObject(emoji);
this.model.removeObject(emoji);
});
}
}

View File

@ -10,7 +10,7 @@ export default Ember.Controller.extend({
show: debounce(function() {
this.set("loading", true);
ScreenedIpAddress.findAll(this.get("filter")).then(result => {
ScreenedIpAddress.findAll(this.filter).then(result => {
this.setProperties({ model: result, loading: false });
});
}, 250).observes("filter"),
@ -34,7 +34,7 @@ export default Ember.Controller.extend({
},
cancel(record) {
const savedIpAddress = this.get("savedIpAddress");
const savedIpAddress = this.savedIpAddress;
if (savedIpAddress && record.get("editing")) {
record.set("ip_address", savedIpAddress);
}
@ -74,7 +74,7 @@ export default Ember.Controller.extend({
.destroy()
.then(deleted => {
if (deleted) {
this.get("model").removeObject(record);
this.model.removeObject(record);
} else {
bootbox.alert(I18n.t("generic_error"));
}
@ -92,7 +92,7 @@ export default Ember.Controller.extend({
},
recordAdded(arg) {
this.get("model").unshiftObject(arg);
this.model.unshiftObject(arg);
},
rollUp() {

View File

@ -1,40 +1,45 @@
import { exportEntity } from "discourse/lib/export-csv";
import { outputExportResult } from "discourse/lib/export-result";
import StaffActionLog from "admin/models/staff-action-log";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
loading: false,
filters: null,
userHistoryActions: [],
filtersExists: Ember.computed.gt("filterCount", 0),
init() {
this._super(...arguments);
this.userHistoryActions = [];
},
filterActionIdChanged: function() {
const filterActionId = this.get("filterActionId");
const filterActionId = this.filterActionId;
if (filterActionId) {
this._changeFilters({
action_name: filterActionId,
action_id: this.get("userHistoryActions").findBy("id", filterActionId)
action_id: this.userHistoryActions.findBy("id", filterActionId)
.action_id
});
}
}.observes("filterActionId"),
actionFilter: function() {
var name = this.get("filters.action_name");
@computed("filters.action_name")
actionFilter(name) {
if (name) {
return I18n.t("admin.logs.staff_actions.actions." + name);
} else {
return null;
}
}.property("filters.action_name"),
},
showInstructions: Ember.computed.gt("model.length", 0),
_refresh() {
this.set("loading", true);
var filters = this.get("filters"),
var filters = this.filters,
params = {},
count = 0;
@ -51,7 +56,7 @@ export default Ember.Controller.extend({
StaffActionLog.findAll(params)
.then(result => {
this.set("model", result.staff_action_logs);
if (this.get("userHistoryActions").length === 0) {
if (this.userHistoryActions.length === 0) {
let actionTypes = result.user_history_actions.map(action => {
return {
id: action.id,
@ -79,7 +84,7 @@ export default Ember.Controller.extend({
}.on("init"),
_changeFilters: function(props) {
this.get("filters").setProperties(props);
this.filters.setProperties(props);
this.scheduleRefresh();
},

View File

@ -6,7 +6,7 @@ export default Ember.Controller.extend({
filter: null,
show: debounce(function() {
Permalink.findAll(this.get("filter")).then(result => {
Permalink.findAll(this.filter).then(result => {
this.set("model", result);
this.set("loading", false);
});
@ -14,7 +14,7 @@ export default Ember.Controller.extend({
actions: {
recordAdded(arg) {
this.get("model").unshiftObject(arg);
this.model.unshiftObject(arg);
},
destroy: function(record) {
@ -27,7 +27,7 @@ export default Ember.Controller.extend({
record.destroy().then(
deleted => {
if (deleted) {
this.get("model").removeObject(record);
this.model.removeObject(record);
} else {
bootbox.alert(I18n.t("generic_error"));
}

View File

@ -1,13 +1,17 @@
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
@computed
adminRoutes: function() {
return this.get("model")
return this.model
.map(p => {
if (p.get("enabled")) {
return p.admin_route;
}
})
.compact();
}.property(),
},
actions: {
clearFilter() {
this.setProperties({ filter: "", onlyOverridden: false });

View File

@ -1,7 +1,10 @@
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
queryParams: ["start_date", "end_date", "category_id", "group_id", "filter"],
queryParams: ["start_date", "end_date", "filters"],
start_date: null,
end_date: null,
filters: null,
@computed("model.type")
reportOptions(type) {
@ -12,28 +15,5 @@ export default Ember.Controller.extend({
}
return options;
},
@computed("category_id", "group_id", "start_date", "end_date", "filter")
filters(categoryId, groupId, startDate, endDate, filter) {
return {
categoryId,
groupId,
filter,
startDate,
endDate
};
},
actions: {
onParamsChange(params) {
this.setProperties({
start_date: params.startDate,
filter: params.filter,
category_id: params.categoryId,
group_id: params.groupId,
end_date: params.endDate
});
}
}
});

View File

@ -5,12 +5,19 @@ export default Ember.Controller.extend({
period: DEFAULT_PERIOD,
searchType: "all",
searchTypeOptions: [
{
id: "all",
name: I18n.t("admin.logs.search_logs.types.all_search_types")
},
{ id: "header", name: I18n.t("admin.logs.search_logs.types.header") },
{ id: "full_page", name: I18n.t("admin.logs.search_logs.types.full_page") }
]
init() {
this._super(...arguments);
this.searchTypeOptions = [
{
id: "all",
name: I18n.t("admin.logs.search_logs.types.all_search_types")
},
{ id: "header", name: I18n.t("admin.logs.search_logs.types.header") },
{
id: "full_page",
name: I18n.t("admin.logs.search_logs.types.full_page")
}
];
}
});

View File

@ -6,16 +6,23 @@ export default Ember.Controller.extend({
period: DEFAULT_PERIOD,
searchType: "all",
searchTypeOptions: [
{
id: "all",
name: I18n.t("admin.logs.search_logs.types.all_search_types")
},
{ id: "header", name: I18n.t("admin.logs.search_logs.types.header") },
{ id: "full_page", name: I18n.t("admin.logs.search_logs.types.full_page") },
{
id: "click_through_only",
name: I18n.t("admin.logs.search_logs.types.click_through_only")
}
]
init() {
this._super(...arguments);
this.searchTypeOptions = [
{
id: "all",
name: I18n.t("admin.logs.search_logs.types.all_search_types")
},
{ id: "header", name: I18n.t("admin.logs.search_logs.types.header") },
{
id: "full_page",
name: I18n.t("admin.logs.search_logs.types.full_page")
},
{
id: "click_through_only",
name: I18n.t("admin.logs.search_logs.types.click_through_only")
}
];
}
});

View File

@ -8,16 +8,18 @@ export default Ember.Controller.extend({
filterContentNow(category) {
// If we have no content, don't bother filtering anything
if (!!Ember.isEmpty(this.get("allSiteSettings"))) return;
if (!!Ember.isEmpty(this.allSiteSettings)) return;
let filter;
if (this.get("filter")) {
filter = this.get("filter").toLowerCase();
if (this.filter) {
filter = this.filter.toLowerCase().trim();
}
if ((!filter || 0 === filter.length) && !this.get("onlyOverridden")) {
this.set("visibleSiteSettings", this.get("allSiteSettings"));
this.transitionToRoute("adminSiteSettings");
if ((!filter || 0 === filter.length) && !this.onlyOverridden) {
this.set("visibleSiteSettings", this.allSiteSettings);
if (this.categoryNameKey === "all_results") {
this.transitionToRoute("adminSiteSettings");
}
return;
}
@ -29,9 +31,9 @@ export default Ember.Controller.extend({
const matchesGroupedByCategory = [all];
const matches = [];
this.get("allSiteSettings").forEach(settingsCategory => {
this.allSiteSettings.forEach(settingsCategory => {
const siteSettings = settingsCategory.siteSettings.filter(item => {
if (this.get("onlyOverridden") && !item.get("overridden")) return false;
if (this.onlyOverridden && !item.get("overridden")) return false;
if (filter) {
const setting = item.get("setting").toLowerCase();
return (
@ -72,12 +74,12 @@ export default Ember.Controller.extend({
},
filterContent: debounce(function() {
if (this.get("_skipBounce")) {
if (this._skipBounce) {
this.set("_skipBounce", false);
} else {
this.filterContentNow();
}
}, 250).observes("filter", "onlyOverridden"),
}, 250).observes("filter", "onlyOverridden", "model"),
actions: {
clearFilter() {

View File

@ -6,8 +6,8 @@ export default Ember.Controller.extend(bufferedProperty("siteText"), {
actions: {
saveChanges() {
const buffered = this.get("buffered");
this.get("siteText")
const buffered = this.buffered;
this.siteText
.save(buffered.getProperties("value"))
.then(() => {
this.commitBuffer();
@ -20,10 +20,10 @@ export default Ember.Controller.extend(bufferedProperty("siteText"), {
this.set("saved", false);
bootbox.confirm(I18n.t("admin.site_text.revert_confirm"), result => {
if (result) {
this.get("siteText")
this.siteText
.revert()
.then(props => {
const buffered = this.get("buffered");
const buffered = this.buffered;
buffered.setProperties(props);
this.commitBuffer();
})

View File

@ -30,7 +30,7 @@ export default Ember.Controller.extend({
},
search() {
const q = this.get("q");
const q = this.q;
if (q !== lastSearch) {
this.set("searching", true);
Ember.run.debounce(this, this._performSearch, 400);

View File

@ -1,17 +1,23 @@
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(GrantBadgeController, {
adminUser: Ember.inject.controller(),
user: Ember.computed.alias("adminUser.model"),
userBadges: Ember.computed.alias("model"),
allBadges: Ember.computed.alias("badges"),
sortedBadges: Ember.computed.sort("model", "badgeSortOrder"),
badgeSortOrder: ["granted_at:desc"],
groupedBadges: function() {
const allBadges = this.get("model");
init() {
this._super(...arguments);
this.badgeSortOrder = ["granted_at:desc"];
},
@computed("model", "model.[]", "model.expandedBadges.[]")
groupedBadges() {
const allBadges = this.model;
var grouped = _.groupBy(allBadges, badge => badge.badge_id);
@ -46,26 +52,26 @@ export default Ember.Controller.extend(GrantBadgeController, {
.sortBy(group => group.granted_at)
.reverse()
.value();
}.property("model", "model.[]", "model.expandedBadges.[]"),
},
actions: {
expandGroup: function(userBadge) {
const model = this.get("model");
const model = this.model;
model.set("expandedBadges", model.get("expandedBadges") || []);
model.get("expandedBadges").pushObject(userBadge.badge.id);
},
grantBadge() {
this.grantBadge(
this.get("selectedBadgeId"),
this.selectedBadgeId,
this.get("user.username"),
this.get("badgeReason")
this.badgeReason
).then(
() => {
this.set("badgeReason", "");
Ember.run.next(() => {
// Update the selected badge ID after the combobox has re-rendered.
const newSelectedBadge = this.get("grantableBadges")[0];
const newSelectedBadge = this.grantableBadges[0];
if (newSelectedBadge) {
this.set("selectedBadgeId", newSelectedBadge.get("id"));
}
@ -85,7 +91,7 @@ export default Ember.Controller.extend(GrantBadgeController, {
result => {
if (result) {
userBadge.revoke().then(() => {
this.get("model").removeObject(userBadge);
this.model.removeObject(userBadge);
});
}
}

View File

@ -5,23 +5,27 @@ const MAX_FIELDS = 20;
export default Ember.Controller.extend({
fieldTypes: null,
createDisabled: Ember.computed.gte("model.length", MAX_FIELDS),
fieldSortOrder: ["position"],
sortedFields: Ember.computed.sort("model", "fieldSortOrder"),
init() {
this._super(...arguments);
this.fieldSortOrder = ["position"];
},
actions: {
createField() {
const f = this.store.createRecord("user-field", {
field_type: "text",
position: MAX_FIELDS
});
this.get("model").pushObject(f);
this.model.pushObject(f);
},
moveUp(f) {
const idx = this.get("sortedFields").indexOf(f);
const idx = this.sortedFields.indexOf(f);
if (idx) {
const prev = this.get("sortedFields").objectAt(idx - 1);
const prev = this.sortedFields.objectAt(idx - 1);
const prevPos = prev.get("position");
prev.update({ position: f.get("position") });
@ -30,9 +34,9 @@ export default Ember.Controller.extend({
},
moveDown(f) {
const idx = this.get("sortedFields").indexOf(f);
const idx = this.sortedFields.indexOf(f);
if (idx > -1) {
const next = this.get("sortedFields").objectAt(idx + 1);
const next = this.sortedFields.objectAt(idx + 1);
const nextPos = next.get("position");
next.update({ position: f.get("position") });
@ -41,7 +45,7 @@ export default Ember.Controller.extend({
},
destroy(f) {
const model = this.get("model");
const model = this.model;
// Only confirm if we already been saved
if (f.get("id")) {

View File

@ -107,16 +107,16 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
groupAdded(added) {
this.get("model")
this.model
.groupAdded(added)
.catch(() => bootbox.alert(I18n.t("generic_error")));
},
groupRemoved(groupId) {
this.get("model")
this.model
.groupRemoved(groupId)
.then(() => {
if (groupId === this.get("originalPrimaryGroupId")) {
if (groupId === this.originalPrimaryGroupId) {
this.set("originalPrimaryGroupId", null);
}
})
@ -125,65 +125,65 @@ export default Ember.Controller.extend(CanCheckEmails, {
actions: {
impersonate() {
return this.get("model").impersonate();
return this.model.impersonate();
},
logOut() {
return this.get("model").logOut();
return this.model.logOut();
},
resetBounceScore() {
return this.get("model").resetBounceScore();
return this.model.resetBounceScore();
},
approve() {
return this.get("model").approve();
return this.model.approve();
},
deactivate() {
return this.get("model").deactivate();
return this.model.deactivate();
},
sendActivationEmail() {
return this.get("model").sendActivationEmail();
return this.model.sendActivationEmail();
},
activate() {
return this.get("model").activate();
return this.model.activate();
},
revokeAdmin() {
return this.get("model").revokeAdmin();
return this.model.revokeAdmin();
},
grantAdmin() {
return this.get("model").grantAdmin();
return this.model.grantAdmin();
},
revokeModeration() {
return this.get("model").revokeModeration();
return this.model.revokeModeration();
},
grantModeration() {
return this.get("model").grantModeration();
return this.model.grantModeration();
},
saveTrustLevel() {
return this.get("model").saveTrustLevel();
return this.model.saveTrustLevel();
},
restoreTrustLevel() {
return this.get("model").restoreTrustLevel();
return this.model.restoreTrustLevel();
},
lockTrustLevel(locked) {
return this.get("model").lockTrustLevel(locked);
return this.model.lockTrustLevel(locked);
},
unsilence() {
return this.get("model").unsilence();
return this.model.unsilence();
},
silence() {
return this.get("model").silence();
return this.model.silence();
},
deleteAllPosts() {
return this.get("model").deleteAllPosts();
return this.model.deleteAllPosts();
},
anonymize() {
return this.get("model").anonymize();
return this.model.anonymize();
},
disableSecondFactor() {
return this.get("model").disableSecondFactor();
return this.model.disableSecondFactor();
},
clearPenaltyHistory() {
const user = this.get("model");
const user = this.model;
const path = `/admin/users/${user.get("id")}/penalty_history`;
return ajax(path, { type: "DELETE" })
@ -194,27 +194,25 @@ export default Ember.Controller.extend(CanCheckEmails, {
destroy() {
const postCount = this.get("model.post_count");
if (postCount <= 5) {
return this.get("model").destroy({ deletePosts: true });
return this.model.destroy({ deletePosts: true });
} else {
return this.get("model").destroy();
return this.model.destroy();
}
},
viewActionLogs() {
this.get("adminTools").showActionLogs(this, {
this.adminTools.showActionLogs(this, {
target_user: this.get("model.username")
});
},
showSuspendModal() {
this.get("adminTools").showSuspendModal(this.get("model"));
this.adminTools.showSuspendModal(this.model);
},
unsuspend() {
this.get("model")
.unsuspend()
.catch(popupAjaxError);
this.model.unsuspend().catch(popupAjaxError);
},
showSilenceModal() {
this.get("adminTools").showSilenceModal(this.get("model"));
this.adminTools.showSilenceModal(this.model);
},
saveUsername(newUsername) {
@ -260,13 +258,13 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
generateApiKey() {
this.get("model").generateApiKey();
this.model.generateApiKey();
},
saveCustomGroups() {
const currentIds = this.get("customGroupIds");
const bufferedIds = this.get("customGroupIdsBuffer");
const availableGroups = this.get("availableGroups");
const currentIds = this.customGroupIds;
const bufferedIds = this.customGroupIdsBuffer;
const availableGroups = this.availableGroups;
bufferedIds
.filter(id => !currentIds.includes(id))
@ -294,7 +292,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
},
resetPrimaryGroup() {
this.set("model.primary_group_id", this.get("originalPrimaryGroupId"));
this.set("model.primary_group_id", this.originalPrimaryGroupId);
},
regenerateApiKey() {
@ -304,7 +302,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
I18n.t("yes_value"),
result => {
if (result) {
this.get("model").generateApiKey();
this.model.generateApiKey();
}
}
);
@ -317,7 +315,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
I18n.t("yes_value"),
result => {
if (result) {
this.get("model").revokeApiKey();
this.model.revokeApiKey();
}
}
);

View File

@ -2,6 +2,7 @@ import debounce from "discourse/lib/debounce";
import { i18n } from "discourse/lib/computed";
import AdminUser from "admin/models/admin-user";
import CanCheckEmails from "discourse/mixins/can-check-emails";
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(CanCheckEmails, {
model: null,
@ -14,9 +15,10 @@ export default Ember.Controller.extend(CanCheckEmails, {
selectAll: false,
searchHint: i18n("search_hint"),
title: function() {
return I18n.t("admin.users.titles." + this.get("query"));
}.property("query"),
@computed("query")
title(query) {
return I18n.t("admin.users.titles." + query);
},
_filterUsers: debounce(function() {
this._refreshUsers();
@ -25,11 +27,11 @@ export default Ember.Controller.extend(CanCheckEmails, {
_refreshUsers() {
this.set("refreshing", true);
AdminUser.findAll(this.get("query"), {
filter: this.get("listFilter"),
show_emails: this.get("showEmails"),
order: this.get("order"),
ascending: this.get("ascending")
AdminUser.findAll(this.query, {
filter: this.listFilter,
show_emails: this.showEmails,
order: this.order,
ascending: this.ascending
})
.then(result => this.set("model", result))
.finally(() => this.set("refreshing", false));

View File

@ -39,7 +39,7 @@ export default Ember.Controller.extend({
actions: {
recordAdded(arg) {
const a = this.findAction(this.get("actionNameKey"));
const a = this.findAction(this.actionNameKey);
if (a) {
a.words.unshiftObject(arg);
a.incrementProperty("count");
@ -49,7 +49,7 @@ export default Ember.Controller.extend({
this.get("adminWatchedWords.model").forEach(action => {
if (match) return;
if (action.nameKey !== this.get("actionNameKey")) {
if (action.nameKey !== this.actionNameKey) {
match = action.words.findBy("id", arg.id);
if (match) {
action.words.removeObject(match);
@ -62,7 +62,7 @@ export default Ember.Controller.extend({
},
recordRemoved(arg) {
const a = this.findAction(this.get("actionNameKey"));
const a = this.findAction(this.actionNameKey);
if (a) {
a.words.removeObject(arg);
a.decrementProperty("count");

View File

@ -8,21 +8,21 @@ export default Ember.Controller.extend({
regularExpressions: null,
filterContentNow() {
if (!!Ember.isEmpty(this.get("allWatchedWords"))) return;
if (!!Ember.isEmpty(this.allWatchedWords)) return;
let filter;
if (this.get("filter")) {
filter = this.get("filter").toLowerCase();
if (this.filter) {
filter = this.filter.toLowerCase();
}
if (filter === undefined || filter.length < 1) {
this.set("model", this.get("allWatchedWords"));
this.set("model", this.allWatchedWords);
return;
}
const matchesByAction = [];
this.get("allWatchedWords").forEach(wordsForAction => {
this.allWatchedWords.forEach(wordsForAction => {
const wordRecords = wordsForAction.words.filter(wordRecord => {
return wordRecord.word.indexOf(filter) > -1;
});
@ -41,7 +41,7 @@ export default Ember.Controller.extend({
filterContent: debounce(function() {
this.filterContentNow();
this.set("filtered", !Ember.isEmpty(this.get("filter")));
this.set("filtered", !Ember.isEmpty(this.filter));
}, 250).observes("filter"),
actions: {

View File

@ -4,9 +4,14 @@ import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
pingDisabled: false,
incomingEventIds: [],
incomingCount: Ember.computed.alias("incomingEventIds.length"),
init() {
this._super(...arguments);
this.incomingEventIds = [];
},
@computed("incomingCount")
hasIncoming(incomingCount) {
return incomingCount > 0;
@ -29,7 +34,7 @@ export default Ember.Controller.extend({
},
_addIncoming(eventId) {
const incomingEventIds = this.get("incomingEventIds");
const incomingEventIds = this.incomingEventIds;
if (incomingEventIds.indexOf(eventId) === -1) {
incomingEventIds.pushObject(eventId);
@ -38,7 +43,7 @@ export default Ember.Controller.extend({
actions: {
loadMore() {
this.get("model").loadMore();
this.model.loadMore();
},
ping() {
@ -60,12 +65,12 @@ export default Ember.Controller.extend({
ajax(`/admin/api/web_hooks/${webHookId}/events/bulk`, {
type: "GET",
data: { ids: this.get("incomingEventIds") }
data: { ids: this.incomingEventIds }
}).then(data => {
const objects = data.map(event =>
this.store.createRecord("web-hook-event", event)
);
this.get("model").unshiftObjects(objects);
this.model.unshiftObjects(objects);
this.set("incomingEventIds", []);
});
}

View File

@ -82,8 +82,9 @@ export default Ember.Controller.extend({
actions: {
save() {
this.set("saved", false);
const url = extractDomainFromUrl(this.get("model.payload_url"));
const model = this.get("model");
const url = this.get("model.payload_url");
const domain = extractDomainFromUrl(url);
const model = this.model;
const isNew = model.get("isNew");
const saveWebHook = () => {
@ -91,9 +92,7 @@ export default Ember.Controller.extend({
.save()
.then(() => {
this.set("saved", true);
this.get("adminWebHooks")
.get("model")
.addObject(model);
this.adminWebHooks.get("model").addObject(model);
if (isNew) {
this.transitionToRoute("adminWebHooks.show", model.get("id"));
@ -103,10 +102,10 @@ export default Ember.Controller.extend({
};
if (
url === "localhost" ||
url.match(/192\.168\.\d+\.\d+/) ||
url.match(/127\.\d+\.\d+\.\d+/) ||
url === Discourse.BaseUrl
domain === "localhost" ||
domain.match(/192\.168\.\d+\.\d+/) ||
domain.match(/127\.\d+\.\d+\.\d+/) ||
url.startsWith(Discourse.BaseUrl)
) {
return bootbox.confirm(
I18n.t("admin.web_hooks.warn_local_payload_url"),
@ -130,13 +129,11 @@ export default Ember.Controller.extend({
I18n.t("yes_value"),
result => {
if (result) {
const model = this.get("model");
const model = this.model;
model
.destroyRecord()
.then(() => {
this.get("adminWebHooks")
.get("model")
.removeObject(model);
this.adminWebHooks.get("model").removeObject(model);
this.transitionToRoute("adminWebHooks");
})
.catch(popupAjaxError);

View File

@ -12,7 +12,7 @@ export default Ember.Controller.extend({
webhook
.destroyRecord()
.then(() => {
this.get("model").removeObject(webhook);
this.model.removeObject(webhook);
})
.catch(popupAjaxError);
}
@ -21,7 +21,7 @@ export default Ember.Controller.extend({
},
loadMore() {
this.get("model").loadMore();
this.model.loadMore();
}
}
});

View File

@ -103,7 +103,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
actions: {
updateName() {
let name = this.get("name");
let name = this.name;
if (Ember.isEmpty(name)) {
name = $("#file-input")[0].files[0].name;
this.set("name", name.split(".")[0]);
@ -123,14 +123,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
options.data.append("file", file);
ajax(this.get("uploadUrl"), options)
ajax(this.uploadUrl, options)
.then(result => {
const upload = {
upload_id: result.upload_id,
name: this.get("name"),
name: this.name,
original_filename: file.name
};
this.get("adminCustomizeThemesShow").send("addUpload", upload);
this.adminCustomizeThemesShow.send("addUpload", upload);
this.send("closeModal");
})
.catch(e => {

View File

@ -5,9 +5,9 @@ export default Ember.Controller.extend(ModalFunctionality, {
actions: {
selectBase() {
this.get("adminCustomizeColors").send(
this.adminCustomizeColors.send(
"newColorSchemeWithBase",
this.get("selectedBaseThemeId")
this.selectedBaseThemeId
);
this.send("closeModal");
}

View File

@ -5,7 +5,7 @@ import { observes } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend(ModalFunctionality, {
@observes("model")
modelChanged() {
const model = this.get("model");
const model = this.model;
const copy = Ember.A();
const store = this.store;
@ -19,7 +19,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
},
moveItem(item, delta) {
const copy = this.get("workingCopy");
const copy = this.workingCopy;
const index = copy.indexOf(item);
if (index + delta < 0 || index + delta >= copy.length) {
return;
@ -37,7 +37,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
this.moveItem(item, 1);
},
delete(item) {
this.get("workingCopy").removeObject(item);
this.workingCopy.removeObject(item);
},
cancel() {
this.setProperties({ model: null, workingCopy: null });
@ -54,10 +54,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
editing: true,
name: I18n.t("admin.badges.badge_grouping")
});
this.get("workingCopy").pushObject(obj);
this.workingCopy.pushObject(obj);
},
saveAll() {
let items = this.get("workingCopy");
let items = this.workingCopy;
const groupIds = items.map(i => i.get("id") || -1);
const names = items.map(i => i.get("name"));
@ -66,7 +66,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
method: "POST"
}).then(
data => {
items = this.get("model");
items = this.model;
items.clear();
data.badge_groupings.forEach(g => {
items.pushObject(this.store.createRecord("badge-grouping", g));

View File

@ -121,13 +121,18 @@ export default Ember.Controller.extend(ModalFunctionality, {
urlPlaceholder: "https://github.com/discourse/sample_theme",
advancedVisible: false,
themesController: Ember.inject.controller("adminCustomizeThemes"),
createTypes: [
{ name: I18n.t("admin.customize.theme.theme"), value: THEMES },
{ name: I18n.t("admin.customize.theme.component"), value: COMPONENTS }
],
selectedType: Ember.computed.alias("themesController.currentTab"),
component: Ember.computed.equal("selectedType", COMPONENTS),
init() {
this._super(...arguments);
this.createTypes = [
{ name: I18n.t("admin.customize.theme.theme"), value: THEMES },
{ name: I18n.t("admin.customize.theme.component"), value: COMPONENTS }
];
},
@computed("themesController.installedThemes")
themes(installedThemes) {
return POPULAR_THEMES.map(t => {
@ -166,14 +171,14 @@ export default Ember.Controller.extend(ModalFunctionality, {
@observes("privateChecked")
privateWasChecked() {
this.get("privateChecked")
this.privateChecked
? this.set("urlPlaceholder", "git@github.com:discourse/sample_theme.git")
: this.set("urlPlaceholder", "https://github.com/discourse/sample_theme");
const checked = this.get("privateChecked");
const checked = this.privateChecked;
if (checked && !this._keyLoading) {
this._keyLoading = true;
ajax(this.get("keyGenUrl"), { method: "POST" })
ajax(this.keyGenUrl, { method: "POST" })
.then(pair => {
this.setProperties({
privateKey: pair.private_key,
@ -228,13 +233,13 @@ export default Ember.Controller.extend(ModalFunctionality, {
},
installTheme() {
if (this.get("create")) {
if (this.create) {
this.set("loading", true);
const theme = this.store.createRecord(this.get("recordType"));
const theme = this.store.createRecord(this.recordType);
theme
.save({ name: this.get("name"), component: this.get("component") })
.save({ name: this.name, component: this.component })
.then(() => {
this.get("themesController").send("addTheme", theme);
this.themesController.send("addTheme", theme);
this.send("closeModal");
})
.catch(popupAjaxError)
@ -247,21 +252,21 @@ export default Ember.Controller.extend(ModalFunctionality, {
type: "POST"
};
if (this.get("local")) {
if (this.local) {
options.processData = false;
options.contentType = false;
options.data = new FormData();
options.data.append("theme", this.get("localFile"));
options.data.append("theme", this.localFile);
}
if (this.get("remote") || this.get("popular")) {
if (this.remote || this.popular) {
options.data = {
remote: this.get("uploadUrl"),
branch: this.get("branch")
remote: this.uploadUrl,
branch: this.branch
};
if (this.get("privateChecked")) {
options.data.private_key = this.get("privateKey");
if (this.privateChecked) {
options.data.private_key = this.privateKey;
}
}
@ -271,13 +276,10 @@ export default Ember.Controller.extend(ModalFunctionality, {
}
this.set("loading", true);
ajax(this.get("importUrl"), options)
ajax(this.importUrl, options)
.then(result => {
const theme = this.store.createRecord(
this.get("recordType"),
result.theme
);
this.get("adminCustomizeThemes").send("addTheme", theme);
const theme = this.store.createRecord(this.recordType, result.theme);
this.adminCustomizeThemes.send("addTheme", theme);
this.send("closeModal");
})
.then(() => {

View File

@ -19,19 +19,19 @@ export default Ember.Controller.extend(PenaltyController, {
actions: {
silence() {
if (this.get("submitDisabled")) {
if (this.submitDisabled) {
return;
}
this.set("silencing", true);
this.penalize(() => {
return this.get("user").silence({
silenced_till: this.get("silenceUntil"),
reason: this.get("reason"),
message: this.get("message"),
post_id: this.get("postId"),
post_action: this.get("postAction"),
post_edit: this.get("postEdit")
return this.user.silence({
silenced_till: this.silenceUntil,
reason: this.reason,
message: this.message,
post_id: this.postId,
post_action: this.postAction,
post_edit: this.postEdit
});
}).finally(() => this.set("silencing", false));
}

View File

@ -19,20 +19,20 @@ export default Ember.Controller.extend(PenaltyController, {
actions: {
suspend() {
if (this.get("submitDisabled")) {
if (this.submitDisabled) {
return;
}
this.set("suspending", true);
this.penalize(() => {
return this.get("user").suspend({
suspend_until: this.get("suspendUntil"),
reason: this.get("reason"),
message: this.get("message"),
post_id: this.get("postId"),
post_action: this.get("postAction"),
post_edit: this.get("postEdit")
return this.user.suspend({
suspend_until: this.suspendUntil,
reason: this.reason,
message: this.message,
post_id: this.postId,
post_action: this.postAction,
post_edit: this.postEdit
});
}).finally(() => this.set("suspending", false));
}

View File

@ -11,15 +11,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
actions: {
uploadDone({ url }) {
this.get("images").addObject(url);
this.images.addObject(url);
},
remove(url) {
this.get("images").removeObject(url);
this.images.removeObject(url);
},
close() {
this.save(this.get("images").join("\n"));
this.save(this.images.join("\n"));
this.send("closeModal");
}
}

View File

@ -24,14 +24,14 @@ export default Ember.Mixin.create(ModalFunctionality, {
},
penalize(cb) {
let before = this.get("before");
let before = this.before;
let promise = before ? before() : Ember.RSVP.resolve();
return promise
.then(() => cb())
.then(result => {
this.send("closeModal");
let callback = this.get("successCallback");
let callback = this.successCallback;
if (callback) {
callback(result);
}

View File

@ -3,10 +3,13 @@ import computed from "ember-addons/ember-computed-decorators";
export default Ember.Mixin.create({
queryParams: ["period"],
period: "monthly",
availablePeriods: ["yearly", "quarterly", "monthly", "weekly"],
init() {
this._super(...arguments);
this.availablePeriods = ["yearly", "quarterly", "monthly", "weekly"];
},
@computed("period")
startDate(period) {

View File

@ -13,7 +13,8 @@ const CUSTOM_TYPES = [
"uploaded_image_list",
"compact_list",
"secret_list",
"upload"
"upload",
"group_list"
];
export default Ember.Mixin.create({
@ -112,6 +113,7 @@ export default Ember.Mixin.create({
.then(() => {
this.set("validationMessage", null);
this.commitBuffer();
this.afterSave();
})
.catch(e => {
if (e.jqXHR.responseJSON && e.jqXHR.responseJSON.errors) {

View File

@ -1,19 +1,20 @@
export default Ember.Mixin.create({
overridden: function() {
let val = this.get("value"),
defaultVal = this.get("default");
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Mixin.create({
@computed("value", "default")
overridden(val, defaultVal) {
if (val === null) val = "";
if (defaultVal === null) defaultVal = "";
return val.toString() !== defaultVal.toString();
}.property("value", "default"),
},
validValues: function() {
@computed("valid_values")
validValues(validValues) {
const vals = [],
translateNames = this.get("translate_names");
translateNames = this.translate_names;
this.get("valid_values").forEach(v => {
validValues.forEach(v => {
if (v.name && v.name.length > 0 && translateNames) {
vals.addObject({ name: I18n.t(v.name), value: v.value });
} else {
@ -21,12 +22,12 @@ export default Ember.Mixin.create({
}
});
return vals;
}.property("valid_values"),
},
allowsNone: function() {
const validValues = this.get("valid_values");
@computed("valid_values")
allowsNone(validValues) {
if (validValues && validValues.indexOf("") >= 0) {
return "admin.settings.none";
}
}.property("valid_values")
}
});

View File

@ -1,6 +1,10 @@
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = ["updated_at"];
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link"
];
const AdminDashboard = Discourse.Model.extend({});

View File

@ -52,7 +52,7 @@ const AdminUser = Discourse.User.extend({
canResetBounceScore: Ember.computed.gt("bounce_score", 0),
resetBounceScore() {
return ajax(`/admin/users/${this.get("id")}/reset_bounce_score`, {
return ajax(`/admin/users/${this.id}/reset_bounce_score`, {
type: "POST"
}).then(() =>
this.setProperties({
@ -63,109 +63,112 @@ const AdminUser = Discourse.User.extend({
},
generateApiKey() {
const self = this;
return ajax("/admin/users/" + this.get("id") + "/generate_api_key", {
return ajax(`/admin/users/${this.id}/generate_api_key`, {
type: "POST"
}).then(function(result) {
}).then(result => {
const apiKey = ApiKey.create(result.api_key);
self.set("api_key", apiKey);
this.set("api_key", apiKey);
return apiKey;
});
},
groupAdded(added) {
return ajax("/admin/users/" + this.get("id") + "/groups", {
return ajax(`/admin/users/${this.id}/groups`, {
type: "POST",
data: { group_id: added.id }
}).then(() => this.get("groups").pushObject(added));
}).then(() => this.groups.pushObject(added));
},
groupRemoved(groupId) {
return ajax("/admin/users/" + this.get("id") + "/groups/" + groupId, {
return ajax(`/admin/users/${this.id}/groups/${groupId}`, {
type: "DELETE"
}).then(() => {
this.set("groups.[]", this.get("groups").rejectBy("id", groupId));
if (this.get("primary_group_id") === groupId) {
this.set("groups.[]", this.groups.rejectBy("id", groupId));
if (this.primary_group_id === groupId) {
this.set("primary_group_id", null);
}
});
},
revokeApiKey() {
return ajax("/admin/users/" + this.get("id") + "/revoke_api_key", {
return ajax(`/admin/users/${this.id}/revoke_api_key`, {
type: "DELETE"
}).then(() => this.set("api_key", null));
},
deleteAllPosts() {
let deletedPosts = 0;
const user = this,
message = I18n.messageFormat("admin.user.delete_all_posts_confirm_MF", {
const user = this;
const message = I18n.messageFormat(
"admin.user.delete_all_posts_confirm_MF",
{
POSTS: user.get("post_count"),
TOPICS: user.get("topic_count")
}),
buttons = [
{
label: I18n.t("composer.cancel"),
class: "d-modal-cancel",
link: true
},
{
label:
`${iconHTML("exclamation-triangle")} ` +
I18n.t("admin.user.delete_all_posts"),
class: "btn btn-danger",
callback: () => {
openProgressModal();
}
);
const buttons = [
{
label: I18n.t("composer.cancel"),
class: "d-modal-cancel",
link: true
},
{
label:
`${iconHTML("exclamation-triangle")} ` +
I18n.t("admin.user.delete_all_posts"),
class: "btn btn-danger",
callback: () => {
openProgressModal();
performDelete();
}
}
];
const openProgressModal = () => {
bootbox.dialog(
`<p>${I18n.t(
"admin.user.delete_posts_progress"
)}</p><div class='progress-bar'><span></span></div>`,
[],
{ classes: "delete-posts-progress" }
);
};
const performDelete = () => {
let deletedPercentage = 0;
return ajax(`/admin/users/${user.get("id")}/delete_posts_batch`, {
type: "PUT"
})
.then(({ posts_deleted }) => {
if (posts_deleted === 0) {
user.set("post_count", 0);
bootbox.hideAll();
} else {
deletedPosts += posts_deleted;
deletedPercentage = Math.floor(
(deletedPosts * 100) / user.get("post_count")
);
$(".delete-posts-progress .progress-bar > span").css({
width: `${deletedPercentage}%`
});
performDelete();
}
}
],
openProgressModal = () => {
bootbox.dialog(
`<p>${I18n.t(
"admin.user.delete_posts_progress"
)}</p><div class='progress-bar'><span></span></div>`,
[],
{ classes: "delete-posts-progress" }
);
},
performDelete = () => {
let deletedPercentage = 0;
return ajax(`/admin/users/${user.get("id")}/delete_posts_batch`, {
type: "PUT"
})
.then(({ posts_deleted }) => {
if (posts_deleted === 0) {
user.set("post_count", 0);
bootbox.hideAll();
} else {
deletedPosts += posts_deleted;
deletedPercentage = Math.floor(
(deletedPosts * 100) / user.get("post_count")
);
$(".delete-posts-progress .progress-bar > span").css({
width: `${deletedPercentage}%`
});
performDelete();
}
})
.catch(e => {
bootbox.hideAll();
let error;
AdminUser.find(user.get("id")).then(u => user.setProperties(u));
if (e.responseJSON && e.responseJSON.errors) {
error = e.responseJSON.errors[0];
}
error = error || I18n.t("admin.user.delete_posts_failed");
bootbox.alert(error);
});
};
.catch(e => {
bootbox.hideAll();
let error;
AdminUser.find(user.get("id")).then(u => user.setProperties(u));
if (e.responseJSON && e.responseJSON.errors) {
error = e.responseJSON.errors[0];
}
error = error || I18n.t("admin.user.delete_posts_failed");
bootbox.alert(error);
});
};
bootbox.dialog(message, buttons, { classes: "delete-all-posts" });
},
revokeAdmin() {
return ajax(`/admin/users/${this.get("id")}/revoke_admin`, {
return ajax(`/admin/users/${this.id}/revoke_admin`, {
type: "PUT"
}).then(() => {
this.setProperties({
@ -177,7 +180,7 @@ const AdminUser = Discourse.User.extend({
},
grantAdmin() {
return ajax(`/admin/users/${this.get("id")}/grant_admin`, {
return ajax(`/admin/users/${this.id}/grant_admin`, {
type: "PUT"
})
.then(() => {
@ -187,12 +190,11 @@ const AdminUser = Discourse.User.extend({
},
revokeModeration() {
const self = this;
return ajax("/admin/users/" + this.get("id") + "/revoke_moderation", {
return ajax(`/admin/users/${this.id}/revoke_moderation`, {
type: "PUT"
})
.then(function() {
self.setProperties({
.then(() => {
this.setProperties({
moderator: false,
can_grant_moderation: true,
can_revoke_moderation: false
@ -202,12 +204,11 @@ const AdminUser = Discourse.User.extend({
},
grantModeration() {
const self = this;
return ajax("/admin/users/" + this.get("id") + "/grant_moderation", {
return ajax(`/admin/users/${this.id}/grant_moderation`, {
type: "PUT"
})
.then(function() {
self.setProperties({
.then(() => {
this.setProperties({
moderator: true,
can_grant_moderation: false,
can_revoke_moderation: true
@ -217,7 +218,7 @@ const AdminUser = Discourse.User.extend({
},
disableSecondFactor() {
return ajax(`/admin/users/${this.get("id")}/disable_second_factor`, {
return ajax(`/admin/users/${this.id}/disable_second_factor`, {
type: "PUT"
})
.then(() => {
@ -227,11 +228,10 @@ const AdminUser = Discourse.User.extend({
},
approve() {
const self = this;
return ajax("/admin/users/" + this.get("id") + "/approve", {
return ajax(`/admin/users/${this.id}/approve`, {
type: "PUT"
}).then(function() {
self.setProperties({
}).then(() => {
this.setProperties({
can_approve: false,
approved: true,
approved_by: Discourse.User.current()
@ -240,20 +240,18 @@ const AdminUser = Discourse.User.extend({
},
setOriginalTrustLevel() {
this.set("originalTrustLevel", this.get("trust_level"));
this.set("originalTrustLevel", this.trust_level);
},
dirty: propertyNotEqual("originalTrustLevel", "trustLevel.id"),
saveTrustLevel() {
return ajax("/admin/users/" + this.id + "/trust_level", {
return ajax(`/admin/users/${this.id}/trust_level`, {
type: "PUT",
data: { level: this.get("trustLevel.id") }
})
.then(function() {
window.location.reload();
})
.catch(function(e) {
.then(() => window.location.reload())
.catch(e => {
let error;
if (e.responseJSON && e.responseJSON.errors) {
error = e.responseJSON.errors[0];
@ -261,25 +259,23 @@ const AdminUser = Discourse.User.extend({
error =
error ||
I18n.t("admin.user.trust_level_change_failed", {
error: "http: " + e.status + " - " + e.body
error: this._formatError(e)
});
bootbox.alert(error);
});
},
restoreTrustLevel() {
this.set("trustLevel.id", this.get("originalTrustLevel"));
this.set("trustLevel.id", this.originalTrustLevel);
},
lockTrustLevel(locked) {
return ajax("/admin/users/" + this.id + "/trust_level_lock", {
return ajax(`/admin/users/${this.id}/trust_level_lock`, {
type: "PUT",
data: { locked: !!locked }
})
.then(function() {
window.location.reload();
})
.catch(function(e) {
.then(() => window.location.reload())
.catch(e => {
let error;
if (e.responseJSON && e.responseJSON.errors) {
error = e.responseJSON.errors[0];
@ -287,23 +283,22 @@ const AdminUser = Discourse.User.extend({
error =
error ||
I18n.t("admin.user.trust_level_change_failed", {
error: "http: " + e.status + " - " + e.body
error: this._formatError(e)
});
bootbox.alert(error);
});
},
canLockTrustLevel: function() {
return this.get("trust_level") < 4;
}.property("trust_level"),
canLockTrustLevel: Ember.computed.lt("trust_level", 4),
canSuspend: Ember.computed.not("staff"),
suspendDuration: function() {
const suspended_at = moment(this.suspended_at),
suspended_till = moment(this.suspended_till);
return suspended_at.format("L") + " - " + suspended_till.format("L");
}.property("suspended_till", "suspended_at"),
@computed("suspended_till", "suspended_at")
suspendDuration(suspendedTill, suspendedAt) {
suspendedAt = moment(suspendedAt);
suspendedTill = moment(suspendedTill);
return suspendedAt.format("L") + " - " + suspendedTill.format("L");
},
suspend(data) {
return ajax(`/admin/users/${this.id}/suspend`, {
@ -321,21 +316,17 @@ const AdminUser = Discourse.User.extend({
logOut() {
return ajax("/admin/users/" + this.id + "/log_out", {
type: "POST",
data: { username_or_email: this.get("username") }
}).then(function() {
bootbox.alert(I18n.t("admin.user.logged_out"));
});
data: { username_or_email: this.username }
}).then(() => bootbox.alert(I18n.t("admin.user.logged_out")));
},
impersonate() {
return ajax("/admin/impersonate", {
type: "POST",
data: { username_or_email: this.get("username") }
data: { username_or_email: this.username }
})
.then(function() {
document.location = Discourse.getURL("/");
})
.catch(function(e) {
.then(() => (document.location = Discourse.getURL("/")))
.catch(e => {
if (e.status === 404) {
bootbox.alert(I18n.t("admin.impersonate.not_found"));
} else {
@ -345,31 +336,27 @@ const AdminUser = Discourse.User.extend({
},
activate() {
return ajax("/admin/users/" + this.id + "/activate", {
return ajax(`/admin/users/${this.id}/activate`, {
type: "PUT"
})
.then(function() {
window.location.reload();
})
.catch(function(e) {
var error = I18n.t("admin.user.activate_failed", {
error: "http: " + e.status + " - " + e.body
.then(() => window.location.reload())
.catch(e => {
const error = I18n.t("admin.user.activate_failed", {
error: this._formatError(e)
});
bootbox.alert(error);
});
},
deactivate() {
return ajax("/admin/users/" + this.id + "/deactivate", {
return ajax(`/admin/users/${this.id}/deactivate`, {
type: "PUT",
data: { context: document.location.pathname }
})
.then(function() {
window.location.reload();
})
.catch(function(e) {
var error = I18n.t("admin.user.deactivate_failed", {
error: "http: " + e.status + " - " + e.body
.then(() => window.location.reload())
.catch(e => {
const error = I18n.t("admin.user.deactivate_failed", {
error: this._formatError(e)
});
bootbox.alert(error);
});
@ -381,18 +368,14 @@ const AdminUser = Discourse.User.extend({
return ajax(`/admin/users/${this.id}/unsilence`, {
type: "PUT"
})
.then(result => {
this.setProperties(result.unsilence);
})
.then(result => this.setProperties(result.unsilence))
.catch(e => {
let error = I18n.t("admin.user.unsilence_failed", {
error: `http: ${e.status} - ${e.body}`
const error = I18n.t("admin.user.unsilence_failed", {
error: this._formatError(e)
});
bootbox.alert(error);
})
.finally(() => {
this.set("silencingUser", false);
});
.finally(() => this.set("silencingUser", false));
},
silence(data) {
@ -401,44 +384,38 @@ const AdminUser = Discourse.User.extend({
type: "PUT",
data
})
.then(result => {
this.setProperties(result.silence);
})
.then(result => this.setProperties(result.silence))
.catch(e => {
let error = I18n.t("admin.user.silence_failed", {
error: `http: ${e.status} - ${e.body}`
const error = I18n.t("admin.user.silence_failed", {
error: this._formatError(e)
});
bootbox.alert(error);
})
.finally(() => {
this.set("silencingUser", false);
});
.finally(() => this.set("silencingUser", false));
},
sendActivationEmail() {
return ajax(userPath("action/send_activation_email"), {
type: "POST",
data: { username: this.get("username") }
data: { username: this.username }
})
.then(function() {
bootbox.alert(I18n.t("admin.user.activation_email_sent"));
})
.then(() => bootbox.alert(I18n.t("admin.user.activation_email_sent")))
.catch(popupAjaxError);
},
anonymize() {
const user = this,
message = I18n.t("admin.user.anonymize_confirm");
const user = this;
const message = I18n.t("admin.user.anonymize_confirm");
const performAnonymize = function() {
return ajax("/admin/users/" + user.get("id") + "/anonymize.json", {
return ajax(`/admin/users/${user.get("id")}/anonymize.json`, {
type: "PUT"
})
.then(function(data) {
if (data.success) {
if (data.username) {
document.location = Discourse.getURL(
"/admin/users/" + user.get("id") + "/" + data.username
`/admin/users/${user.get("id")}/${data.username}`
);
} else {
document.location = Discourse.getURL("/admin/users/list/active");
@ -450,9 +427,7 @@ const AdminUser = Discourse.User.extend({
}
}
})
.catch(function() {
bootbox.alert(I18n.t("admin.user.anonymize_failed"));
});
.catch(() => bootbox.alert(I18n.t("admin.user.anonymize_failed")));
};
const buttons = [
@ -476,9 +451,9 @@ const AdminUser = Discourse.User.extend({
},
destroy(opts) {
const user = this,
message = I18n.t("admin.user.delete_confirm"),
location = document.location.pathname;
const user = this;
const message = I18n.t("admin.user.delete_confirm");
const location = document.location.pathname;
const performDestroy = function(block) {
bootbox.dialog(I18n.t("admin.user.deleting_user"));
@ -491,7 +466,7 @@ const AdminUser = Discourse.User.extend({
if (opts && opts.deletePosts) {
formData["delete_posts"] = true;
}
return ajax("/admin/users/" + user.get("id") + ".json", {
return ajax(`/admin/users/${user.get("id")}.json`, {
type: "DELETE",
data: formData
})
@ -543,15 +518,13 @@ const AdminUser = Discourse.User.extend({
},
loadDetails() {
const user = this;
if (user.get("loadedDetails")) {
return Ember.RSVP.resolve(user);
if (this.loadedDetails) {
return Ember.RSVP.resolve(this);
}
return AdminUser.find(user.get("id")).then(result => {
user.setProperties(result);
user.set("loadedDetails", true);
return AdminUser.find(this.id).then(result => {
const userProperties = Object.assign(result, { loadedDetails: true });
this.setProperties(userProperties);
});
},
@ -569,23 +542,25 @@ const AdminUser = Discourse.User.extend({
silencedBy: wrapAdmin,
@computed("approved_by")
approvedBy: wrapAdmin
approvedBy: wrapAdmin,
_formatError(event) {
return `http: ${event.status} - ${event.body}`;
}
});
AdminUser.reopenClass({
find(user_id) {
return ajax("/admin/users/" + user_id + ".json").then(result => {
return ajax(`/admin/users/${user_id}.json`).then(result => {
result.loadedDetails = true;
return AdminUser.create(result);
});
},
findAll(query, filter) {
return ajax("/admin/users/list/" + query + ".json", {
return ajax(`/admin/users/list/${query}.json`, {
data: filter
}).then(function(users) {
return users.map(u => AdminUser.create(u));
});
}).then(users => users.map(u => AdminUser.create(u)));
}
});

View File

@ -8,7 +8,7 @@ const ApiKey = Discourse.Model.extend({
regenerate() {
return ajax(KEY_ENDPOINT, {
type: "PUT",
data: { id: this.get("id") }
data: { id: this.id }
}).then(result => {
this.set("key", result.api_key.key);
return this;
@ -18,7 +18,7 @@ const ApiKey = Discourse.Model.extend({
revoke() {
return ajax(KEY_ENDPOINT, {
type: "DELETE",
data: { id: this.get("id") }
data: { id: this.id }
});
}
});

View File

@ -3,11 +3,11 @@ import { extractError } from "discourse/lib/ajax-error";
const Backup = Discourse.Model.extend({
destroy() {
return ajax("/admin/backups/" + this.get("filename"), { type: "DELETE" });
return ajax("/admin/backups/" + this.filename, { type: "DELETE" });
},
restore() {
return ajax("/admin/backups/" + this.get("filename") + "/restore", {
return ajax("/admin/backups/" + this.filename + "/restore", {
type: "POST",
data: { client_id: window.MessageBus.clientId }
});

View File

@ -8,7 +8,7 @@ import { propertyNotEqual, i18n } from "discourse/lib/computed";
const ColorSchemeColor = Discourse.Model.extend({
@on("init")
startTrackingChanges() {
this.set("originals", { hex: this.get("hex") || "FFFFFF" });
this.set("originals", { hex: this.hex || "FFFFFF" });
// force changed property to be recalculated
this.notifyPropertyChange("hex");
@ -17,8 +17,8 @@ const ColorSchemeColor = Discourse.Model.extend({
// Whether value has changed since it was last saved.
@computed("hex")
changed(hex) {
if (!this.get("originals")) return false;
if (hex !== this.get("originals").hex) return true;
if (!this.originals) return false;
if (hex !== this.originals.hex) return true;
return false;
},
@ -29,16 +29,16 @@ const ColorSchemeColor = Discourse.Model.extend({
// Whether the saved value is different than Discourse's default color scheme.
@computed("default_hex", "hex")
savedIsOverriden(defaultHex) {
return this.get("originals").hex !== defaultHex;
return this.originals.hex !== defaultHex;
},
revert() {
this.set("hex", this.get("default_hex"));
this.set("hex", this.default_hex);
},
undo() {
if (this.get("originals")) {
this.set("hex", this.get("originals").hex);
if (this.originals) {
this.set("hex", this.originals.hex);
}
},
@ -75,13 +75,8 @@ const ColorSchemeColor = Discourse.Model.extend({
@observes("hex")
hexValueChanged() {
if (this.get("hex")) {
this.set(
"hex",
this.get("hex")
.toString()
.replace(/[^0-9a-fA-F]/g, "")
);
if (this.hex) {
this.set("hex", this.hex.toString().replace(/[^0-9a-fA-F]/g, ""));
}
},

View File

@ -1,94 +1,80 @@
import { ajax } from "discourse/lib/ajax";
import ColorSchemeColor from "admin/models/color-scheme-color";
import computed from "ember-addons/ember-computed-decorators";
const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
init: function() {
init() {
this._super(...arguments);
this.startTrackingChanges();
},
description: function() {
@computed
description() {
return "" + this.name;
}.property(),
},
startTrackingChanges: function() {
this.set("originals", {
name: this.get("name")
});
startTrackingChanges() {
this.set("originals", { name: this.name });
},
schemeJson() {
let buffer = [];
this.get("colors").forEach(c => {
const buffer = [];
this.colors.forEach(c => {
buffer.push(` "${c.get("name")}": "${c.get("hex")}"`);
});
return [`"${this.get("name")}": {`, buffer.join(",\n"), "}"].join("\n");
return [`"${this.name}": {`, buffer.join(",\n"), "}"].join("\n");
},
copy: function() {
var newScheme = ColorScheme.create({
name: this.get("name"),
copy() {
const newScheme = ColorScheme.create({
name: this.name,
can_edit: true,
colors: Ember.A()
});
this.get("colors").forEach(c => {
this.colors.forEach(c => {
newScheme.colors.pushObject(
ColorSchemeColor.create({
name: c.get("name"),
hex: c.get("hex"),
default_hex: c.get("default_hex")
})
ColorSchemeColor.create(c.getProperties("name", "hex", "default_hex"))
);
});
return newScheme;
},
changed: function() {
@computed("name", "colors.@each.changed", "saving")
changed(name) {
if (!this.originals) return false;
if (this.originals["name"] !== this.get("name")) return true;
if (
_.any(this.get("colors"), function(c) {
return c.get("changed");
})
)
return true;
return false;
}.property("name", "colors.@each.changed", "saving"),
if (this.originals.name !== name) return true;
if (this.colors.any(c => c.get("changed"))) return true;
disableSave: function() {
if (this.get("theme_id")) {
return false;
},
@computed("changed")
disableSave(changed) {
if (this.theme_id) {
return false;
}
return (
!this.get("changed") ||
this.get("saving") ||
_.any(this.get("colors"), function(c) {
return !c.get("valid");
})
);
}.property("changed"),
newRecord: function() {
return !this.get("id");
}.property("id"),
return !changed || this.saving || this.colors.any(c => !c.get("valid"));
},
save: function(opts) {
if (this.get("is_base") || this.get("disableSave")) return;
newRecord: Ember.computed.not("id"),
var self = this;
this.set("savingStatus", I18n.t("saving"));
this.set("saving", true);
save(opts) {
if (this.is_base || this.disableSave) return;
var data = {};
this.setProperties({ savingStatus: I18n.t("saving"), saving: true });
const data = {};
if (!opts || !opts.enabledOnly) {
data.name = this.name;
data.base_scheme_id = this.get("base_scheme_id");
data.base_scheme_id = this.base_scheme_id;
data.colors = [];
this.get("colors").forEach(c => {
if (!self.id || c.get("changed")) {
data.colors.pushObject({ name: c.get("name"), hex: c.get("hex") });
this.colors.forEach(c => {
if (!this.id || c.get("changed")) {
data.colors.pushObject(c.getProperties("name", "hex"));
}
});
}
@ -101,33 +87,34 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
dataType: "json",
contentType: "application/json"
}
).then(function(result) {
).then(result => {
if (result.id) {
self.set("id", result.id);
this.set("id", result.id);
}
if (!opts || !opts.enabledOnly) {
self.startTrackingChanges();
self.get("colors").forEach(c => c.startTrackingChanges());
this.startTrackingChanges();
this.colors.forEach(c => c.startTrackingChanges());
}
self.set("savingStatus", I18n.t("saved"));
self.set("saving", false);
self.notifyPropertyChange("description");
this.setProperties({ savingStatus: I18n.t("saved"), saving: false });
this.notifyPropertyChange("description");
});
},
destroy: function() {
destroy() {
if (this.id) {
return ajax("/admin/color_schemes/" + this.id, { type: "DELETE" });
return ajax(`/admin/color_schemes/${this.id}`, { type: "DELETE" });
}
}
});
var ColorSchemes = Ember.ArrayProxy.extend({});
const ColorSchemes = Ember.ArrayProxy.extend({});
ColorScheme.reopenClass({
findAll: function() {
var colorSchemes = ColorSchemes.create({ content: [], loading: true });
return ajax("/admin/color_schemes").then(function(all) {
findAll() {
const colorSchemes = ColorSchemes.create({ content: [], loading: true });
return ajax("/admin/color_schemes").then(all => {
all.forEach(colorScheme => {
colorSchemes.pushObject(
ColorScheme.create({
@ -137,7 +124,7 @@ ColorScheme.reopenClass({
theme_id: colorScheme.theme_id,
theme_name: colorScheme.theme_name,
base_scheme_id: colorScheme.base_scheme_id,
colors: colorScheme.colors.map(function(c) {
colors: colorScheme.colors.map(c => {
return ColorSchemeColor.create({
name: c.name,
hex: c.hex,

Some files were not shown because too many files have changed in this diff Show More