diff --git a/.travis.yml b/.travis.yml index cb8c3c021c..465c6366df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,7 @@ before_install: - git clone --depth=1 https://github.com/discourse/discourse-spoiler-alert.git plugins/discourse-spoiler-alert - 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 - eslint app/assets/javascripts - eslint --ext .es6 app/assets/javascripts diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 index 14bc031c0a..175463c0a1 100644 --- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 @@ -1,8 +1,12 @@ import { ajax } from 'discourse/lib/ajax'; import CanCheckEmails from 'discourse/mixins/can-check-emails'; import { propertyNotEqual, setting } from 'discourse/lib/computed'; +import { userPath } from 'discourse/lib/url'; +import { popupAjaxError } from 'discourse/lib/ajax-error'; export default Ember.Controller.extend(CanCheckEmails, { + editingUsername: false, + editingName: false, editingTitle: false, originalPrimaryGroupId: null, availableGroups: null, @@ -54,23 +58,58 @@ export default Ember.Controller.extend(CanCheckEmails, { anonymize() { return this.get('model').anonymize(); }, destroy() { return this.get('model').destroy(); }, + toggleUsernameEdit() { + this.set('userUsernameValue', this.get('model.username')); + this.toggleProperty('editingUsername'); + }, + + saveUsername() { + const oldUsername = this.get('model.username'); + this.set('model.username', this.get('userUsernameValue')); + + return ajax(`/users/${oldUsername.toLowerCase()}/preferences/username`, { + data: { new_username: this.get('userUsernameValue') }, + type: 'PUT' + }).catch(e => { + this.set('model.username', oldUsername); + popupAjaxError(e); + }).finally(() => this.toggleProperty('editingUsername')); + }, + + toggleNameEdit() { + this.set('userNameValue', this.get('model.name')); + this.toggleProperty('editingName'); + }, + + saveName() { + const oldName = this.get('model.name'); + this.set('model.name', this.get('userNameValue')); + + return ajax(userPath(`${this.get('model.username').toLowerCase()}.json`), { + data: { name: this.get('userNameValue') }, + type: 'PUT' + }).catch(e => { + this.set('model.name', oldName); + popupAjaxError(e); + }).finally(() => this.toggleProperty('editingName')); + }, + toggleTitleEdit() { this.set('userTitleValue', this.get('model.title')); this.toggleProperty('editingTitle'); }, saveTitle() { - const self = this; + const prevTitle = this.get('userTitleValue'); - return ajax(`/users/${this.get('model.username').toLowerCase()}.json`, { + this.set('model.title', this.get('userTitleValue')); + return ajax(userPath(`${this.get('model.username').toLowerCase()}.json`), { data: {title: this.get('userTitleValue')}, type: 'PUT' - }).catch(function(e) { - bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body})); - }).finally(function() { - self.set('model.title', self.get('userTitleValue')); - self.toggleProperty('editingTitle'); - }); + }).catch(e => { + this.set('model.title', prevTitle); + popupAjaxError(e); + }).finally(() => this.toggleProperty('editingTitle')); }, generateApiKey() { diff --git a/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6 index 0d8aec0771..43af644266 100644 --- a/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-users-list-show.js.es6 @@ -7,7 +7,7 @@ import { observes } from 'ember-addons/ember-computed-decorators'; export default Ember.Controller.extend({ query: null, queryParams: ['order', 'ascending'], - order: 'seen', + order: null, ascending: null, showEmails: false, refreshing: false, diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6 index 48764b671d..b1e1202a90 100644 --- a/app/assets/javascripts/admin/models/admin-user.js.es6 +++ b/app/assets/javascripts/admin/models/admin-user.js.es6 @@ -5,6 +5,7 @@ import { popupAjaxError } from 'discourse/lib/ajax-error'; import ApiKey from 'admin/models/api-key'; import Group from 'discourse/models/group'; import TL3Requirements from 'admin/models/tl3-requirements'; +import { userPath } from 'discourse/lib/url'; const AdminUser = Discourse.User.extend({ @@ -114,11 +115,10 @@ const AdminUser = Discourse.User.extend({ }, revokeAdmin() { - const self = this; - return ajax("/admin/users/" + this.get('id') + "/revoke_admin", { + return ajax(`/admin/users/${this.get('id')}/revoke_admin`, { type: 'PUT' - }).then(function() { - self.setProperties({ + }).then(() => { + this.setProperties({ admin: false, can_grant_admin: true, can_revoke_admin: false @@ -127,15 +127,10 @@ const AdminUser = Discourse.User.extend({ }, grantAdmin() { - const self = this; - return ajax("/admin/users/" + this.get('id') + "/grant_admin", { + return ajax(`/admin/users/${this.get('id')}/grant_admin`, { type: 'PUT' - }).then(function() { - self.setProperties({ - admin: true, - can_grant_admin: false, - can_revoke_admin: true - }); + }).then(() => { + bootbox.alert(I18n.t("admin.user.grant_admin_confirm")); }).catch(popupAjaxError); }, @@ -346,7 +341,7 @@ const AdminUser = Discourse.User.extend({ }, sendActivationEmail() { - return ajax('/users/action/send_activation_email', { + return ajax(userPath('action/send_activation_email'), { type: 'POST', data: { username: this.get('username') } }).then(function() { diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs index 923fb1c09b..f172c65124 100644 --- a/app/assets/javascripts/admin/templates/user-index.hbs +++ b/app/assets/javascripts/admin/templates/user-index.hbs @@ -22,18 +22,40 @@
{{i18n "login.provide_new_email"}}
+ {{input value=newEmail class="activate-new-email"}} +{{/d-modal-body}} + + diff --git a/app/assets/javascripts/discourse/templates/modal/activation-resent.hbs b/app/assets/javascripts/discourse/templates/modal/activation-resent.hbs new file mode 100644 index 0000000000..e694c838bf --- /dev/null +++ b/app/assets/javascripts/discourse/templates/modal/activation-resent.hbs @@ -0,0 +1,5 @@ +{{#d-modal-body}} + {{{i18n 'login.sent_activation_email_again' currentEmail=currentEmail}}} +{{/d-modal-body}} + +{{modal-footer-close closeModal=(action "closeModal")}} diff --git a/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs b/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs deleted file mode 100644 index d5dcb92fa6..0000000000 --- a/app/assets/javascripts/discourse/templates/modal/edit-topic-auto-close.hbs +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/app/assets/javascripts/discourse/templates/modal/edit-topic-status-update.hbs b/app/assets/javascripts/discourse/templates/modal/edit-topic-status-update.hbs new file mode 100644 index 0000000000..8fca98f413 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/modal/edit-topic-status-update.hbs @@ -0,0 +1,103 @@ + diff --git a/app/assets/javascripts/discourse/templates/modal/not-activated.hbs b/app/assets/javascripts/discourse/templates/modal/not-activated.hbs index f8e4aeee29..4ed586628b 100644 --- a/app/assets/javascripts/discourse/templates/modal/not-activated.hbs +++ b/app/assets/javascripts/discourse/templates/modal/not-activated.hbs @@ -1,12 +1,14 @@ {{#d-modal-body}} - {{#if emailSent}} - {{{i18n 'login.sent_activation_email_again' currentEmail=currentEmail}}} - {{else}} - {{{i18n 'login.not_activated' sentTo=sentTo}}} - {{i18n 'login.resend_activation_email'}} - {{/if}} + {{{i18n 'login.not_activated' sentTo=sentTo}}} {{/d-modal-body}} diff --git a/app/assets/javascripts/discourse/templates/preferences.hbs b/app/assets/javascripts/discourse/templates/preferences.hbs index 4be554bdf6..6fea4f7f6f 100644 --- a/app/assets/javascripts/discourse/templates/preferences.hbs +++ b/app/assets/javascripts/discourse/templates/preferences.hbs @@ -263,12 +263,14 @@ -<%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/users/#{topic.user.username_lower}")).html_safe %>
+<%= t('author_wrote', author: link_to("@#{username}", "#{Discourse.base_url}/u/#{topic.user.username_lower}")).html_safe %>
<% end %><%= topic.posts.first.cooked.html_safe %> diff --git a/app/views/robots_txt/index.erb b/app/views/robots_txt/index.erb index 8ae193da42..e4c6a446bc 100644 --- a/app/views/robots_txt/index.erb +++ b/app/views/robots_txt/index.erb @@ -10,6 +10,7 @@ Disallow: /auth/github/callback Disallow: /auth/cas/callback Disallow: /assets/browser-update*.js Disallow: /users/ +Disallow: /u/ Disallow: /badges/ Disallow: /search Disallow: /search/ diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 73ef1724b6..e24626f203 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -46,7 +46,7 @@ <% if (u = post.user) %>- <%= u.username %> + <%= u.username %> <%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>