mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Move profile-related "settings" and "account" panel information to "edit profile"
Summary: Ref T1703. Put this stuff on Profile -> Edit Profile instead of spread across Settings -> Account and Settings -> Profile. Makes it custom-field driven. Test Plan: {F49333} {F49334} Reviewers: chad, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1703 Differential Revision: https://secure.phabricator.com/D6397
This commit is contained in:
parent
c5f2e617d8
commit
62ab1dcc62
4 changed files with 29 additions and 61 deletions
|
@ -104,23 +104,31 @@ final class PhabricatorPeopleProfileController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav->appendChild($header);
|
$actions = id(new PhabricatorActionListView())
|
||||||
$nav->appendChild($content);
|
->setUser($viewer);
|
||||||
|
|
||||||
if ($user->getPHID() == $viewer->getPHID()) {
|
$can_edit = ($user->getPHID() == $viewer->getPHID());
|
||||||
$nav->addFilter(
|
|
||||||
null,
|
$actions->addAction(
|
||||||
pht('Edit Profile...'),
|
id(new PhabricatorActionView())
|
||||||
'/settings/panel/profile/');
|
->setIcon('edit')
|
||||||
}
|
->setName(pht('Edit Profile'))
|
||||||
|
->setHref($this->getApplicationURI('editprofile/'.$user->getID().'/'))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
if ($viewer->getIsAdmin()) {
|
if ($viewer->getIsAdmin()) {
|
||||||
$nav->addFilter(
|
$actions->addAction(
|
||||||
null,
|
id(new PhabricatorActionView())
|
||||||
pht('Administrate User...'),
|
->setIcon('blame')
|
||||||
'/people/edit/'.$user->getID().'/');
|
->setName(pht('Administrate User'))
|
||||||
|
->setHref($this->getApplicationURI('edit/'.$user->getID().'/')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nav->appendChild($header);
|
||||||
|
$nav->appendChild($actions);
|
||||||
|
$nav->appendChild($content);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
$nav,
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -26,6 +26,9 @@ final class PhabricatorUserRealNameField
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNewValueForApplicationTransactions() {
|
public function getNewValueForApplicationTransactions() {
|
||||||
|
if (!$this->isEditable()) {
|
||||||
|
return $this->getObject()->getRealName();
|
||||||
|
}
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +45,12 @@ final class PhabricatorUserRealNameField
|
||||||
return id(new AphrontFormTextControl())
|
return id(new AphrontFormTextControl())
|
||||||
->setName($this->getFieldKey())
|
->setName($this->getFieldKey())
|
||||||
->setValue($this->value)
|
->setValue($this->value)
|
||||||
->setLabel($this->getFieldName());
|
->setLabel($this->getFieldName())
|
||||||
|
->setDisabled(!$this->isEditable());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isEditable() {
|
||||||
|
return PhabricatorEnv::getEnvConfig('account.editable');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,8 @@ final class PhabricatorSettingsPanelAccount
|
||||||
|
|
||||||
public function processRequest(AphrontRequest $request) {
|
public function processRequest(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
$editable = PhabricatorEnv::getEnvConfig('account.editable');
|
|
||||||
|
|
||||||
$e_realname = $editable ? true : null;
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
|
|
||||||
if ($editable) {
|
|
||||||
$user->setRealName($request->getStr('realname'));
|
|
||||||
if (!strlen($user->getRealName())) {
|
|
||||||
$errors[] = pht('Real name must be nonempty.');
|
|
||||||
$e_realname = pht('Required');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_timezone = $request->getStr('timezone');
|
$new_timezone = $request->getStr('timezone');
|
||||||
if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
|
if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) {
|
||||||
$user->setTimezoneIdentifier($new_timezone);
|
$user->setTimezoneIdentifier($new_timezone);
|
||||||
|
@ -72,13 +60,6 @@ final class PhabricatorSettingsPanelAccount
|
||||||
id(new AphrontFormStaticControl())
|
id(new AphrontFormStaticControl())
|
||||||
->setLabel(pht('Username'))
|
->setLabel(pht('Username'))
|
||||||
->setValue($user->getUsername()))
|
->setValue($user->getUsername()))
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormTextControl())
|
|
||||||
->setLabel(pht('Real Name'))
|
|
||||||
->setName('realname')
|
|
||||||
->setError($e_realname)
|
|
||||||
->setValue($user->getRealName())
|
|
||||||
->setDisabled(!$editable))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSelectControl())
|
id(new AphrontFormSelectControl())
|
||||||
->setLabel(pht('Timezone'))
|
->setLabel(pht('Timezone'))
|
||||||
|
|
|
@ -25,9 +25,6 @@ final class PhabricatorSettingsPanelProfile
|
||||||
$e_image = null;
|
$e_image = null;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$profile->setTitle($request->getStr('title'));
|
|
||||||
$profile->setBlurb($request->getStr('blurb'));
|
|
||||||
|
|
||||||
$sex = $request->getStr('sex');
|
$sex = $request->getStr('sex');
|
||||||
$sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE);
|
$sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE);
|
||||||
if (in_array($sex, $sexes)) {
|
if (in_array($sex, $sexes)) {
|
||||||
|
@ -148,12 +145,6 @@ final class PhabricatorSettingsPanelProfile
|
||||||
$form
|
$form
|
||||||
->setUser($request->getUser())
|
->setUser($request->getUser())
|
||||||
->setEncType('multipart/form-data')
|
->setEncType('multipart/form-data')
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormTextControl())
|
|
||||||
->setLabel(pht('Title'))
|
|
||||||
->setName('title')
|
|
||||||
->setValue($profile->getTitle())
|
|
||||||
->setCaption(pht('Serious business title.')))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSelectControl())
|
id(new AphrontFormSelectControl())
|
||||||
->setOptions($sexes)
|
->setOptions($sexes)
|
||||||
|
@ -166,26 +157,6 @@ final class PhabricatorSettingsPanelProfile
|
||||||
->setLabel(pht('Translation'))
|
->setLabel(pht('Translation'))
|
||||||
->setName('translation')
|
->setName('translation')
|
||||||
->setValue($user->getTranslation()))
|
->setValue($user->getTranslation()))
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormMarkupControl())
|
|
||||||
->setLabel(pht('Profile URI'))
|
|
||||||
->setValue(
|
|
||||||
phutil_tag(
|
|
||||||
'a',
|
|
||||||
array(
|
|
||||||
'href' => $profile_uri,
|
|
||||||
),
|
|
||||||
$profile_uri)))
|
|
||||||
->appendChild(hsprintf(
|
|
||||||
'<p class="aphront-form-instructions">%s</p>',
|
|
||||||
pht('Write something about yourself! Make sure to include important ' .
|
|
||||||
'information like your favorite Pokemon and which Starcraft race ' .
|
|
||||||
'you play.')))
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormTextAreaControl())
|
|
||||||
->setLabel(pht('Blurb'))
|
|
||||||
->setName('blurb')
|
|
||||||
->setValue($profile->getBlurb()))
|
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormMarkupControl())
|
id(new AphrontFormMarkupControl())
|
||||||
->setLabel(pht('Profile Image'))
|
->setLabel(pht('Profile Image'))
|
||||||
|
|
Loading…
Reference in a new issue