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(
'names' => array(
'core.pkg.css' => '8378907a',
'core.pkg.js' => '5058979d',
'core.pkg.css' => 'cc8abd0e',
'core.pkg.js' => 'e0379ae5',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '2de124c9',
'differential.pkg.js' => '6223dd9d',
@ -132,7 +132,7 @@ return array(
'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23',
'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
'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-icon.css' => 'b0a6b1b6',
'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__/behavior.js' => '1ea62783',
'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/normalizer/TypeaheadNormalizer.js' => 'e6e25838',
'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-test-payment-form.js' => 'fc91ab6c',
'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/projects/behavior-project-boards.js' => 'ba4fa35c',
'rsrc/js/application/projects/behavior-project-create.js' => '065227cc',
@ -456,7 +456,7 @@ return array(
'rsrc/js/core/KeyboardShortcutManager.js' => 'c1700f6f',
'rsrc/js/core/MultirowRowManager.js' => 'b5d57730',
'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/TextAreaUtils.js' => '5c93c52c',
'rsrc/js/core/Title.js' => 'df5e11d2',
@ -486,7 +486,7 @@ return array(
'rsrc/js/core/behavior-object-selector.js' => '49b73b36',
'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
'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-remarkup-preview.js' => 'f7379f45',
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
@ -639,7 +639,7 @@ return array(
'javelin-behavior-phabricator-notification-example' => '8ce821c5',
'javelin-behavior-phabricator-object-selector' => '49b73b36',
'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-search-typeahead' => '048330fa',
'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6',
@ -651,7 +651,7 @@ return array(
'javelin-behavior-pholio-mock-view' => 'fbe497e7',
'javelin-behavior-phui-dropdown-menu' => '54733475',
'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-project-boards' => 'ba4fa35c',
'javelin-behavior-project-create' => '065227cc',
@ -702,7 +702,7 @@ return array(
'javelin-scrollbar' => '087e919c',
'javelin-sound' => '949c0fe5',
'javelin-stratcom' => '6c53634d',
'javelin-tokenizer' => 'c431f925',
'javelin-tokenizer' => '8d3bc1b2',
'javelin-typeahead' => '70baed2f',
'javelin-typeahead-composite-source' => '503e17fd',
'javelin-typeahead-normalizer' => 'e6e25838',
@ -757,7 +757,7 @@ return array(
'phabricator-notification-menu-css' => 'f31c0bde',
'phabricator-object-selector-css' => '85ee8ce6',
'phabricator-phtize' => 'd254d646',
'phabricator-prefab' => 'be38fe4e',
'phabricator-prefab' => '666c80c5',
'phabricator-remarkup-css' => '275e362f',
'phabricator-search-results-css' => '7dea472c',
'phabricator-shaped-request' => '7cbe244b',
@ -804,7 +804,7 @@ return array(
'phui-feed-story-css' => 'b7b26d23',
'phui-font-icon-base-css' => 'ecbbb4c2',
'phui-fontkit-css' => '9cda225e',
'phui-form-css' => 'afdb2c6e',
'phui-form-css' => '0b98e572',
'phui-form-view-css' => 'cf7da606',
'phui-header-view-css' => '55bb32dd',
'phui-icon-view-css' => 'b0a6b1b6',
@ -1293,6 +1293,18 @@ return array(
'javelin-vector',
'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(
'javelin-dom',
),
@ -1391,15 +1403,6 @@ return array(
'javelin-request',
'javelin-router',
),
'7d470398' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'phuix-dropdown-menu',
'phuix-action-list-view',
'phuix-action-view',
'javelin-workflow',
),
'7e41274a' => array(
'javelin-install',
),
@ -1496,6 +1499,12 @@ return array(
'javelin-dom',
'javelin-util',
),
'8d3bc1b2' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'8ef9ab58' => array(
'javelin-behavior',
'javelin-dom',
@ -1645,6 +1654,15 @@ return array(
'javelin-uri',
'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(
'javelin-behavior',
'javelin-stratcom',
@ -1741,22 +1759,19 @@ return array(
'javelin-util',
'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(
'javelin-install',
'javelin-dom',
),
'c14b5995' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'c1700f6f' => array(
'javelin-install',
'javelin-util',
@ -1764,12 +1779,6 @@ return array(
'javelin-dom',
'javelin-vector',
),
'c431f925' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'c72aa091' => array(
'javelin-behavior',
'javelin-dom',
@ -1961,15 +1970,6 @@ return array(
'javelin-behavior',
'javelin-uri',
),
'eeaa9e5a' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'efe49472' => array(
'javelin-install',
'javelin-util',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,6 +14,14 @@ JX.behavior('policy-control', function(config) {
var input = JX.$(config.inputID);
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)
.setWidth(260)
.setAlign('left');

View file

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

View file

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