← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:bug-oci-project-selector-ui into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:bug-oci-project-selector-ui into launchpad:master with ~pappacena/launchpad:bug-oci-project-navigation as a prerequisite.

Commit message:
Hiding the OCI project picker from bugtask UI when possible

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/394210
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:bug-oci-project-selector-ui into launchpad:master.
diff --git a/lib/lp/app/widgets/launchpadtarget.py b/lib/lp/app/widgets/launchpadtarget.py
index b2cc50b..1b00e68 100644
--- a/lib/lp/app/widgets/launchpadtarget.py
+++ b/lib/lp/app/widgets/launchpadtarget.py
@@ -127,6 +127,10 @@ class LaunchpadTargetWidget(BrowserWidget, InputWidget):
         except (InputErrors, UnexpectedFormData):
             return False
 
+    @property
+    def selected_target_type(self):
+        return self.request.form_ng.getOne(self.name, self.default_option)
+
     def getInputValue(self):
         """See zope.formlib.interfaces.IInputWidget."""
         self.setUpSubWidgets()
diff --git a/lib/lp/app/widgets/templates/launchpad-target.pt b/lib/lp/app/widgets/templates/launchpad-target.pt
index 0d3b6a3..fde9115 100644
--- a/lib/lp/app/widgets/templates/launchpad-target.pt
+++ b/lib/lp/app/widgets/templates/launchpad-target.pt
@@ -36,16 +36,33 @@
     </td>
   </tr>
 
-  <tr>
-    <td>
-      <label>
-        <input type="radio" value="ociproject"
-               tal:replace="structure view/options/ociproject" />
-       OCI project
-      </label>
-    </td>
-    <td>
-      <tal:product tal:replace="structure view/ociproject_widget" />
-    </td>
-  </tr>
+  <tal:comment replace="nothing">
+    In this section, we have more "advanced" target types (for now, only OCI
+    projects).
+    The general idea is to hide them for not-so-advanced users, but we need
+    to automatically expand it in case one of the hidden options is selected.
+  </tal:comment>
+  <tal:more-targets
+    define="expanded python: view.selected_target_type == 'ociproject'">
+    <tr tal:attributes="class python: 'hidden' if expanded else ''">
+      <td colspan="2" style="width: 100%; text-align: right">
+          <a class="moretargets-expander" href="#"
+             style="text-style: italic; font-size: 95%">more targets...</a>
+      </td>
+    </tr>
+
+    <tr tal:attributes="class python: ('moretargets-collapsible-content' +
+                                       ('hidden' if expanded else ''))">
+      <td>
+        <label>
+          <input type="radio" value="ociproject"
+                 tal:replace="structure view/options/ociproject" />
+         OCI project
+        </label>
+      </td>
+      <td>
+        <tal:product tal:replace="structure view/ociproject_widget" />
+      </td>
+    </tr>
+  </tal:more-targets>
 </table>
diff --git a/lib/lp/bugs/javascript/bugtask_index.js b/lib/lp/bugs/javascript/bugtask_index.js
index ef0324b..4df24c7 100644
--- a/lib/lp/bugs/javascript/bugtask_index.js
+++ b/lib/lp/bugs/javascript/bugtask_index.js
@@ -795,6 +795,27 @@ namespace.setup_bugtask_row = function(conf) {
             icon_node, row_node, { animate_node: content_node });
         expander.setUp();
     }
+
+    // Set-up expander on "more targets" link.
+    // We have this here to hide extra complexities from the end user, so they
+    // don't get confused with options that are not obvious to everyone (like
+    // OCI projects).
+    icon_node = Y.one(
+        'tr#' + conf.form_row_id + ' a.moretargets-expander');
+    row_node = Y.one(
+        'tr#' + conf.form_row_id + ' .moretargets-collapsible-content');
+    content_node = row_node;
+    expander = new Y.lp.app.widgets.expander.Expander(
+            icon_node, row_node, { no_animation: true });
+    // Do not add arrow icon automatically. This link should be small and
+    // discrete.
+    expander.setIcon = function() {};
+    // Hides the original link.
+    // If we have more targets than just OCI project to hide, it might worth
+    // keeping the link to collapse/expand. But with only one extra option, it
+    // makes no sense to hide the element again.
+    expander.setExpanded = function() { icon_node.addClass('hidden'); };
+    expander.setUp();
 };
 
 /**
diff --git a/lib/lp/bugs/stories/bugtask-management/xx-bugtask-edit-forms.txt b/lib/lp/bugs/stories/bugtask-management/xx-bugtask-edit-forms.txt
index f4abae5..058685d 100644
--- a/lib/lp/bugs/stories/bugtask-management/xx-bugtask-edit-forms.txt
+++ b/lib/lp/bugs/stories/bugtask-management/xx-bugtask-edit-forms.txt
@@ -49,6 +49,7 @@ respective bug task.
     Distribution
     ...
     Project (Find…)
+    more targets...
     OCI project (Find...)
     Status  Importance  Milestone
     New...  Low...      (nothing selected)...

Follow ups