@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorProjectWorkboardProfileMenuItem
4 extends PhabricatorProfileMenuItem {
5
6 const MENUITEMKEY = 'project.workboard';
7
8 public function getMenuItemTypeName() {
9 return pht('Project Workboard');
10 }
11
12 private function getDefaultName() {
13 return pht('Workboard');
14 }
15
16 public function getMenuItemTypeIcon() {
17 return 'fa-columns';
18 }
19
20 public function canMakeDefault(
21 PhabricatorProfileMenuItemConfiguration $config) {
22 return true;
23 }
24
25 public function shouldEnableForObject($object) {
26 $viewer = $this->getViewer();
27
28 // Workboards are only available if Maniphest is enabled.
29 $class = PhabricatorManiphestApplication::class;
30 if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
31 return false;
32 }
33
34 return true;
35 }
36
37 public function getDisplayName(
38 PhabricatorProfileMenuItemConfiguration $config) {
39 $name = $config->getMenuItemProperty('name');
40
41 if (phutil_nonempty_string($name)) {
42 return $name;
43 }
44
45 return $this->getDefaultName();
46 }
47
48 public function buildEditEngineFields(
49 PhabricatorProfileMenuItemConfiguration $config) {
50 return array(
51 id(new PhabricatorTextEditField())
52 ->setKey('name')
53 ->setLabel(pht('Name'))
54 ->setPlaceholder($this->getDefaultName())
55 ->setValue($config->getMenuItemProperty('name')),
56 );
57 }
58
59 protected function newMenuItemViewList(
60 PhabricatorProfileMenuItemConfiguration $config) {
61 $project = $config->getProfileObject();
62
63 $id = $project->getID();
64 $uri = $project->getWorkboardURI();
65 $name = $this->getDisplayName($config);
66
67 $item = $this->newItemView()
68 ->setURI($uri)
69 ->setName($name)
70 ->setIcon('fa-columns');
71
72 return array(
73 $item,
74 );
75 }
76
77}