mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 09:48:39 +01:00
Improve errors associated with adding new login providers
Summary: Ref T1536. - When users try to add a one-of provider which already exists, give them a better error (a dialog explaining what's up with reasonable choices). - Disable such providers and label why they're disabled on the "new provider" screen. Test Plan: {F47012} {F47013} Reviewers: chad, btrahan Reviewed By: chad CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6256
This commit is contained in:
parent
619069e234
commit
46a7c61c80
6 changed files with 106 additions and 51 deletions
|
@ -814,7 +814,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'aphront-form-view-css' =>
|
'aphront-form-view-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/d541ef47/rsrc/css/aphront/form-view.css',
|
'uri' => '/res/068dd7ed/rsrc/css/aphront/form-view.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
@ -4057,7 +4057,7 @@ celerity_register_resource_map(array(
|
||||||
), array(
|
), array(
|
||||||
'packages' =>
|
'packages' =>
|
||||||
array(
|
array(
|
||||||
'c85c10a8' =>
|
'f0f013fd' =>
|
||||||
array(
|
array(
|
||||||
'name' => 'core.pkg.css',
|
'name' => 'core.pkg.css',
|
||||||
'symbols' =>
|
'symbols' =>
|
||||||
|
@ -4105,7 +4105,7 @@ celerity_register_resource_map(array(
|
||||||
40 => 'phabricator-property-list-view-css',
|
40 => 'phabricator-property-list-view-css',
|
||||||
41 => 'phabricator-tag-view-css',
|
41 => 'phabricator-tag-view-css',
|
||||||
),
|
),
|
||||||
'uri' => '/res/pkg/c85c10a8/core.pkg.css',
|
'uri' => '/res/pkg/f0f013fd/core.pkg.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
),
|
),
|
||||||
'f2ad0683' =>
|
'f2ad0683' =>
|
||||||
|
@ -4299,16 +4299,16 @@ celerity_register_resource_map(array(
|
||||||
'reverse' =>
|
'reverse' =>
|
||||||
array(
|
array(
|
||||||
'aphront-attached-file-view-css' => 'adc3c36d',
|
'aphront-attached-file-view-css' => 'adc3c36d',
|
||||||
'aphront-dialog-view-css' => 'c85c10a8',
|
'aphront-dialog-view-css' => 'f0f013fd',
|
||||||
'aphront-error-view-css' => 'c85c10a8',
|
'aphront-error-view-css' => 'f0f013fd',
|
||||||
'aphront-form-view-css' => 'c85c10a8',
|
'aphront-form-view-css' => 'f0f013fd',
|
||||||
'aphront-list-filter-view-css' => 'c85c10a8',
|
'aphront-list-filter-view-css' => 'f0f013fd',
|
||||||
'aphront-pager-view-css' => 'c85c10a8',
|
'aphront-pager-view-css' => 'f0f013fd',
|
||||||
'aphront-panel-view-css' => 'c85c10a8',
|
'aphront-panel-view-css' => 'f0f013fd',
|
||||||
'aphront-table-view-css' => 'c85c10a8',
|
'aphront-table-view-css' => 'f0f013fd',
|
||||||
'aphront-tokenizer-control-css' => 'c85c10a8',
|
'aphront-tokenizer-control-css' => 'f0f013fd',
|
||||||
'aphront-tooltip-css' => 'c85c10a8',
|
'aphront-tooltip-css' => 'f0f013fd',
|
||||||
'aphront-typeahead-control-css' => 'c85c10a8',
|
'aphront-typeahead-control-css' => 'f0f013fd',
|
||||||
'differential-changeset-view-css' => 'dd27a69b',
|
'differential-changeset-view-css' => 'dd27a69b',
|
||||||
'differential-core-view-css' => 'dd27a69b',
|
'differential-core-view-css' => 'dd27a69b',
|
||||||
'differential-inline-comment-editor' => '9488bb69',
|
'differential-inline-comment-editor' => '9488bb69',
|
||||||
|
@ -4322,7 +4322,7 @@ celerity_register_resource_map(array(
|
||||||
'differential-table-of-contents-css' => 'dd27a69b',
|
'differential-table-of-contents-css' => 'dd27a69b',
|
||||||
'diffusion-commit-view-css' => 'c8ce2d88',
|
'diffusion-commit-view-css' => 'c8ce2d88',
|
||||||
'diffusion-icons-css' => 'c8ce2d88',
|
'diffusion-icons-css' => 'c8ce2d88',
|
||||||
'global-drag-and-drop-css' => 'c85c10a8',
|
'global-drag-and-drop-css' => 'f0f013fd',
|
||||||
'inline-comment-summary-css' => 'dd27a69b',
|
'inline-comment-summary-css' => 'dd27a69b',
|
||||||
'javelin-aphlict' => 'f2ad0683',
|
'javelin-aphlict' => 'f2ad0683',
|
||||||
'javelin-behavior' => 'a9f14d76',
|
'javelin-behavior' => 'a9f14d76',
|
||||||
|
@ -4396,55 +4396,55 @@ celerity_register_resource_map(array(
|
||||||
'javelin-util' => 'a9f14d76',
|
'javelin-util' => 'a9f14d76',
|
||||||
'javelin-vector' => 'a9f14d76',
|
'javelin-vector' => 'a9f14d76',
|
||||||
'javelin-workflow' => 'a9f14d76',
|
'javelin-workflow' => 'a9f14d76',
|
||||||
'lightbox-attachment-css' => 'c85c10a8',
|
'lightbox-attachment-css' => 'f0f013fd',
|
||||||
'maniphest-task-summary-css' => 'adc3c36d',
|
'maniphest-task-summary-css' => 'adc3c36d',
|
||||||
'maniphest-transaction-detail-css' => 'adc3c36d',
|
'maniphest-transaction-detail-css' => 'adc3c36d',
|
||||||
'phabricator-action-list-view-css' => 'c85c10a8',
|
'phabricator-action-list-view-css' => 'f0f013fd',
|
||||||
'phabricator-application-launch-view-css' => 'c85c10a8',
|
'phabricator-application-launch-view-css' => 'f0f013fd',
|
||||||
'phabricator-busy' => 'f2ad0683',
|
'phabricator-busy' => 'f2ad0683',
|
||||||
'phabricator-content-source-view-css' => 'dd27a69b',
|
'phabricator-content-source-view-css' => 'dd27a69b',
|
||||||
'phabricator-core-css' => 'c85c10a8',
|
'phabricator-core-css' => 'f0f013fd',
|
||||||
'phabricator-crumbs-view-css' => 'c85c10a8',
|
'phabricator-crumbs-view-css' => 'f0f013fd',
|
||||||
'phabricator-drag-and-drop-file-upload' => '9488bb69',
|
'phabricator-drag-and-drop-file-upload' => '9488bb69',
|
||||||
'phabricator-dropdown-menu' => 'f2ad0683',
|
'phabricator-dropdown-menu' => 'f2ad0683',
|
||||||
'phabricator-file-upload' => 'f2ad0683',
|
'phabricator-file-upload' => 'f2ad0683',
|
||||||
'phabricator-filetree-view-css' => 'c85c10a8',
|
'phabricator-filetree-view-css' => 'f0f013fd',
|
||||||
'phabricator-flag-css' => 'c85c10a8',
|
'phabricator-flag-css' => 'f0f013fd',
|
||||||
'phabricator-form-view-css' => 'c85c10a8',
|
'phabricator-form-view-css' => 'f0f013fd',
|
||||||
'phabricator-header-view-css' => 'c85c10a8',
|
'phabricator-header-view-css' => 'f0f013fd',
|
||||||
'phabricator-hovercard' => 'f2ad0683',
|
'phabricator-hovercard' => 'f2ad0683',
|
||||||
'phabricator-jump-nav' => 'c85c10a8',
|
'phabricator-jump-nav' => 'f0f013fd',
|
||||||
'phabricator-keyboard-shortcut' => 'f2ad0683',
|
'phabricator-keyboard-shortcut' => 'f2ad0683',
|
||||||
'phabricator-keyboard-shortcut-manager' => 'f2ad0683',
|
'phabricator-keyboard-shortcut-manager' => 'f2ad0683',
|
||||||
'phabricator-main-menu-view' => 'c85c10a8',
|
'phabricator-main-menu-view' => 'f0f013fd',
|
||||||
'phabricator-menu-item' => 'f2ad0683',
|
'phabricator-menu-item' => 'f2ad0683',
|
||||||
'phabricator-nav-view-css' => 'c85c10a8',
|
'phabricator-nav-view-css' => 'f0f013fd',
|
||||||
'phabricator-notification' => 'f2ad0683',
|
'phabricator-notification' => 'f2ad0683',
|
||||||
'phabricator-notification-css' => 'c85c10a8',
|
'phabricator-notification-css' => 'f0f013fd',
|
||||||
'phabricator-notification-menu-css' => 'c85c10a8',
|
'phabricator-notification-menu-css' => 'f0f013fd',
|
||||||
'phabricator-object-item-list-view-css' => 'c85c10a8',
|
'phabricator-object-item-list-view-css' => 'f0f013fd',
|
||||||
'phabricator-object-selector-css' => 'dd27a69b',
|
'phabricator-object-selector-css' => 'dd27a69b',
|
||||||
'phabricator-phtize' => 'f2ad0683',
|
'phabricator-phtize' => 'f2ad0683',
|
||||||
'phabricator-prefab' => 'f2ad0683',
|
'phabricator-prefab' => 'f2ad0683',
|
||||||
'phabricator-project-tag-css' => 'adc3c36d',
|
'phabricator-project-tag-css' => 'adc3c36d',
|
||||||
'phabricator-property-list-view-css' => 'c85c10a8',
|
'phabricator-property-list-view-css' => 'f0f013fd',
|
||||||
'phabricator-remarkup-css' => 'c85c10a8',
|
'phabricator-remarkup-css' => 'f0f013fd',
|
||||||
'phabricator-shaped-request' => '9488bb69',
|
'phabricator-shaped-request' => '9488bb69',
|
||||||
'phabricator-side-menu-view-css' => 'c85c10a8',
|
'phabricator-side-menu-view-css' => 'f0f013fd',
|
||||||
'phabricator-standard-page-view' => 'c85c10a8',
|
'phabricator-standard-page-view' => 'f0f013fd',
|
||||||
'phabricator-tag-view-css' => 'c85c10a8',
|
'phabricator-tag-view-css' => 'f0f013fd',
|
||||||
'phabricator-textareautils' => 'f2ad0683',
|
'phabricator-textareautils' => 'f2ad0683',
|
||||||
'phabricator-tooltip' => 'f2ad0683',
|
'phabricator-tooltip' => 'f2ad0683',
|
||||||
'phabricator-transaction-view-css' => 'c85c10a8',
|
'phabricator-transaction-view-css' => 'f0f013fd',
|
||||||
'phabricator-zindex-css' => 'c85c10a8',
|
'phabricator-zindex-css' => 'f0f013fd',
|
||||||
'phui-button-css' => 'c85c10a8',
|
'phui-button-css' => 'f0f013fd',
|
||||||
'phui-form-css' => 'c85c10a8',
|
'phui-form-css' => 'f0f013fd',
|
||||||
'phui-icon-view-css' => 'c85c10a8',
|
'phui-icon-view-css' => 'f0f013fd',
|
||||||
'phui-spacing-css' => 'c85c10a8',
|
'phui-spacing-css' => 'f0f013fd',
|
||||||
'sprite-apps-large-css' => 'c85c10a8',
|
'sprite-apps-large-css' => 'f0f013fd',
|
||||||
'sprite-gradient-css' => 'c85c10a8',
|
'sprite-gradient-css' => 'f0f013fd',
|
||||||
'sprite-icons-css' => 'c85c10a8',
|
'sprite-icons-css' => 'f0f013fd',
|
||||||
'sprite-menu-css' => 'c85c10a8',
|
'sprite-menu-css' => 'f0f013fd',
|
||||||
'syntax-highlighting-css' => 'c85c10a8',
|
'syntax-highlighting-css' => 'f0f013fd',
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
|
@ -56,8 +56,22 @@ final class PhabricatorAuthEditController
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
if ($configs) {
|
if ($configs) {
|
||||||
// TODO: We could link to the other config's edit interface here.
|
$id = head($configs)->getID();
|
||||||
throw new Exception("This provider is already configured!");
|
$dialog = id(new AphrontDialogView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setMethod('GET')
|
||||||
|
->setSubmitURI($this->getApplicationURI('config/edit/'.$id.'/'))
|
||||||
|
->setTitle(pht('Provider Already Configured'))
|
||||||
|
->appendChild(
|
||||||
|
pht(
|
||||||
|
'This provider ("%s") already exists, and you can not add more '.
|
||||||
|
'than one instance of it. You can edit the existing provider, '.
|
||||||
|
'or you can choose a different provider.',
|
||||||
|
$provider->getProviderName()))
|
||||||
|
->addCancelButton($this->getApplicationURI('config/new/'))
|
||||||
|
->addSubmitButton(pht('Edit Existing Provider'));
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = $provider->getDefaultProviderConfig();
|
$config = $provider->getDefaultProviderConfig();
|
||||||
|
|
|
@ -46,12 +46,31 @@ final class PhabricatorAuthNewController
|
||||||
->setName('provider')
|
->setName('provider')
|
||||||
->setError($e_provider);
|
->setError($e_provider);
|
||||||
|
|
||||||
|
$configured = PhabricatorAuthProvider::getAllProviders();
|
||||||
|
$configured_classes = array();
|
||||||
|
foreach ($configured as $configured_provider) {
|
||||||
|
$configured_classes[get_class($configured_provider)] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort providers by login order, and move disabled providers to the
|
||||||
|
// bottom.
|
||||||
$providers = msort($providers, 'getLoginOrder');
|
$providers = msort($providers, 'getLoginOrder');
|
||||||
|
$providers = array_diff_key($providers, $configured_classes) + $providers;
|
||||||
|
|
||||||
foreach ($providers as $provider) {
|
foreach ($providers as $provider) {
|
||||||
|
if (isset($configured_classes[get_class($provider)])) {
|
||||||
|
$disabled = true;
|
||||||
|
$description = pht('This provider is already configured.');
|
||||||
|
} else {
|
||||||
|
$disabled = false;
|
||||||
|
$description = $provider->getDescriptionForCreate();
|
||||||
|
}
|
||||||
$options->addButton(
|
$options->addButton(
|
||||||
get_class($provider),
|
get_class($provider),
|
||||||
$provider->getNameForCreate(),
|
$provider->getNameForCreate(),
|
||||||
$provider->getDescriptionForCreate());
|
$description,
|
||||||
|
$disabled ? 'disabled' : null,
|
||||||
|
$disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
|
|
|
@ -14,6 +14,13 @@ final class AphrontDialogView extends AphrontView {
|
||||||
private $headerColor = PhabricatorActionHeaderView::HEADER_DARK_GREY;
|
private $headerColor = PhabricatorActionHeaderView::HEADER_DARK_GREY;
|
||||||
private $footers = array();
|
private $footers = array();
|
||||||
private $isStandalone;
|
private $isStandalone;
|
||||||
|
private $method = 'POST';
|
||||||
|
|
||||||
|
|
||||||
|
public function setMethod($method) {
|
||||||
|
$this->method = $method;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setIsStandalone($is_standalone) {
|
public function setIsStandalone($is_standalone) {
|
||||||
$this->isStandalone = $is_standalone;
|
$this->isStandalone = $is_standalone;
|
||||||
|
@ -159,7 +166,7 @@ final class AphrontDialogView extends AphrontView {
|
||||||
|
|
||||||
$form_attributes = array(
|
$form_attributes = array(
|
||||||
'action' => $this->submitURI,
|
'action' => $this->submitURI,
|
||||||
'method' => 'post',
|
'method' => $this->method,
|
||||||
'id' => $this->formID,
|
'id' => $this->formID,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,18 @@ final class AphrontFormRadioButtonControl extends AphrontFormControl {
|
||||||
|
|
||||||
private $buttons = array();
|
private $buttons = array();
|
||||||
|
|
||||||
public function addButton($value, $label, $caption, $class = null) {
|
public function addButton(
|
||||||
|
$value,
|
||||||
|
$label,
|
||||||
|
$caption,
|
||||||
|
$class = null,
|
||||||
|
$disabled = false) {
|
||||||
$this->buttons[] = array(
|
$this->buttons[] = array(
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'caption' => $caption,
|
'caption' => $caption,
|
||||||
'class' => $class,
|
'class' => $class,
|
||||||
|
'disabled' => $disabled,
|
||||||
);
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +38,9 @@ final class AphrontFormRadioButtonControl extends AphrontFormControl {
|
||||||
'checked' => ($button['value'] == $this->getValue())
|
'checked' => ($button['value'] == $this->getValue())
|
||||||
? 'checked'
|
? 'checked'
|
||||||
: null,
|
: null,
|
||||||
'disabled' => $this->getDisabled() ? 'disabled' : null,
|
'disabled' => ($this->getDisabled() || $button['disabled'])
|
||||||
|
? 'disabled'
|
||||||
|
: null,
|
||||||
));
|
));
|
||||||
$label = phutil_tag(
|
$label = phutil_tag(
|
||||||
'label',
|
'label',
|
||||||
|
|
|
@ -190,6 +190,7 @@ table.aphront-form-control-radio-layout th {
|
||||||
color: #222222;
|
color: #222222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
table.aphront-form-control-checkbox-layout th {
|
table.aphront-form-control-checkbox-layout th {
|
||||||
padding-top: 2px;
|
padding-top: 2px;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
|
@ -204,6 +205,12 @@ table.aphront-form-control-checkbox-layout th {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.aphront-form-control-radio-layout label.disabled,
|
||||||
|
.aphront-form-control-checkbox-layout label.disabled {
|
||||||
|
color: #777777;
|
||||||
|
}
|
||||||
|
|
||||||
.aphront-form-radio-caption {
|
.aphront-form-radio-caption {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue