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 2016/09/18 03:11:26 UTC
[whimsy] branch master updated: rough in grant
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 1f54393 rough in grant
1f54393 is described below
commit 1f543937bf98b0c7b081a4b88346b5985f420235
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sat Sep 17 23:11:09 2016 -0400
rough in grant
---
www/secmail/public/secmail.css | 4 +-
www/secmail/tasks.rb | 5 +
www/secmail/templates/grant.erb | 10 +-
www/secmail/templates/icla.erb | 2 +-
www/secmail/views/actions/ccla.json.rb | 3 +-
.../views/actions/{ccla.json.rb => grant.json.rb} | 59 ++++------
www/secmail/views/actions/icla.json.rb | 3 +-
www/secmail/views/forms/grant.js.rb | 122 ++++++++++++++++++++-
8 files changed, 156 insertions(+), 52 deletions(-)
diff --git a/www/secmail/public/secmail.css b/www/secmail/public/secmail.css
index 2510e05..3b93e3f 100644
--- a/www/secmail/public/secmail.css
+++ b/www/secmail/public/secmail.css
@@ -56,11 +56,11 @@ table.form {
margin-top: 2em;
}
-.form input {
+.form input, .form textarea {
width: 100%;
}
-.form input:invalid {
+.form input:invalid, .form textarea:invalid {
border: 1px solid red;
}
diff --git a/www/secmail/tasks.rb b/www/secmail/tasks.rb
index a560ae1..2c835f9 100644
--- a/www/secmail/tasks.rb
+++ b/www/secmail/tasks.rb
@@ -19,6 +19,11 @@ class Wunderbar::JsonBuilder
@_target[:tasklist].last[:form] << ['input', '', *args]
end
+ def _textarea *args
+ return if @task
+ @_target[:tasklist].last[:form] << ['textarea', *args]
+ end
+
def _message mail
if @task
super
diff --git a/www/secmail/templates/grant.erb b/www/secmail/templates/grant.erb
index 54ae4b4..5513903 100644
--- a/www/secmail/templates/grant.erb
+++ b/www/secmail/templates/grant.erb
@@ -1,13 +1,7 @@
-to: <%= @gname.inspect %> <<%= @gemail %>>
-from: <%= @from %>
-cc: secretary@apache.org
-bcc: <%= @bcc %>
-subject: Your Grant sent to Apache Secretary
-
-Dear <%= @gname %>,
+Dear <%= @name %>,
This message acknowledges receipt of the following document, which has been filed in the Apache Software Foundation records:
- <%= @commit_message %>
+ <%= @document %>
<%= @sig %>
diff --git a/www/secmail/templates/icla.erb b/www/secmail/templates/icla.erb
index 257f8d7..ef8d367 100644
--- a/www/secmail/templates/icla.erb
+++ b/www/secmail/templates/icla.erb
@@ -1,4 +1,4 @@
-Dear <%= @email.display_names.join(', ') %>,
+Dear <%= @pubname %>,
This message acknowledges receipt of your ICLA, which has been filed in the Apache Software Foundation records.
diff --git a/www/secmail/views/actions/ccla.json.rb b/www/secmail/views/actions/ccla.json.rb
index df40163..32c2bf4 100644
--- a/www/secmail/views/actions/ccla.json.rb
+++ b/www/secmail/views/actions/ccla.json.rb
@@ -119,10 +119,9 @@ end
# send confirmation email
task "email #@email" do
# build mail from template
- @email = message.from
mail = message.reply(
from: @from,
- to: @email.addrs,
+ to: "#{@contact.inspect} <#{@email}>",
cc: [
'secretary@apache.org',
("private@#{pmc.mail_list}.apache.org" if pmc), # copy pmc
diff --git a/www/secmail/views/actions/ccla.json.rb b/www/secmail/views/actions/grant.json.rb
similarity index 63%
copy from www/secmail/views/actions/ccla.json.rb
copy to www/secmail/views/actions/grant.json.rb
index df40163..110e997 100644
--- a/www/secmail/views/actions/ccla.json.rb
+++ b/www/secmail/views/actions/grant.json.rb
@@ -1,7 +1,7 @@
#
# File an ICLA:
-# - add files to documents/cclas
-# - add entry to officers/cclas.txt
+# - add files to documents/grants
+# - add entry to officers/grants.txt
# - respond to original email
#
@@ -32,14 +32,14 @@ end
_personalize_email(env.user)
# initialize commit message
-@document = "CCLA from #{@company}"
+@document = "Software Grant from #{@company}"
########################################################################
-# document/cclas #
+# document/grants #
########################################################################
-# write attachment (+ signature, if present) to the documents/cclas directory
-task "svn commit documents/cclas/#@filename#{fileext}" do
+# write attachment (+ signature, if present) to the documents/grants directory
+task "svn commit documents/grants/#@filename#{fileext}" do
form do
_input value: @selected, name: 'selected'
@@ -51,44 +51,33 @@ task "svn commit documents/cclas/#@filename#{fileext}" do
complete do |dir|
# checkout empty directory
svn 'checkout', '--depth', 'empty',
- 'https://svn.apache.org/repos/private/documents/cclas', "#{dir}/cclas"
+ 'https://svn.apache.org/repos/private/documents/grants', "#{dir}/grants"
# create/add file(s)
- dest = message.write_svn("#{dir}/cclas", @filename, @selected, @signature)
+ dest = message.write_svn("#{dir}/grants", @filename, @selected, @signature)
# Show files to be added
- svn 'status', "#{dir}/cclas"
+ svn 'status', "#{dir}/grants"
# commit changes
- svn 'commit', "#{dir}/cclas/#{@filename}#{fileext}", '-m', @document
+ svn 'commit', "#{dir}/grants/#{@filename}#{fileext}", '-m', @document
end
end
########################################################################
-# officers/cclas.txt #
+# officers/grants.txt #
########################################################################
-# insert line into iclas.txt
-task "svn commit foundation/officers/cclas.txt" do
+# insert line into grants.txt
+task "svn commit foundation/officers/grants.txt" do
# construct line to be inserted
- @cclalines = "notinavail:" + @company.strip
-
- unless @contact.empty?
- @cclalines += " - #{@contact.strip}"
- end
-
- @cclalines += ":#{@email.strip}:Signed Corp CLA"
-
- unless @employees.empty?
- @cclalines += " for #{@employees.strip.gsub(/\s*\n\s*/, ', ')}"
- end
-
- unless @product.empty?
- @cclalines += " for #{@product.strip}"
- end
+ @grantlines = "#{@company.strip}" +
+ "\n file: #{@filename}#{fileext}" +
+ "\n for: #{@description.strip.gsub(/\r?\n\s*/,"\n ")}"
form do
- _input value: @cclalines, name: 'cclalines'
+ _textarea @grantlines, name: 'grantlines',
+ rows: @grantlines.split("\n").length
end
complete do |dir|
@@ -97,12 +86,12 @@ task "svn commit foundation/officers/cclas.txt" do
'https://svn.apache.org/repos/private/foundation/officers',
"#{dir}/officers"
- # retrieve cclas.txt
- dest = "#{dir}/officers/cclas.txt"
+ # retrieve grants.txt
+ dest = "#{dir}/officers/grants.txt"
svn 'update', dest
- # update cclas.txt
- File.write dest, File.read(dest) + @cclalines + "\n"
+ # update grants.txt
+ File.write dest, File.read(dest) + @grantlines + "\n"
# show the changes
svn 'diff', dest
@@ -119,16 +108,14 @@ end
# send confirmation email
task "email #@email" do
# build mail from template
- @email = message.from
mail = message.reply(
from: @from,
- to: @email.addrs,
cc: [
'secretary@apache.org',
("private@#{pmc.mail_list}.apache.org" if pmc), # copy pmc
(podling.private_mail_list if podling) # copy podling
],
- body: template('ccla.erb')
+ body: template('grant.erb')
)
# echo email
diff --git a/www/secmail/views/actions/icla.json.rb b/www/secmail/views/actions/icla.json.rb
index d686072..88048c2 100644
--- a/www/secmail/views/actions/icla.json.rb
+++ b/www/secmail/views/actions/icla.json.rb
@@ -112,10 +112,9 @@ end
# send confirmation email
task "email #@email" do
# build mail from template
- @email = message.from
mail = message.reply(
from: @from,
- to: @email.addrs,
+ to: "#{@name.inspect} <#{@email}>",
cc: [
'secretary@apache.org',
("private@#{pmc.mail_list}.apache.org" if pmc), # copy pmc
diff --git a/www/secmail/views/forms/grant.js.rb b/www/secmail/views/forms/grant.js.rb
index 1a8cccd..56bbc41 100644
--- a/www/secmail/views/forms/grant.js.rb
+++ b/www/secmail/views/forms/grant.js.rb
@@ -1,5 +1,125 @@
class Grant < React
+ def initialize
+ @filed = false
+ @submitted = false
+ end
+
def render
- _p 'Software Grant'
+ _h4 'Grant'
+
+ _div.buttons do
+ _button 'clear form', onClick: -> {@name = @email = ''}
+ end
+
+ _form method: 'post', action: '../../tasklist/grant', target: 'content' do
+ _input type: 'hidden', name: 'message'
+ _input type: 'hidden', name: 'selected'
+ _input type: 'hidden', name: 'signature', value: @@signature
+
+ _table.form do
+ _tr do
+ _th 'From'
+ _td do
+ _input name: 'company', value: @company, required: true,
+ disabled: @filed
+ end
+ end
+
+ _tr do
+ _th 'For'
+ _td do
+ _textarea name: 'description', value: @description, rows: 5,
+ required: true, disabled: @filed
+ end
+ end
+
+ _tr do
+ _th 'Signed By'
+ _td do
+ _input name: 'name', value: @name, required: true, disabled: @filed
+ end
+ end
+
+ _tr do
+ _th 'E-mail'
+ _td do
+ _input name: 'email', value: @email, required: true, type: 'email',
+ disabled: @filed
+ end
+ end
+
+ _tr do
+ _th 'File Name'
+ _td do
+ _input name: 'filename', value: @filename, required: true,
+ pattern: '[a-zA-Z][-\w]+(\.[a-z]+)?', disabled: @filed
+ end
+ end
+
+ _tr do
+ _th 'Project'
+ _td do
+ _input name: 'project', value: @project, disabled: @filed
+ end
+ end
+ end
+
+ _input.btn.btn_primary value: 'File', type: 'submit', ref: 'file'
+ end
+ end
+
+ # on initial display, default various fields based on headers, and update
+ # state
+ def componentDidMount()
+ name = @@headers.name
+
+ # reorder name if there is a single comma present
+ parts = name.split(',')
+ if parts.length == 2 and parts[1] !~ /^\s*(jr|ph\.d)\.?$/i
+ name = "#{parts[1].strip()} #{parts[0]}"
+ end
+
+ @name = name
+ @email = @@headers.from
+ self.componentDidUpdate()
+
+ # watch for status updates
+ window.addEventListener 'message', self.status_update
+ end
+
+ def componentWillUnmount()
+ window.removeEventListener 'message', self.status_update
+ end
+
+ # as fields change, enable/disable the associated buttons and adjust
+ # input requirements.
+ def componentDidUpdate()
+ # Grant file form
+ valid = %w(company name email filename).all? do |name|
+ document.querySelector("input[name=#{name}]").validity.valid
+ end
+
+ valid &= document.querySelector("textarea[name=description]").validity.valid
+
+ $file.disabled = !valid or @filed or @submitted
+
+ # wire up form
+ jQuery('form')[0].addEventListener('submit', self.file)
+ jQuery('input[name=message]').val(window.parent.location.pathname)
+ jQuery('input[name=selected]').val(@@selected)
+ end
+
+ # handle Grant form submission
+ def file(event)
+ setTimeout 0 do
+ @submitted = true
+ @filed = true
+ end
+ end
+
+ # when tasks complete (or are aborted) reset form
+ def status_update(event)
+ @submitted = false
+ @filed = false
end
end
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].