@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

lkassianik and committed by
lpriestley
09d4ea88 4e112537

+27 -7
+27 -7
src/applications/phurl/controller/PhabricatorPhurlURLViewController.php
··· 96 96 $url, 97 97 PhabricatorPolicyCapability::CAN_EDIT); 98 98 99 - $actions->addAction( 100 - id(new PhabricatorActionView()) 101 - ->setName(pht('Edit')) 102 - ->setIcon('fa-pencil') 103 - ->setHref($this->getApplicationURI("url/edit/{$id}/")) 104 - ->setDisabled(!$can_edit) 105 - ->setWorkflow(!$can_edit)); 99 + $allowed_protocols = PhabricatorEnv::getEnvConfig('uri.allowed-protocols'); 100 + $uri = new PhutilURI($url->getLongURL()); 101 + $url_protocol = $uri->getProtocol(); 102 + 103 + $can_access = false; 104 + $redirect_uri = $url->getMonogram(); 105 + 106 + if (strlen($url_protocol)) { 107 + $can_access = in_array($url_protocol, $allowed_protocols); 108 + $redirect_uri = $uri; 109 + } 110 + 111 + $actions 112 + ->addAction( 113 + id(new PhabricatorActionView()) 114 + ->setName(pht('Edit')) 115 + ->setIcon('fa-pencil') 116 + ->setHref($this->getApplicationURI("url/edit/{$id}/")) 117 + ->setDisabled(!$can_edit) 118 + ->setWorkflow(!$can_edit)) 119 + ->addAction( 120 + id(new PhabricatorActionView()) 121 + ->setName(pht('Visit URL')) 122 + ->setIcon('fa-external-link') 123 + ->setHref($redirect_uri) 124 + ->setDisabled(!$can_edit || !$can_access) 125 + ->setWorkflow(!$can_edit)); 106 126 107 127 return $actions; 108 128 }