2011-03-25 05:32:26 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class HeraldTranscriptListController extends HeraldController {
|
2011-03-25 05:32:26 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
2011-06-18 22:07:02 +02:00
|
|
|
$user = $request->getUser();
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Get one page of data together with the pager.
|
2011-03-25 05:32:26 +01:00
|
|
|
// Pull these objects manually since the serialized fields are gigantic.
|
|
|
|
$transcript = new HeraldTranscript();
|
2011-04-07 23:24:54 +02:00
|
|
|
|
|
|
|
$conn_r = $transcript->establishConnection('r');
|
|
|
|
$phid = $request->getStr('phid');
|
|
|
|
$where_clause = '';
|
|
|
|
if ($phid) {
|
|
|
|
$where_clause = qsprintf(
|
|
|
|
$conn_r,
|
|
|
|
'WHERE objectPHID = %s',
|
2011-04-09 01:15:00 +02:00
|
|
|
$phid);
|
2011-04-07 23:24:54 +02:00
|
|
|
}
|
|
|
|
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
$pager->setOffset($request->getInt('offset'));
|
|
|
|
$pager->setURI($request->getRequestURI(), 'offset');
|
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
$limit_clause = qsprintf(
|
|
|
|
$conn_r,
|
|
|
|
'LIMIT %d, %d',
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
$pager->getOffset(),
|
|
|
|
$pager->getPageSize() + 1);
|
2011-04-09 01:15:00 +02:00
|
|
|
|
2011-03-25 05:32:26 +01:00
|
|
|
$data = queryfx_all(
|
2011-04-07 23:24:54 +02:00
|
|
|
$conn_r,
|
2011-03-25 05:32:26 +01:00
|
|
|
'SELECT id, objectPHID, time, duration, dryRun FROM %T
|
2011-04-07 23:24:54 +02:00
|
|
|
%Q
|
2011-03-25 05:32:26 +01:00
|
|
|
ORDER BY id DESC
|
2011-04-09 01:15:00 +02:00
|
|
|
%Q',
|
2011-04-07 23:24:54 +02:00
|
|
|
$transcript->getTableName(),
|
2011-04-09 01:15:00 +02:00
|
|
|
$where_clause,
|
|
|
|
$limit_clause);
|
|
|
|
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
$data = $pager->sliceResults($data);
|
2011-03-25 05:32:26 +01:00
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Render the table.
|
2011-03-25 05:32:26 +01:00
|
|
|
$handles = array();
|
|
|
|
if ($data) {
|
|
|
|
$phids = ipull($data, 'objectPHID', 'objectPHID');
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-03-25 05:32:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data as $xscript) {
|
|
|
|
$rows[] = array(
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
phabricator_date($xscript['time'], $user),
|
|
|
|
phabricator_time($xscript['time'], $user),
|
2011-03-25 05:32:26 +01:00
|
|
|
$handles[$xscript['objectPHID']]->renderLink(),
|
|
|
|
$xscript['dryRun'] ? 'Yes' : '',
|
|
|
|
number_format((int)(1000 * $xscript['duration'])).' ms',
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2011-03-25 05:32:26 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/herald/transcript/'.$xscript['id'].'/',
|
|
|
|
'class' => 'button small grey',
|
|
|
|
),
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('View Transcript')),
|
2011-03-25 05:32:26 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
2013-05-20 17:24:07 +02:00
|
|
|
pht('Date'),
|
|
|
|
pht('Time'),
|
|
|
|
pht('Object'),
|
|
|
|
pht('Dry Run'),
|
|
|
|
pht('Duration'),
|
|
|
|
pht('View'),
|
2011-03-25 05:32:26 +01:00
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
|
|
|
'right',
|
|
|
|
'wide wrap',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'action',
|
|
|
|
));
|
|
|
|
|
2011-04-09 01:15:00 +02:00
|
|
|
// Render the whole page.
|
2011-03-25 05:32:26 +01:00
|
|
|
$panel = new AphrontPanelView();
|
2013-01-19 21:15:41 +01:00
|
|
|
$panel->setHeader(pht('Herald Transcripts'));
|
2011-03-25 05:32:26 +01:00
|
|
|
$panel->appendChild($table);
|
2011-04-09 01:15:00 +02:00
|
|
|
$panel->appendChild($pager);
|
2013-01-19 21:15:41 +01:00
|
|
|
$panel->setNoBackground();
|
2011-03-25 05:32:26 +01:00
|
|
|
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
$nav = $this->renderNav();
|
|
|
|
$nav->selectFilter('transcript');
|
|
|
|
$nav->appendChild($panel);
|
|
|
|
|
2013-01-21 16:46:13 +01:00
|
|
|
$crumbs = id($this->buildApplicationCrumbs())
|
|
|
|
->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Transcripts')));
|
|
|
|
$nav->setCrumbs($crumbs);
|
|
|
|
|
2013-05-20 17:24:07 +02:00
|
|
|
return $this->buildApplicationPage(
|
General Herald refactoring pass
Summary:
**Who can delete global rules?**: I discussed this with @jungejason. The current behavior is that the rule author or any administrator can delete a global rule, but this
isn't consistent with who can edit a rule (anyone) and doesn't really make much sense (it's an artifact of the global/personal split). I proposed that anyone can delete a
rule but we don't actually delete them, and log the deletion. However, when it came time to actually write the code for this I backed off a bit and continued actually
deleting the rules -- I think this does a reasonable job of balancing accountability with complexity. So the new impelmentation is:
- Personal rules can be deleted only by their owners.
- Global rules can be deleted by any user.
- All deletes are logged.
- Logs are more detailed.
- All logged actions can be viewed in aggregate.
**Minor Cleanup**
- Merged `HomeController` and `AllController`.
- Moved most queries to Query classes.
- Use AphrontFormSelectControl::renderSelectTag() where appropriate (this is a fairly recent addition).
- Use an AphrontErrorView to render the dry run notice (this didn't exist when I ported).
- Reenable some transaction code (this works again now).
- Removed the ability for admins to change rule authors (this was a little buggy, messy, and doesn't make tons of sense after the personal/global rule split).
- Rules which depend on other rules now display the right options (all global rules, all your personal rules for personal rules).
- Fix a bug in AphrontTableView where the "no data" cell would be rendered too wide if some columns are not visible.
- Allow selectFilter() in AphrontNavFilterView to be called without a 'default' argument.
Test Plan:
- Browsed, created, edited, deleted personal and gules.
- Verified generated logs.
- Did some dry runs.
- Verified transcript list and transcript details.
- Created/edited all/any rules; created/edited once/every time rules.
- Filtered admin views by users.
Reviewers: jungejason, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D2040
2012-03-30 19:49:55 +02:00
|
|
|
$nav,
|
2011-03-25 05:32:26 +01:00
|
|
|
array(
|
2013-05-20 17:24:07 +02:00
|
|
|
'title' => pht('Herald Transcripts'),
|
|
|
|
'device' => true,
|
|
|
|
'dust' => true,
|
2011-03-25 05:32:26 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|