Bug 1381622: add UI considerations for actions; r?jonasfj draft
authorDustin J. Mitchell <dustin@mozilla.com>
Mon, 17 Jul 2017 20:39:08 +0000
changeset 610076 9bc0b08023461180e87ccdbfdeef5ad11be4ac66
parent 610038 9278792968b2785acff08be8164711b42ea935fb
child 637768 97eaa81f8e27cc1326acde357353d8dfc7850dde
push id68790
push userdmitchell@mozilla.com
push dateMon, 17 Jul 2017 22:45:27 +0000
reviewersjonasfj
bugs1381622
milestone56.0a1
Bug 1381622: add UI considerations for actions; r?jonasfj MozReview-Commit-ID: CuhPkD3Xbic
taskcluster/docs/action-spec.rst
taskcluster/docs/action-uis.rst
taskcluster/docs/actions.rst
--- a/taskcluster/docs/action-spec.rst
+++ b/taskcluster/docs/action-spec.rst
@@ -197,33 +197,21 @@ specified with by the action's ``schema`
     ],
     "variables: {},
   }
 
 User interfaces for triggering actions, like Treeherder, are expected to provide
 JSON input that satisfies this schema. These interfaces are also expected to
 validate the input against the schema before attempting to trigger the action.
 
-It is expected that such user interfaces will attempt to auto-generate HTML
-forms from JSON schema specified. However, a user-interface implementor may also
-decide to hand write an HTML form for a particularly common or complex JSON
-schema. As long as the input generated from the form conforms to the schema
-specified for the given action. To ensure that, implementers should do a deep
-comparison between a schema for which a hand-written HTML form exists, and the
-schema required by the action.
-
 It is perfectly legal to reference external schemas using
 constructs like ``{"$ref": "https://example.com/my-schema.json"}``, in this case
 it however strongly recommended that the external resource is available over
 HTTPS and allows CORS requests from any source.
 
-In fact, user interface implementors should feel encouraged to publish schemas
-for which they have hand written input forms, so that action developers can
-use these when applicable.
-
 When writing schemas it is strongly encouraged that the JSON schema
 ``description`` properties are used to provide detailed descriptions. It is
 assumed that consumers will render these ``description`` properties as markdown.
 
 
 Variables
 ---------
 
new file mode 100644
--- /dev/null
+++ b/taskcluster/docs/action-uis.rst
@@ -0,0 +1,73 @@
+User Interface Considerations
+=============================
+
+The actions system decouples in-tree changes from user interface changes by
+taking advantage of graceful degradation. User interfaces, when presented with
+an unfamiliar action, fall back to a usable default behavior, and can later be
+upgraded to handle that action with a more refined approach.
+
+Default Behavior
+----------------
+
+Every user interface should support the following:
+
+ * Displaying a list of actions relevant to each task, and displaying
+   task-group tasks for the associated task-group.
+
+ * Providing an opportuntity for the user to enter input for an action.  This
+   might be in JSON or YAML, or using a form auto-generated from the action's
+   JSON-schema.  If the action has no schema, this step should be skipped.
+   The user's input should be validated against the schema.
+
+ * For ``action.kind = 'task'``, rendering the template using the JSON-e
+   library, using the variables described in :doc:`action-spec`.
+
+ * Calling ``Queue.createTask`` with the resulting task, using the user's
+   Taskcluster credentials.
+   
+
+Creating Tasks
+--------------
+
+When executing an action, a UI must ensure that the user is authorized to
+perform the action, and that the user is not being "tricked" into executing
+an unexpected action.
+
+To accomplish the first, the UI should create tasks with the user's Taskcluster
+credentials. Do not use credentials configured as part of the service itself!
+
+To accomplish the second, use the decision tasks's ``scopes`` property as the
+`authorizedScopes
+<https://docs.taskcluster.net/manual/design/apis/hawk/authorized-scopes>`_ for
+the ``Queue.createTask`` call.  This prevents action tasks from doing anything
+the original decision task couldn't do.
+
+Specialized Behavior
+--------------------
+
+The default behavior is too clumsy for day-to-day use for common actions.  User
+interfaces may want to provide a more natural interface that still takes advantage
+of the actions system.
+
+Specialized Input
+.................
+
+A user interface may provide specialized input forms for specific schemas.  The
+input generated from the form must conform to the schema.
+
+To ensure that the schema has not changed, implementers should do a deep
+comparison between a schema for which a hand-written form exists, and the
+schema required by the action. If the two differ, the default behavior should
+be used instead.
+
+Specialized Triggering
+......................
+
+A user interface may want to trigger a specific action using a dedicated UI
+element.  For example, an "start interactive session" button might be placed
+next to each failing test in a list of tests.
+
+The user interface should find the appropriate action by deep-comparing
+schemas, just like for specialized input.  If no matching action is found, an
+error message should be presented to the user. Tasks without schemas cannot be
+triggered by custom UI elements.
--- a/taskcluster/docs/actions.rst
+++ b/taskcluster/docs/actions.rst
@@ -19,9 +19,10 @@ At a very high level, the process looks 
    task", including the provided information. That action task is responsible
    for carrying out the named action, and may create new sub-tasks if necessary
    (for example, to re-trigger a task).
 
 
 .. toctree::
 
     action-spec
+    action-uis
     action-implementation