From a95bb6006df83956d6dc215b3e43425ea571da6d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 21 Sep 2016 17:15:57 -0400 Subject: [PATCH] Show staff count on invites page, don't warn if you have 3 --- .../javascripts/wizard/components/invite-list.js.es6 | 6 +++++- .../javascripts/wizard/components/staff-count.js.es6 | 7 +++++++ .../wizard/templates/components/staff-count.hbs | 5 +++++ app/assets/stylesheets/wizard.scss | 4 ++++ config/locales/client.en.yml | 4 ++++ lib/wizard/builder.rb | 4 ++++ 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/wizard/components/staff-count.js.es6 create mode 100644 app/assets/javascripts/wizard/templates/components/staff-count.hbs diff --git a/app/assets/javascripts/wizard/components/invite-list.js.es6 b/app/assets/javascripts/wizard/components/invite-list.js.es6 index daa9ee61ac3..6d70da3ed80 100644 --- a/app/assets/javascripts/wizard/components/invite-list.js.es6 +++ b/app/assets/javascripts/wizard/components/invite-list.js.es6 @@ -29,7 +29,11 @@ export default Ember.Component.extend({ const users = this.get('users'); this.set('field.value', JSON.stringify(users)); - this.set('field.warning', users.length ? null : 'invites.none_added'); + + const staffCount = this.get('step.fieldsById.staff_count.value'); + const showWarning = (staffCount < 3 && users.length === 0); + + this.set('field.warning', showWarning ? 'invites.none_added' : null); }, actions: { diff --git a/app/assets/javascripts/wizard/components/staff-count.js.es6 b/app/assets/javascripts/wizard/components/staff-count.js.es6 new file mode 100644 index 00000000000..023d556f9bd --- /dev/null +++ b/app/assets/javascripts/wizard/components/staff-count.js.es6 @@ -0,0 +1,7 @@ +import computed from 'ember-addons/ember-computed-decorators'; + +export default Ember.Component.extend({ + @computed('field.value') + showStaffCount: staffCount => staffCount > 1 +}); + diff --git a/app/assets/javascripts/wizard/templates/components/staff-count.hbs b/app/assets/javascripts/wizard/templates/components/staff-count.hbs new file mode 100644 index 00000000000..e8f6a1f2f13 --- /dev/null +++ b/app/assets/javascripts/wizard/templates/components/staff-count.hbs @@ -0,0 +1,5 @@ +{{#if showStaffCount}} +
+ {{i18n "wizard.staff_count" count=field.value}} +
+{{/if}} diff --git a/app/assets/stylesheets/wizard.scss b/app/assets/stylesheets/wizard.scss index 3324237759a..bae9a0f28c8 100644 --- a/app/assets/stylesheets/wizard.scss +++ b/app/assets/stylesheets/wizard.scss @@ -48,6 +48,10 @@ body.wizard { z-index: 10; } +.staff-count { + font-weight: bold; +} + .wizard-step-emoji { .radio-area { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1cef9f93d90..d34ad061dd1 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3236,6 +3236,10 @@ en: uploading: "Uploading..." quit: "Maybe Later" + staff_count: + one: "Your forum currently has 1 staff member. " + other: "Your forum currently has %{count} staff members." + invites: add_user: "add" none_added: "You haven’t invited any staff. Are you sure you want to continue?" diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb index 7726e36976f..f8a7360fa1c 100644 --- a/lib/wizard/builder.rb +++ b/lib/wizard/builder.rb @@ -209,6 +209,10 @@ class Wizard end @wizard.append_step('invites') do |step| + + staff_count = User.where("moderator = true or admin = true").where("id <> ?", Discourse.system_user.id).count + step.add_field(id: 'staff_count', type: 'component', value: staff_count) + step.add_field(id: 'invite_list', type: 'component') step.on_update do |updater|