Differential D20308 Diff 48505 src/applications/project/controller/trigger/PhabricatorProjectTriggerViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/trigger/PhabricatorProjectTriggerViewController.php
| Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | private function newColumnsView(PhabricatorProjectTrigger $trigger) { | ||||
| // trigger isn't widely used and is safe to edit, when it may actually | // trigger isn't widely used and is safe to edit, when it may actually | ||||
| // be in use on workboards they don't have access to. | // be in use on workboards they don't have access to. | ||||
| // Query the columns with the omnipotent viewer first, then pull out their | // Query the columns with the omnipotent viewer first, then pull out their | ||||
| // PHIDs and throw the actual objects away. Re-query with the real viewer | // PHIDs and throw the actual objects away. Re-query with the real viewer | ||||
| // so we load only the columns they can actually see, but have a list of | // so we load only the columns they can actually see, but have a list of | ||||
| // all the impacted column PHIDs. | // all the impacted column PHIDs. | ||||
| // (We're also exposing the status of columns the user might not be able | |||||
| // to see. This technically violates policy, but the trigger usage table | |||||
| // hints at it anyway and it seems unlikely to ever have any security | |||||
| // impact, but is useful in assessing whether a trigger is really in use | |||||
| // or not.) | |||||
| $omnipotent_viewer = PhabricatorUser::getOmnipotentUser(); | $omnipotent_viewer = PhabricatorUser::getOmnipotentUser(); | ||||
| $all_columns = id(new PhabricatorProjectColumnQuery()) | $all_columns = id(new PhabricatorProjectColumnQuery()) | ||||
| ->setViewer($omnipotent_viewer) | ->setViewer($omnipotent_viewer) | ||||
| ->withTriggerPHIDs(array($trigger->getPHID())) | ->withTriggerPHIDs(array($trigger->getPHID())) | ||||
| ->execute(); | ->execute(); | ||||
| $column_phids = mpull($all_columns, 'getPHID'); | $column_map = mpull($all_columns, 'getStatus', 'getPHID'); | ||||
| if ($column_phids) { | if ($column_map) { | ||||
| $visible_columns = id(new PhabricatorProjectColumnQuery()) | $visible_columns = id(new PhabricatorProjectColumnQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs($column_phids) | ->withPHIDs(array_keys($column_map)) | ||||
| ->execute(); | ->execute(); | ||||
| $visible_columns = mpull($visible_columns, null, 'getPHID'); | $visible_columns = mpull($visible_columns, null, 'getPHID'); | ||||
| } else { | } else { | ||||
| $visible_columns = array(); | $visible_columns = array(); | ||||
| } | } | ||||
| $rows = array(); | $rows = array(); | ||||
| foreach ($column_phids as $column_phid) { | foreach ($column_map as $column_phid => $column_status) { | ||||
| $column = idx($visible_columns, $column_phid); | $column = idx($visible_columns, $column_phid); | ||||
| if ($column) { | if ($column) { | ||||
| $project = $column->getProject(); | $project = $column->getProject(); | ||||
| $project_name = phutil_tag( | $project_name = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $project->getURI(), | 'href' => $project->getURI(), | ||||
| ), | ), | ||||
| $project->getDisplayName()); | $project->getDisplayName()); | ||||
| $column_name = phutil_tag( | $column_name = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $column->getBoardURI(), | 'href' => $column->getBoardURI(), | ||||
| ), | ), | ||||
| $column->getDisplayName()); | $column->getDisplayName()); | ||||
| } else { | } else { | ||||
| $project_name = null; | $project_name = null; | ||||
| $column_name = phutil_tag('em', array(), pht('Restricted Column')); | $column_name = phutil_tag('em', array(), pht('Restricted Column')); | ||||
| } | } | ||||
| if ($column_status == PhabricatorProjectColumn::STATUS_ACTIVE) { | |||||
| $status_icon = id(new PHUIIconView()) | |||||
| ->setIcon('fa-columns', 'blue') | |||||
| ->setTooltip(pht('Active Column')); | |||||
| } else { | |||||
| $status_icon = id(new PHUIIconView()) | |||||
| ->setIcon('fa-eye-slash', 'grey') | |||||
| ->setTooltip(pht('Hidden Column')); | |||||
| } | |||||
| $rows[] = array( | $rows[] = array( | ||||
| $status_icon, | |||||
| $project_name, | $project_name, | ||||
| $column_name, | $column_name, | ||||
| ); | ); | ||||
| } | } | ||||
| $table_view = id(new AphrontTableView($rows)) | $table_view = id(new AphrontTableView($rows)) | ||||
| ->setNoDataString(pht('This trigger is not used by any columns.')) | ->setNoDataString(pht('This trigger is not used by any columns.')) | ||||
| ->setHeaders( | ->setHeaders( | ||||
| array( | array( | ||||
| null, | |||||
| pht('Project'), | pht('Project'), | ||||
| pht('Column'), | pht('Column'), | ||||
| )) | )) | ||||
| ->setColumnClasses( | ->setColumnClasses( | ||||
| array( | array( | ||||
| null, | null, | ||||
| null, | |||||
| 'wide pri', | 'wide pri', | ||||
| )); | )); | ||||
| $header_view = id(new PHUIHeaderView()) | $header_view = id(new PHUIHeaderView()) | ||||
| ->setHeader(pht('Used by Columns')); | ->setHeader(pht('Used by Columns')); | ||||
| return id(new PHUIObjectBoxView()) | return id(new PHUIObjectBoxView()) | ||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ||||
| ▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines | |||||