diff --git a/.eslintignore b/.eslintignore index 644318acf68..cc014c8b92f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,7 +11,6 @@ lib/javascripts/messageformat.js lib/javascripts/moment.js lib/javascripts/moment_locale/ lib/highlight_js/ -lib/es6_module_transpiler/support/es6-module-transpiler.js public/javascripts/ spec/phantom_js/smoke_test.js vendor/ diff --git a/.eslintrc b/.eslintrc index 4148a259baa..86bdc29e2ad 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,28 +6,27 @@ "browser": true, "builtin": true }, - ecmaVersion: 7, + "parserOptions": { + "ecmaVersion": 7, + "sourceType": "module" + }, "globals": {"Ember":true, "jQuery":true, "$":true, + "QUnit":true, "RSVP":true, "Discourse":true, "Em":true, "Handlebars":true, "I18n":true, "bootbox":true, - "module":true, "moduleFor":true, "moduleForComponent":true, "Pretender":true, "sandbox":true, "controllerFor":true, "test":true, - "ok":true, - "not":true, - "expect":true, - "equal":true, "visit":true, "andThen":true, "click":true, @@ -48,12 +47,8 @@ "find":true, "sinon":true, "moment":true, - "start":true, "_":true, "alert":true, - "containsInstance":true, - "deepEqual":true, - "notEqual":true, "define":true, "require":true, "requirejs":true, diff --git a/.image_optim.yml b/.image_optim.yml deleted file mode 100644 index 746b85dc3b4..00000000000 --- a/.image_optim.yml +++ /dev/null @@ -1,12 +0,0 @@ -skip_missing_workers: true -allow_lossy: false -# PNG -advpng: false -optipng: - level: 2 -pngcrush: false -pngout: false -pngquant: false -# JPG -jpegrecompress: false -timeout: 15 diff --git a/.travis.yml b/.travis.yml index 1c681386e01..25827245817 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,7 @@ env: - RUBY_GC_MALLOC_LIMIT=50000000 matrix: - "RAILS_MASTER=0 QUNIT_RUN=0" - - "RAILS_MASTER=1 QUNIT_RUN=0" - "RAILS_MASTER=0 QUNIT_RUN=1" - - "RAILS_MASTER=1 QUNIT_RUN=1" addons: postgresql: 9.5 @@ -20,9 +18,6 @@ addons: - jhead matrix: - allow_failures: - - env: "RAILS_MASTER=1 QUNIT_RUN=0" - - env: "RAILS_MASTER=1 QUNIT_RUN=1" fast_finish: true rvm: @@ -36,6 +31,7 @@ sudo: required dist: trusty cache: + yarn: true directories: - vendor/bundle @@ -46,7 +42,7 @@ before_install: - git clone --depth=1 https://github.com/discourse/discourse-cakeday.git plugins/discourse-cakeday - git clone --depth=1 https://github.com/discourse/discourse-canned-replies.git plugins/discourse-canned-replies - git clone --depth=1 https://github.com/discourse/discourse-slack-official.git plugins/discourse-slack-official - - npm i -g eslint babel-eslint + - yarn global add eslint babel-eslint - eslint app/assets/javascripts - eslint --ext .es6 app/assets/javascripts - eslint --ext .es6 test/javascripts @@ -61,4 +57,4 @@ install: - bash -c "if [ '$RAILS_MASTER' == '0' ]; then bundle install --without development --deployment --retry=3 --jobs=3; fi" script: - - bash -c "if [ '$QUNIT_RUN' == '0' ]; then bundle exec rspec && bundle exec rake plugin:spec; else bundle exec rake qunit:test['200000']; fi" + - bash -c "if [ '$QUNIT_RUN' == '0' ]; then bundle exec rspec && bundle exec rake plugin:spec; else LOAD_PLUGINS=1 bundle exec rake qunit:test['300000']; fi" diff --git a/.tx/config b/.tx/config index bd09128d4c4..77c2f933219 100644 --- a/.tx/config +++ b/.tx/config @@ -26,12 +26,6 @@ source_file = plugins/poll/config/locales/server.en.yml source_lang = en type = YML -[discourse-org.imgurserverenyml] -file_filter = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server..yml -source_file = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.en.yml -source_lang = en -type = YML - [discourse-org.narrativeclientenyml] file_filter = plugins/discourse-narrative-bot/config/locales/client..yml source_file = plugins/discourse-narrative-bot/config/locales/client.en.yml diff --git a/Gemfile b/Gemfile index a3222a8b26c..091bf3fd1eb 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ end gem 'mail' gem 'mime-types', require: 'mime/types/columnar' +gem 'mini_mime' gem 'hiredis' gem 'redis', require: ["redis", "redis/connection/hiredis"] @@ -48,10 +49,9 @@ gem 'onebox' gem 'http_accept_language', '~>2.0.5', require: false gem 'ember-rails', '0.18.5' -gem 'ember-source', '2.10.0' +gem 'ember-source' gem 'ember-handlebars-template', '0.7.5' gem 'barber' -gem 'babel-transpiler' gem 'message_bus' @@ -74,6 +74,10 @@ gem 'discourse_image_optim', require: 'image_optim' gem 'multi_json' gem 'mustache' gem 'nokogiri' + +# this may end up deprecating nokogiri +gem 'oga', require: false + gem 'omniauth' gem 'omniauth-openid' gem 'openid-redis-store' @@ -94,13 +98,13 @@ gem 'r2', '~> 0.2.5', require: false gem 'rake' gem 'thor', require: false -gem 'rest-client' gem 'rinku' gem 'sanitize' gem 'sidekiq' # for sidekiq web -gem 'sinatra', require: false +gem 'tilt', require: false + gem 'execjs', require: false gem 'mini_racer' gem 'highline', require: false @@ -118,7 +122,6 @@ group :test do gem 'webmock', require: false gem 'fakeweb', '~> 1.3.0', require: false gem 'minitest', require: false - gem 'timecop' # TODO: Remove once we upgrade to Rails 5. gem 'test_after_commit' end diff --git a/Gemfile.lock b/Gemfile.lock index 1b617ecdee2..dce01c3c166 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,20 +39,18 @@ GEM tzinfo (~> 1.1) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) - annotate (2.7.1) + annotate (2.7.2) activerecord (>= 3.2, < 6.0) - rake (>= 10.4, < 12.0) + rake (>= 10.4, < 13.0) + ansi (1.5.0) arel (6.0.4) + ast (2.3.0) aws-sdk (2.5.3) aws-sdk-resources (= 2.5.3) aws-sdk-core (2.5.3) jmespath (~> 1.0) aws-sdk-resources (2.5.3) aws-sdk-core (= 2.5.3) - babel-source (5.8.34) - babel-transpiler (0.7.0) - babel-source (>= 4.0, < 6) - execjs (~> 2.0) barber (0.11.2) ember-source (>= 1.0, < 3) execjs (>= 1.2, < 3) @@ -62,21 +60,21 @@ GEM rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootsnap (0.3.0) + bootsnap (1.0.0) msgpack (~> 1.0) builder (3.2.3) - bullet (5.4.2) + bullet (5.5.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.10.0) byebug (9.0.6) certified (1.0.0) coderay (1.1.1) concurrent-ruby (1.0.5) - connection_pool (2.2.0) + connection_pool (2.2.1) crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.2) - debug_inspector (0.0.2) + debug_inspector (0.0.3) diff-lcs (1.3) discourse-qunit-rails (0.0.9) railties @@ -86,8 +84,6 @@ GEM image_size (~> 1.5) in_threads (~> 1.3) progress (~> 3.0, >= 3.0.1) - domain_name (0.5.25) - unf (>= 0.0.5, < 1.0.0) email_reply_trimmer (0.1.6) ember-data-source (2.2.1) ember-source (>= 1.8, < 3.0) @@ -101,9 +97,9 @@ GEM ember-source (>= 1.1.0) jquery-rails (>= 1.0.17) railties (>= 3.1) - ember-source (2.10.0) + ember-source (2.13.3) erubis (2.7.0) - excon (0.55.0) + excon (0.56.0) execjs (2.7.0) exifr (1.2.5) fabrication (2.9.8) @@ -118,32 +114,30 @@ GEM fastimage (2.1.0) ffi (1.9.18) flamegraph (0.9.5) - foreman (0.82.0) + foreman (0.84.0) thor (~> 0.19.1) fspath (3.1.0) gc_tracer (1.5.1) - globalid (0.3.7) - activesupport (>= 4.1.0) + globalid (0.4.0) + activesupport (>= 4.2.0) guess_html_encoding (0.0.11) hashdiff (0.3.4) hashie (3.5.5) highline (1.7.8) hiredis (0.6.1) htmlentities (4.3.4) - http-cookie (1.0.2) - domain_name (~> 0.5) http_accept_language (2.0.5) - i18n (0.8.1) + i18n (0.8.4) image_size (1.5.0) in_threads (1.4.0) jmespath (1.3.1) - jquery-rails (4.2.1) + jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jwt (1.5.6) kgio (2.11.0) - libv8 (5.3.332.38.5) + libv8 (5.7.492.65.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -152,31 +146,31 @@ GEM loofah (2.0.3) nokogiri (>= 1.5.9) lru_redux (1.1.0) - mail (2.6.6.rc1) + mail (2.6.6) mime-types (>= 1.16, < 4) - memory_profiler (0.9.7) + memory_profiler (0.9.8) message_bus (2.0.2) rack (>= 1.1.3) metaclass (0.0.4) method_source (0.8.2) mime-types (2.99.3) - mini_portile2 (2.1.0) - mini_racer (0.1.9) - libv8 (~> 5.3) - minitest (5.10.1) - mocha (1.1.0) + mini_mime (0.1.3) + mini_portile2 (2.2.0) + mini_racer (0.1.11) + libv8 (~> 5.7) + minitest (5.10.2) + mocha (1.2.1) metaclass (~> 0.0.1) - mock_redis (0.15.4) + mock_redis (0.17.3) moneta (1.0.0) msgpack (1.1.0) multi_json (1.12.1) multi_xml (0.6.0) multipart-post (2.0.0) mustache (1.0.5) - netrc (0.11.0) - nokogiri (1.7.2) - mini_portile2 (~> 2.1.0) - nokogumbo (1.4.10) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) + nokogumbo (1.4.13) nokogiri oauth (0.5.1) oauth2 (1.3.1) @@ -185,7 +179,10 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - oj (3.0.5) + oga (2.10) + ast + ruby-ll (~> 2.1) + oj (3.1.0) omniauth (1.6.1) hashie (>= 3.4.6, < 3.6.0) rack (>= 1.6.2, < 3) @@ -214,7 +211,7 @@ GEM omniauth-twitter (1.3.0) omniauth-oauth (~> 1.1) rack - onebox (1.8.10) + onebox (1.8.16) fast_blank (>= 1.0.0) htmlentities (~> 4.3) moneta (~> 1.0) @@ -225,7 +222,7 @@ GEM openid-redis-store (0.0.2) redis ruby-openid - pg (0.19.0) + pg (0.20.0) progress (3.3.1) pry (0.10.4) coderay (~> 1.1.0) @@ -236,10 +233,10 @@ GEM pry-rails (0.3.4) pry (>= 0.9.10) public_suffix (2.0.5) - puma (3.6.0) + puma (3.9.1) r2 (0.2.6) rack (1.6.8) - rack-mini-profiler (0.10.4) + rack-mini-profiler (0.10.5) rack (>= 1.2.0) rack-openid (1.3.1) rack (>= 1.1.0) @@ -275,84 +272,79 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.18.0) - rake (11.3.0) - rake-compiler (0.9.9) + rake (12.0.0) + rake-compiler (1.0.4) rake - rb-fsevent (0.9.7) - rb-inotify (0.9.7) + rb-fsevent (0.9.8) + rb-inotify (0.9.8) ffi (>= 0.5.0) rbtrace (0.4.8) ffi (>= 1.0.6) msgpack (>= 0.4.3) trollop (>= 1.16.2) redis (3.3.3) - redis-namespace (1.5.2) + redis-namespace (1.5.3) redis (~> 3.0, >= 3.0.4) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rinku (2.0.0) + rinku (2.0.2) rmmseg-cpp (0.2.9) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-html-matchers (0.7.0) + rspec-support (~> 3.6.0) + rspec-html-matchers (0.9.1) nokogiri (~> 1) - rspec (~> 3) - rspec-mocks (3.4.1) + rspec (>= 3.0.0.a, < 4) + rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-rails (3.4.2) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) + rspec-support (~> 3.6.0) + rspec-rails (3.6.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) rtlit (0.0.5) + ruby-ll (2.1.2) + ansi + ast ruby-openid (2.7.0) ruby-readability (0.7.0) guess_html_encoding (>= 0.0.4) nokogiri (>= 1.6.0) ruby_dep (1.5.0) safe_yaml (1.0.4) - sanitize (4.4.0) + sanitize (4.5.0) crass (~> 1.0.2) nokogiri (>= 1.4.4) nokogumbo (~> 1.4.1) - sass (3.4.23) + sass (3.4.24) sassc (1.11.2) bundler ffi (~> 1.9.6) sass (>= 3.3.0) - seed-fu (2.3.5) - activerecord (>= 3.1, < 4.3) - activesupport (>= 3.1, < 4.3) + seed-fu (2.3.6) + activerecord (>= 3.1) + activesupport (>= 3.1) shoulda (3.5.0) shoulda-context (~> 1.0, >= 1.0.1) shoulda-matchers (>= 1.4.1, < 3.0) shoulda-context (1.2.2) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) - sidekiq (4.2.4) + sidekiq (5.0.3) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) - redis (~> 3.2, >= 3.2.1) + redis (~> 3.3, >= 3.3.3) simple-rss (1.3.1) - sinatra (1.4.6) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) slop (3.6.0) spork (1.0.0rc4) spork-rails (4.0.0) @@ -370,16 +362,15 @@ GEM activerecord (>= 3.2) thor (0.19.4) thread_safe (0.3.6) - tilt (2.0.5) - timecop (0.8.1) + tilt (2.0.7) trollop (2.1.2) tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (3.0.2) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.1) + unf_ext (0.0.7.4) unicorn (5.3.0) kgio (~> 2.6) raindrops (~> 0.7) @@ -396,7 +387,6 @@ DEPENDENCIES active_model_serializers (~> 0.8.3) annotate aws-sdk - babel-transpiler barber better_errors binding_of_caller @@ -409,7 +399,7 @@ DEPENDENCIES email_reply_trimmer (= 0.1.6) ember-handlebars-template (= 0.7.5) ember-rails (= 0.18.5) - ember-source (= 2.10.0) + ember-source excon execjs fabrication (= 2.9.8) @@ -432,6 +422,7 @@ DEPENDENCIES memory_profiler message_bus mime-types + mini_mime mini_racer minitest mocha @@ -439,6 +430,7 @@ DEPENDENCIES multi_json mustache nokogiri + oga oj omniauth omniauth-facebook @@ -465,7 +457,6 @@ DEPENDENCIES rbtrace redis redis-namespace - rest-client rinku rmmseg-cpp rspec @@ -479,16 +470,15 @@ DEPENDENCIES shoulda sidekiq simple-rss - sinatra spork-rails stackprof test_after_commit thor - timecop + tilt uglifier unf unicorn webmock BUNDLED WITH - 1.14.6 + 1.15.1 diff --git a/app/assets/javascripts/admin/components/ip-lookup.js.es6 b/app/assets/javascripts/admin/components/ip-lookup.js.es6 index 0c9b73d54ac..a185e4c0b6e 100644 --- a/app/assets/javascripts/admin/components/ip-lookup.js.es6 +++ b/app/assets/javascripts/admin/components/ip-lookup.js.es6 @@ -1,4 +1,5 @@ import { ajax } from 'discourse/lib/ajax'; +import AdminUser from 'admin/models/admin-user'; export default Ember.Component.extend({ classNames: ["ip-lookup"], @@ -44,7 +45,6 @@ export default Ember.Component.extend({ self.set("totalOthersWithSameIP", result.total); }); - const AdminUser = require('admin/models/admin-user').default; AdminUser.findAll("active", data).then(function (users) { self.setProperties({ other_accounts: users, diff --git a/app/assets/javascripts/admin/components/permalink-form.js.es6 b/app/assets/javascripts/admin/components/permalink-form.js.es6 index 2bde845c0c6..90dcf2a7b20 100644 --- a/app/assets/javascripts/admin/components/permalink-form.js.es6 +++ b/app/assets/javascripts/admin/components/permalink-form.js.es6 @@ -1,3 +1,5 @@ +import Permalink from 'admin/models/permalink'; + export default Ember.Component.extend({ classNames: ['permalink-form'], formSubmitted: false, @@ -18,8 +20,6 @@ export default Ember.Component.extend({ actions: { submit: function() { - const Permalink = require('admin/models/permalink').default; - if (!this.get('formSubmitted')) { const self = this; self.set('formSubmitted', true); diff --git a/app/assets/javascripts/admin/controllers/admin-email-preview-digest.js.es6 b/app/assets/javascripts/admin/controllers/admin-email-preview-digest.js.es6 index 8065d732fcc..eb03301c92d 100644 --- a/app/assets/javascripts/admin/controllers/admin-email-preview-digest.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-email-preview-digest.js.es6 @@ -2,11 +2,13 @@ import EmailPreview from 'admin/models/email-preview'; import { popupAjaxError } from 'discourse/lib/ajax-error'; export default Ember.Controller.extend({ + username: null, + lastSeen: null, - emailEmpty: Em.computed.empty('email'), - sendEmailDisabled: Em.computed.or('emailEmpty', 'sendingEmail'), - showSendEmailForm: Em.computed.notEmpty('model.html_content'), - htmlEmpty: Em.computed.empty('model.html_content'), + emailEmpty: Ember.computed.empty('email'), + sendEmailDisabled: Ember.computed.or('emailEmpty', 'sendingEmail'), + showSendEmailForm: Ember.computed.notEmpty('model.html_content'), + htmlEmpty: Ember.computed.empty('model.html_content'), actions: { refresh() { @@ -14,7 +16,14 @@ export default Ember.Controller.extend({ this.set('loading', true); this.set('sentEmail', false); - EmailPreview.findDigest(this.get('lastSeen'), this.get('username')).then(email => { + + let username = this.get('username'); + if (!username) { + username = this.currentUser.get('username'); + this.set('username', username); + } + + EmailPreview.findDigest(username, this.get('lastSeen')).then(email => { model.setProperties(email.getProperties('html_content', 'text_content')); this.set('loading', false); }); @@ -28,16 +37,14 @@ export default Ember.Controller.extend({ this.set('sendingEmail', true); this.set('sentEmail', false); - const self = this; - - EmailPreview.sendDigest(this.get('lastSeen'), this.get('username'), this.get('email')).then(result => { + EmailPreview.sendDigest(this.get('username'), this.get('lastSeen'), this.get('email')).then(result => { if (result.errors) { bootbox.alert(result.errors); } else { - self.set('sentEmail', true); + this.set('sentEmail', true); } - }).catch(popupAjaxError).finally(function() { - self.set('sendingEmail', false); + }).catch(popupAjaxError).finally(() => { + this.set('sendingEmail', false); }); } } diff --git a/app/assets/javascripts/admin/controllers/admin-group.js.es6 b/app/assets/javascripts/admin/controllers/admin-group.js.es6 index a0f4961b62f..52dbc07791b 100644 --- a/app/assets/javascripts/admin/controllers/admin-group.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-group.js.es6 @@ -15,6 +15,15 @@ export default Ember.Controller.extend({ ]; }.property(), + visibilityLevelOptions: function() { + return [ + { name: I18n.t("groups.visibility_levels.public"), value: 0 }, + { name: I18n.t("groups.visibility_levels.members"), value: 1 }, + { name: I18n.t("groups.visibility_levels.staff"), value: 2 }, + { name: I18n.t("groups.visibility_levels.owners"), value: 3 } + ]; + }.property(), + trustLevelOptions: function() { return [ { name: I18n.t("groups.trust_levels.none"), value: 0 }, @@ -22,14 +31,16 @@ export default Ember.Controller.extend({ ]; }.property(), - @computed('model.visible', 'model.public') - disableMembershipRequestSetting(visible, publicGroup) { - return !visible || publicGroup; + @computed('model.visibility_level', 'model.public') + disableMembershipRequestSetting(visibility_level, publicGroup) { + visibility_level = parseInt(visibility_level); + return (visibility_level !== 0) || publicGroup; }, - @computed('model.visible', 'model.allow_membership_requests') - disablePublicSetting(visible, allowMembershipRequests) { - return !visible || allowMembershipRequests; + @computed('model.visibility_level', 'model.allow_membership_requests') + disablePublicSetting(visibility_level, allowMembershipRequests) { + visibility_level = parseInt(visibility_level); + return (visibility_level !== 0) || allowMembershipRequests; }, actions: { diff --git a/app/assets/javascripts/admin/models/api-key.js.es6 b/app/assets/javascripts/admin/models/api-key.js.es6 index 2a7cf867783..024a1433929 100644 --- a/app/assets/javascripts/admin/models/api-key.js.es6 +++ b/app/assets/javascripts/admin/models/api-key.js.es6 @@ -1,4 +1,6 @@ +import AdminUser from 'admin/models/admin-user'; import { ajax } from 'discourse/lib/ajax'; + const ApiKey = Discourse.Model.extend({ /** @@ -36,8 +38,7 @@ ApiKey.reopenClass({ @param {...} var_args the properties to initialize this with @returns {ApiKey} the ApiKey instance **/ - create: function() { - const AdminUser = require('admin/models/admin-user').default; + create() { var result = this._super.apply(this, arguments); if (result.user) { result.user = AdminUser.create(result.user); diff --git a/app/assets/javascripts/admin/models/email-preview.js.es6 b/app/assets/javascripts/admin/models/email-preview.js.es6 index acc7462b925..2aaca02d1e7 100644 --- a/app/assets/javascripts/admin/models/email-preview.js.es6 +++ b/app/assets/javascripts/admin/models/email-preview.js.es6 @@ -1,42 +1,24 @@ import { ajax } from 'discourse/lib/ajax'; const EmailPreview = Discourse.Model.extend({}); +export function oneWeekAgo() { + return moment().locale('en').subtract(7, 'days').format('YYYY-MM-DD'); +} + EmailPreview.reopenClass({ - findDigest: function(lastSeenAt, username) { - - if (Em.isEmpty(lastSeenAt)) { - lastSeenAt = this.oneWeekAgo(); - } - - if (Em.isEmpty(username)) { - username = Discourse.User.current().username; - } + findDigest(username, lastSeenAt) { return ajax("/admin/email/preview-digest.json", { - data: { last_seen_at: lastSeenAt, username: username } - }).then(function (result) { - return EmailPreview.create(result); - }); + data: { last_seen_at: lastSeenAt || oneWeekAgo(), username } + }).then(result => EmailPreview.create(result)); }, - sendDigest: function(lastSeenAt, username, email) { - if (Em.isEmpty(lastSeenAt)) { - lastSeenAt = this.oneWeekAgo(); - } - - if (Em.isEmpty(username)) { - username = Discourse.User.current().username; - } - + sendDigest(username, lastSeenAt, email) { return ajax("/admin/email/send-digest.json", { - data: { last_seen_at: lastSeenAt, username: username, email: email } + data: { last_seen_at: lastSeenAt || oneWeekAgo(), username, email } }); }, - oneWeekAgo() { - const en = moment().locale('en'); - return en.subtract(7, 'days').format('YYYY-MM-DD'); - } }); export default EmailPreview; diff --git a/app/assets/javascripts/admin/models/web-hook.js.es6 b/app/assets/javascripts/admin/models/web-hook.js.es6 index 325d9310452..27d72878b08 100644 --- a/app/assets/javascripts/admin/models/web-hook.js.es6 +++ b/app/assets/javascripts/admin/models/web-hook.js.es6 @@ -37,7 +37,7 @@ export default RestModel.extend({ }, groupFinder(term) { - return Group.findAll({search: term, ignore_automatic: false}); + return Group.findAll({ term: term, ignore_automatic: false }); }, @computed('wildcard_web_hook', 'web_hook_event_types.[]') @@ -82,4 +82,3 @@ export default RestModel.extend({ return this.createProperties(); } }); - diff --git a/app/assets/javascripts/admin/routes/admin-email-preview-digest.js.es6 b/app/assets/javascripts/admin/routes/admin-email-preview-digest.js.es6 index 7ca2f727722..0ee7b697554 100644 --- a/app/assets/javascripts/admin/routes/admin-email-preview-digest.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-email-preview-digest.js.es6 @@ -1,16 +1,17 @@ -import EmailPreview from 'admin/models/email-preview'; +import { default as EmailPreview, oneWeekAgo } from 'admin/models/email-preview'; export default Discourse.Route.extend({ model() { - return EmailPreview.findDigest(); + return EmailPreview.findDigest(this.currentUser.get('username')); }, afterModel(model) { const controller = this.controllerFor('adminEmailPreviewDigest'); controller.setProperties({ - model: model, - lastSeen: moment().subtract(7, 'days').format('YYYY-MM-DD'), + model, + username: this.currentUser.get('username'), + lastSeen: oneWeekAgo(), showHtml: true }); } diff --git a/app/assets/javascripts/admin/routes/admin-group.js.es6 b/app/assets/javascripts/admin/routes/admin-group.js.es6 index 3575496edd4..0009f834e13 100644 --- a/app/assets/javascripts/admin/routes/admin-group.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-group.js.es6 @@ -4,7 +4,7 @@ export default Discourse.Route.extend({ model(params) { if (params.name === 'new') { - return Group.create({ automatic: false, visible: true }); + return Group.create({ automatic: false, visibility_level: 0 }); } const group = this.modelFor('adminGroupsType').findBy('name', params.name); diff --git a/app/assets/javascripts/admin/routes/admin-reports.js.es6 b/app/assets/javascripts/admin/routes/admin-reports.js.es6 index 47ece705808..65771110e86 100644 --- a/app/assets/javascripts/admin/routes/admin-reports.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-reports.js.es6 @@ -1,16 +1,9 @@ -/** - Handles routes for admin reports +import Report from 'admin/models/report'; - @class AdminReportsRoute - @extends Discourse.Route - @namespace Discourse - @module Discourse -**/ export default Discourse.Route.extend({ queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} }, - model: function(params) { - const Report = require('admin/models/report').default; + model(params) { return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']); }, diff --git a/app/assets/javascripts/admin/templates/components/site-settings/string.hbs b/app/assets/javascripts/admin/templates/components/site-settings/string.hbs index 71d7216f273..77e254b42f2 100644 --- a/app/assets/javascripts/admin/templates/components/site-settings/string.hbs +++ b/app/assets/javascripts/admin/templates/components/site-settings/string.hbs @@ -1,3 +1,8 @@ -{{text-field value=value classNames="input-setting-string"}} +{{#if setting.textarea}} + {{textarea value=value classNames="input-setting-textarea"}} +{{else}} + {{text-field value=value classNames="input-setting-string"}} +{{/if}} + {{setting-validation-message message=validationMessage}}
{{{unbound setting.description}}}
diff --git a/app/assets/javascripts/admin/templates/email-preview-digest.hbs b/app/assets/javascripts/admin/templates/email-preview-digest.hbs index 7f31c6e9bf2..87372268c74 100644 --- a/app/assets/javascripts/admin/templates/email-preview-digest.hbs +++ b/app/assets/javascripts/admin/templates/email-preview-digest.hbs @@ -1,11 +1,11 @@

{{i18n 'admin.email.preview_digest_desc'}}

-
+