Skip to content

Commit 74b438d

Browse files
author
epriestley
committed
Move "Mailing Lists" to a separate application
Summary: There's currently no way to get here from the UI since nav tabs don't exist anymore. It's also always been hard to find this feature even when we had the tabs, since it's surprising that it's inside "MetaMTA". - Move mailing lists to a separate application. - Add `buildApplicationPage()`, since we don't really need `buildStandardPageResponse()` any more -- we can infer all the information from `PhabricatorApplication`. This will let us get rid of a lot of the `PhabricatorXXXController` classes which just define application information. - Add `getApplicationURI()` to reduce code duplication, and in case we want to let you move applications around some day. Test Plan: Looked/edited/saved mailing lists. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T631 Differential Revision: https://secure.phabricator.com/D3248
1 parent df31625 commit 74b438d

13 files changed

+132
-41
lines changed

src/__celerity_resource_map__.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2564,7 +2564,7 @@
25642564
),
25652565
'phabricator-nav-view-css' =>
25662566
array(
2567-
'uri' => '/res/82636b80/rsrc/css/aphront/phabricator-nav-view.css',
2567+
'uri' => '/res/051b6ab6/rsrc/css/aphront/phabricator-nav-view.css',
25682568
'type' => 'css',
25692569
'requires' =>
25702570
array(

src/__phutil_library_map__.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@
551551
'PhabricatorApplicationFact' => 'applications/fact/application/PhabricatorApplicationFact.php',
552552
'PhabricatorApplicationFlags' => 'applications/flag/application/PhabricatorApplicationFlags.php',
553553
'PhabricatorApplicationLaunchView' => 'applications/meta/view/PhabricatorApplicationLaunchView.php',
554+
'PhabricatorApplicationMailingLists' => 'applications/mailinglists/application/PhabricatorApplicationMailingLists.php',
554555
'PhabricatorApplicationManiphest' => 'applications/maniphest/application/PhabricatorApplicationManiphest.php',
555556
'PhabricatorApplicationPeople' => 'applications/people/application/PhabricatorApplicationPeople.php',
556557
'PhabricatorApplicationPhriction' => 'applications/phriction/application/PhabricatorApplicationPhriction.php',
@@ -777,6 +778,8 @@
777778
'PhabricatorMailImplementationSendGridAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php',
778779
'PhabricatorMailImplementationTestAdapter' => 'applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php',
779780
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
781+
'PhabricatorMailingListsEditController' => 'applications/mailinglists/controller/PhabricatorMailingListsEditController.php',
782+
'PhabricatorMailingListsListController' => 'applications/mailinglists/controller/PhabricatorMailingListsListController.php',
780783
'PhabricatorMainMenuGroupView' => 'view/page/menu/PhabricatorMainMenuGroupView.php',
781784
'PhabricatorMainMenuIconView' => 'view/page/menu/PhabricatorMainMenuIconView.php',
782785
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
@@ -795,9 +798,7 @@
795798
'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php',
796799
'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php',
797800
'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php',
798-
'PhabricatorMetaMTAMailingList' => 'applications/metamta/storage/PhabricatorMetaMTAMailingList.php',
799-
'PhabricatorMetaMTAMailingListEditController' => 'applications/metamta/controller/PhabricatorMetaMTAMailingListEditController.php',
800-
'PhabricatorMetaMTAMailingListsController' => 'applications/metamta/controller/PhabricatorMetaMTAMailingListsController.php',
801+
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
801802
'PhabricatorMetaMTAReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAReceiveController.php',
802803
'PhabricatorMetaMTAReceivedListController' => 'applications/metamta/controller/PhabricatorMetaMTAReceivedListController.php',
803804
'PhabricatorMetaMTAReceivedMail' => 'applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php',
@@ -1670,6 +1671,7 @@
16701671
'PhabricatorApplicationFact' => 'PhabricatorApplication',
16711672
'PhabricatorApplicationFlags' => 'PhabricatorApplication',
16721673
'PhabricatorApplicationLaunchView' => 'AphrontView',
1674+
'PhabricatorApplicationMailingLists' => 'PhabricatorApplication',
16731675
'PhabricatorApplicationManiphest' => 'PhabricatorApplication',
16741676
'PhabricatorApplicationPeople' => 'PhabricatorApplication',
16751677
'PhabricatorApplicationPhriction' => 'PhabricatorApplication',
@@ -1678,7 +1680,7 @@
16781680
'PhabricatorApplicationSettings' => 'PhabricatorApplication',
16791681
'PhabricatorApplicationStatusView' => 'AphrontView',
16801682
'PhabricatorApplicationsController' => 'PhabricatorController',
1681-
'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController',
1683+
'PhabricatorApplicationsListController' => 'PhabricatorController',
16821684
'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController',
16831685
'PhabricatorAuditComment' => 'PhabricatorAuditDAO',
16841686
'PhabricatorAuditCommitListView' => 'AphrontView',
@@ -1869,6 +1871,8 @@
18691871
'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'PhabricatorMailImplementationAdapter',
18701872
'PhabricatorMailImplementationSendGridAdapter' => 'PhabricatorMailImplementationAdapter',
18711873
'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter',
1874+
'PhabricatorMailingListsEditController' => 'PhabricatorController',
1875+
'PhabricatorMailingListsListController' => 'PhabricatorController',
18721876
'PhabricatorMainMenuGroupView' => 'AphrontView',
18731877
'PhabricatorMainMenuIconView' => 'AphrontView',
18741878
'PhabricatorMainMenuSearchView' => 'AphrontView',
@@ -1882,8 +1886,6 @@
18821886
'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase',
18831887
'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase',
18841888
'PhabricatorMetaMTAMailingList' => 'PhabricatorMetaMTADAO',
1885-
'PhabricatorMetaMTAMailingListEditController' => 'PhabricatorMetaMTAController',
1886-
'PhabricatorMetaMTAMailingListsController' => 'PhabricatorMetaMTAController',
18871889
'PhabricatorMetaMTAReceiveController' => 'PhabricatorMetaMTAController',
18881890
'PhabricatorMetaMTAReceivedListController' => 'PhabricatorMetaMTAController',
18891891
'PhabricatorMetaMTAReceivedMail' => 'PhabricatorMetaMTADAO',

src/aphront/configuration/AphrontDefaultApplicationConfiguration.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ public function getURIMap() {
8585
'' => 'PhabricatorMetaMTAListController',
8686
'send/' => 'PhabricatorMetaMTASendController',
8787
'view/(?P<id>\d+)/' => 'PhabricatorMetaMTAViewController',
88-
'lists/' => 'PhabricatorMetaMTAMailingListsController',
89-
'lists/edit/(?:(?P<id>\d+)/)?'
90-
=> 'PhabricatorMetaMTAMailingListEditController',
9188
'receive/' => 'PhabricatorMetaMTAReceiveController',
9289
'received/' => 'PhabricatorMetaMTAReceivedListController',
9390
'sendgrid/' => 'PhabricatorMetaMTASendGridReceiveController',

src/applications/base/PhabricatorApplication.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function getCoreApplicationOrder() {
6666
return null;
6767
}
6868

69+
public function getTitleGlyph() {
70+
return null;
71+
}
72+
6973

7074
/* -( URI Routing )-------------------------------------------------------- */
7175

src/applications/base/controller/PhabricatorController.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,44 @@ public function buildStandardPageResponse($view, array $data) {
128128
return $response;
129129
}
130130

131+
public function getApplicationURI($path = '') {
132+
if (!$this->getCurrentApplication()) {
133+
throw new Exception("No application!");
134+
}
135+
return $this->getCurrentApplication()->getBaseURI().ltrim($path, '/');
136+
}
137+
138+
public function buildApplicationPage($view, array $options) {
139+
$page = $this->buildStandardPageView();
140+
141+
$application = $this->getCurrentApplication();
142+
if ($application) {
143+
$page->setApplicationName($application->getName());
144+
$page->setTitle(idx($options, 'title'));
145+
if ($application->getTitleGlyph()) {
146+
$page->setGlyph($application->getTitleGlyph());
147+
}
148+
}
149+
150+
if (!($view instanceof AphrontSideNavFilterView)) {
151+
$nav = new AphrontSideNavFilterView();
152+
if ($application) {
153+
$nav->setCurrentApplication($application);
154+
}
155+
$nav->setUser($this->getRequest()->getUser());
156+
$nav->setFlexNav(true);
157+
$nav->setShowApplicationMenu(true);
158+
$nav->appendChild($view);
159+
160+
$view = $nav;
161+
}
162+
163+
$page->appendChild($view);
164+
165+
$response = new AphrontWebpageResponse();
166+
return $response->setContent($page->render());
167+
}
168+
131169
public function didProcessRequest($response) {
132170
$request = $this->getRequest();
133171
$response->setRequest($request);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
final class PhabricatorApplicationMailingLists extends PhabricatorApplication {
20+
21+
public function getName() {
22+
return 'Mailing Lists';
23+
}
24+
25+
public function getBaseURI() {
26+
return '/mailinglists/';
27+
}
28+
29+
public function getShortDescription() {
30+
return 'Manage External Lists';
31+
}
32+
33+
public function getRoutes() {
34+
return array(
35+
'/mailinglists/' => array(
36+
'' => 'PhabricatorMailingListsListController',
37+
'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorMailingListsEditController',
38+
),
39+
);
40+
}
41+
42+
public function getTitleGlyph() {
43+
return '@';
44+
}
45+
46+
}

src/applications/metamta/controller/PhabricatorMetaMTAMailingListEditController.php renamed to src/applications/mailinglists/controller/PhabricatorMailingListsEditController.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
final class PhabricatorMetaMTAMailingListEditController
20-
extends PhabricatorMetaMTAController {
19+
final class PhabricatorMailingListsEditController
20+
extends PhabricatorController {
2121

2222
private $id;
2323

@@ -74,7 +74,7 @@ public function processRequest() {
7474
try {
7575
$list->save();
7676
return id(new AphrontRedirectResponse())
77-
->setURI('/mail/lists/');
77+
->setURI($this->getApplicationURI());
7878
} catch (AphrontQueryDuplicateKeyException $ex) {
7979
$e_email = 'Duplicate';
8080
$errors[] = 'Another mailing list already uses that address.';
@@ -92,9 +92,9 @@ public function processRequest() {
9292
$form = new AphrontFormView();
9393
$form->setUser($request->getUser());
9494
if ($list->getID()) {
95-
$form->setAction('/mail/lists/edit/'.$list->getID().'/');
95+
$form->setAction($this->getApplicationURI('/edit/'.$list->getID().'/'));
9696
} else {
97-
$form->setAction('/mail/lists/edit/');
97+
$form->setAction($this->getApplicationURI('/edit/'));
9898
}
9999

100100
$form
@@ -119,18 +119,14 @@ public function processRequest() {
119119
->setError($e_uri)
120120
->setCaption('Optional link to mailing list archives or info.')
121121
->setValue($list->getURI()))
122-
->appendChild(
123-
id(new AphrontFormStaticControl())
124-
->setLabel('ID')
125-
->setValue(nonempty($list->getID(), '-')))
126122
->appendChild(
127123
id(new AphrontFormStaticControl())
128124
->setLabel('PHID')
129125
->setValue(nonempty($list->getPHID(), '-')))
130126
->appendChild(
131127
id(new AphrontFormSubmitControl())
132128
->setValue('Save')
133-
->addCancelButton('/mail/lists/'));
129+
->addCancelButton($this->getApplicationURI()));
134130

135131
$panel = new AphrontPanelView();
136132
if ($list->getID()) {
@@ -142,8 +138,11 @@ public function processRequest() {
142138
$panel->appendChild($form);
143139
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
144140

145-
return $this->buildStandardPageResponse(
146-
array($error_view, $panel),
141+
return $this->buildApplicationPage(
142+
array(
143+
$error_view,
144+
$panel,
145+
),
147146
array(
148147
'title' => 'Edit Mailing List',
149148
));

src/applications/metamta/controller/PhabricatorMetaMTAMailingListsController.php renamed to src/applications/mailinglists/controller/PhabricatorMailingListsListController.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
* limitations under the License.
1717
*/
1818

19-
final class PhabricatorMetaMTAMailingListsController
20-
extends PhabricatorMetaMTAController {
19+
final class PhabricatorMailingListsListController
20+
extends PhabricatorController {
2121

2222
public function processRequest() {
2323
$request = $this->getRequest();
2424
$user = $request->getUser();
2525
$offset = $request->getInt('offset', 0);
2626

2727
$pager = new AphrontPagerView();
28-
$pager->setPageSize(1000);
28+
$pager->setPageSize(250);
2929
$pager->setOffset($offset);
3030
$pager->setURI($request->getRequestURI(), 'offset');
3131

@@ -45,14 +45,13 @@ public function processRequest() {
4545
$rows = array();
4646
foreach ($lists as $list) {
4747
$rows[] = array(
48-
phutil_escape_html($list->getPHID()),
49-
phutil_escape_html($list->getEmail()),
5048
phutil_escape_html($list->getName()),
49+
phutil_escape_html($list->getEmail()),
5150
phutil_render_tag(
5251
'a',
5352
array(
5453
'class' => 'button grey small',
55-
'href' => '/mail/lists/edit/'.$list->getID().'/',
54+
'href' => $this->getApplicationURI('/edit/'.$list->getID().'/'),
5655
),
5756
'Edit'),
5857
);
@@ -61,14 +60,12 @@ public function processRequest() {
6160
$table = new AphrontTableView($rows);
6261
$table->setHeaders(
6362
array(
64-
'PHID',
65-
'Email',
6663
'Name',
64+
'Email',
6765
'',
6866
));
6967
$table->setColumnClasses(
7068
array(
71-
null,
7269
null,
7370
'wide',
7471
'action',
@@ -77,10 +74,10 @@ public function processRequest() {
7774
$panel = new AphrontPanelView();
7875
$panel->appendChild($table);
7976
$panel->setHeader('Mailing Lists');
80-
$panel->setCreateButton('Add New List', '/mail/lists/edit/');
77+
$panel->setCreateButton('Add New List', $this->getApplicationURI('/edit/'));
8178
$panel->appendChild($pager);
8279

83-
return $this->buildStandardPageResponse(
80+
return $this->buildApplicationPage(
8481
$panel,
8582
array(
8683
'title' => 'Mailing Lists',

src/applications/metamta/storage/PhabricatorMetaMTAMailingList.php renamed to src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php

File renamed without changes.

src/applications/meta/application/PhabricatorApplicationApplications.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function getRoutes() {
3838
);
3939
}
4040

41+
public function getTitleGlyph() {
42+
return "\xE0\xBC\x84";
43+
}
44+
4145
public function shouldAppearInLaunchView() {
4246
return false;
4347
}

0 commit comments

Comments
 (0)