Add some missing strings for custom policies

Summary: Ref T603. Fix/provide some rendering stuff related to custom policies.

Test Plan: After setting stuff to custom policies (made easier by future diffs), looked at the various places strings appear in the UI and saw more sensible ones.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7297
This commit is contained in:
epriestley
2013-10-14 12:05:43 -07:00
parent 6c1b00fa40
commit 7364a3bedd
2 changed files with 24 additions and 1 deletions

View File

@@ -3,13 +3,15 @@
final class PhabricatorPolicyType extends PhabricatorPolicyConstants { final class PhabricatorPolicyType extends PhabricatorPolicyConstants {
const TYPE_GLOBAL = 'global'; const TYPE_GLOBAL = 'global';
const TYPE_CUSTOM = 'custom';
const TYPE_PROJECT = 'project'; const TYPE_PROJECT = 'project';
const TYPE_MASKED = 'masked'; const TYPE_MASKED = 'masked';
public static function getPolicyTypeOrder($type) { public static function getPolicyTypeOrder($type) {
static $map = array( static $map = array(
self::TYPE_GLOBAL => 0, self::TYPE_GLOBAL => 0,
self::TYPE_PROJECT => 1, self::TYPE_CUSTOM => 1,
self::TYPE_PROJECT => 2,
self::TYPE_MASKED => 9, self::TYPE_MASKED => 9,
); );
return idx($map, $type, 9); return idx($map, $type, 9);
@@ -19,6 +21,8 @@ final class PhabricatorPolicyType extends PhabricatorPolicyConstants {
switch ($type) { switch ($type) {
case self::TYPE_GLOBAL: case self::TYPE_GLOBAL:
return pht('Basic Policies'); return pht('Basic Policies');
case self::TYPE_CUSTOM:
return pht('Advanced');
case self::TYPE_PROJECT: case self::TYPE_PROJECT:
return pht('Members of Project...'); return pht('Members of Project...');
case self::TYPE_MASKED: case self::TYPE_MASKED:

View File

@@ -64,6 +64,12 @@ final class PhabricatorPolicy
$policy->setType(PhabricatorPolicyType::TYPE_PROJECT); $policy->setType(PhabricatorPolicyType::TYPE_PROJECT);
$policy->setName($handle->getName()); $policy->setName($handle->getName());
break; break;
case PhabricatorPolicyPHIDTypePolicy::TYPECONST:
// TODO: This creates a weird handle-based version of a rule policy.
// It behaves correctly, but can't be applied since it doesn't have
// any rules. It is used to render transactions, and might need some
// cleanup.
break;
default: default:
$policy->setType(PhabricatorPolicyType::TYPE_MASKED); $policy->setType(PhabricatorPolicyType::TYPE_MASKED);
$policy->setName($handle->getFullName()); $policy->setName($handle->getFullName());
@@ -81,6 +87,9 @@ final class PhabricatorPolicy
} }
public function getType() { public function getType() {
if (!$this->type) {
return PhabricatorPolicyType::TYPE_CUSTOM;
}
return $this->type; return $this->type;
} }
@@ -90,6 +99,9 @@ final class PhabricatorPolicy
} }
public function getName() { public function getName() {
if (!$this->name) {
return pht('Custom Policy');
}
return $this->name; return $this->name;
} }
@@ -116,6 +128,7 @@ final class PhabricatorPolicy
case PhabricatorPolicyType::TYPE_PROJECT: case PhabricatorPolicyType::TYPE_PROJECT:
return 'policy-project'; return 'policy-project';
break; break;
case PhabricatorPolicyType::TYPE_CUSTOM:
case PhabricatorPolicyType::TYPE_MASKED: case PhabricatorPolicyType::TYPE_MASKED:
return 'policy-custom'; return 'policy-custom';
break; break;
@@ -173,6 +186,10 @@ final class PhabricatorPolicy
return pht( return pht(
'%s can take this action.', '%s can take this action.',
$handle->getFullName()); $handle->getFullName());
} else if ($type == PhabricatorPolicyPHIDTypePolicy::TYPECONST) {
return pht(
'This object has a custom policy controlling who can take this '.
'action.');
} else { } else {
return pht( return pht(
'This object has an unknown or invalid policy setting ("%s").', 'This object has an unknown or invalid policy setting ("%s").',
@@ -222,6 +239,8 @@ final class PhabricatorPolicy
switch ($this->getType()) { switch ($this->getType()) {
case PhabricatorPolicyType::TYPE_PROJECT: case PhabricatorPolicyType::TYPE_PROJECT:
return pht('%s (Project)', $desc); return pht('%s (Project)', $desc);
case PhabricatorPolicyType::TYPE_CUSTOM:
return pht('Custom Policy');
case PhabricatorPolicyType::TYPE_MASKED: case PhabricatorPolicyType::TYPE_MASKED:
return pht( return pht(
'%s (You do not have permission to view policy details.)', '%s (You do not have permission to view policy details.)',