whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: General UI tweaks
Date Mon, 02 Jul 2018 15:46:40 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 8962630  General UI tweaks
8962630 is described below

commit 8962630c1d363753dca12c058be1e14bd28d917f
Author: Sebb <sebb@apache.org>
AuthorDate: Mon Jul 2 16:46:38 2018 +0100

    General UI tweaks
    
    Use a single hash for all the data
    Use display_name where relevant
    Tweak Ponymail URLs
---
 www/project/icla/main.rb                  | 43 +++++++------------
 www/project/icla/views/app.html.rb        |  2 +-
 www/project/icla/views/pages/invite.js.rb | 69 ++++++++++++++++++++-----------
 3 files changed, 61 insertions(+), 53 deletions(-)

diff --git a/www/project/icla/main.rb b/www/project/icla/main.rb
index 5229ce2..3b26efd 100755
--- a/www/project/icla/main.rb
+++ b/www/project/icla/main.rb
@@ -18,25 +18,21 @@ disable :logging # suppress log of requests to stderr/error.log
 
 helpers do
   def projectsForUser(userName)
-    pmcs = ASF::Committee.pmcs.map(&:name).sort
-    ppmcs = ASF::Podling.list.
-      select {|podling| podling.status == 'current'}.
-      map(&:name).sort
     user = ASF::Person.find(userName)
     committees = user.committees.map(&:name)
-    pmcs.select! {|pmc| committees.include?(pmc)}
-    ppmcs.select! {|ppmc|
-      committees.include?('incubator') |
-      committees.include?(ppmc)}
-    # mailList is a hash where the key is the name of the PMC/PPMC and
-    # the value is the name of the mail list for the committee
-    mailList = pmcs.map{|pmc| [pmc, ASF::Committee.find(pmc).mail_list]}.to_h.
-      merge(ppmcs.map{|ppmc| [ppmc, ASF::Podling.find(ppmc).mail_list]}.to_h)
-    hash = {
-      'pmcs' => pmcs,
-      'ppmcs' => ppmcs,
-      'pmcmail' => mailList
-    }
+
+    # allData is a hash where the key is the name of the PMC/PPMC and
+    # the value is a hash of the data for the PMC/PPMC
+    pmcData = ASF::Committee.pmcs. # get PMCs
+      select {|pmc| committees.include?(pmc.name)}. # keep the ones relevant to the user
+      sort_by{|p| p.name}.
+      map{|p| [p.name, {pmc: true, display_name: p.display_name, mail_list: p.mail_list}]}.to_h
 # convert to hash of data items
+    ppmcData =   
+      ASF::Podling.list.select {|podling| podling.status == 'current'}. # get the podlings
+      select {|p| committees.include?('incubator') || committees.include?(p.name)}. # keep
the ones relevant to the user
+      sort_by{|p| p.name}.
+      map{|p| [p.name, {pmc: false, display_name: p.display_name, mail_list: p.mail_list}]}.to_h
# convert to hash of data items
+    pmcData.merge(ppmcData)
   end
   def loadProgress(token)
     if @token
@@ -99,10 +95,7 @@ get '/invite' do
   @user = env.user
   @member = getMember(@user)
   # get a complete list of PMC and PPMC names and mail lists
-  projects = projectsForUser(@member)
-  @pmcs = projects['pmcs']
-  @ppmcs = projects['ppmcs']
-  @pmc_mail = projects['pmcmail']
+  @allData = projectsForUser(@member)
 
   @cssmtime = File.mtime('public/css/icla.css').to_i
   @appmtime = Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
@@ -122,9 +115,7 @@ get '/discuss' do
   loadProgress(@token) if @token
 
   # not needed for this form but required for other forms
-  @pmcs = []
-  @ppmcs = []
-  @pmc_mail = {}
+  @allData = {}
 
   @cssmtime = File.mtime('public/css/icla.css').to_i
   @appmtime = Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
@@ -143,9 +134,7 @@ get '/vote' do
   loadProgress(@token) if @token
 
   # not needed for this form but required for other forms
-  @pmcs = []
-  @ppmcs = []
-  @pmc_mail = {}
+  @allData = {}
 
   @cssmtime = File.mtime('public/css/icla.css').to_i
   @appmtime = Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
diff --git a/www/project/icla/views/app.html.rb b/www/project/icla/views/app.html.rb
index 8f966ea..c9887ce 100755
--- a/www/project/icla/views/app.html.rb
+++ b/www/project/icla/views/app.html.rb
@@ -373,7 +373,7 @@ _html lang: 'en', _width: '80' do
     _script src: "app.js?#{@appmtime}"
 
     _.render '#main' do
-      _Main data: {pmcs: @pmcs, ppmcs: @ppmcs, pmc_mail: @pmc_mail,
+      _Main data: {allData: @allData,
         token: @token, progress: @progress, user: @user, member: @member,
         debug: @debug},
         view: @view
diff --git a/www/project/icla/views/pages/invite.js.rb b/www/project/icla/views/pages/invite.js.rb
index 49d3c46..31bfdd1 100644
--- a/www/project/icla/views/pages/invite.js.rb
+++ b/www/project/icla/views/pages/invite.js.rb
@@ -18,7 +18,6 @@ class Invite < Vue
     @pmcOrPpmc = ''
     @phasePrefix = ''
     @member = Server.data.member
-    @pmc_mail = Server.data.pmc_mail
     @user = Server.data.user
 
 # initialize conditional text
@@ -89,12 +88,12 @@ class Invite < Vue
       _label "PMC/PPMC (required)", for: 'pmc'
       _select.form_control.pmc! required: true, onChange: self.setPMC, value: @pmc do
         _option ''
-        Server.data.pmcs.each do |pmc|
-          _option pmc
+        Server.data.allData.each_key do |pmc|
+          _option pmc if Server.data.allData[pmc]['pmc']
         end
         _option '---'
-        Server.data.ppmcs.each do |ppmc|
-          _option ppmc
+        Server.data.allData.each_key do |ppmc|
+          _option ppmc unless Server.data.allData[ppmc]['pmc']
         end
       end
     end
@@ -130,7 +129,7 @@ class Invite < Vue
     end
     if @showPMCVoteLink or @showPPMCVoteLink
       _ 'Navigate to '
-      _a "ponymail", href: "https://lists.apache.org"
+      _a "Ponymail", href: "https://lists.apache.org/list.html?private@#{@mail_list}.apache.org:lte=1M:[VOTE][RESULT]",
target: _blank
       _ ', select the appropriate message, right-click PermaLink, copy link'
       _ ' to the clip-board, and paste the link here.'
       _p
@@ -163,6 +162,12 @@ class Invite < Vue
       }
     end
     if @showPMCNoticeLink or @showPPMCNoticeLink
+      _ 'Navigate to '
+      _a "Ponymail", href: "https://lists.apache.org/list.html?board@apache.org:lte=1M:NOTICE%20for%20#{@display_name}",
target: _blank
+      _ ', select the appropriate message, right-click PermaLink, copy link'
+      _ ' to the clip-board, and paste the link here.'
+      _p
+
       _div.form_group do
         _label "NOTICE link", for: 'noticelink'
         _input.form_control.noticelink! type: 'url', onChange: self.setNoticeLink,
@@ -181,8 +186,8 @@ class Invite < Vue
           onClick: -> {@role = :committer;
             @disabled = false
             @subject = @subjectPhase + ' Invite ' + @iclaname +
-              ' to become a committer for ' + @pmc
-            @proposalText = 'I propose to invite ' + @iclaname +
+              ' to become a committer for ' + @display_name
+            @proposalText = 'I propose we invite ' + @iclaname +
               ' to become a committer.'
             @voteProposalText = @proposalText + "\nHere is my +1."
           }
@@ -195,8 +200,8 @@ class Invite < Vue
           onClick: -> {@role = :pmc
             @disabled = false
             @subject = @subjectPhase + ' Invite ' + @iclaname +
-              ' to become committer and ' + @pmcOrPPMC + ' member for ' + @pmc
-            @proposalText = 'I propose to invite ' + @iclaname +
+              ' to become committer and ' + @pmcOrPPMC + ' member for ' + @display_name
+            @proposalText = 'I propose we invite ' + @iclaname +
               ' to become a committer and ' + @pmcOrPPMC + ' member.'
             @voteProposalText = @proposalText + ' Here is my +1.'
           }
@@ -210,8 +215,8 @@ class Invite < Vue
             onClick: -> {@role = :invite
               @disabled = false
               @subject = @subjectPhase + ' Invite ' + @iclaname +
-              ' to submit an ICLA for ' + @pmc
-              @proposalText = 'I propose to invite ' + @iclaname +
+              ' to submit an ICLA for ' + @display_name
+              @proposalText = 'I propose we invite ' + @iclaname +
                 ' to submit an ICLA.'
             }
             _span @phasePrefix +
@@ -223,7 +228,7 @@ class Invite < Vue
     end
     if @showDiscussFrame
       _div 'From: ' + @member
-      _div 'To: private@' + @pmc_mail[@pmc] + '.apache.org'
+      _div 'To: private@' + @mail_list + '.apache.org'
       _div 'Subject: ' + @subject
       _p
       _span @proposalText
@@ -235,7 +240,7 @@ class Invite < Vue
     end
     if @showVoteFrame
       _div 'From: ' + @member
-      _div 'To: private@' + @pmc_mail[@pmc] + '.apache.org'
+      _div 'To: private@' + @mail_list + '.apache.org'
       _div 'Subject: ' + @subject
       _p
       _span @voteProposalText
@@ -394,11 +399,25 @@ def setIclaName(event)
 
   def setPMC(event)
     @pmc = event.target.value
-    @pmcOrPPMC = (Server.data.pmcs.include? @pmc)? 'PMC' : 'PPMC'
-    @phase = :discuss
-    @subject = ''
-    @showPhaseFrame = true
-    @showRoleFrame = true
+    if Server.data.allData[@pmc]
+      @isPMC = Server.data.allData[@pmc]['pmc']
+      @pmcOrPPMC = @isPMC ? 'PMC' : 'PPMC'
+      @phase = :discuss
+      @subject = ''
+      @showPhaseFrame = true
+      @showRoleFrame = true
+      @mail_list = Server.data.allData[@pmc]['mail_list']
+      @display_name = Server.data.allData[@pmc]['display_name']
+    else
+      @isPMC = false # true, but not the whole story!
+      @pmcOrPPMC = '---'
+      @phase = :discuss
+      @subject = ''
+      @showPhaseFrame = false
+      @showRoleFrame = false
+      @mail_list = '---'
+      @display_name = '---'
+    end
     self.checkValidity()
     selectDiscuss()
   end
@@ -457,10 +476,10 @@ def setIclaName(event)
     @showDiscussFrame = false;
     @showVoteFrame = false;
     @showRoleFrame = false;
-    @showPMCVoteLink = Server.data.pmcs.include? @pmc
-    @showPPMCVoteLink = Server.data.ppmcs.include? @pmc
-    @showPMCNoticeLink = Server.data.pmcs.include? @pmc
-    @showPPMCNoticeLink = Server.data.ppmcs.include? @pmc
+    @showPMCVoteLink = @isPMC
+    @showPPMCVoteLink = @isPMC
+    @showPMCNoticeLink = @isPMC
+    @showPPMCNoticeLink = @isPMC
     @showVoteErrorMessage = false;
     @showNoticeErrorMessage = false;
     checkVoteLink() if document.getElementById('votelink');
@@ -484,7 +503,7 @@ def setIclaName(event)
         a message via lists.apache.org"
         @showVoteErrorMessage = true;
       end
-      if not @votelink=~ /.*private\.#{@pmc_mail[@pmc]}(\.incubator)?\.apache\.org.*/
+      if not @votelink=~ /.*private\.#{@mail_list}(\.incubator)?\.apache\.org.*/
         @voteErrorMessage = "Error: Please link to\
         the [RESULT][VOTE] message sent to the private list."
         @showVoteErrorMessage = true;
@@ -511,7 +530,7 @@ def setIclaName(event)
         a message via lists.apache.org"
         @showNoticeErrorMessage = true;
       end
-      if @showPMCNoticeLink and not @noticelink=~ /.*board\@apache\.org.*/
+      if @showPMCNoticeLink and not @noticelink=~ /.*board\.apache\.org.*/
         @noticeErrorMessage = "Error: please link to\
         the NOTICE message sent to the board list."
         @showNoticeErrorMessage = true;


Mime
View raw message