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:
parent
4e112537b2
commit
09d4ea884f
1 changed files with 27 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue