Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/view/DiffusionCommitGraphView.php
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | private function getRepository() { | ||||
| if (!$drequest) { | if (!$drequest) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $drequest->getRepository(); | return $drequest->getRepository(); | ||||
| } | } | ||||
| public function render() { | public function render() { | ||||
| $viewer = $this->getUser(); | $viewer = $this->getViewer(); | ||||
| $drequest = $this->getDiffusionRequest(); | |||||
| $repository = $drequest->getRepository(); | |||||
| require_celerity_resource('diffusion-css'); | require_celerity_resource('diffusion-css'); | ||||
| Javelin::initBehavior('phabricator-tooltips'); | |||||
| $show_builds = $this->shouldShowBuilds(); | $show_builds = $this->shouldShowBuilds(); | ||||
| $show_revisions = $this->shouldShowRevisions(); | $show_revisions = $this->shouldShowRevisions(); | ||||
| $items = $this->newHistoryItems(); | $items = $this->newHistoryItems(); | ||||
| $rows = array(); | $rows = array(); | ||||
| $last_date = null; | $last_date = null; | ||||
| foreach ($items as $item) { | foreach ($items as $item) { | ||||
| $content = array(); | $content = array(); | ||||
| $item_epoch = $item['epoch']; | $item_epoch = $item['epoch']; | ||||
| $item_hash = $item['hash']; | $item_hash = $item['hash']; | ||||
| $commit = $item['commit']; | $commit = $item['commit']; | ||||
| $item_date = phabricator_date($item_epoch, $viewer); | $item_date = phabricator_date($item_epoch, $viewer); | ||||
| if ($item_date !== $last_date) { | if ($item_date !== $last_date) { | ||||
| $last_date = $item_date; | $last_date = $item_date; | ||||
| $content[] = $item_date; | $content[] = phutil_tag( | ||||
| 'div', | |||||
| array( | |||||
| 'class' => 'diffusion-commit-graph-date-header', | |||||
| ), | |||||
| $item_date); | |||||
| } | } | ||||
| $commit_description = $this->getCommitDescription($commit); | $commit_description = $this->getCommitDescription($commit); | ||||
| $commit_link = $this->getCommitURI($commit, $item_hash); | $commit_link = $this->getCommitURI($item_hash); | ||||
| $short_hash = $this->getCommitObjectName($commit, $item_hash); | $short_hash = $this->getCommitObjectName($item_hash); | ||||
| $is_disabled = $this->getCommitIsDisabled($commit); | $is_disabled = $this->getCommitIsDisabled($commit); | ||||
| $author_view = $this->getCommitAuthorView($commit); | $author_view = $this->getCommitAuthorView($commit); | ||||
| $item_view = id(new PHUIObjectItemView()) | $item_view = id(new PHUIObjectItemView()) | ||||
| ->setHeader($commit_description) | ->setHeader($commit_description) | ||||
| ->setObjectName($short_hash) | ->setObjectName($short_hash) | ||||
| ->setHref($commit_link) | ->setHref($commit_link) | ||||
| Show All 26 Lines | foreach ($items as $item) { | ||||
| } | } | ||||
| $view = id(new PHUIObjectItemListView()) | $view = id(new PHUIObjectItemListView()) | ||||
| ->setFlush(true) | ->setFlush(true) | ||||
| ->addItem($item_view); | ->addItem($item_view); | ||||
| $content[] = $view; | $content[] = $view; | ||||
| $rows[] = array( | $rows[] = $content; | ||||
| $content, | |||||
| ); | |||||
| } | } | ||||
| $graph = $this->newGraphView(); | $graph = $this->newGraphView(); | ||||
| foreach ($rows as $idx => $row) { | |||||
| $cells = array(); | |||||
| if ($graph) { | if ($graph) { | ||||
| $idx = 0; | $cells[] = phutil_tag( | ||||
| foreach ($rows as $key => $row) { | 'td', | ||||
| array_unshift($row, $graph[$idx++]); | array( | ||||
| $rows[$key] = $row; | 'class' => 'diffusion-commit-graph-path-cell', | ||||
| } | ), | ||||
| $graph[$idx]); | |||||
| } | } | ||||
| foreach ($rows as $key => $row) { | $cells[] = phutil_tag( | ||||
| $cells = array(); | 'td', | ||||
| foreach ($row as $cell) { | array( | ||||
| $cells[] = phutil_tag('td', array(), $cell); | 'class' => 'diffusion-commit-graph-content-cell', | ||||
| } | ), | ||||
| $rows[$key] = phutil_tag('tr', array(), $cells); | $row); | ||||
| $rows[$idx] = phutil_tag('tr', array(), $cells); | |||||
| } | } | ||||
| $table = phutil_tag('table', array(), $rows); | $table = phutil_tag( | ||||
| 'table', | |||||
| array( | |||||
| 'class' => 'diffusion-commit-graph-table', | |||||
| ), | |||||
| $rows); | |||||
| return $table; | return $table; | ||||
| } | } | ||||
| private function newGraphView() { | private function newGraphView() { | ||||
| if (!$this->getParents()) { | if (!$this->getParents()) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | | ||||
| PhabricatorRepositoryCommit::IMPORTED_CHANGE; | PhabricatorRepositoryCommit::IMPORTED_CHANGE; | ||||
| if (!$commit->isPartiallyImported($partial_import)) { | if (!$commit->isPartiallyImported($partial_import)) { | ||||
| return phutil_tag('em', array(), pht("Importing\xE2\x80\xA6")); | return phutil_tag('em', array(), pht("Importing\xE2\x80\xA6")); | ||||
| } | } | ||||
| return $commit->getCommitData()->getSummary(); | return $commit->getCommitData()->getSummary(); | ||||
| } | } | ||||
| private function getCommitURI($commit, $hash) { | private function getCommitURI($hash) { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| if ($repository) { | if ($repository) { | ||||
| return $repository->getCommitURI($hash); | return $repository->getCommitURI($hash); | ||||
| } | } | ||||
| $commit = $this->getCommit($hash); | |||||
| return $commit->getURI(); | return $commit->getURI(); | ||||
| } | } | ||||
| private function getCommitObjectName($commit, $hash) { | private function getCommitObjectName($hash) { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| if ($repository) { | if ($repository) { | ||||
| return $repository->formatCommitName( | return $repository->formatCommitName( | ||||
| $hash, | $hash, | ||||
| $is_local = true); | $is_local = true); | ||||
| } | } | ||||
| $commit = $this->getCommit($hash); | |||||
| return $commit->getDisplayName(); | return $commit->getDisplayName(); | ||||
| } | } | ||||
| private function getCommitIsDisabled($commit) { | private function getCommitIsDisabled($commit) { | ||||
| if (!$commit) { | if (!$commit) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines | |||||