1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Give custom controls passable disabled states

Summary: Fixes T9871. Ref T10004. These won't win any awards but it fixes them being incredibly weird and confusing.

Test Plan:
{F1029090}

  - Tried to use controls, got reasonable behavior.
  - Used normal controls to make sure I didn't break anything.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9871, T10004

Differential Revision: https://secure.phabricator.com/D14814
This commit is contained in:
epriestley 2015-12-17 13:27:36 -08:00
parent ed43b31cb1
commit a07a06ab08
9 changed files with 96 additions and 59 deletions

View file

@ -7,8 +7,8 @@
*/ */
return array( return array(
'names' => array( 'names' => array(
'core.pkg.css' => '8378907a', 'core.pkg.css' => 'cc8abd0e',
'core.pkg.js' => '5058979d', 'core.pkg.js' => 'e0379ae5',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '2de124c9', 'differential.pkg.css' => '2de124c9',
'differential.pkg.js' => '6223dd9d', 'differential.pkg.js' => '6223dd9d',
@ -132,7 +132,7 @@ return array(
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23', 'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
'rsrc/css/phui/phui-fontkit.css' => '9cda225e', 'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
'rsrc/css/phui/phui-form-view.css' => 'cf7da606', 'rsrc/css/phui/phui-form-view.css' => 'cf7da606',
'rsrc/css/phui/phui-form.css' => 'afdb2c6e', 'rsrc/css/phui/phui-form.css' => '0b98e572',
'rsrc/css/phui/phui-header-view.css' => '55bb32dd', 'rsrc/css/phui/phui-header-view.css' => '55bb32dd',
'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6', 'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6',
'rsrc/css/phui/phui-image-mask.css' => '5a8b09c8', 'rsrc/css/phui/phui-image-mask.css' => '5a8b09c8',
@ -244,7 +244,7 @@ return array(
'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9', 'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9',
'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', 'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783',
'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', 'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a',
'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'c431f925', 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '8d3bc1b2',
'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f', 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f',
'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838', 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd',
@ -415,7 +415,7 @@ return array(
'rsrc/js/application/phortune/behavior-stripe-payment-form.js' => '3f5d6dbf', 'rsrc/js/application/phortune/behavior-stripe-payment-form.js' => '3f5d6dbf',
'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'fc91ab6c', 'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'fc91ab6c',
'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef', 'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef',
'rsrc/js/application/policy/behavior-policy-control.js' => '7d470398', 'rsrc/js/application/policy/behavior-policy-control.js' => 'ae45872f',
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '5e9f347c', 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '5e9f347c',
'rsrc/js/application/projects/behavior-project-boards.js' => 'ba4fa35c', 'rsrc/js/application/projects/behavior-project-boards.js' => 'ba4fa35c',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc', 'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
@ -456,7 +456,7 @@ return array(
'rsrc/js/core/KeyboardShortcutManager.js' => 'c1700f6f', 'rsrc/js/core/KeyboardShortcutManager.js' => 'c1700f6f',
'rsrc/js/core/MultirowRowManager.js' => 'b5d57730', 'rsrc/js/core/MultirowRowManager.js' => 'b5d57730',
'rsrc/js/core/Notification.js' => 'ccf1cbf8', 'rsrc/js/core/Notification.js' => 'ccf1cbf8',
'rsrc/js/core/Prefab.js' => 'be38fe4e', 'rsrc/js/core/Prefab.js' => '666c80c5',
'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
'rsrc/js/core/TextAreaUtils.js' => '5c93c52c', 'rsrc/js/core/TextAreaUtils.js' => '5c93c52c',
'rsrc/js/core/Title.js' => 'df5e11d2', 'rsrc/js/core/Title.js' => 'df5e11d2',
@ -486,7 +486,7 @@ return array(
'rsrc/js/core/behavior-object-selector.js' => '49b73b36', 'rsrc/js/core/behavior-object-selector.js' => '49b73b36',
'rsrc/js/core/behavior-oncopy.js' => '2926fff2', 'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
'rsrc/js/core/behavior-phabricator-nav.js' => '56a1ca03', 'rsrc/js/core/behavior-phabricator-nav.js' => '56a1ca03',
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'eeaa9e5a', 'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'c14b5995',
'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b', 'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b',
'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45', 'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45',
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e', 'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
@ -639,7 +639,7 @@ return array(
'javelin-behavior-phabricator-notification-example' => '8ce821c5', 'javelin-behavior-phabricator-notification-example' => '8ce821c5',
'javelin-behavior-phabricator-object-selector' => '49b73b36', 'javelin-behavior-phabricator-object-selector' => '49b73b36',
'javelin-behavior-phabricator-oncopy' => '2926fff2', 'javelin-behavior-phabricator-oncopy' => '2926fff2',
'javelin-behavior-phabricator-remarkup-assist' => 'eeaa9e5a', 'javelin-behavior-phabricator-remarkup-assist' => 'c14b5995',
'javelin-behavior-phabricator-reveal-content' => '60821bc7', 'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => '048330fa', 'javelin-behavior-phabricator-search-typeahead' => '048330fa',
'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6', 'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6',
@ -651,7 +651,7 @@ return array(
'javelin-behavior-pholio-mock-view' => 'fbe497e7', 'javelin-behavior-pholio-mock-view' => 'fbe497e7',
'javelin-behavior-phui-dropdown-menu' => '54733475', 'javelin-behavior-phui-dropdown-menu' => '54733475',
'javelin-behavior-phui-object-box-tabs' => '2bfa2836', 'javelin-behavior-phui-object-box-tabs' => '2bfa2836',
'javelin-behavior-policy-control' => '7d470398', 'javelin-behavior-policy-control' => 'ae45872f',
'javelin-behavior-policy-rule-editor' => '5e9f347c', 'javelin-behavior-policy-rule-editor' => '5e9f347c',
'javelin-behavior-project-boards' => 'ba4fa35c', 'javelin-behavior-project-boards' => 'ba4fa35c',
'javelin-behavior-project-create' => '065227cc', 'javelin-behavior-project-create' => '065227cc',
@ -702,7 +702,7 @@ return array(
'javelin-scrollbar' => '087e919c', 'javelin-scrollbar' => '087e919c',
'javelin-sound' => '949c0fe5', 'javelin-sound' => '949c0fe5',
'javelin-stratcom' => '6c53634d', 'javelin-stratcom' => '6c53634d',
'javelin-tokenizer' => 'c431f925', 'javelin-tokenizer' => '8d3bc1b2',
'javelin-typeahead' => '70baed2f', 'javelin-typeahead' => '70baed2f',
'javelin-typeahead-composite-source' => '503e17fd', 'javelin-typeahead-composite-source' => '503e17fd',
'javelin-typeahead-normalizer' => 'e6e25838', 'javelin-typeahead-normalizer' => 'e6e25838',
@ -757,7 +757,7 @@ return array(
'phabricator-notification-menu-css' => 'f31c0bde', 'phabricator-notification-menu-css' => 'f31c0bde',
'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-object-selector-css' => '85ee8ce6',
'phabricator-phtize' => 'd254d646', 'phabricator-phtize' => 'd254d646',
'phabricator-prefab' => 'be38fe4e', 'phabricator-prefab' => '666c80c5',
'phabricator-remarkup-css' => '275e362f', 'phabricator-remarkup-css' => '275e362f',
'phabricator-search-results-css' => '7dea472c', 'phabricator-search-results-css' => '7dea472c',
'phabricator-shaped-request' => '7cbe244b', 'phabricator-shaped-request' => '7cbe244b',
@ -804,7 +804,7 @@ return array(
'phui-feed-story-css' => 'b7b26d23', 'phui-feed-story-css' => 'b7b26d23',
'phui-font-icon-base-css' => 'ecbbb4c2', 'phui-font-icon-base-css' => 'ecbbb4c2',
'phui-fontkit-css' => '9cda225e', 'phui-fontkit-css' => '9cda225e',
'phui-form-css' => 'afdb2c6e', 'phui-form-css' => '0b98e572',
'phui-form-view-css' => 'cf7da606', 'phui-form-view-css' => 'cf7da606',
'phui-header-view-css' => '55bb32dd', 'phui-header-view-css' => '55bb32dd',
'phui-icon-view-css' => 'b0a6b1b6', 'phui-icon-view-css' => 'b0a6b1b6',
@ -1293,6 +1293,18 @@ return array(
'javelin-vector', 'javelin-vector',
'differential-inline-comment-editor', 'differential-inline-comment-editor',
), ),
'666c80c5' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-typeahead',
'javelin-tokenizer',
'javelin-typeahead-preloaded-source',
'javelin-typeahead-ondemand-source',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
),
'6882e80a' => array( '6882e80a' => array(
'javelin-dom', 'javelin-dom',
), ),
@ -1391,15 +1403,6 @@ return array(
'javelin-request', 'javelin-request',
'javelin-router', 'javelin-router',
), ),
'7d470398' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'phuix-dropdown-menu',
'phuix-action-list-view',
'phuix-action-view',
'javelin-workflow',
),
'7e41274a' => array( '7e41274a' => array(
'javelin-install', 'javelin-install',
), ),
@ -1496,6 +1499,12 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-util', 'javelin-util',
), ),
'8d3bc1b2' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'8ef9ab58' => array( '8ef9ab58' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1645,6 +1654,15 @@ return array(
'javelin-uri', 'javelin-uri',
'phabricator-file-upload', 'phabricator-file-upload',
), ),
'ae45872f' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'phuix-dropdown-menu',
'phuix-action-list-view',
'phuix-action-view',
'javelin-workflow',
),
'b064af76' => array( 'b064af76' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1741,22 +1759,19 @@ return array(
'javelin-util', 'javelin-util',
'javelin-request', 'javelin-request',
), ),
'be38fe4e' => array(
'javelin-install',
'javelin-util',
'javelin-dom',
'javelin-typeahead',
'javelin-tokenizer',
'javelin-typeahead-preloaded-source',
'javelin-typeahead-ondemand-source',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
),
'bff6884b' => array( 'bff6884b' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
), ),
'c14b5995' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'c1700f6f' => array( 'c1700f6f' => array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',
@ -1764,12 +1779,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-vector', 'javelin-vector',
), ),
'c431f925' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'c72aa091' => array( 'c72aa091' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1961,15 +1970,6 @@ return array(
'javelin-behavior', 'javelin-behavior',
'javelin-uri', 'javelin-uri',
), ),
'eeaa9e5a' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'efe49472' => array( 'efe49472' => array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',

View file

@ -272,6 +272,7 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
'capability' => $this->capability, 'capability' => $this->capability,
'editURI' => '/policy/edit/'.$context_path, 'editURI' => '/policy/edit/'.$context_path,
'customPlaceholder' => $this->getCustomPolicyPlaceholder(), 'customPlaceholder' => $this->getCustomPolicyPlaceholder(),
'disabled' => $this->getDisabled(),
)); ));
$selected = idx($flat_options, $this->getValue(), array()); $selected = idx($flat_options, $this->getValue(), array());
@ -350,6 +351,7 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
$viewer, $viewer,
$space_phid), $space_phid),
array( array(
'disabled' => $this->getDisabled(),
'name' => 'spacePHID', 'name' => 'spacePHID',
'class' => 'aphront-space-select-control-knob', 'class' => 'aphront-space-select-control-knob',
)); ));

View file

@ -112,6 +112,7 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
'username' => $username, 'username' => $username,
'placeholder' => $placeholder, 'placeholder' => $placeholder,
'browseURI' => $browse_uri, 'browseURI' => $browse_uri,
'disabled' => $this->getDisabled(),
)); ));
} }

View file

@ -31,14 +31,16 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
// currently ship JS or CSS. // currently ship JS or CSS.
require_celerity_resource('lightbox-attachment-css'); require_celerity_resource('lightbox-attachment-css');
Javelin::initBehavior( if (!$this->getDisabled()) {
'aphront-drag-and-drop-textarea', Javelin::initBehavior(
array( 'aphront-drag-and-drop-textarea',
'target' => $id, array(
'activatedClass' => 'aphront-textarea-drag-and-drop', 'target' => $id,
'uri' => '/file/dropupload/', 'activatedClass' => 'aphront-textarea-drag-and-drop',
'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(), 'uri' => '/file/dropupload/',
)); 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(),
));
}
Javelin::initBehavior( Javelin::initBehavior(
'phabricator-remarkup-assist', 'phabricator-remarkup-assist',
@ -53,6 +55,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
'name' => pht('name'), 'name' => pht('name'),
'URL' => pht('URL'), 'URL' => pht('URL'),
), ),
'disabled' => $this->getDisabled(),
)); ));
Javelin::initBehavior('phabricator-tooltips', array()); Javelin::initBehavior('phabricator-tooltips', array());
@ -175,12 +178,18 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
$tip); $tip);
} }
$sigils = array();
$sigils[] = 'remarkup-assist';
if (!$this->getDisabled()) {
$sigils[] = 'has-tooltip';
}
$buttons[] = javelin_tag( $buttons[] = javelin_tag(
'a', 'a',
array( array(
'class' => implode(' ', $classes), 'class' => implode(' ', $classes),
'href' => $href, 'href' => $href,
'sigil' => 'remarkup-assist has-tooltip', 'sigil' => implode(' ', $sigils),
'meta' => $meta, 'meta' => $meta,
'mustcapture' => $mustcapture, 'mustcapture' => $mustcapture,
'target' => $target, 'target' => $target,
@ -220,6 +229,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
'div', 'div',
array( array(
'sigil' => 'remarkup-assist-control', 'sigil' => 'remarkup-assist-control',
'class' => $this->getDisabled() ? 'disabled-control' : null,
), ),
array( array(
$buttons, $buttons,

View file

@ -142,7 +142,9 @@ textarea::-webkit-input-placeholder {
} }
select[disabled], select[disabled],
input[disabled] { input[disabled],
textarea[disabled],
.disabled-control {
opacity: 0.5; opacity: 0.5;
} }

View file

@ -46,7 +46,8 @@ JX.install('Tokenizer', {
properties : { properties : {
limit : null, limit : null,
renderTokenCallback : null, renderTokenCallback : null,
browseURI: null browseURI: null,
disabled: false
}, },
members : { members : {
@ -65,6 +66,11 @@ JX.install('Tokenizer', {
_placeholder : null, _placeholder : null,
start : function() { start : function() {
if (this.getDisabled()) {
JX.DOM.alterClass(this._containerNode, 'disabled-control', true);
return;
}
if (__DEV__) { if (__DEV__) {
if (!this._typeahead) { if (!this._typeahead) {
throw new Error( throw new Error(

View file

@ -14,6 +14,14 @@ JX.behavior('policy-control', function(config) {
var input = JX.$(config.inputID); var input = JX.$(config.inputID);
var value = config.value; var value = config.value;
if (config.disabled) {
JX.DOM.alterClass(control, 'disabled-control', true);
JX.DOM.listen(control, 'click', null, function(e) {
e.kill();
});
return;
}
var menu = new JX.PHUIXDropdownMenu(control) var menu = new JX.PHUIXDropdownMenu(control)
.setWidth(260) .setWidth(260)
.setAlign('left'); .setAlign('left');

View file

@ -240,6 +240,10 @@ JX.install('Prefab', {
tokenizer.setBrowseURI(config.browseURI); tokenizer.setBrowseURI(config.browseURI);
} }
if (config.disabled) {
tokenizer.setDisabled(true);
}
JX.Stratcom.addData(root, {'tokenizer' : tokenizer}); JX.Stratcom.addData(root, {'tokenizer' : tokenizer});
return { return {

View file

@ -196,6 +196,10 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
e.kill(); e.kill();
if (config.disabled) {
return;
}
var root = e.getNode('remarkup-assist-control'); var root = e.getNode('remarkup-assist-control');
var area = JX.DOM.find(root, 'textarea'); var area = JX.DOM.find(root, 'textarea');