public function adjustPanelHeader(PhabricatorUser $viewer, PhabricatorDashboardPanel $panel, PhabricatorDashboardPanelRenderingEngine $engine, PHUIHeaderView $header)
 {
     $search_engine = $this->getSearchEngine($panel);
     $key = $panel->getProperty('key');
     $href = $search_engine->getQueryResultsPageURI($key);
     $icon = id(new PHUIIconView())->setIcon('fa-search')->setHref($href);
     $header->addActionItem($icon);
     return $header;
 }
Ejemplo n.º 2
0
 protected function getTagContent()
 {
     if (!$this->handle) {
         throw new PhutilInvalidStateException('setObjectHandle');
     }
     $viewer = $this->getUser();
     $handle = $this->handle;
     require_celerity_resource('phui-hovercard-view-css');
     // If we're a fully custom Hovercard, skip the common UI
     $children = $this->renderChildren();
     if ($children) {
         return $children;
     }
     $title = array(id(new PHUISpacesNamespaceContextView())->setUser($viewer)->setObject($this->getObject()), $this->title ? $this->title : $handle->getName());
     $header = new PHUIHeaderView();
     $header->setHeader($title);
     if ($this->tags) {
         foreach ($this->tags as $tag) {
             $header->addActionItem($tag);
         }
     }
     $body = array();
     if ($this->detail) {
         $body_title = $this->detail;
     } else {
         // Fallback for object handles
         $body_title = $handle->getFullName();
     }
     $body[] = phutil_tag_div('phui-hovercard-body-header', $body_title);
     foreach ($this->fields as $field) {
         $item = array(phutil_tag('strong', array(), $field['label']), ': ', phutil_tag('span', array(), $field['value']));
         $body[] = phutil_tag_div('phui-hovercard-body-item', $item);
     }
     if ($this->badges) {
         $badges = id(new PHUIBadgeBoxView())->addItems($this->badges)->setCollapsed(true);
         $body[] = phutil_tag('div', array('class' => 'phui-hovercard-body-item hovercard-badges'), $badges);
     }
     if ($handle->getImageURI()) {
         // Probably a user, we don't need to assume something else
         // "Prepend" the image by appending $body
         $body = phutil_tag('div', array('class' => 'phui-hovercard-body-image'), phutil_tag('div', array('class' => 'profile-header-picture-frame', 'style' => 'background-image: url(' . $handle->getImageURI() . ');'), ''))->appendHTML(phutil_tag('div', array('class' => 'phui-hovercard-body-details'), $body));
     }
     $buttons = array();
     foreach ($this->actions as $action) {
         $options = array('class' => 'button grey', 'href' => $action['uri']);
         if ($action['workflow']) {
             $options['sigil'] = 'workflow';
             $buttons[] = javelin_tag('a', $options, $action['label']);
         } else {
             $buttons[] = phutil_tag('a', $options, $action['label']);
         }
     }
     $tail = null;
     if ($buttons) {
         $tail = phutil_tag_div('phui-hovercard-tail', $buttons);
     }
     $hovercard = phutil_tag_div('phui-hovercard-container grouped', array(phutil_tag_div('phui-hovercard-head', $header), phutil_tag_div('phui-hovercard-body grouped', $body), $tail));
     return $hovercard;
 }
 private function addPanelHeaderActions(PHUIHeaderView $header)
 {
     $panel = $this->getPanel();
     $dashboard_id = $this->getDashboardID();
     $edit_uri = id(new PhutilURI('/dashboard/panel/edit/' . $panel->getID() . '/'));
     if ($dashboard_id) {
         $edit_uri->setQueryParam('dashboardID', $dashboard_id);
     }
     $action_edit = id(new PHUIIconView())->setIcon('fa-pencil')->setWorkflow(true)->setHref((string) $edit_uri);
     $header->addActionItem($action_edit);
     if ($dashboard_id) {
         $uri = id(new PhutilURI('/dashboard/removepanel/' . $dashboard_id . '/'))->setQueryParam('panelPHID', $panel->getPHID());
         $action_remove = id(new PHUIIconView())->setIcon('fa-trash-o')->setHref((string) $uri)->setWorkflow(true);
         $header->addActionItem($action_remove);
     }
     return $header;
 }