Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/view/DifferentialChangesetListView.php
Show First 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | private function renderViewOptionsDropdown( | ||||
$qparams = array( | $qparams = array( | ||||
'ref' => $ref, | 'ref' => $ref, | ||||
'whitespace' => $this->whitespace, | 'whitespace' => $this->whitespace, | ||||
); | ); | ||||
if ($this->standaloneURI) { | if ($this->standaloneURI) { | ||||
$uri = new PhutilURI($this->standaloneURI); | $uri = new PhutilURI($this->standaloneURI); | ||||
$uri->setQueryParams($uri->getQueryParams() + $qparams); | $uri = $this->appendDefaultQueryParams($uri, $qparams); | ||||
$meta['standaloneURI'] = (string)$uri; | $meta['standaloneURI'] = (string)$uri; | ||||
} | } | ||||
$repository = $this->repository; | $repository = $this->repository; | ||||
if ($repository) { | if ($repository) { | ||||
try { | try { | ||||
$meta['diffusionURI'] = | $meta['diffusionURI'] = | ||||
(string)$repository->getDiffusionBrowseURIForPath( | (string)$repository->getDiffusionBrowseURIForPath( | ||||
$viewer, | $viewer, | ||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff), | $changeset->getAbsoluteRepositoryPath($repository, $this->diff), | ||||
idx($changeset->getMetadata(), 'line:first'), | idx($changeset->getMetadata(), 'line:first'), | ||||
$this->getBranch()); | $this->getBranch()); | ||||
} catch (DiffusionSetupException $e) { | } catch (DiffusionSetupException $e) { | ||||
// Ignore | // Ignore | ||||
epriestley: (This needs a minor adjustment since there are two more callsites, will followup.)
Changed a… | |||||
} | } | ||||
} | } | ||||
$change = $changeset->getChangeType(); | $change = $changeset->getChangeType(); | ||||
if ($this->leftRawFileURI) { | if ($this->leftRawFileURI) { | ||||
if ($change != DifferentialChangeType::TYPE_ADD) { | if ($change != DifferentialChangeType::TYPE_ADD) { | ||||
$uri = new PhutilURI($this->leftRawFileURI); | $uri = new PhutilURI($this->leftRawFileURI); | ||||
$uri->setQueryParams($uri->getQueryParams() + $qparams); | $uri = $this->appendDefaultQueryParams($uri, $qparams); | ||||
$meta['leftURI'] = (string)$uri; | $meta['leftURI'] = (string)$uri; | ||||
} | } | ||||
} | } | ||||
if ($this->rightRawFileURI) { | if ($this->rightRawFileURI) { | ||||
if ($change != DifferentialChangeType::TYPE_DELETE && | if ($change != DifferentialChangeType::TYPE_DELETE && | ||||
$change != DifferentialChangeType::TYPE_MULTICOPY) { | $change != DifferentialChangeType::TYPE_MULTICOPY) { | ||||
$uri = new PhutilURI($this->rightRawFileURI); | $uri = new PhutilURI($this->rightRawFileURI); | ||||
$uri->setQueryParams($uri->getQueryParams() + $qparams); | $uri = $this->appendDefaultQueryParams($uri, $qparams); | ||||
$meta['rightURI'] = (string)$uri; | $meta['rightURI'] = (string)$uri; | ||||
} | } | ||||
} | } | ||||
if ($viewer && $repository) { | if ($viewer && $repository) { | ||||
$path = ltrim( | $path = ltrim( | ||||
$changeset->getAbsoluteRepositoryPath($repository, $this->diff), | $changeset->getAbsoluteRepositoryPath($repository, $this->diff), | ||||
'/'); | '/'); | ||||
Show All 14 Lines | return id(new PHUIButtonView()) | ||||
->setIcon('fa-bars') | ->setIcon('fa-bars') | ||||
->setColor(PHUIButtonView::GREY) | ->setColor(PHUIButtonView::GREY) | ||||
->setHref(idx($meta, 'detailURI', '#')) | ->setHref(idx($meta, 'detailURI', '#')) | ||||
->setMetadata($meta) | ->setMetadata($meta) | ||||
->addSigil('differential-view-options'); | ->addSigil('differential-view-options'); | ||||
} | } | ||||
private function appendDefaultQueryParams(PhutilURI $uri, array $params) { | |||||
// Add these default query parameters to the query string if they do not | |||||
// already exist. | |||||
$have = array(); | |||||
foreach ($uri->getQueryParamsAsPairList() as $pair) { | |||||
list($key, $value) = $pair; | |||||
$have[$key] = true; | |||||
} | |||||
foreach ($params as $key => $value) { | |||||
if (!isset($have[$key])) { | |||||
$uri->appendQueryParam($key, $value); | |||||
} | |||||
} | |||||
return $uri; | |||||
} | |||||
} | } |
(This needs a minor adjustment since there are two more callsites, will followup.)
Changed a revision to "Whitespace: View All". Clicked "View Options > Show Raw File (Right)", saw "whitespace" parameter preserved in URI.