public function processRequest(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->execute(); $table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys.")); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $upload_icon = id(new PHUIIconView())->setIconFont('fa-upload'); $upload_button = id(new PHUIButtonView())->setText(pht('Upload Public Key'))->setHref('/auth/sshkey/upload/?objectPHID=' . $user->getPHID())->setWorkflow(true)->setTag('a')->setIcon($upload_icon); try { PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); $can_generate = true; } catch (Exception $ex) { $can_generate = false; } $generate_icon = id(new PHUIIconView())->setIconFont('fa-lock'); $generate_button = id(new PHUIButtonView())->setText(pht('Generate Keypair'))->setHref('/auth/sshkey/generate/?objectPHID=' . $user->getPHID())->setTag('a')->setWorkflow(true)->setDisabled(!$can_generate)->setIcon($generate_icon); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($generate_button); $header->addActionLink($upload_button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $task = id(new PhabricatorWorkerActiveTask())->load($id); if (!$task) { $tasks = id(new PhabricatorWorkerArchiveTaskQuery())->withIDs(array($id))->execute(); $task = reset($tasks); } $header = new PHUIHeaderView(); if (!$task) { $title = pht('Task Does Not Exist'); $header->setHeader(pht('Task %d Missing', $id)); $error_view = new PHUIInfoView(); $error_view->setTitle(pht('No Such Task')); $error_view->appendChild(phutil_tag('p', array(), pht('This task may have recently been garbage collected.'))); $error_view->setSeverity(PHUIInfoView::SEVERITY_NODATA); $content = $error_view; } else { $title = pht('Task %d', $task->getID()); $header->setHeader(pht('Task %d: %s', $task->getID(), $task->getTaskClass())); $properties = $this->buildPropertyListView($task); $object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($properties); $retry_head = id(new PHUIHeaderView())->setHeader(pht('Retries')); $retry_info = $this->buildRetryListView($task); $retry_box = id(new PHUIObjectBoxView())->setHeader($retry_head)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($retry_info); $content = array($object_box, $retry_box); } $header->setHeaderIcon('fa-sort'); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($content); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view); }
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->addTag($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; }
public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->needPaths(true)->executeOne(); if (!$package) { return new Aphront404Response(); } $paths = $package->getPaths(); $repository_phids = array(); foreach ($paths as $path) { $repository_phids[$path->getRepositoryPHID()] = true; } if ($repository_phids) { $repositories = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array_keys($repository_phids))->execute(); $repositories = mpull($repositories, null, 'getPHID'); } else { $repositories = array(); } $actions = $this->buildPackageActionView($package); $properties = $this->buildPackagePropertyView($package); $properties->setActionList($actions); $header = id(new PHUIHeaderView())->setUser($viewer)->setHeader($package->getName())->setPolicyObject($package); $panel = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $commit_views = array(); $commit_uri = id(new PhutilURI('/audit/'))->setQueryParams(array('auditorPHIDs' => $package->getPHID())); $attention_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->setLimit(10)->execute(); if ($attention_commits) { $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($attention_commits); $commit_views[] = array('view' => $view, 'header' => pht('Commits in this Package that Need Attention'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri->alter('status', 'open'))->setText(pht('View All Problem Commits'))); } $all_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->needCommitData(true)->setLimit(100)->execute(); $view = id(new PhabricatorAuditListView())->setUser($viewer)->setCommits($all_commits)->setNoDataString(pht('No commits in this package.')); $commit_views[] = array('view' => $view, 'header' => pht('Recent Commits in Package'), 'button' => id(new PHUIButtonView())->setTag('a')->setHref($commit_uri)->setText(pht('View All Package Commits'))); $phids = array(); foreach ($commit_views as $commit_view) { $phids[] = $commit_view['view']->getRequiredHandlePHIDs(); } $phids = array_mergev($phids); $handles = $this->loadViewerHandles($phids); $commit_panels = array(); foreach ($commit_views as $commit_view) { $commit_panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader($commit_view['header']); if (isset($commit_view['button'])) { $header->addActionLink($commit_view['button']); } $commit_view['view']->setHandles($handles); $commit_panel->setHeader($header); $commit_panel->appendChild($commit_view['view']); $commit_panels[] = $commit_panel; } $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($package->getName()); $timeline = $this->buildTransactionTimeline($package, new PhabricatorOwnersPackageTransactionQuery()); $timeline->setShouldTerminate(true); return $this->buildApplicationPage(array($crumbs, $panel, $this->renderPathsTable($paths, $repositories), $commit_panels, $timeline), array('title' => $package->getName())); }
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->addActionIcon($icon); return $header; }
public function render() { if (!$this->handle) { throw new PhutilInvalidStateException('setObjectHandle'); } $viewer = $this->getUser(); $handle = $this->handle; require_celerity_resource('phabricator-hovercard-view-css'); $title = array(id(new PHUISpacesNamespaceContextView())->setUser($viewer)->setObject($this->getObject()), pht('%s: %s', $handle->getTypeName(), $this->title ? $this->title : $handle->getName())); $header = new PHUIHeaderView(); $header->setHeader($title); if ($this->tags) { foreach ($this->tags as $tag) { $header->addTag($tag); } } $body = array(); if ($this->detail) { $body_title = $this->detail; } else { // Fallback for object handles $body_title = $handle->getFullName(); } $body[] = phutil_tag_div('phabricator-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('phabricator-hovercard-body-item', $item); } 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' => 'phabricator-hovercard-body-image'), phutil_tag('div', array('class' => 'profile-header-picture-frame', 'style' => 'background-image: url(' . $handle->getImageURI() . ');'), ''))->appendHTML(phutil_tag('div', array('class' => 'phabricator-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('phabricator-hovercard-tail', $buttons); } // Assemble container // TODO: Add color support $hovercard = phutil_tag_div('phabricator-hovercard-container', array(phutil_tag_div('phabricator-hovercard-head', $header), phutil_tag_div('phabricator-hovercard-body grouped', $body), $tail)); // Wrap for thick border // and later the tip at the bottom return phutil_tag_div('phabricator-hovercard-wrapper', $hovercard); }
public function processRequest(AphrontRequest $request) { if ($request->getExists('new')) { return $this->processNew($request); } if ($request->getExists('edit')) { return $this->processEdit($request); } if ($request->getExists('delete')) { return $this->processDelete($request); } $user = $this->getUser(); $viewer = $request->getUser(); $factors = id(new PhabricatorAuthFactorConfig())->loadAllWhere('userPHID = %s', $user->getPHID()); $rows = array(); $rowc = array(); $highlight_id = $request->getInt('id'); foreach ($factors as $factor) { $impl = $factor->getImplementation(); if ($impl) { $type = $impl->getFactorName(); } else { $type = $factor->getFactorKey(); } if ($factor->getID() == $highlight_id) { $rowc[] = 'highlighted'; } else { $rowc[] = null; } $rows[] = array(javelin_tag('a', array('href' => $this->getPanelURI('?edit=' . $factor->getID()), 'sigil' => 'workflow'), $factor->getFactorName()), $type, phabricator_datetime($factor->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $factor->getID()), 'sigil' => 'workflow', 'class' => 'small grey button'), pht('Remove'))); } $table = new AphrontTableView($rows); $table->setNoDataString(pht("You haven't added any authentication factors to your account yet.")); $table->setHeaders(array(pht('Name'), pht('Type'), pht('Created'), '')); $table->setColumnClasses(array('wide pri', '', 'right', 'action')); $table->setRowClasses($rowc); $table->setDeviceVisibility(array(true, false, false, true)); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $help_uri = PhabricatorEnv::getDoclink('User Guide: Multi-Factor Authentication'); $help_icon = id(new PHUIIconView())->setIconFont('fa-info-circle'); $help_button = id(new PHUIButtonView())->setText(pht('Help'))->setHref($help_uri)->setTag('a')->setIcon($help_icon); $create_icon = id(new PHUIIconView())->setIconFont('fa-plus'); $create_button = id(new PHUIButtonView())->setText(pht('Add Authentication Factor'))->setHref($this->getPanelURI('?new=true'))->setTag('a')->setWorkflow(true)->setIcon($create_icon); $header->setHeader(pht('Authentication Factors')); $header->addActionLink($help_button); $header->addActionLink($create_button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function processRequest(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorAuthSSHKeyQuery())->setViewer($viewer)->withObjectPHIDs(array($user->getPHID()))->withIsActive(true)->execute(); $table = id(new PhabricatorAuthSSHKeyTableView())->setUser($viewer)->setKeys($keys)->setCanEdit(true)->setNoDataString(pht("You haven't added any SSH Public Keys.")); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $ssh_actions = PhabricatorAuthSSHKeyTableView::newKeyActionsMenu($viewer, $user); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($ssh_actions); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->needAnswers(true)->needViewerVotes(true)->executeOne(); if (!$question) { return new Aphront404Response(); } $question->attachVotes($viewer->getPHID()); $question_xactions = $this->buildQuestionTransactions($question); $answers = $this->buildAnswers($question->getAnswers()); $authors = mpull($question->getAnswers(), null, 'getAuthorPHID'); if (isset($authors[$viewer->getPHID()])) { $answer_add_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.')); } else { $answer_add_panel = new PonderAddAnswerView(); $answer_add_panel->setQuestion($question)->setUser($viewer)->setActionURI('/ponder/answer/add/'); } $header = new PHUIHeaderView(); $header->setHeader($question->getTitle()); $header->setUser($viewer); $header->setPolicyObject($question); if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) { $header->setStatus('fa-square-o', 'bluegrey', pht('Open')); } else { $header->setStatus('fa-check-square-o', 'dark', pht('Closed')); } $actions = $this->buildActionListView($question); $properties = $this->buildPropertyListView($question, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs->addTextCrumb('Q' . $id, '/Q' . $id); $ponder_view = phutil_tag('div', array('class' => 'ponder-question-view'), array($crumbs, $object_box, $question_xactions, $answers, $answer_add_panel)); return $this->buildApplicationPage(array($ponder_view), array('title' => 'Q' . $question->getID() . ' ' . $question->getTitle(), 'pageObjects' => array_merge(array($question->getPHID()), mpull($question->getAnswers(), 'getPHID')))); }
public function buildView() { if (!$this->user) { throw new PhutilInvalidStateException('setUser'); } $user = $this->user; $stories = $this->stories; $null_view = new AphrontNullView(); require_celerity_resource('phabricator-feed-css'); $last_date = null; foreach ($stories as $story) { $story->setHovercard($this->hovercards); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); if ($date !== $last_date) { if ($last_date !== null) { $null_view->appendChild(phutil_tag_div('phabricator-feed-story-date-separator')); } $last_date = $date; $header = new PHUIHeaderView(); $header->setHeader($date); $header->setHeaderIcon('fa-calendar msr'); $null_view->appendChild($header); } try { $view = $story->renderView(); $view->setUser($user); $view = $view->render(); } catch (Exception $ex) { // If rendering failed for any reason, don't fail the entire feed, // just this one story. $view = id(new PHUIFeedStoryView())->setUser($user)->setChronologicalKey($story->getChronologicalKey())->setEpoch($story->getEpoch())->setTitle(pht('Feed Story Failed to Render (%s)', get_class($story)))->appendChild(pht('%s: %s', get_class($ex), $ex->getMessage())); } $null_view->appendChild($view); } $box = id(new PHUIObjectBoxView())->appendChild($null_view); if (empty($stories)) { $nodatastring = pht('No Stories.'); if ($this->noDataString) { $nodatastring = $this->noDataString; } $view = id(new PHUIBoxView())->addClass('mlt mlb msr msl')->appendChild($nodatastring); $box->appendChild($view); } return $box; }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->needAnswers(true)->needProjectPHIDs(true)->executeOne(); if (!$question) { return new Aphront404Response(); } $answers = $this->buildAnswers($question); $answer_add_panel = id(new PonderAddAnswerView())->setQuestion($question)->setUser($viewer)->setActionURI('/ponder/answer/add/'); $header = new PHUIHeaderView(); $header->setHeader($question->getTitle()); $header->setUser($viewer); $header->setPolicyObject($question); $header->setHeaderIcon('fa-university'); if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) { $header->setStatus('fa-square-o', 'bluegrey', pht('Open')); } else { $text = PonderQuestionStatus::getQuestionStatusFullName($question->getStatus()); $icon = PonderQuestionStatus::getQuestionStatusIcon($question->getStatus()); $header->setStatus($icon, 'dark', $text); } $properties = $this->buildPropertyListView($question); $actions = $this->buildActionListView($question); $details = $this->buildPropertySectionView($question); $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $question, PhabricatorPolicyCapability::CAN_EDIT); $content_id = celerity_generate_unique_node_id(); $timeline = $this->buildTransactionTimeline($question, id(new PonderQuestionTransactionQuery())->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); $xactions = $timeline->getTransactions(); $add_comment = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($question->getPHID())->setShowPreview(false)->setAction($this->getApplicationURI("/question/comment/{$id}/"))->setSubmitButtonName(pht('Comment')); $add_comment = phutil_tag_div('ponder-question-add-comment-view', $add_comment); $comment_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($timeline, $add_comment)); $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($xactions)); $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs->addTextCrumb('Q' . $id, '/Q' . $id); $crumbs->setBorder(true); $subheader = $this->buildSubheaderView($question); $answer_wiki = null; if ($question->getAnswerWiki()) { $wiki = new PHUIRemarkupView($viewer, $question->getAnswerWiki()); $answer_wiki = id(new PHUIObjectBoxView())->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setHeaderText(pht('ANSWER SUMMARY'))->appendChild($wiki)->addClass('ponder-answer-wiki'); } require_celerity_resource('ponder-view-css'); $ponder_content = phutil_tag('div', array('class' => 'ponder-question-content'), array($answer_wiki, $footer, $comment_view, $answers, $answer_add_panel)); $ponder_view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setMainColumn($ponder_content)->setPropertyList($properties)->addPropertySection(pht('DETAILS'), $details)->setActionList($actions)->addClass('ponder-question-view'); $page_objects = array_merge(array($question->getPHID()), mpull($question->getAnswers(), 'getPHID')); return $this->newPage()->setTitle('Q' . $question->getID() . ' ' . $question->getTitle())->setCrumbs($crumbs)->setPageObjectPHIDs($page_objects)->appendChild(array($ponder_view)); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->needAnswers(true)->needProjectPHIDs(true)->executeOne(); if (!$question) { return new Aphront404Response(); } $answers = $this->buildAnswers($question); $answer_add_panel = id(new PonderAddAnswerView())->setQuestion($question)->setUser($viewer)->setActionURI('/ponder/answer/add/'); $header = new PHUIHeaderView(); $header->setHeader($question->getTitle()); $header->setUser($viewer); $header->setPolicyObject($question); if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) { $header->setStatus('fa-square-o', 'bluegrey', pht('Open')); } else { $text = PonderQuestionStatus::getQuestionStatusFullName($question->getStatus()); $icon = PonderQuestionStatus::getQuestionStatusIcon($question->getStatus()); $header->setStatus($icon, 'dark', $text); } $actions = $this->buildActionListView($question); $properties = $this->buildPropertyListView($question, $actions); $sidebar = $this->buildSidebar($question); $content_id = celerity_generate_unique_node_id(); $timeline = $this->buildTransactionTimeline($question, id(new PonderQuestionTransactionQuery())->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); $xactions = $timeline->getTransactions(); $add_comment = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($question->getPHID())->setShowPreview(false)->setHeaderText(pht('Question Comment'))->setAction($this->getApplicationURI("/question/comment/{$id}/"))->setSubmitButtonName(pht('Comment')); $comment_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($timeline, $add_comment)); $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($xactions)); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->appendChild($footer); if ($viewer->getPHID() == $question->getAuthorPHID()) { $status = $question->getStatus(); $answers_list = $question->getAnswers(); if ($answers_list && $status == PonderQuestionStatus::STATUS_OPEN) { $info_view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->appendChild(pht('If this question has been resolved, please consider closing the question and marking the answer as helpful.')); $object_box->setInfoView($info_view); } } $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs->addTextCrumb('Q' . $id, '/Q' . $id); $answer_wiki = null; if ($question->getAnswerWiki()) { $answer = phutil_tag_div('mlt mlb msr msl', $question->getAnswerWiki()); $answer_wiki = id(new PHUIObjectBoxView())->setHeaderText(pht('Answer Summary'))->setColor(PHUIObjectBoxView::COLOR_BLUE)->appendChild($answer); } $ponder_view = id(new PHUITwoColumnView())->setMainColumn(array($object_box, $comment_view, $answer_wiki, $answers, $answer_add_panel))->setSideColumn($sidebar)->addClass('ponder-question-view'); return $this->buildApplicationPage(array($crumbs, $ponder_view), array('title' => 'Q' . $question->getID() . ' ' . $question->getTitle(), 'pageObjects' => array_merge(array($question->getPHID()), mpull($question->getAnswers(), 'getPHID')))); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $id = $request->getURIData('id'); $question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($id))->needAnswers(true)->needProjectPHIDs(true)->executeOne(); if (!$question) { return new Aphront404Response(); } $answers = $this->buildAnswers($question->getAnswers()); $authors = mpull($question->getAnswers(), null, 'getAuthorPHID'); if (isset($authors[$viewer->getPHID()])) { $answer_add_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.')); } else { $answer_add_panel = new PonderAddAnswerView(); $answer_add_panel->setQuestion($question)->setUser($viewer)->setActionURI('/ponder/answer/add/'); } $header = new PHUIHeaderView(); $header->setHeader($question->getTitle()); $header->setUser($viewer); $header->setPolicyObject($question); if ($question->getStatus() == PonderQuestionStatus::STATUS_OPEN) { $header->setStatus('fa-square-o', 'bluegrey', pht('Open')); } else { $text = PonderQuestionStatus::getQuestionStatusFullName($question->getStatus()); $icon = PonderQuestionStatus::getQuestionStatusIcon($question->getStatus()); $header->setStatus($icon, 'dark', $text); } $actions = $this->buildActionListView($question); $properties = $this->buildPropertyListView($question, $actions); $sidebar = $this->buildSidebar($question); $content_id = celerity_generate_unique_node_id(); $timeline = $this->buildTransactionTimeline($question, id(new PonderQuestionTransactionQuery())->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); $xactions = $timeline->getTransactions(); $add_comment = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($question->getPHID())->setShowPreview(false)->setHeaderText(pht('Question Comment'))->setAction($this->getApplicationURI("/question/comment/{$id}/"))->setSubmitButtonName(pht('Comment')); $comment_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($timeline, $add_comment)); $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($xactions)); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties)->appendChild($footer); $crumbs = $this->buildApplicationCrumbs($this->buildSideNavView()); $crumbs->addTextCrumb('Q' . $id, '/Q' . $id); $ponder_view = id(new PHUITwoColumnView())->setMainColumn(array($object_box, $comment_view, $answers, $answer_add_panel))->setSideColumn($sidebar)->addClass('ponder-question-view'); return $this->buildApplicationPage(array($crumbs, $ponder_view), array('title' => 'Q' . $question->getID() . ' ' . $question->getTitle(), 'pageObjects' => array_merge(array($question->getPHID()), mpull($question->getAnswers(), 'getPHID')))); }
public function render() { require_celerity_resource('aphront-dialog-view-css'); $buttons = array(); if ($this->submitButton) { $meta = array(); if ($this->disableWorkflowOnSubmit) { $meta['disableWorkflow'] = true; } $buttons[] = javelin_tag('button', array('name' => '__submit__', 'sigil' => '__default__', 'type' => 'submit', 'meta' => $meta), $this->submitButton); } if ($this->cancelURI) { $meta = array(); if ($this->disableWorkflowOnCancel) { $meta['disableWorkflow'] = true; } $buttons[] = javelin_tag('a', array('href' => $this->cancelURI, 'class' => 'button grey', 'name' => '__cancel__', 'sigil' => 'jx-workflow-button', 'meta' => $meta), $this->cancelText); } if (!$this->user) { throw new Exception(pht('You must call %s when rendering an %s.', 'setUser()', __CLASS__)); } $more = $this->class; if ($this->flush) { $more .= ' aphront-dialog-flush'; } switch ($this->width) { case self::WIDTH_FORM: case self::WIDTH_FULL: $more .= ' aphront-dialog-view-width-' . $this->width; break; case self::WIDTH_DEFAULT: break; default: throw new Exception(pht("Unknown dialog width '%s'!", $this->width)); } if ($this->isStandalone) { $more .= ' aphront-dialog-view-standalone'; } $attributes = array('class' => 'aphront-dialog-view ' . $more, 'sigil' => 'jx-dialog'); $form_attributes = array('action' => $this->submitURI, 'method' => $this->method, 'id' => $this->formID); $hidden_inputs = array(); $hidden_inputs[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__dialog__', 'value' => '1')); foreach ($this->hidden as $desc) { list($key, $value) = $desc; $hidden_inputs[] = javelin_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value, 'sigil' => 'aphront-dialog-application-input')); } if (!$this->renderAsForm) { $buttons = array(phabricator_form($this->user, $form_attributes, array_merge($hidden_inputs, $buttons))); } $children = $this->renderChildren(); $errors = $this->errors; $ex = $this->validationException; $exception_errors = null; if ($ex) { foreach ($ex->getErrors() as $error) { $errors[] = $error->getMessage(); } } if ($errors) { $children = array(id(new PHUIInfoView())->setErrors($errors), $children); } $header = new PHUIHeaderView(); $header->setHeader($this->title); $footer = null; if ($this->footers) { $footer = phutil_tag('div', array('class' => 'aphront-dialog-foot'), $this->footers); } $tail = null; if ($buttons || $footer) { $tail = phutil_tag('div', array('class' => 'aphront-dialog-tail grouped'), array($buttons, $footer)); } $content = array(phutil_tag('div', array('class' => 'aphront-dialog-head'), $header), phutil_tag('div', array('class' => 'aphront-dialog-body phabricator-remarkup grouped'), $children), $tail); if ($this->renderAsForm) { return phabricator_form($this->user, $form_attributes + $attributes, array($hidden_inputs, $content)); } else { return javelin_tag('div', $attributes, $content); } }
public function processRequest(AphrontRequest $request) { $user = $this->getUser(); $editable = PhabricatorEnv::getEnvConfig('account.editable'); $uri = $request->getRequestURI(); $uri->setQueryParams(array()); if ($editable) { $new = $request->getStr('new'); if ($new) { return $this->returnNewAddressResponse($request, $uri, $new); } $delete = $request->getInt('delete'); if ($delete) { return $this->returnDeleteAddressResponse($request, $uri, $delete); } } $verify = $request->getInt('verify'); if ($verify) { return $this->returnVerifyAddressResponse($request, $uri, $verify); } $primary = $request->getInt('primary'); if ($primary) { return $this->returnPrimaryAddressResponse($request, $uri, $primary); } $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID()); $rowc = array(); $rows = array(); foreach ($emails as $email) { $button_verify = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('verify', $email->getID()), 'sigil' => 'workflow'), pht('Verify')); $button_make_primary = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('primary', $email->getID()), 'sigil' => 'workflow'), pht('Make Primary')); $button_remove = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), pht('Remove')); $button_primary = phutil_tag('a', array('class' => 'button small disabled'), pht('Primary')); if (!$email->getIsVerified()) { $action = $button_verify; } else { if ($email->getIsPrimary()) { $action = $button_primary; } else { $action = $button_make_primary; } } if ($email->getIsPrimary()) { $remove = $button_primary; $rowc[] = 'highlighted'; } else { $remove = $button_remove; $rowc[] = null; } $rows[] = array($email->getAddress(), $action, $remove); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Email'), pht('Status'), pht('Remove'))); $table->setColumnClasses(array('wide', 'action', 'action')); $table->setRowClasses($rowc); $table->setColumnVisibility(array(true, true, $editable)); $view = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader(pht('Email Addresses')); if ($editable) { $button = new PHUIButtonView(); $button->setText(pht('Add New Address')); $button->setTag('a'); $button->setHref($uri->alter('new', 'true')); $button->setIcon('fa-plus'); $button->addSigil('workflow'); $header->addActionLink($button); } $view->setHeader($header); $view->setTable($table); return $view; }
public function setHeader(PHUIHeaderView $header) { $header->setTall(true); $this->header = $header; return $this; }
private function renderAddCommentPanel(PhabricatorRepositoryCommit $commit, array $audit_requests) { assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest'); $request = $this->getRequest(); $user = $request->getUser(); if (!$user->isLoggedIn()) { return id(new PhabricatorApplicationTransactionCommentView())->setUser($user)->setRequestURI($request->getRequestURI()); } $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $pane_id = celerity_generate_unique_node_id(); Javelin::initBehavior('differential-keyboard-navigation', array('haunt' => $pane_id)); $draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $user->getPHID(), 'diffusion-audit-' . $commit->getID()); if ($draft) { $draft = $draft->getDraft(); } else { $draft = null; } $actions = $this->getAuditActions($commit, $audit_requests); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); $auditor_source = new DiffusionAuditorDatasource(); $form = id(new AphrontFormView())->setUser($user)->setAction('/audit/addcomment/')->addHiddenInput('commit', $commit->getPHID())->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Action'))->setName('action')->setID('audit-action')->setOptions($actions))->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Add Auditors'))->setName('auditors')->setControlID('add-auditors')->setControlStyle('display: none')->setID('add-auditors-tokenizer')->setDisableBehavior(true)->setDatasource($auditor_source))->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Add CCs'))->setName('ccs')->setControlID('add-ccs')->setControlStyle('display: none')->setID('add-ccs-tokenizer')->setDisableBehavior(true)->setDatasource($mailable_source))->appendChild(id(new PhabricatorRemarkupControl())->setLabel(pht('Comments'))->setName('content')->setValue($draft)->setID('audit-content')->setUser($user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Submit'))); $header = new PHUIHeaderView(); $header->setHeader($is_serious ? pht('Audit Commit') : pht('Creative Accounting')); Javelin::initBehavior('differential-add-reviewers-and-ccs', array('dynamic' => array('add-auditors-tokenizer' => array('actions' => array('add_auditors' => 1), 'src' => $auditor_source->getDatasourceURI(), 'row' => 'add-auditors', 'placeholder' => $auditor_source->getPlaceholderText()), 'add-ccs-tokenizer' => array('actions' => array('add_ccs' => 1), 'src' => $mailable_source->getDatasourceURI(), 'row' => 'add-ccs', 'placeholder' => $mailable_source->getPlaceholderText())), 'select' => 'audit-action')); Javelin::initBehavior('differential-feedback-preview', array('uri' => '/audit/preview/' . $commit->getID() . '/', 'preview' => 'audit-preview', 'content' => 'audit-content', 'action' => 'audit-action', 'previewTokenizers' => array('auditors' => 'add-auditors-tokenizer', 'ccs' => 'add-ccs-tokenizer'), 'inline' => 'inline-comment-preview', 'inlineuri' => '/diffusion/inline/preview/' . $commit->getPHID() . '/')); $loading = phutil_tag_div('aphront-panel-preview-loading-text', pht('Loading preview...')); $preview_panel = phutil_tag_div('aphront-panel-preview aphront-panel-flush', array(phutil_tag('div', array('id' => 'audit-preview'), $loading), phutil_tag('div', array('id' => 'inline-comment-preview')))); // TODO: This is pretty awkward, unify the CSS between Diffusion and // Differential better. require_celerity_resource('differential-core-view-css'); $anchor = id(new PhabricatorAnchorView())->setAnchorName('comment')->setNavigationMarker(true)->render(); $comment_box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form); return phutil_tag('div', array('id' => $pane_id), phutil_tag_div('differential-add-comment-panel', array($anchor, $comment_box, $preview_panel))); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $document = id(new PhrictionDocumentQuery())->setViewer($user)->withSlugs(array(PhabricatorSlug::normalize($this->slug)))->needContent(true)->executeOne(); if (!$document) { return new Aphront404Response(); } $current = $document->getContent(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pager->setURI($request->getRequestURI(), 'page'); $history = id(new PhrictionContent())->loadAllWhere('documentID = %d ORDER BY version DESC LIMIT %d, %d', $document->getID(), $pager->getOffset(), $pager->getPageSize() + 1); $history = $pager->sliceResults($history); $author_phids = mpull($history, 'getAuthorPHID'); $handles = $this->loadViewerHandles($author_phids); $list = new PHUIObjectItemListView(); $list->setFlush(true); foreach ($history as $content) { $author = $handles[$content->getAuthorPHID()]->renderLink(); $slug_uri = PhrictionDocument::getSlugURI($document->getSlug()); $version = $content->getVersion(); $diff_uri = new PhutilURI('/phriction/diff/' . $document->getID() . '/'); $vs_previous = null; if ($content->getVersion() != 1) { $vs_previous = $diff_uri->alter('l', $content->getVersion() - 1)->alter('r', $content->getVersion()); } $vs_head = null; if ($content->getID() != $document->getContentID()) { $vs_head = $diff_uri->alter('l', $content->getVersion())->alter('r', $current->getVersion()); } $change_type = PhrictionChangeType::getChangeTypeLabel($content->getChangeType()); switch ($content->getChangeType()) { case PhrictionChangeType::CHANGE_DELETE: $color = 'red'; break; case PhrictionChangeType::CHANGE_EDIT: $color = 'blue'; break; case PhrictionChangeType::CHANGE_MOVE_HERE: $color = 'yellow'; break; case PhrictionChangeType::CHANGE_MOVE_AWAY: $color = 'orange'; break; case PhrictionChangeType::CHANGE_STUB: $color = 'green'; break; default: throw new Exception('Unknown change type!'); break; } $item = id(new PHUIObjectItemView())->setHeader(pht('%s by %s', $change_type, $author))->setBarColor($color)->addAttribute(phutil_tag('a', array('href' => $slug_uri . '?v=' . $version), pht('Version %s', $version)))->addAttribute(pht('%s %s', phabricator_date($content->getDateCreated(), $user), phabricator_time($content->getDateCreated(), $user))); if ($content->getDescription()) { $item->addAttribute($content->getDescription()); } if ($vs_previous) { $item->addIcon('fa-reply', pht('Show Change'), array('href' => $vs_previous)); } else { $item->addIcon('fa-reply grey', phutil_tag('em', array(), pht('No previous change'))); } if ($vs_head) { $item->addIcon('fa-reply-all', pht('Show Later Changes'), array('href' => $vs_head)); } else { $item->addIcon('fa-reply-all grey', phutil_tag('em', array(), pht('No later changes'))); } $list->addItem($item); } $crumbs = $this->buildApplicationCrumbs(); $crumb_views = $this->renderBreadcrumbs($document->getSlug()); foreach ($crumb_views as $view) { $crumbs->addCrumb($view); } $crumbs->addTextCrumb(pht('History'), PhrictionDocument::getSlugURI($document->getSlug(), 'history')); $header = new PHUIHeaderView(); $header->setHeader(pht('Document History for %s', phutil_tag('a', array('href' => PhrictionDocument::getSlugURI($document->getSlug())), head($history)->getTitle()))); $obj_box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($list)->appendChild($pager); return $this->buildApplicationPage(array($crumbs, $obj_box), array('title' => pht('Document History'))); }
private function buildTagListTable(DiffusionRequest $drequest) { $viewer = $this->getRequest()->getUser(); $tag_limit = 15; $tags = array(); try { $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => null, 'limit' => $tag_limit + 1))); } catch (ConduitException $e) { if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') { throw $e; } } if (!$tags) { return null; } $more_tags = count($tags) > $tag_limit; $tags = array_slice($tags, 0, $tag_limit); $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->withRepository($drequest->getRepository())->needCommitData(true)->execute(); $view = id(new DiffusionTagListView())->setUser($viewer)->setDiffusionRequest($drequest)->setTags($tags)->setCommits($commits); $phids = $view->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $view->setHandles($handles); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader(pht('Tags')); if ($more_tags) { $header->setSubHeader(pht('Showing the %d most recent tags.', $tag_limit)); } $icon = id(new PHUIIconView())->setIconFont('fa-tag'); $button = new PHUIButtonView(); $button->setText(pht('Show All Tags')); $button->setTag('a'); $button->setIcon($icon); $button->setHref($drequest->generateURI(array('action' => 'tags'))); $header->addActionLink($button); $panel->setHeader($header); $panel->appendChild($view); return $panel; }
private function buildTagListTable(DiffusionRequest $drequest) { $viewer = $this->getRequest()->getUser(); $repository = $drequest->getRepository(); switch ($repository->getVersionControlSystem()) { case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: // no tags in SVN return null; } $tag_limit = 15; $tags = array(); $tags = DiffusionRepositoryTag::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.tagsquery', array('commit' => null, 'limit' => $tag_limit + 1))); if (!$tags) { return null; } $more_tags = count($tags) > $tag_limit; $tags = array_slice($tags, 0, $tag_limit); $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($tags, 'getCommitIdentifier'))->withRepository($repository)->needCommitData(true)->execute(); $view = id(new DiffusionTagListView())->setUser($viewer)->setDiffusionRequest($drequest)->setTags($tags)->setCommits($commits); $phids = $view->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $view->setHandles($handles); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader(pht('Tags')); if ($more_tags) { $header->setSubHeader(pht('Showing the %d most recent tags.', $tag_limit)); } $icon = id(new PHUIIconView())->setIconFont('fa-tag'); $button = new PHUIButtonView(); $button->setText(pht('Show All Tags')); $button->setTag('a'); $button->setIcon($icon); $button->setHref($drequest->generateURI(array('action' => 'tags'))); $header->addActionLink($button); $panel->setHeader($header); $panel->setTable($view); return $panel; }
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->addActionIcon($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->addActionIcon($action_remove); } return $header; }
public function setHeader(PHUIHeaderView $header) { $header->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTBLUE); $this->header = $header; return $this; }
private function renderKeyListView(AphrontRequest $request) { $user = $this->getUser(); $viewer = $request->getUser(); $keys = id(new PhabricatorUserSSHKey())->loadAllWhere('userPHID = %s', $user->getPHID()); $rows = array(); foreach ($keys as $key) { $rows[] = array(phutil_tag('a', array('href' => $this->getPanelURI('?edit=' . $key->getID())), $key->getName()), $key->getKeyComment(), $key->getKeyType(), phabricator_date($key->getDateCreated(), $viewer), phabricator_time($key->getDateCreated(), $viewer), javelin_tag('a', array('href' => $this->getPanelURI('?delete=' . $key->getID()), 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Delete'))); } $table = new AphrontTableView($rows); $table->setNoDataString(pht("You haven't added any SSH Public Keys.")); $table->setHeaders(array(pht('Name'), pht('Comment'), pht('Type'), pht('Created'), pht('Time'), '')); $table->setColumnClasses(array('wide pri', '', '', '', 'right', 'action')); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $upload_icon = id(new PHUIIconView())->setIconFont('fa-upload'); $upload_button = id(new PHUIButtonView())->setText(pht('Upload Public Key'))->setHref($this->getPanelURI('?edit=true'))->setTag('a')->setIcon($upload_icon); try { PhabricatorSSHKeyGenerator::assertCanGenerateKeypair(); $can_generate = true; } catch (Exception $ex) { $can_generate = false; } $generate_icon = id(new PHUIIconView())->setIconFont('fa-lock'); $generate_button = id(new PHUIButtonView())->setText(pht('Generate Keypair'))->setHref($this->getPanelURI('?generate=true'))->setTag('a')->setWorkflow(true)->setDisabled(!$can_generate)->setIcon($generate_icon); $header->setHeader(pht('SSH Public Keys')); $header->addActionLink($generate_button); $header->addActionLink($upload_button); $panel->setHeader($header); $panel->appendChild($table); return $panel; }