@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 PhabricatorGuideQuickStartModule extends PhabricatorGuideModule {
4
5 public function getModuleKey() {
6 return 'quickstart';
7 }
8
9 public function getModuleName() {
10 return pht('Quick Start');
11 }
12
13 public function getModulePosition() {
14 return 30;
15 }
16
17 public function getIsModuleEnabled() {
18 return true;
19 }
20
21 public function renderModuleStatus(AphrontRequest $request) {
22 $viewer = $request->getViewer();
23 $instance = PhabricatorEnv::getEnvConfig('cluster.instance');
24
25 $guide_items = new PhabricatorGuideListView();
26
27 $title = pht('Create a Repository');
28 $repository_check = id(new PhabricatorRepositoryQuery())
29 ->setViewer($viewer)
30 ->execute();
31 $href = PhabricatorEnv::getURI('/diffusion/');
32 if ($repository_check) {
33 $icon = 'fa-check';
34 $icon_bg = 'bg-green';
35 $description = pht(
36 "You've created at least one repository.");
37 } else {
38 $icon = 'fa-code';
39 $icon_bg = 'bg-sky';
40 $description =
41 pht('If you are here for code review, let\'s set up your first '.
42 'repository.');
43 }
44
45 $item = id(new PhabricatorGuideItemView())
46 ->setTitle($title)
47 ->setHref($href)
48 ->setIcon($icon)
49 ->setIconBackground($icon_bg)
50 ->setDescription($description);
51 $guide_items->addItem($item);
52
53
54 $title = pht('Create a Project');
55 $project_check = id(new PhabricatorProjectQuery())
56 ->setViewer($viewer)
57 ->execute();
58 $href = PhabricatorEnv::getURI('/project/');
59 if ($project_check) {
60 $icon = 'fa-check';
61 $icon_bg = 'bg-green';
62 $description = pht(
63 "You've created at least one project.");
64 } else {
65 $icon = 'fa-briefcase';
66 $icon_bg = 'bg-sky';
67 $description =
68 pht('Project tags define everything. Create them for teams, tags, '.
69 'or actual projects.');
70 }
71
72 $item = id(new PhabricatorGuideItemView())
73 ->setTitle($title)
74 ->setHref($href)
75 ->setIcon($icon)
76 ->setIconBackground($icon_bg)
77 ->setDescription($description);
78 $guide_items->addItem($item);
79
80
81 $title = pht('Create a Task');
82 $task_check = id(new ManiphestTaskQuery())
83 ->setViewer($viewer)
84 ->execute();
85 $href = PhabricatorEnv::getURI('/maniphest/');
86 if ($task_check) {
87 $icon = 'fa-check';
88 $icon_bg = 'bg-green';
89 $description = pht(
90 "You've created at least one task.");
91 } else {
92 $icon = 'fa-anchor';
93 $icon_bg = 'bg-sky';
94 $description =
95 pht('Create some work for the interns in Maniphest.');
96 }
97
98 $item = id(new PhabricatorGuideItemView())
99 ->setTitle($title)
100 ->setHref($href)
101 ->setIcon($icon)
102 ->setIconBackground($icon_bg)
103 ->setDescription($description);
104 $guide_items->addItem($item);
105
106 $title = pht('User Account Settings');
107 $href = PhabricatorEnv::getURI('/settings/');
108 $preferences = id(new PhabricatorUserPreferencesQuery())
109 ->setViewer($viewer)
110 ->withUsers(array($viewer))
111 ->executeOne();
112
113 $have_settings = ($preferences && $preferences->getPreferences());
114 if ($have_settings) {
115 $icon = 'fa-check';
116 $icon_bg = 'bg-green';
117 $description = pht(
118 "You've adjusted at least one setting on your account.");
119 } else {
120 $icon = 'fa-wrench';
121 $icon_bg = 'bg-sky';
122 $description = pht(
123 'Configure account settings for all users, or just yourself');
124 }
125
126 $item = id(new PhabricatorGuideItemView())
127 ->setTitle($title)
128 ->setHref($href)
129 ->setIcon($icon)
130 ->setIconBackground($icon_bg)
131 ->setDescription($description);
132 $guide_items->addItem($item);
133
134
135 $title = pht('Explore Applications');
136 $href = PhabricatorEnv::getURI('/applications/');
137 $icon = 'fa-globe';
138 $icon_bg = 'bg-sky';
139 $description =
140 pht('See all available applications.');
141
142 $item = id(new PhabricatorGuideItemView())
143 ->setTitle($title)
144 ->setHref($href)
145 ->setIcon($icon)
146 ->setIconBackground($icon_bg)
147 ->setDescription($description);
148 $guide_items->addItem($item);
149
150 if (!$instance) {
151 $title = pht('Invite Collaborators');
152 $people_check = id(new PhabricatorPeopleQuery())
153 ->setViewer($viewer)
154 ->execute();
155 $people = count($people_check);
156 $href = PhabricatorEnv::getURI('/people/invite/send/');
157 if ($people > 1) {
158 $icon = 'fa-check';
159 $icon_bg = 'bg-green';
160 $description = pht(
161 'Your invitations have been accepted. You will not be alone on '.
162 'this journey.');
163 } else {
164 $icon = 'fa-group';
165 $icon_bg = 'bg-sky';
166 $description =
167 pht('Invite the rest of your team to get started.');
168 }
169
170 $item = id(new PhabricatorGuideItemView())
171 ->setTitle($title)
172 ->setHref($href)
173 ->setIcon($icon)
174 ->setIconBackground($icon_bg)
175 ->setDescription($description);
176 $guide_items->addItem($item);
177 }
178
179 $intro = pht(
180 'If you\'re new to %s, these optional steps can help you learn the '.
181 'basics. Feel free to set things up for how you work best and explore '.
182 'these features at your own pace.',
183 PlatformSymbols::getPlatformServerName());
184
185 $intro = new PHUIRemarkupView($viewer, $intro);
186 $intro = id(new PHUIDocumentView())
187 ->appendChild($intro);
188
189 return array($intro, $guide_items);
190
191 }
192
193}