1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +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',
'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' =>
array(
'hash' => 'ff7da044e6f923b8f569dec11f97e5e5',
@ -3439,6 +3453,15 @@ celerity_register_resource_map(array(
),
'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' =>
array(
'uri' => '/res/e71e4a67/rsrc/css/application/phriction/phriction-document-css.css',

View file

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

View file

@ -38,16 +38,24 @@ final class PhrequentUIEventListener
$object->getPHID());
if (!$tracking) {
$track_action = id(new PhabricatorActionView())
->setName(pht('Track Time'))
->setIcon('history')
->setWorkflow(true)
->setHref('/phrequent/track/start/'.$object->getPHID().'/');
->setUser($user)
->setName(pht('Start Tracking Time'))
->setIcon('history')
->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/phrequent/track/start/'.$object->getPHID().'/');
} else {
$track_action = id(new PhabricatorActionView())
->setName(pht('Stop Tracking'))
->setIcon('history')
->setWorkflow(true)
->setHref('/phrequent/track/stop/'.$object->getPHID().'/');
->setUser($user)
->setName(pht('Stop Tracking Time'))
->setIcon('history')
->setWorkflow(true)
->setRenderAsForm(true)
->setHref('/phrequent/track/stop/'.$object->getPHID().'/');
}
if (!$user->isLoggedIn()) {
$track_action->setDisabled(true);
}
$actions = $event->getValue('actions');
@ -69,13 +77,51 @@ final class PhrequentUIEventListener
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(
$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->addProperty(
pht('Time Spent'),
$time_spent == 0 ? 'none' :
phabricator_format_relative_time_detailed($time_spent));
$view->addProperty(pht('Time Spent'), $property);
}
}

View file

@ -114,6 +114,17 @@ final class PhrequentUserTimeQuery extends PhabricatorOffsetPagedQuery {
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) {
$usertime_dao = new PhrequentUserTime();
$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