mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-07 12:28:28 +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,
|
$url,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
$actions->addAction(
|
$allowed_protocols = PhabricatorEnv::getEnvConfig('uri.allowed-protocols');
|
||||||
id(new PhabricatorActionView())
|
$uri = new PhutilURI($url->getLongURL());
|
||||||
->setName(pht('Edit'))
|
$url_protocol = $uri->getProtocol();
|
||||||
->setIcon('fa-pencil')
|
|
||||||
->setHref($this->getApplicationURI("url/edit/{$id}/"))
|
$can_access = false;
|
||||||
->setDisabled(!$can_edit)
|
$redirect_uri = $url->getMonogram();
|
||||||
->setWorkflow(!$can_edit));
|
|
||||||
|
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;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue