1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

Ref T8989, Add a "Visit URL" link to Phurl items.

Summary: Ref T8989, Add a "Visit URL" link to Phurl items and make it actionable if the URI has a valid protocol.

Test Plan:
- Create a Phurl object with a URI of "google.com".
- "Visit URL" action in action view should be greyed out.
- Edit object to have URI "http://google.com" and save. "Visit URL" link should be available and should redirect to the intended URL.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: chad, Korvin

Maniphest Tasks: T8989

Differential Revision: https://secure.phabricator.com/D14379
This commit is contained in:
lkassianik 2015-11-02 16:40:56 +00:00 committed by lpriestley
parent 4e112537b2
commit 09d4ea884f

View file

@ -96,13 +96,33 @@ final class PhabricatorPhurlURLViewController
$url,
PhabricatorPolicyCapability::CAN_EDIT);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("url/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$allowed_protocols = PhabricatorEnv::getEnvConfig('uri.allowed-protocols');
$uri = new PhutilURI($url->getLongURL());
$url_protocol = $uri->getProtocol();
$can_access = false;
$redirect_uri = $url->getMonogram();
if (strlen($url_protocol)) {
$can_access = in_array($url_protocol, $allowed_protocols);
$redirect_uri = $uri;
}
$actions
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("url/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit))
->addAction(
id(new PhabricatorActionView())
->setName(pht('Visit URL'))
->setIcon('fa-external-link')
->setHref($redirect_uri)
->setDisabled(!$can_edit || !$can_access)
->setWorkflow(!$can_edit));
return $actions;
}