mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Make Project slug/hashtag transactions render a little more nicely
Summary: Ref T12732. Use `renderValue()` to build `renderValueList()` so we get nice fancy text for these. Test Plan: {F4967410} Reviewers: chad, amckinley Reviewed By: amckinley Maniphest Tasks: T12732 Differential Revision: https://secure.phabricator.com/D17966
This commit is contained in:
parent
abd791889c
commit
10b3879232
2 changed files with 33 additions and 10 deletions
|
@ -40,26 +40,29 @@ final class PhabricatorProjectSlugsTransaction
|
|||
$add = array_diff($new, $old);
|
||||
$rem = array_diff($old, $new);
|
||||
|
||||
$add = $this->renderHashtags($add);
|
||||
$rem = $this->renderHashtags($rem);
|
||||
|
||||
if ($add && $rem) {
|
||||
return pht(
|
||||
'%s changed project hashtag(s), added %d: %s; removed %d: %s.',
|
||||
$this->renderAuthor(),
|
||||
count($add),
|
||||
$this->renderSlugList($add),
|
||||
$this->renderValueList($add),
|
||||
count($rem),
|
||||
$this->renderSlugList($rem));
|
||||
$this->renderValueList($rem));
|
||||
} else if ($add) {
|
||||
return pht(
|
||||
'%s added %d project hashtag(s): %s.',
|
||||
$this->renderAuthor(),
|
||||
count($add),
|
||||
$this->renderSlugList($add));
|
||||
$this->renderValueList($add));
|
||||
} else if ($rem) {
|
||||
return pht(
|
||||
'%s removed %d project hashtag(s): %s.',
|
||||
$this->renderAuthor(),
|
||||
count($rem),
|
||||
$this->renderSlugList($rem));
|
||||
$this->renderValueList($rem));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,29 +73,32 @@ final class PhabricatorProjectSlugsTransaction
|
|||
$add = array_diff($new, $old);
|
||||
$rem = array_diff($old, $new);
|
||||
|
||||
$add = $this->renderHashtags($add);
|
||||
$rem = $this->renderHashtags($rem);
|
||||
|
||||
if ($add && $rem) {
|
||||
return pht(
|
||||
'%s changed %s hashtag(s), added %d: %s; removed %d: %s.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject(),
|
||||
count($add),
|
||||
$this->renderSlugList($add),
|
||||
$this->renderValueList($add),
|
||||
count($rem),
|
||||
$this->renderSlugList($rem));
|
||||
$this->renderValueList($rem));
|
||||
} else if ($add) {
|
||||
return pht(
|
||||
'%s added %d %s hashtag(s): %s.',
|
||||
$this->renderAuthor(),
|
||||
count($add),
|
||||
$this->renderObject(),
|
||||
$this->renderSlugList($add));
|
||||
$this->renderValueList($add));
|
||||
} else if ($rem) {
|
||||
return pht(
|
||||
'%s removed %d %s hashtag(s): %s.',
|
||||
$this->renderAuthor(),
|
||||
count($rem),
|
||||
$this->renderObject(),
|
||||
$this->renderSlugList($rem));
|
||||
$this->renderValueList($rem));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,8 +163,12 @@ final class PhabricatorProjectSlugsTransaction
|
|||
return $errors;
|
||||
}
|
||||
|
||||
private function renderSlugList($slugs) {
|
||||
return implode(', ', $slugs);
|
||||
private function renderHashtags(array $tags) {
|
||||
$result = array();
|
||||
foreach ($tags as $tag) {
|
||||
$result[] = '#'.$tag;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -208,6 +208,19 @@ abstract class PhabricatorModularTransactionType
|
|||
$value);
|
||||
}
|
||||
|
||||
final protected function renderValueList(array $values) {
|
||||
$result = array();
|
||||
foreach ($values as $value) {
|
||||
$result[] = $this->renderValue($value);
|
||||
}
|
||||
|
||||
if ($this->isTextMode()) {
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
return phutil_implode_html(', ', $result);
|
||||
}
|
||||
|
||||
final protected function renderOldValue() {
|
||||
return $this->renderValue($this->getOldValue());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue