-
Notifications
You must be signed in to change notification settings - Fork 0
FIX: proper handling of group memberships #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: group-dm-user-addition-pre
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,34 +1,69 @@ | ||||||||||||||||||||||||||
| export default Em.ObjectController.extend({ | ||||||||||||||||||||||||||
| needs: ['adminGroups'], | ||||||||||||||||||||||||||
| members: null, | ||||||||||||||||||||||||||
| disableSave: false, | ||||||||||||||||||||||||||
| usernames: null, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| currentPage: function() { | ||||||||||||||||||||||||||
| if (this.get("user_count") == 0) { return 0; } | ||||||||||||||||||||||||||
| return Math.floor(this.get("offset") / this.get("limit")) + 1; | ||||||||||||||||||||||||||
| }.property("limit", "offset", "user_count"), | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| totalPages: function() { | ||||||||||||||||||||||||||
| if (this.get("user_count") == 0) { return 0; } | ||||||||||||||||||||||||||
|
Comment on lines
+7
to
+12
|
||||||||||||||||||||||||||
| if (this.get("user_count") == 0) { return 0; } | |
| return Math.floor(this.get("offset") / this.get("limit")) + 1; | |
| }.property("limit", "offset", "user_count"), | |
| totalPages: function() { | |
| if (this.get("user_count") == 0) { return 0; } | |
| if (this.get("user_count") === 0) { return 0; } | |
| return Math.floor(this.get("offset") / this.get("limit")) + 1; | |
| }.property("limit", "offset", "user_count"), | |
| totalPages: function() { | |
| if (this.get("user_count") === 0) { return 0; } |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment indicates incomplete functionality. The usernames input should be cleared after successfully adding members to provide better user feedback.
| // TODO: should clear the input | |
| if (Em.isEmpty(this.get("usernames"))) { return; } | |
| this.get("model").addMembers(this.get("usernames")); | |
| if (Em.isEmpty(this.get("usernames"))) { return; } | |
| var usernames = this.get("usernames"); | |
| this.set("usernames", null); | |
| this.get("model").addMembers(usernames); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,53 @@ | ||
| {{#if automatic}} | ||
| <h3>{{name}}</h3> | ||
| {{else}} | ||
| {{text-field value=name placeholderKey="admin.groups.name_placeholder"}} | ||
| {{/if}} | ||
| <form class="form-horizontal"> | ||
|
|
||
| <div class="control-group"> | ||
| <label class="control-label">{{i18n 'admin.groups.group_members'}}</label> | ||
| <div class="controls"> | ||
| {{user-selector usernames=usernames id="group-users" placeholderKey="admin.groups.selector_placeholder" tabindex="1" disabled=automatic}} | ||
| <div> | ||
| {{#if automatic}} | ||
| <h3>{{name}}</h3> | ||
| {{else}} | ||
| <label for="name">{{i18n 'admin.groups.name'}}</label> | ||
| {{text-field name="name" value=name placeholderKey="admin.groups.name_placeholder"}} | ||
| {{/if}} | ||
| </div> | ||
| </div> | ||
| <div class="control-group"> | ||
| <div class="controls"> | ||
| {{input type="checkbox" checked=visible}} {{i18n 'groups.visible'}} | ||
|
|
||
| {{#if id}} | ||
| <div> | ||
| <label>{{i18n 'admin.groups.group_members'}} ({{user_count}})</label> | ||
| <div> | ||
| <a {{bind-attr class=":previous showingFirst:disabled"}} {{action "previous"}}>{{fa-icon "fast-backward"}}</a> | ||
| {{currentPage}}/{{totalPages}} | ||
| <a {{bind-attr class=":next showingLast:disabled"}} {{action "next"}}>{{fa-icon "fast-forward"}}</a> | ||
| </div> | ||
| <div class="ac-wrap clearfix"> | ||
| {{each member in members itemView="group-member"}} | ||
| </div> | ||
| </div> | ||
|
|
||
| {{#unless automatic}} | ||
| <div> | ||
| <label for="user-selector">{{i18n 'admin.groups.add_members'}}</label> | ||
| {{user-selector usernames=usernames placeholderKey="admin.groups.selector_placeholder" id="user-selector"}} | ||
| <button {{action "addMembers"}} class='btn add'>{{fa-icon "plus"}} {{i18n 'admin.groups.add'}}</button> | ||
| </div> | ||
| {{/unless}} | ||
| {{/if}} | ||
|
|
||
| <div> | ||
| <label> | ||
| {{input type="checkbox" checked=visible}} | ||
| {{i18n 'groups.visible'}} | ||
| </label> | ||
| </div> | ||
| </div> | ||
| <div class="control-group"> | ||
| <label class="control-label">{{i18n 'groups.alias_levels.title'}}</label> | ||
| <div class="controls"> | ||
| {{combo-box valueAttribute="value" value=alias_level content=aliasLevelOptions}} | ||
|
|
||
| <div> | ||
| <label for="alias">{{i18n 'groups.alias_levels.title'}}</label> | ||
| {{combo-box name="alias" valueAttribute="value" value=alias_level content=aliasLevelOptions}} | ||
| </div> | ||
| </div> | ||
| <div class='controls'> | ||
| <button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn'>{{i18n 'admin.customize.save'}}</button> | ||
| {{#unless automatic}} | ||
| <button {{action "destroy"}} class='btn btn-danger'><i class="fa fa-trash-o"></i>{{i18n 'admin.customize.delete'}}</button> | ||
| {{/unless}} | ||
| </div> | ||
|
|
||
| <div class='buttons'> | ||
| <button {{action "save"}} {{bind-attr disabled="disableSave"}} class='btn btn-primary'>{{i18n 'admin.customize.save'}}</button> | ||
| {{#unless automatic}} | ||
| <button {{action "destroy"}} class='btn btn-danger'>{{fa-icon "trash-o"}}{{i18n 'admin.customize.delete'}}</button> | ||
| {{/unless}} | ||
| </div> | ||
|
|
||
| </form> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {{avatar member imageSize="small"}} {{member.username}} {{#unless automatic}}<a class='remove' {{action "removeMember" member}}>{{fa-icon "times"}}</a>{{/unless}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export default Discourse.View.extend({ | ||
| classNames: ["item"], | ||
| templateName: "admin/templates/group_member" | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,53 +7,80 @@ | |||||
| @module Discourse | ||||||
| **/ | ||||||
| Discourse.Group = Discourse.Model.extend({ | ||||||
| limit: 50, | ||||||
| offset: 0, | ||||||
| user_count: 0, | ||||||
|
|
||||||
| userCountDisplay: function(){ | ||||||
| var c = this.get('user_count'); | ||||||
| // don't display zero its ugly | ||||||
| if(c > 0) { | ||||||
| return c; | ||||||
| } | ||||||
| if (c > 0) { return c; } | ||||||
| }.property('user_count'), | ||||||
|
|
||||||
| findMembers: function() { | ||||||
| if (Em.isEmpty(this.get('name'))) { return Ember.RSVP.resolve([]); } | ||||||
| if (Em.isEmpty(this.get('name'))) { return ; } | ||||||
|
||||||
| if (Em.isEmpty(this.get('name'))) { return ; } | |
| if (Em.isEmpty(this.get('name'))) { return Ember.RSVP.resolve(); } |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return statement returns undefined instead of a Promise. This breaks consistency with other methods that return Promises. Change to return Ember.RSVP.resolve(); to maintain consistent return type.
| if (!this.get('id')) { return }; | |
| if (!this.get('id')) { return Ember.RSVP.resolve(); } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1 @@ | ||
|
|
||
| <input type="text"> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict equality (
===) instead of loose equality (==) for comparisons to avoid type coercion issues.