1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Generalize rules for "workflow" sigil

Summary:
See discussion in D6130. Basically, all of these should activate workflow:

  <a data-sigil="workflow" href="...">...</a>

  <div data-sigil="workflow">
    <a href="...">...</a>
  </div>

  <form data-sigil="workflow" action="...">...</form>

  <div data-sigil="workflow">
    <form action="...">...</form>
  </div>

The only case where we don't want to activate workflow is this one:

  <form data-sigil="workflow">
    <a href="...">...</a>
  </form>

Here, the form should workflow but the `<a />` should not.

These cases aren't really covered:

  // Undefined no matter where "workflow" is because it's nonsense.
  <a><a>...</a></a>

  // As above except like a million times more dumb.
  <form><form>...</form></form>

  // This one is ambiguous. The <a /> will currently workflow. We don't do
  // this anywhere and probably never will. If we want a different rule we
  // can cross that bridge when we come to it.
  <div data-sigil="workflow">
    <form action="...">
      <a href="...">...</a>
    </form>
  </div>

Test Plan: Clicked/submitted some things with workflow.

Reviewers: chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6131
This commit is contained in:
epriestley 2013-06-05 16:21:21 -07:00
parent 3029d72d5c
commit 94c29007b6
2 changed files with 56 additions and 46 deletions

View file

@ -2335,7 +2335,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-workflow' =>
array(
'uri' => '/res/425777cc/rsrc/js/core/behavior-workflow.js',
'uri' => '/res/4a0595c1/rsrc/js/core/behavior-workflow.js',
'type' => 'js',
'requires' =>
array(
@ -3705,7 +3705,7 @@ celerity_register_resource_map(array(
),
'phui-list-view-css' =>
array(
'uri' => '/res/0dc7b882/rsrc/css/phui/phui-list.css',
'uri' => '/res/77c3509f/rsrc/css/phui/phui-list.css',
'type' => 'css',
'requires' =>
array(
@ -4063,7 +4063,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/21f9f13d/core.pkg.css',
'type' => 'css',
),
'98f60e3f' =>
'f2ad0683' =>
array(
'name' => 'core.pkg.js',
'symbols' =>
@ -4106,7 +4106,7 @@ celerity_register_resource_map(array(
35 => 'phabricator-hovercard',
36 => 'javelin-behavior-phabricator-hovercards',
),
'uri' => '/res/pkg/98f60e3f/core.pkg.js',
'uri' => '/res/pkg/f2ad0683/core.pkg.js',
'type' => 'js',
),
'4ccfeb47' =>
@ -4279,17 +4279,17 @@ celerity_register_resource_map(array(
'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '21f9f13d',
'inline-comment-summary-css' => 'dd27a69b',
'javelin-aphlict' => '98f60e3f',
'javelin-aphlict' => 'f2ad0683',
'javelin-behavior' => 'a9f14d76',
'javelin-behavior-aphlict-dropdown' => '98f60e3f',
'javelin-behavior-aphlict-listen' => '98f60e3f',
'javelin-behavior-aphront-basic-tokenizer' => '98f60e3f',
'javelin-behavior-aphlict-dropdown' => 'f2ad0683',
'javelin-behavior-aphlict-listen' => 'f2ad0683',
'javelin-behavior-aphront-basic-tokenizer' => 'f2ad0683',
'javelin-behavior-aphront-drag-and-drop' => '9488bb69',
'javelin-behavior-aphront-drag-and-drop-textarea' => '9488bb69',
'javelin-behavior-aphront-form-disable-on-submit' => '98f60e3f',
'javelin-behavior-aphront-form-disable-on-submit' => 'f2ad0683',
'javelin-behavior-audit-preview' => '96909266',
'javelin-behavior-dark-console' => '4ccfeb47',
'javelin-behavior-device' => '98f60e3f',
'javelin-behavior-device' => 'f2ad0683',
'javelin-behavior-differential-accept-with-errors' => '9488bb69',
'javelin-behavior-differential-add-reviewers-and-ccs' => '9488bb69',
'javelin-behavior-differential-comment-jump' => '9488bb69',
@ -4305,33 +4305,33 @@ celerity_register_resource_map(array(
'javelin-behavior-diffusion-commit-graph' => '96909266',
'javelin-behavior-diffusion-pull-lastmodified' => '96909266',
'javelin-behavior-error-log' => '4ccfeb47',
'javelin-behavior-global-drag-and-drop' => '98f60e3f',
'javelin-behavior-history-install' => '98f60e3f',
'javelin-behavior-konami' => '98f60e3f',
'javelin-behavior-lightbox-attachments' => '98f60e3f',
'javelin-behavior-global-drag-and-drop' => 'f2ad0683',
'javelin-behavior-history-install' => 'f2ad0683',
'javelin-behavior-konami' => 'f2ad0683',
'javelin-behavior-lightbox-attachments' => 'f2ad0683',
'javelin-behavior-load-blame' => '9488bb69',
'javelin-behavior-maniphest-batch-selector' => 'c0c9bc0b',
'javelin-behavior-maniphest-subpriority-editor' => 'c0c9bc0b',
'javelin-behavior-maniphest-transaction-controls' => 'c0c9bc0b',
'javelin-behavior-maniphest-transaction-expand' => 'c0c9bc0b',
'javelin-behavior-maniphest-transaction-preview' => 'c0c9bc0b',
'javelin-behavior-phabricator-active-nav' => '98f60e3f',
'javelin-behavior-phabricator-autofocus' => '98f60e3f',
'javelin-behavior-phabricator-gesture' => '98f60e3f',
'javelin-behavior-phabricator-hovercards' => '98f60e3f',
'javelin-behavior-phabricator-keyboard-shortcuts' => '98f60e3f',
'javelin-behavior-phabricator-nav' => '98f60e3f',
'javelin-behavior-phabricator-active-nav' => 'f2ad0683',
'javelin-behavior-phabricator-autofocus' => 'f2ad0683',
'javelin-behavior-phabricator-gesture' => 'f2ad0683',
'javelin-behavior-phabricator-hovercards' => 'f2ad0683',
'javelin-behavior-phabricator-keyboard-shortcuts' => 'f2ad0683',
'javelin-behavior-phabricator-nav' => 'f2ad0683',
'javelin-behavior-phabricator-object-selector' => '9488bb69',
'javelin-behavior-phabricator-oncopy' => '98f60e3f',
'javelin-behavior-phabricator-remarkup-assist' => '98f60e3f',
'javelin-behavior-phabricator-reveal-content' => '98f60e3f',
'javelin-behavior-phabricator-search-typeahead' => '98f60e3f',
'javelin-behavior-phabricator-tooltips' => '98f60e3f',
'javelin-behavior-phabricator-watch-anchor' => '98f60e3f',
'javelin-behavior-refresh-csrf' => '98f60e3f',
'javelin-behavior-phabricator-oncopy' => 'f2ad0683',
'javelin-behavior-phabricator-remarkup-assist' => 'f2ad0683',
'javelin-behavior-phabricator-reveal-content' => 'f2ad0683',
'javelin-behavior-phabricator-search-typeahead' => 'f2ad0683',
'javelin-behavior-phabricator-tooltips' => 'f2ad0683',
'javelin-behavior-phabricator-watch-anchor' => 'f2ad0683',
'javelin-behavior-refresh-csrf' => 'f2ad0683',
'javelin-behavior-repository-crossreference' => '9488bb69',
'javelin-behavior-toggle-class' => '98f60e3f',
'javelin-behavior-workflow' => '98f60e3f',
'javelin-behavior-toggle-class' => 'f2ad0683',
'javelin-behavior-workflow' => 'f2ad0683',
'javelin-dom' => 'a9f14d76',
'javelin-event' => 'a9f14d76',
'javelin-history' => 'a9f14d76',
@ -4356,32 +4356,32 @@ celerity_register_resource_map(array(
'maniphest-transaction-detail-css' => '03ab92cf',
'phabricator-action-list-view-css' => '21f9f13d',
'phabricator-application-launch-view-css' => '21f9f13d',
'phabricator-busy' => '98f60e3f',
'phabricator-busy' => 'f2ad0683',
'phabricator-content-source-view-css' => 'dd27a69b',
'phabricator-core-buttons-css' => '21f9f13d',
'phabricator-core-css' => '21f9f13d',
'phabricator-crumbs-view-css' => '21f9f13d',
'phabricator-drag-and-drop-file-upload' => '9488bb69',
'phabricator-dropdown-menu' => '98f60e3f',
'phabricator-file-upload' => '98f60e3f',
'phabricator-dropdown-menu' => 'f2ad0683',
'phabricator-file-upload' => 'f2ad0683',
'phabricator-filetree-view-css' => '21f9f13d',
'phabricator-flag-css' => '21f9f13d',
'phabricator-form-view-css' => '21f9f13d',
'phabricator-header-view-css' => '21f9f13d',
'phabricator-hovercard' => '98f60e3f',
'phabricator-hovercard' => 'f2ad0683',
'phabricator-jump-nav' => '21f9f13d',
'phabricator-keyboard-shortcut' => '98f60e3f',
'phabricator-keyboard-shortcut-manager' => '98f60e3f',
'phabricator-keyboard-shortcut' => 'f2ad0683',
'phabricator-keyboard-shortcut-manager' => 'f2ad0683',
'phabricator-main-menu-view' => '21f9f13d',
'phabricator-menu-item' => '98f60e3f',
'phabricator-menu-item' => 'f2ad0683',
'phabricator-nav-view-css' => '21f9f13d',
'phabricator-notification' => '98f60e3f',
'phabricator-notification' => 'f2ad0683',
'phabricator-notification-css' => '21f9f13d',
'phabricator-notification-menu-css' => '21f9f13d',
'phabricator-object-item-list-view-css' => '21f9f13d',
'phabricator-object-selector-css' => 'dd27a69b',
'phabricator-phtize' => '98f60e3f',
'phabricator-prefab' => '98f60e3f',
'phabricator-phtize' => 'f2ad0683',
'phabricator-prefab' => 'f2ad0683',
'phabricator-project-tag-css' => '03ab92cf',
'phabricator-property-list-view-css' => '21f9f13d',
'phabricator-remarkup-css' => '21f9f13d',
@ -4389,8 +4389,8 @@ celerity_register_resource_map(array(
'phabricator-side-menu-view-css' => '21f9f13d',
'phabricator-standard-page-view' => '21f9f13d',
'phabricator-tag-view-css' => '21f9f13d',
'phabricator-textareautils' => '98f60e3f',
'phabricator-tooltip' => '98f60e3f',
'phabricator-textareautils' => 'f2ad0683',
'phabricator-tooltip' => 'f2ad0683',
'phabricator-transaction-view-css' => '21f9f13d',
'phabricator-zindex-css' => '21f9f13d',
'phui-form-css' => '21f9f13d',

View file

@ -16,9 +16,12 @@ JX.behavior('workflow', function() {
if (JX.Stratcom.pass()) {
return;
}
var target = e.getNode('workflow');
// NOTE: We activate workflow if any parent node has the "workflow" sigil,
// not just the <form /> itself.
e.prevent();
JX.Workflow.newFromForm(target).start();
JX.Workflow.newFromForm(e.getNode('tag:form')).start();
});
JX.Stratcom.listen(
@ -29,8 +32,15 @@ JX.behavior('workflow', function() {
return;
}
var target = e.getNode('workflow');
if (!JX.DOM.isType(target, 'a')) {
// NOTE: As above, we want to activate workflow if a parent node has
// the sigil, not just the <a /> that the user clicked. However, there
// is an exception in this case: if the <a /> does not have workflow and
// is inside a <form /> which does, we don't workflow it (this covers
// things like "help" links in captions). Test if the node with the
// workflow sigil is a form.
var workflow_node = e.getNode('workflow');
if (JX.DOM.isType(workflow_node, 'form')) {
// This covers the case of an <a /> without workflow inside a <form />
// with workflow.
return;
@ -41,7 +51,7 @@ JX.behavior('workflow', function() {
}
e.prevent();
JX.Workflow.newFromLink(target).start();
JX.Workflow.newFromLink(e.getNode('tag:a')).start();
});
});