private function buildVersionsView(PhabricatorPackagesPackage $package)
 {
     $viewer = $this->getViewer();
     $versions = id(new PhabricatorPackagesVersionQuery())->setViewer($viewer)->withPackagePHIDs(array($package->getPHID()))->setLimit(25)->execute();
     $versions_list = id(new PhabricatorPackagesVersionListView())->setViewer($viewer)->setVersions($versions);
     $all_href = urisprintf('version/?package=%s#R', $package->getPHID());
     $all_href = $this->getApplicationURI($all_href);
     $view_all = id(new PHUIButtonView())->setTag('a')->setIcon('fa-search')->setText(pht('View All'))->setHref($all_href);
     $header = id(new PHUIHeaderView())->setHeader(pht('Versions'))->addActionLink($view_all);
     $versions_view = id(new PHUIObjectBoxView())->setHeader($header)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setObjectList($versions_list);
     return $versions_view;
 }
 protected function buildJoinClauseParts(AphrontDatabaseConnection $conn)
 {
     $joins = parent::buildJoinClauseParts($conn);
     $join_publisher = $this->fullKeys !== null;
     $join_package = $this->fullKeys !== null || $join_publisher;
     if ($join_package) {
         $package_table = new PhabricatorPackagesPackage();
         $joins[] = qsprintf($conn, 'JOIN %T p ON v.packagePHID = p.phid', $package_table->getTableName());
     }
     if ($join_publisher) {
         $publisher_table = new PhabricatorPackagesPublisher();
         $joins[] = qsprintf($conn, 'JOIN %T u ON u.phid = p.publisherPHID', $publisher_table->getTableName());
     }
     return $joins;
 }
 public function validateTransactions($object, array $xactions)
 {
     $errors = array();
     if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
         $errors[] = $this->newRequiredError(pht('Packages must have a name.'));
         return $errors;
     }
     foreach ($xactions as $xaction) {
         $value = $xaction->getNewValue();
         try {
             PhabricatorPackagesPackage::assertValidPackageName($value);
         } catch (Exception $ex) {
             $errors[] = $this->newInvalidError($ex->getMessage(), $xaction);
         }
     }
     return $errors;
 }
 public function validateTransactions($object, array $xactions)
 {
     $errors = array();
     if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
         $errors[] = $this->newRequiredError(pht('Each package provided by a publisher must have a ' . 'unique package key.'));
         return $errors;
     }
     if (!$this->isNewObject()) {
         foreach ($xactions as $xaction) {
             $errors[] = $this->newInvalidError(pht('Once a package is created, its key can not be changed.'), $xaction);
         }
     }
     foreach ($xactions as $xaction) {
         $value = $xaction->getNewValue();
         try {
             PhabricatorPackagesPackage::assertValidPackageKey($value);
         } catch (Exception $ex) {
             $errors[] = $this->newInvalidError($ex->getMessage(), $xaction);
         }
     }
     return $errors;
 }
 protected function newEditableObject()
 {
     $viewer = $this->getViewer();
     return PhabricatorPackagesPackage::initializeNewPackage($viewer);
 }