public function buildManagementPanelContent() { $repository = $this->getRepository(); $viewer = $this->getViewer(); $uris = $repository->getURIs(); Javelin::initBehavior('phabricator-tooltips'); $rows = array(); foreach ($uris as $uri) { $uri_name = $uri->getDisplayURI(); $uri_name = phutil_tag('a', array('href' => $uri->getViewURI()), $uri_name); if ($uri->getIsDisabled()) { $status_icon = 'fa-times grey'; } else { $status_icon = 'fa-check green'; } $uri_status = id(new PHUIIconView())->setIcon($status_icon); $io_type = $uri->getEffectiveIOType(); $io_map = PhabricatorRepositoryURI::getIOTypeMap(); $io_spec = idx($io_map, $io_type, array()); $io_icon = idx($io_spec, 'icon'); $io_color = idx($io_spec, 'color'); $io_label = idx($io_spec, 'label', $io_type); $uri_io = array(id(new PHUIIconView())->setIcon("{$io_icon} {$io_color}"), ' ', $io_label); $display_type = $uri->getEffectiveDisplayType(); $display_map = PhabricatorRepositoryURI::getDisplayTypeMap(); $display_spec = idx($display_map, $display_type, array()); $display_icon = idx($display_spec, 'icon'); $display_color = idx($display_spec, 'color'); $display_label = idx($display_spec, 'label', $display_type); $uri_display = array(id(new PHUIIconView())->setIcon("{$display_icon} {$display_color}"), ' ', $display_label); $rows[] = array($uri_status, $uri_name, $uri_io, $uri_display); } $table = id(new AphrontTableView($rows))->setNoDataString(pht('This repository has no URIs.'))->setHeaders(array(null, pht('URI'), pht('I/O'), pht('Display')))->setColumnClasses(array(null, 'pri wide', null, null)); $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: URIs'); $add_href = $repository->getPathURI('uri/edit/'); $header = id(new PHUIHeaderView())->setHeader(pht('Repository URIs'))->addActionLink(id(new PHUIButtonView())->setIcon('fa-plus')->setHref($add_href)->setTag('a')->setText(pht('Add New URI')))->addActionLink(id(new PHUIButtonView())->setIcon('fa-book')->setHref($doc_href)->setTag('a')->setText(pht('Documentation'))); $is_new = $repository->isNewlyInitialized(); $messages = array(); if ($repository->isHosted()) { if ($is_new) { $host_message = pht('Phabricator will host this repository.'); } else { $host_message = pht('Phabricator is hosting this repository.'); } $messages[] = array(id(new PHUIIconView())->setIcon('fa-folder'), ' ', $host_message); } else { if ($is_new) { $observe_message = pht('Phabricator will observe a remote repository.'); } else { $observe_message = pht('This repository is hosted remotely. Phabricator is observing it.'); } $messages[] = array(id(new PHUIIconView())->setIcon('fa-download'), ' ', $observe_message); } $info_view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setErrors($messages); return id(new PHUIObjectBoxView())->setHeader($header)->setInfoView($info_view)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTable($table); }
public function getTitle() { $author_phid = $this->getAuthorPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case self::TYPE_URI: return pht('%s changed this URI from "%s" to "%s".', $this->renderHandleLink($author_phid), $old, $new); case self::TYPE_IO: $map = PhabricatorRepositoryURI::getIOTypeMap(); $old_label = idx(idx($map, $old, array()), 'label', $old); $new_label = idx(idx($map, $new, array()), 'label', $new); return pht('%s changed the display type for this URI from "%s" to "%s".', $this->renderHandleLink($author_phid), $old_label, $new_label); case self::TYPE_DISPLAY: $map = PhabricatorRepositoryURI::getDisplayTypeMap(); $old_label = idx(idx($map, $old, array()), 'label', $old); $new_label = idx(idx($map, $new, array()), 'label', $new); return pht('%s changed the display type for this URI from "%s" to "%s".', $this->renderHandleLink($author_phid), $old_label, $new_label); case self::TYPE_DISABLE: if ($new) { return pht('%s disabled this URI.', $this->renderHandleLink($author_phid)); } else { return pht('%s enabled this URI.', $this->renderHandleLink($author_phid)); } case self::TYPE_CREDENTIAL: if ($old && $new) { return pht('%s changed the credential for this URI from %s to %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($old), $this->renderHandleLink($new)); } else { if ($old) { return pht('%s removed %s as the credential for this URI.', $this->renderHandleLink($author_phid), $this->renderHandleLink($old)); } else { if ($new) { return pht('%s set the credential for this URI to %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($new)); } } } } return parent::getTitle(); }
private function buildPropertySection(PhabricatorRepositoryURI $uri) { $viewer = $this->getViewer(); $properties = id(new PHUIPropertyListView())->setUser($viewer); $properties->addProperty(pht('URI'), $uri->getDisplayURI()); $credential_phid = $uri->getCredentialPHID(); $command_engine = $uri->newCommandEngine(); $is_optional = $command_engine->isCredentialOptional(); $is_supported = $command_engine->isCredentialSupported(); $is_builtin = $uri->isBuiltin(); if ($is_builtin) { $credential_icon = 'fa-circle-o'; $credential_color = 'grey'; $credential_label = pht('Builtin'); $credential_note = pht('Builtin URIs do not use credentials.'); } else { if (!$is_supported) { $credential_icon = 'fa-circle-o'; $credential_color = 'grey'; $credential_label = pht('Not Supported'); $credential_note = pht('This protocol does not support authentication.'); } else { if (!$credential_phid) { if ($is_optional) { $credential_icon = 'fa-circle-o'; $credential_color = 'green'; $credential_label = pht('No Credential'); $credential_note = pht('Configured for anonymous access.'); } else { $credential_icon = 'fa-times'; $credential_color = 'red'; $credential_label = pht('Required'); $credential_note = pht('Credential required but not configured.'); } } else { // Don't raise a policy exception if we can't see the credential. $credentials = id(new PassphraseCredentialQuery())->setViewer($viewer)->withPHIDs(array($credential_phid))->execute(); $credential = head($credentials); if (!$credential) { $handles = $viewer->loadHandles(array($credential_phid)); $handle = $handles[$credential_phid]; if ($handle->getPolicyFiltered()) { $credential_icon = 'fa-lock'; $credential_color = 'grey'; $credential_label = pht('Restricted'); $credential_note = pht('You do not have permission to view the configured ' . 'credential.'); } else { $credential_icon = 'fa-times'; $credential_color = 'red'; $credential_label = pht('Invalid'); $credential_note = pht('Configured credential is invalid.'); } } else { $provides = $credential->getProvidesType(); $needs = $command_engine->getPassphraseProvidesCredentialType(); if ($provides != $needs) { $credential_icon = 'fa-times'; $credential_color = 'red'; $credential_label = pht('Wrong Type'); } else { $credential_icon = 'fa-check'; $credential_color = 'green'; $credential_label = $command_engine->getPassphraseCredentialLabel(); } $credential_note = $viewer->renderHandle($credential_phid); } } } } $credential_item = id(new PHUIStatusItemView())->setIcon($credential_icon, $credential_color)->setTarget(phutil_tag('strong', array(), $credential_label))->setNote($credential_note); $credential_view = id(new PHUIStatusListView())->addItem($credential_item); $properties->addProperty(pht('Credential'), $credential_view); $io_type = $uri->getEffectiveIOType(); $io_map = PhabricatorRepositoryURI::getIOTypeMap(); $io_spec = idx($io_map, $io_type, array()); $io_icon = idx($io_spec, 'icon'); $io_color = idx($io_spec, 'color'); $io_label = idx($io_spec, 'label', $io_type); $io_note = idx($io_spec, 'note'); $io_item = id(new PHUIStatusItemView())->setIcon($io_icon, $io_color)->setTarget(phutil_tag('strong', array(), $io_label))->setNote($io_note); $io_view = id(new PHUIStatusListView())->addItem($io_item); $properties->addProperty(pht('I/O'), $io_view); $display_type = $uri->getEffectiveDisplayType(); $display_map = PhabricatorRepositoryURI::getDisplayTypeMap(); $display_spec = idx($display_map, $display_type, array()); $display_icon = idx($display_spec, 'icon'); $display_color = idx($display_spec, 'color'); $display_label = idx($display_spec, 'label', $display_type); $display_note = idx($display_spec, 'note'); $display_item = id(new PHUIStatusItemView())->setIcon($display_icon, $display_color)->setTarget(phutil_tag('strong', array(), $display_label))->setNote($display_note); $display_view = id(new PHUIStatusListView())->addItem($display_item); $properties->addProperty(pht('Display'), $display_view); return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($properties); }