You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/01/22 22:39:50 UTC
[whimsy] branch master updated: allow multiple people to be added
at once
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new dea4f00 allow multiple people to be added at once
dea4f00 is described below
commit dea4f0098696f8faa4294059930f4e2176530aea
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Jan 22 17:39:28 2017 -0500
allow multiple people to be added at once
---
www/roster/views/actions/ppmc.json.rb | 19 ++++++++++----
www/roster/views/ppmc/confirm.js.rb | 4 +--
www/roster/views/ppmc/main.js.rb | 1 +
www/roster/views/ppmc/members.js.rb | 47 +++++++++++++++++++++++++++--------
4 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/www/roster/views/actions/ppmc.json.rb b/www/roster/views/actions/ppmc.json.rb
index 4824fd2..8cd5281 100644
--- a/www/roster/views/actions/ppmc.json.rb
+++ b/www/roster/views/actions/ppmc.json.rb
@@ -1,28 +1,37 @@
if env.password
- person = ASF::Person.find(@id)
+ people = @ids.split(',').map {|id| ASF::Person.find(id)}
project = ASF::Project.find(@ppmc)
# update LDAP
ASF::LDAP.bind(env.user, env.password) do
if @action == 'add'
- project.add(person)
+ project.add(people)
elsif @action == 'remove'
- project.remove(person)
+ project.remove(people)
end
end
# compose E-mail
action = (@action == 'add' ? 'added to' : 'removed from')
- details = [person.dn, project.dn]
+ details = people.map {|person| person.dn} + [project.dn]
from = ASF::Person.find(env.user)
ppmc = ASF::Podling.find(@ppmc)
+ # extract people's names (for short lists) or ids (for longer lists)
+ if people.length <= 2
+ who = people.map {|person| person.public_name}.join(' and ')
+ else
+ who = people[0..-2].map {|person| person.id}.join(', ') +
+ ', and ' + person.last.id
+ end
+
+ # draft email
mail = Mail.new do
from "#{from.public_name} <#{...@apache.org>".untaint
to ppmc.private_mail_list.untaint
cc 'private@incubator.apache.org'
bcc 'root@apache.org'
- subject "#{person.public_name} #{action} #{ppmc.display_name} PPMC"
+ subject "#{who} #{action} #{ppmc.display_name} PPMC"
body "Current roster can be found at:\n\n" +
" https://whimsy.apache.org/roster/ppmc/#{ppmc.id}\n\n" +
"LDAP details:\n\n #{details.join("\n ")}"
diff --git a/www/roster/views/ppmc/confirm.js.rb b/www/roster/views/ppmc/confirm.js.rb
index ebbde69..2ff8f5e 100644
--- a/www/roster/views/ppmc/confirm.js.rb
+++ b/www/roster/views/ppmc/confirm.js.rb
@@ -38,7 +38,7 @@ class PPMCConfirm < React
def componentDidMount()
jQuery('#confirm').on('show.bs.modal') do |event|
button = event.relatedTarget
- @id = button.parentNode.dataset.id
+ @ids = button.parentNode.dataset.ids
@action = button.dataset.action
@text = button.dataset.confirmation
@color = button.classList[1]
@@ -56,7 +56,7 @@ class PPMCConfirm < React
method: 'post',
credentials: 'include',
headers: {'Content-Type' => 'application/json'},
- body: {ppmc: @@ppmc, id: @id, action: action, targets: targets}.inspect
+ body: {ppmc: @@ppmc, ids: @ids, action: action, targets: targets}.inspect
}
@disabled = true
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index be6c907..28267ea 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -22,6 +22,7 @@ class PPMC < React
_span 'Double click on a row to show actions.'
unless @ppmc.roster.keys().empty?
_span " Click on \u2795 to add."
+ _span " Multiple people can be added with a single confirmation."
end
end
end
diff --git a/www/roster/views/ppmc/members.js.rb b/www/roster/views/ppmc/members.js.rb
index f519798..cb00c60 100644
--- a/www/roster/views/ppmc/members.js.rb
+++ b/www/roster/views/ppmc/members.js.rb
@@ -9,6 +9,8 @@ class PPMCMembers < React
end
def render
+ pending = []
+
_h2.pmc! 'PPMC'
_table.table.table_hover do
_thead do
@@ -22,6 +24,28 @@ class PPMCMembers < React
_tbody do
@roster.each do |person|
_PPMCMember auth: @@auth, person: person, ppmc: @@ppmc
+ pending << person.id if person.status == :pending
+ end
+
+ if pending.length > 1
+ _tr do
+ _td colspan: 2
+ _td data_ids: pending.join(',') do
+
+ # produce a list of ids to be added
+ if pending.length == 2
+ list = "#{pending[0]} and #{pending[1]}"
+ else
+ list = pending[0..-2].join(', ') + ", and " + pending[-1]
+ end
+
+ _button.btn.btn_success 'Add all to the PPMC',
+ data_action: 'add',
+ data_target: '#confirm', data_toggle: 'modal',
+ data_confirmation: "Add #{list} to the " +
+ "#{@@ppmc.display_name} PPMC?"
+ end
+ end
end
if @@auth and not @@ppmc.roster.keys().empty?
@@ -32,11 +56,12 @@ class PPMCMembers < React
end
end
- if @state == :open
- _div.search_box do
- _CommitterSearch add: self.add, exclude: @roster.map {|person| person.id}
- end
- end
+ if @state == :open
+ _div.search_box do
+ _CommitterSearch add: self.add,
+ exclude: @roster.map {|person| person.id}
+ end
+ end
end
# update props on initial load
@@ -66,7 +91,7 @@ class PPMCMembers < React
# add a person to the displayed list of PMC members
def add(person)
- person.status = 'pending'
+ person.status = :pending
@roster << person
@state = :closed
end
@@ -92,9 +117,9 @@ class PPMCMember < React
_td @@person.name
end
- _td data_id: @@person.id do
+ _td data_ids: @@person.id do
if @state == :open
- if @@person.status == 'pending'
+ if @@person.status == :pending
_button.btn.btn_primary 'Add to the PPMC',
data_action: 'add',
data_target: '#confirm', data_toggle: 'modal',
@@ -107,8 +132,8 @@ class PPMCMember < React
data_confirmation: "Remove #{@@person.name} from the " +
"#{@@ppmc.display_name} PPMC?"
end
- elsif @@person.status == 'pending'
- _span'pending'
+ elsif @@person.status == :pending
+ _span 'pending'
elsif @@ppmc.mentors.include? @@person.id
_span.chair 'mentor'
end
@@ -124,7 +149,7 @@ class PPMCMember < React
# automatically open pending entries
def componentWillReceiveProps(newprops)
@state = :closed if newprops.person.id != self.props.person.id
- @state = :open if @@person.status == 'pending'
+ @state = :open if @@person.status == :pending
end
# toggle display of buttons
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].