private function renderWatchAction(PhabricatorProject $project) { $viewer = $this->getViewer(); $id = $project->getID(); if (!$viewer->isLoggedIn()) { $is_watcher = false; $is_ancestor = false; } else { $viewer_phid = $viewer->getPHID(); $is_watcher = $project->isUserWatcher($viewer_phid); $is_ancestor = $project->isUserAncestorWatcher($viewer_phid); } if ($is_ancestor && !$is_watcher) { $watch_icon = 'fa-eye'; $watch_text = pht('Watching Ancestor'); $watch_href = "/project/watch/{$id}/?via=profile"; $watch_disabled = true; } else { if (!$is_watcher) { $watch_icon = 'fa-eye'; $watch_text = pht('Watch Project'); $watch_href = "/project/watch/{$id}/?via=profile"; $watch_disabled = false; } else { $watch_icon = 'fa-eye-slash'; $watch_text = pht('Unwatch Project'); $watch_href = "/project/unwatch/{$id}/?via=profile"; $watch_disabled = false; } } $watch_icon = id(new PHUIIconView())->setIcon($watch_icon); return id(new PHUIButtonView())->setTag('a')->setWorkflow(true)->setIcon($watch_icon)->setText($watch_text)->setHref($watch_href)->setDisabled($watch_disabled); }
private function renderWatchAction(PhabricatorProject $project) { $viewer = $this->getViewer(); $viewer_phid = $viewer->getPHID(); $id = $project->getID(); $is_watcher = $viewer_phid && $project->isUserWatcher($viewer_phid); if (!$is_watcher) { $watch_icon = 'fa-eye'; $watch_text = pht('Watch Project'); $watch_href = "/project/watch/{$id}/?via=profile"; } else { $watch_icon = 'fa-eye-slash'; $watch_text = pht('Unwatch Project'); $watch_href = "/project/unwatch/{$id}/?via=profile"; } $watch_icon = id(new PHUIIconView())->setIcon($watch_icon); return id(new PHUIButtonView())->setTag('a')->setWorkflow(true)->setIcon($watch_icon)->setText($watch_text)->setHref($watch_href); }