mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-14 16:51:08 +01:00
Separate handle "status" and "availability"
Summary: Ref T7707. Handles currently have a "status" field and a "disabled" field. The "status" field has these possible values: "open", "closed", "1", "2". durp durp durp Instead, do: - status = <open, closed> - availability = <full, partial, none, disabled> I think these make more sense? And are a bit more general? And use the same kind of constants for all values! Test Plan: Looked at all affected handles in all states (probably). Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7707 Differential Revision: https://secure.phabricator.com/D12832
This commit is contained in:
parent
bc101e7c73
commit
04186e02cf
20 changed files with 76 additions and 75 deletions
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
return array(
|
||||
'names' => array(
|
||||
'core.pkg.css' => '7ac320f1',
|
||||
'core.pkg.css' => '9990f46d',
|
||||
'core.pkg.js' => 'a2f2598e',
|
||||
'darkconsole.pkg.js' => 'e7393ebb',
|
||||
'differential.pkg.css' => 'bb338e4b',
|
||||
|
@ -37,7 +37,7 @@ return array(
|
|||
'rsrc/css/application/base/main-menu-view.css' => '663e3810',
|
||||
'rsrc/css/application/base/notification-menu.css' => '3c9d8aa1',
|
||||
'rsrc/css/application/base/phabricator-application-launch-view.css' => '16ca323f',
|
||||
'rsrc/css/application/base/standard-page-view.css' => '2acd4611',
|
||||
'rsrc/css/application/base/standard-page-view.css' => '61e68a55',
|
||||
'rsrc/css/application/chatlog/chatlog.css' => '852140ff',
|
||||
'rsrc/css/application/conduit/conduit-api.css' => '7bc725c4',
|
||||
'rsrc/css/application/config/config-options.css' => '7fedf08b',
|
||||
|
@ -731,7 +731,7 @@ return array(
|
|||
'phabricator-side-menu-view-css' => 'c1db9e9c',
|
||||
'phabricator-slowvote-css' => '266df6a1',
|
||||
'phabricator-source-code-view-css' => '2ceee894',
|
||||
'phabricator-standard-page-view' => '2acd4611',
|
||||
'phabricator-standard-page-view' => '61e68a55',
|
||||
'phabricator-textareautils' => '5c93c52c',
|
||||
'phabricator-title' => 'df5e11d2',
|
||||
'phabricator-tooltip' => '1d298e3a',
|
||||
|
|
|
@ -2143,7 +2143,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOAuthServerTokenController' => 'applications/oauthserver/controller/PhabricatorOAuthServerTokenController.php',
|
||||
'PhabricatorObjectHandle' => 'applications/phid/PhabricatorObjectHandle.php',
|
||||
'PhabricatorObjectHandleConstants' => 'applications/phid/handle/const/PhabricatorObjectHandleConstants.php',
|
||||
'PhabricatorObjectHandleStatus' => 'applications/phid/handle/const/PhabricatorObjectHandleStatus.php',
|
||||
'PhabricatorObjectHasAsanaSubtaskEdgeType' => 'applications/doorkeeper/edge/PhabricatorObjectHasAsanaSubtaskEdgeType.php',
|
||||
'PhabricatorObjectHasAsanaTaskEdgeType' => 'applications/doorkeeper/edge/PhabricatorObjectHasAsanaTaskEdgeType.php',
|
||||
'PhabricatorObjectHasContributorEdgeType' => 'applications/transactions/edges/PhabricatorObjectHasContributorEdgeType.php',
|
||||
|
@ -5549,7 +5548,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOAuthServerTestController' => 'PhabricatorOAuthServerController',
|
||||
'PhabricatorOAuthServerTokenController' => 'PhabricatorAuthController',
|
||||
'PhabricatorObjectHandle' => 'PhabricatorPolicyInterface',
|
||||
'PhabricatorObjectHandleStatus' => 'PhabricatorObjectHandleConstants',
|
||||
'PhabricatorObjectHasAsanaSubtaskEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorObjectHasAsanaTaskEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorObjectHasContributorEdgeType' => 'PhabricatorEdgeType',
|
||||
|
|
|
@ -42,7 +42,7 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType {
|
|||
->setURI('/E'.$id);
|
||||
|
||||
if ($is_cancelled) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ final class PhabricatorDashboardPanelPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setURI("/{$monogram}");
|
||||
|
||||
if ($panel->getIsArchived()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class DifferentialRevisionPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setFullName("D{$id}: {$title}");
|
||||
|
||||
if ($revision->isClosed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ final class PhabricatorFlagSearchEngine
|
|||
->setHeader($flag->getHandle()->getFullName())
|
||||
->setHref($flag->getHandle()->getURI());
|
||||
|
||||
$status_open = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
||||
$status_open = PhabricatorObjectHandle::STATUS_OPEN;
|
||||
if ($flag->getHandle()->getStatus() != $status_open) {
|
||||
$item->setDisabled(true);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ final class FundInitiativePHIDType extends PhabricatorPHIDType {
|
|||
$name = $initiative->getName();
|
||||
|
||||
if ($initiative->isClosed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
|
||||
$handle->setName($name);
|
||||
|
|
|
@ -39,7 +39,7 @@ final class ManiphestTaskPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setURI("/T{$id}");
|
||||
|
||||
if ($task->isClosed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ final class PassphraseCredentialPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setURI("/K{$id}");
|
||||
|
||||
if ($credential->getIsDestroyed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,28 @@ final class PhabricatorPeopleUserPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setURI('/p/'.$user->getUsername().'/');
|
||||
$handle->setFullName($user->getFullName());
|
||||
$handle->setImageURI($user->getProfileImageURI());
|
||||
$handle->setDisabled(!$user->isUserActivated());
|
||||
if ($user->hasStatus()) {
|
||||
$status = $user->getStatus();
|
||||
$handle->setStatus($status->getTextStatus());
|
||||
$handle->setTitle($status->getTerseSummary($query->getViewer()));
|
||||
|
||||
$availability = null;
|
||||
if (!$user->isUserActivated()) {
|
||||
$availability = PhabricatorObjectHandle::AVAILABILITY_DISABLED;
|
||||
} else {
|
||||
if ($user->hasStatus()) {
|
||||
// NOTE: This first call returns an event; then we get the event
|
||||
// status.
|
||||
$status = $user->getStatus()->getStatus();
|
||||
switch ($status) {
|
||||
case PhabricatorCalendarEvent::STATUS_AWAY:
|
||||
$availability = PhabricatorObjectHandle::AVAILABILITY_NONE;
|
||||
break;
|
||||
case PhabricatorCalendarEvent::STATUS_SPORADIC:
|
||||
$availability = PhabricatorObjectHandle::AVAILABILITY_PARTIAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($availability) {
|
||||
$handle->setAvailability($availability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
final class PhabricatorObjectHandle
|
||||
implements PhabricatorPolicyInterface {
|
||||
|
||||
const AVAILABILITY_FULL = 'full';
|
||||
const AVAILABILITY_NONE = 'none';
|
||||
const AVAILABILITY_PARTIAL = 'partial';
|
||||
const AVAILABILITY_DISABLED = 'disabled';
|
||||
|
||||
const STATUS_OPEN = 'open';
|
||||
const STATUS_CLOSED = 'closed';
|
||||
|
||||
private $uri;
|
||||
private $phid;
|
||||
private $type;
|
||||
|
@ -13,9 +21,9 @@ final class PhabricatorObjectHandle
|
|||
private $icon;
|
||||
private $tagColor;
|
||||
private $timestamp;
|
||||
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
||||
private $status = self::STATUS_OPEN;
|
||||
private $availability = self::AVAILABILITY_FULL;
|
||||
private $complete;
|
||||
private $disabled;
|
||||
private $objectName;
|
||||
private $policyFiltered;
|
||||
|
||||
|
@ -129,6 +137,19 @@ final class PhabricatorObjectHandle
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
public function setAvailability($availability) {
|
||||
$this->availability = $availability;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAvailability() {
|
||||
return $this->availability;
|
||||
}
|
||||
|
||||
public function isDisabled() {
|
||||
return ($this->getAvailability() == self::AVAILABILITY_DISABLED);
|
||||
}
|
||||
|
||||
public function setStatus($status) {
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
|
@ -225,33 +246,6 @@ final class PhabricatorObjectHandle
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether or not the underlying object is disabled. See
|
||||
* @{method:isDisabled} for an explanation of what it means to be disabled.
|
||||
*
|
||||
* @param bool True if the handle represents a disabled object.
|
||||
* @return this
|
||||
*/
|
||||
public function setDisabled($disabled) {
|
||||
$this->disabled = $disabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the handle represents an object which has been disabled --
|
||||
* for example, disabled users, archived projects, etc. These objects are
|
||||
* complete and exist, but should be excluded from some system interactions
|
||||
* (for instance, they usually should not appear in typeaheads, and should
|
||||
* not have mail/notifications delivered to or about them).
|
||||
*
|
||||
* @return bool True if the handle represents a disabled object.
|
||||
*/
|
||||
public function isDisabled() {
|
||||
return $this->disabled;
|
||||
}
|
||||
|
||||
|
||||
public function renderLink($name = null) {
|
||||
if ($name === null) {
|
||||
$name = $this->getLinkName();
|
||||
|
@ -260,14 +254,12 @@ final class PhabricatorObjectHandle
|
|||
$classes[] = 'phui-handle';
|
||||
$title = $this->title;
|
||||
|
||||
if ($this->status != PhabricatorObjectHandleStatus::STATUS_OPEN) {
|
||||
if ($this->status != self::STATUS_OPEN) {
|
||||
$classes[] = 'handle-status-'.$this->status;
|
||||
$title = $title ? $title : $this->status;
|
||||
}
|
||||
|
||||
if ($this->disabled) {
|
||||
$classes[] = 'handle-disabled';
|
||||
$title = pht('Disabled'); // Overwrite status.
|
||||
if ($this->availability != self::AVAILABILITY_FULL) {
|
||||
$classes[] = 'handle-availability-'.$this->availability;
|
||||
}
|
||||
|
||||
if ($this->getType() == PhabricatorPeopleUserPHIDType::TYPECONST) {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorObjectHandleStatus
|
||||
extends PhabricatorObjectHandleConstants {
|
||||
|
||||
const STATUS_OPEN = 'open';
|
||||
const STATUS_CLOSED = 'closed';
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ final class PholioMockPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setFullName("M{$id}: {$name}");
|
||||
|
||||
if ($mock->isClosed()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ final class PhrictionDocumentPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setURI(PhrictionDocument::getSlugURI($slug));
|
||||
|
||||
if ($status != PhrictionDocumentStatus::STATUS_EXISTS) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,10 @@ final class PhabricatorProjectColumnPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$handle->setName($column->getDisplayName());
|
||||
$handle->setURI('/project/board/'.$column->getProject()->getID().'/');
|
||||
$handle->setDisabled($column->isHidden());
|
||||
|
||||
if ($column->isHidden()) {
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ final class PhabricatorProjectProjectPHIDType extends PhabricatorPHIDType {
|
|||
$handle->setTagColor($project->getColor());
|
||||
|
||||
if ($project->isArchived()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class PhabricatorSearchResultView extends AphrontView {
|
|||
->setImageURI($handle->getImageURI())
|
||||
->addAttribute($type_name);
|
||||
|
||||
if ($handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
||||
if ($handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) {
|
||||
$item->setDisabled(true);
|
||||
$item->addAttribute(pht('Closed'));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ final class PhabricatorTypeaheadTokenView
|
|||
->setIcon($handle->getIcon());
|
||||
|
||||
if ($handle->isDisabled() ||
|
||||
$handle->getStatus() == PhabricatorObjectHandleStatus::STATUS_CLOSED) {
|
||||
$handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) {
|
||||
$token->setTokenType(self::TYPE_DISABLED);
|
||||
} else {
|
||||
$token->setColor($handle->getTagColor());
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
|
|||
|
||||
$href = $this->getObjectHref($object, $handle, $id);
|
||||
$text = $this->getObjectNamePrefix().$id;
|
||||
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
|
||||
$status_closed = PhabricatorObjectHandle::STATUS_CLOSED;
|
||||
|
||||
if ($anchor) {
|
||||
$href = $href.'#'.$anchor;
|
||||
|
@ -126,7 +126,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
|
|||
|
||||
$name = $handle->getFullName();
|
||||
$href = $handle->getURI();
|
||||
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
|
||||
$status_closed = PhabricatorObjectHandle::STATUS_CLOSED;
|
||||
$attr = array(
|
||||
'phid' => $handle->getPHID(),
|
||||
'closed' => ($handle->getStatus() == $status_closed),
|
||||
|
@ -140,7 +140,7 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
|
|||
$href,
|
||||
PhabricatorObjectHandle $handle) {
|
||||
|
||||
$status_closed = PhabricatorObjectHandleStatus::STATUS_CLOSED;
|
||||
$status_closed = PhabricatorObjectHandle::STATUS_CLOSED;
|
||||
$strikethrough = $handle->getStatus() == $status_closed ?
|
||||
'text-decoration: line-through;' :
|
||||
'text-decoration: none;';
|
||||
|
|
|
@ -80,23 +80,23 @@ a.handle-status-closed:hover {
|
|||
color: #19558D;
|
||||
}
|
||||
|
||||
a.handle-disabled,
|
||||
a.handle-status-away,
|
||||
a.handle-status-sporadic {
|
||||
a.handle-availability-disabled,
|
||||
a.handle-availability-none,
|
||||
a.handle-availability-partial {
|
||||
padding-left: 11px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: -4px center;
|
||||
}
|
||||
|
||||
a.handle-status-away {
|
||||
a.handle-availability-none {
|
||||
background-image: url(/rsrc/image/icon/fatcow/bullet_red.png);
|
||||
}
|
||||
|
||||
a.handle-status-sporadic {
|
||||
a.handle-availability-partial {
|
||||
background-image: url(/rsrc/image/icon/fatcow/bullet_orange.png);
|
||||
}
|
||||
|
||||
a.handle-disabled {
|
||||
a.handle-availability-disabled {
|
||||
background-image: url(/rsrc/image/icon/fatcow/bullet_black.png);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue