Differential D20398 Diff 48689 src/applications/dashboard/controller/dashboard/PhabricatorDashboardViewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/controller/dashboard/PhabricatorDashboardViewController.php
| Show All 26 Lines | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
| PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
| $title = $dashboard->getName(); | $title = $dashboard->getName(); | ||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $header = $this->buildHeaderView(); | $header = $this->buildHeaderView(); | ||||
| $curtain = $this->buildCurtainView($dashboard); | $curtain = $this->buildCurtainView($dashboard); | ||||
| $usage_box = $this->newUsageView($dashboard); | |||||
| $timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
| $dashboard, | $dashboard, | ||||
| new PhabricatorDashboardTransactionQuery()); | new PhabricatorDashboardTransactionQuery()); | ||||
| $timeline->setShouldTerminate(true); | $timeline->setShouldTerminate(true); | ||||
| $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) | $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->setDashboard($dashboard) | ->setDashboard($dashboard) | ||||
| ->setArrangeMode($can_edit) | ->setArrangeMode($can_edit) | ||||
| ->renderDashboard(); | ->renderDashboard(); | ||||
| $dashboard_box = id(new PHUIBoxView()) | $dashboard_box = id(new PHUIBoxView()) | ||||
| ->addClass('dashboard-preview-box') | ->addClass('dashboard-preview-box') | ||||
| ->appendChild($rendered_dashboard); | ->appendChild($rendered_dashboard); | ||||
| $view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->setCurtain($curtain) | ->setCurtain($curtain) | ||||
| ->setMainColumn( | ->setMainColumn( | ||||
| array( | array( | ||||
| $dashboard_box, | $dashboard_box, | ||||
| $usage_box, | |||||
| $timeline, | $timeline, | ||||
| )); | )); | ||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->appendChild($view); | ->appendChild($view); | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ($dashboard->isArchived()) { | ||||
| ->setHref($this->getApplicationURI("archive/{$id}/")) | ->setHref($this->getApplicationURI("archive/{$id}/")) | ||||
| ->setDisabled(!$can_edit) | ->setDisabled(!$can_edit) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| } | } | ||||
| return $curtain; | return $curtain; | ||||
| } | } | ||||
| private function newUsageView(PhabricatorDashboard $dashboard) { | |||||
| $viewer = $this->getViewer(); | |||||
| $custom_phids = array(); | |||||
| if ($viewer->getPHID()) { | |||||
| $custom_phids[] = $viewer->getPHID(); | |||||
| } | |||||
| $items = id(new PhabricatorProfileMenuItemConfigurationQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withAffectedObjectPHIDs( | |||||
| array( | |||||
| $dashboard->getPHID(), | |||||
| )) | |||||
| ->withCustomPHIDs($custom_phids, $include_global = true) | |||||
| ->execute(); | |||||
| $handle_phids = array(); | |||||
| foreach ($items as $item) { | |||||
| $handle_phids[] = $item->getProfilePHID(); | |||||
| $custom_phid = $item->getCustomPHID(); | |||||
| if ($custom_phid) { | |||||
| $handle_phids[] = $custom_phid; | |||||
| } | |||||
| } | |||||
| if ($handle_phids) { | |||||
| $handles = $viewer->loadHandles($handle_phids); | |||||
| } else { | |||||
| $handles = array(); | |||||
| } | |||||
| $items = msortv($items, 'newUsageSortVector'); | |||||
| $rows = array(); | |||||
| foreach ($items as $item) { | |||||
| $profile_phid = $item->getProfilePHID(); | |||||
| $custom_phid = $item->getCustomPHID(); | |||||
| $profile = $handles[$profile_phid]->renderLink(); | |||||
| $profile_icon = $handles[$profile_phid]->getIcon(); | |||||
| if ($custom_phid) { | |||||
| $custom = $handles[$custom_phid]->renderLink(); | |||||
| } else { | |||||
| $custom = pht('Global'); | |||||
| } | |||||
| $type = $item->getProfileMenuTypeDescription(); | |||||
| $rows[] = array( | |||||
| id(new PHUIIconView())->setIcon($profile_icon), | |||||
| $type, | |||||
| $profile, | |||||
| $custom, | |||||
| ); | |||||
| } | |||||
| $usage_table = id(new AphrontTableView($rows)) | |||||
| ->setHeaders( | |||||
| array( | |||||
| null, | |||||
| pht('Type'), | |||||
| pht('Menu'), | |||||
| pht('Global/Personal'), | |||||
| )) | |||||
| ->setColumnClasses( | |||||
| array( | |||||
| 'center', | |||||
| null, | |||||
| 'pri', | |||||
| 'wide', | |||||
| )); | |||||
| $header_view = id(new PHUIHeaderView()) | |||||
| ->setHeader(pht('Dashboard Used By')); | |||||
| $usage_box = id(new PHUIObjectBoxView()) | |||||
| ->setTable($usage_table) | |||||
| ->setHeader($header_view); | |||||
| return $usage_box; | |||||
| } | |||||
| } | } | ||||