1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Fix 403s in Phrequent by rendering actions as forms, and make properties fancier

Summary:
Also cleans up some stuff like logged out users a bit. This provides a more subtle alternative to {D5485}.

(This is fairly rough, and the icons need to be sprited if we stick with this approach.)

Test Plan:
{F38047}
{F38048}

Reviewers: hach-que, btrahan

Reviewed By: hach-que

CC: aran, chad

Maniphest Tasks: T2857

Differential Revision: https://secure.phabricator.com/D5494
This commit is contained in:
epriestley 2013-03-30 19:37:13 -07:00
parent 33f2bf7c32
commit 1196675697
7 changed files with 114 additions and 13 deletions

View file

@ -448,6 +448,20 @@ celerity_register_resource_map(array(
'disk' => '/rsrc/image/menu_texture.png', 'disk' => '/rsrc/image/menu_texture.png',
'type' => 'png', 'type' => 'png',
), ),
'/rsrc/image/phrequent_active.png' =>
array(
'hash' => '716cddc08630eaa33934b2008723cac0',
'uri' => '/res/716cddc0/rsrc/image/phrequent_active.png',
'disk' => '/rsrc/image/phrequent_active.png',
'type' => 'png',
),
'/rsrc/image/phrequent_inactive.png' =>
array(
'hash' => 'f9099683873c01c5de1dc6650bd668fe',
'uri' => '/res/f9099683/rsrc/image/phrequent_inactive.png',
'disk' => '/rsrc/image/phrequent_inactive.png',
'type' => 'png',
),
'/rsrc/image/search.png' => '/rsrc/image/search.png' =>
array( array(
'hash' => 'ff7da044e6f923b8f569dec11f97e5e5', 'hash' => 'ff7da044e6f923b8f569dec11f97e5e5',
@ -3439,6 +3453,15 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/css/application/pholio/pholio-inline-comments.css', 'disk' => '/rsrc/css/application/pholio/pholio-inline-comments.css',
), ),
'phrequent-css' =>
array(
'uri' => '/res/8fc8f63c/rsrc/css/application/phrequent/phrequent.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/phrequent/phrequent.css',
),
'phriction-document-css' => 'phriction-document-css' =>
array( array(
'uri' => '/res/e71e4a67/rsrc/css/application/phriction/phriction-document-css.css', 'uri' => '/res/e71e4a67/rsrc/css/application/phriction/phriction-document-css.css',

View file

@ -1,7 +1,7 @@
<?php <?php
final class PhrequentTrackController final class PhrequentTrackController
extends PhabricatorApplicationsController { extends PhrequentController {
private $verb; private $verb;
private $phid; private $phid;
@ -25,6 +25,7 @@ final class PhrequentTrackController
} else if ($this->isStoppingTracking()) { } else if ($this->isStoppingTracking()) {
$this->stopTracking($user, $this->phid); $this->stopTracking($user, $this->phid);
} }
return id(new AphrontRedirectResponse()); return id(new AphrontRedirectResponse());
} }

View file

@ -38,16 +38,24 @@ final class PhrequentUIEventListener
$object->getPHID()); $object->getPHID());
if (!$tracking) { if (!$tracking) {
$track_action = id(new PhabricatorActionView()) $track_action = id(new PhabricatorActionView())
->setName(pht('Track Time')) ->setUser($user)
->setIcon('history') ->setName(pht('Start Tracking Time'))
->setWorkflow(true) ->setIcon('history')
->setHref('/phrequent/track/start/'.$object->getPHID().'/'); ->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/phrequent/track/start/'.$object->getPHID().'/');
} else { } else {
$track_action = id(new PhabricatorActionView()) $track_action = id(new PhabricatorActionView())
->setName(pht('Stop Tracking')) ->setUser($user)
->setIcon('history') ->setName(pht('Stop Tracking Time'))
->setWorkflow(true) ->setIcon('history')
->setHref('/phrequent/track/stop/'.$object->getPHID().'/'); ->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/phrequent/track/stop/'.$object->getPHID().'/');
}
if (!$user->isLoggedIn()) {
$track_action->setDisabled(true);
} }
$actions = $event->getValue('actions'); $actions = $event->getValue('actions');
@ -69,13 +77,51 @@ final class PhrequentUIEventListener
return; return;
} }
$depth = false;
$stack = PhrequentUserTimeQuery::loadUserStack($user);
if ($stack) {
$stack = array_values($stack);
for ($ii = 0; $ii < count($stack); $ii++) {
if ($stack[$ii]->getObjectPHID() == $object->getPHID()) {
$depth = ($ii + 1);
break;
}
}
}
$time_spent = PhrequentUserTimeQuery::getTotalTimeSpentOnObject( $time_spent = PhrequentUserTimeQuery::getTotalTimeSpentOnObject(
$object->getPHID()); $object->getPHID());
if (!$depth && !$time_spent) {
return;
}
require_celerity_resource('phrequent-css');
$property = array();
if ($depth == 1) {
$property[] = phutil_tag(
'div',
array(
'class' => 'phrequent-tracking-property phrequent-active',
),
pht('Currently Tracking'));
} else if ($depth > 1) {
$property[] = phutil_tag(
'div',
array(
'class' => 'phrequent-tracking-property phrequent-on-stack',
),
pht('On Stack'));
}
if ($time_spent) {
$property[] = phabricator_format_relative_time_detailed($time_spent);
}
$view = $event->getValue('view'); $view = $event->getValue('view');
$view->addProperty( $view->addProperty(pht('Time Spent'), $property);
pht('Time Spent'),
$time_spent == 0 ? 'none' :
phabricator_format_relative_time_detailed($time_spent));
} }
} }

View file

@ -114,6 +114,17 @@ final class PhrequentUserTimeQuery extends PhabricatorOffsetPagedQuery {
return $count['N'] > 0; return $count['N'] > 0;
} }
public static function loadUserStack(PhabricatorUser $user) {
if (!$user->isLoggedIn()) {
return array();
}
return id(new PhrequentUserTime())->loadAllWhere(
'userPHID = %s AND dateEnded IS NULL
ORDER BY dateStarted DESC, id DESC',
$user->getPHID());
}
public static function getTotalTimeSpentOnObject($phid) { public static function getTotalTimeSpentOnObject($phid) {
$usertime_dao = new PhrequentUserTime(); $usertime_dao = new PhrequentUserTime();
$conn = $usertime_dao->establishConnection('r'); $conn = $usertime_dao->establishConnection('r');

View file

@ -0,0 +1,20 @@
/**
* @provides phrequent-css
*/
.phrequent-tracking-property {
padding: 6px 6px 6px 28px;
margin-bottom: 2px;
background: #e9e9e9;
background-repeat: no-repeat;
background-position: 6px center;
}
.phrequent-active {
background-image: url(/rsrc/image/phrequent_active.png);
}
.phrequent-on-stack {
color: #777777;
background-image: url(/rsrc/image/phrequent_inactive.png);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB