mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-26 19:20:18 +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);
|
$add = array_diff($new, $old);
|
||||||
$rem = array_diff($old, $new);
|
$rem = array_diff($old, $new);
|
||||||
|
|
||||||
|
$add = $this->renderHashtags($add);
|
||||||
|
$rem = $this->renderHashtags($rem);
|
||||||
|
|
||||||
if ($add && $rem) {
|
if ($add && $rem) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s changed project hashtag(s), added %d: %s; removed %d: %s.',
|
'%s changed project hashtag(s), added %d: %s; removed %d: %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
count($add),
|
count($add),
|
||||||
$this->renderSlugList($add),
|
$this->renderValueList($add),
|
||||||
count($rem),
|
count($rem),
|
||||||
$this->renderSlugList($rem));
|
$this->renderValueList($rem));
|
||||||
} else if ($add) {
|
} else if ($add) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s added %d project hashtag(s): %s.',
|
'%s added %d project hashtag(s): %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
count($add),
|
count($add),
|
||||||
$this->renderSlugList($add));
|
$this->renderValueList($add));
|
||||||
} else if ($rem) {
|
} else if ($rem) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s removed %d project hashtag(s): %s.',
|
'%s removed %d project hashtag(s): %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
count($rem),
|
count($rem),
|
||||||
$this->renderSlugList($rem));
|
$this->renderValueList($rem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,29 +73,32 @@ final class PhabricatorProjectSlugsTransaction
|
||||||
$add = array_diff($new, $old);
|
$add = array_diff($new, $old);
|
||||||
$rem = array_diff($old, $new);
|
$rem = array_diff($old, $new);
|
||||||
|
|
||||||
|
$add = $this->renderHashtags($add);
|
||||||
|
$rem = $this->renderHashtags($rem);
|
||||||
|
|
||||||
if ($add && $rem) {
|
if ($add && $rem) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s changed %s hashtag(s), added %d: %s; removed %d: %s.',
|
'%s changed %s hashtag(s), added %d: %s; removed %d: %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
$this->renderObject(),
|
$this->renderObject(),
|
||||||
count($add),
|
count($add),
|
||||||
$this->renderSlugList($add),
|
$this->renderValueList($add),
|
||||||
count($rem),
|
count($rem),
|
||||||
$this->renderSlugList($rem));
|
$this->renderValueList($rem));
|
||||||
} else if ($add) {
|
} else if ($add) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s added %d %s hashtag(s): %s.',
|
'%s added %d %s hashtag(s): %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
count($add),
|
count($add),
|
||||||
$this->renderObject(),
|
$this->renderObject(),
|
||||||
$this->renderSlugList($add));
|
$this->renderValueList($add));
|
||||||
} else if ($rem) {
|
} else if ($rem) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s removed %d %s hashtag(s): %s.',
|
'%s removed %d %s hashtag(s): %s.',
|
||||||
$this->renderAuthor(),
|
$this->renderAuthor(),
|
||||||
count($rem),
|
count($rem),
|
||||||
$this->renderObject(),
|
$this->renderObject(),
|
||||||
$this->renderSlugList($rem));
|
$this->renderValueList($rem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +163,12 @@ final class PhabricatorProjectSlugsTransaction
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderSlugList($slugs) {
|
private function renderHashtags(array $tags) {
|
||||||
return implode(', ', $slugs);
|
$result = array();
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
$result[] = '#'.$tag;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,19 @@ abstract class PhabricatorModularTransactionType
|
||||||
$value);
|
$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() {
|
final protected function renderOldValue() {
|
||||||
return $this->renderValue($this->getOldValue());
|
return $this->renderValue($this->getOldValue());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue