Skip to content

Commit c0d42a8

Browse files
author
epriestley
committedMay 2, 2016
Split Repository EditEngine form into smaller pages
Summary: Ref T10748. This allows an EditEngine form to be broken up into pages. This is less powerful than `PHUIPagedFormView`, because the pages are not sequential / stateful. Each form saves immediately once it's submitted, and can not take you to a new form or back/forward in a series of forms. For example, you can't create a workflow where the user fills out 5 pages of information before we create an object, like the current repository workflow does. However, the only place we've ever wanted to do this is repositories and it's fairly bad there, so I feel reasonably confident we aren't going to miss this in the future. (We do "choose a type of service/repository/rule -> fill out one page of info" fairly often, but can do this without the full-power paging stuff.) Test Plan: - Created a repository usin the new Manage UI, filling out only a handful of fields. - Edited a repository using the new Manage UI. - All forms are now EditEngine forms offering paged views of the big huge underlying form: {F1254371} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15832
1 parent 99718b6 commit c0d42a8

14 files changed

+341
-19
lines changed
 

‎src/__phutil_library_map__.php

+2
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,7 @@
23582358
'PhabricatorEditEngineSelectCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineSelectCommentAction.php',
23592359
'PhabricatorEditEngineTokenizerCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineTokenizerCommentAction.php',
23602360
'PhabricatorEditField' => 'applications/transactions/editfield/PhabricatorEditField.php',
2361+
'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php',
23612362
'PhabricatorEditType' => 'applications/transactions/edittype/PhabricatorEditType.php',
23622363
'PhabricatorEditor' => 'infrastructure/PhabricatorEditor.php',
23632364
'PhabricatorElasticFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php',
@@ -6872,6 +6873,7 @@
68726873
'PhabricatorEditEngineSelectCommentAction' => 'PhabricatorEditEngineCommentAction',
68736874
'PhabricatorEditEngineTokenizerCommentAction' => 'PhabricatorEditEngineCommentAction',
68746875
'PhabricatorEditField' => 'Phobject',
6876+
'PhabricatorEditPage' => 'Phobject',
68756877
'PhabricatorEditType' => 'Phobject',
68766878
'PhabricatorEditor' => 'Phobject',
68776879
'PhabricatorElasticFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine',

‎src/applications/base/PhabricatorApplication.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,11 @@ protected function getEditRoutePattern($base = null) {
624624
'(?P<id>[0-9]\d*)/)?'.
625625
'(?:'.
626626
'(?:'.
627-
'(?P<editAction>parameters|nodefault|nocreate|nomanage|comment)'.
627+
'(?P<editAction>parameters|nodefault|nocreate|nomanage|comment)/'.
628628
'|'.
629-
'(?:form/(?P<formKey>[^/]+))'.
629+
'(?:form/(?P<formKey>[^/]+)/)?(?:page/(?P<pageKey>[^/]+)/)?'.
630630
')'.
631-
'/)?';
631+
')?';
632632
}
633633

634634
protected function getQueryRoutePattern($base = null) {

‎src/applications/diffusion/controller/DiffusionRepositoryEditDangerousController.php

+21-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,30 @@ public function handleRequest(AphrontRequest $request) {
1313
$drequest = $this->getDiffusionRequest();
1414
$repository = $drequest->getRepository();
1515

16+
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
17+
1618
if (!$repository->canAllowDangerousChanges()) {
17-
return new Aphront400Response();
19+
if ($repository->isSVN()) {
20+
return $this->newDialog()
21+
->setTitle(pht('Not in Danger'))
22+
->appendParagraph(
23+
pht(
24+
'It is not possible for users to push any dangerous changes '.
25+
'to a Subversion repository. Pushes to a Subversion repository '.
26+
'can always be reverted and never destroy data.'))
27+
->addCancelButton($edit_uri);
28+
} else {
29+
return $this->newDialog()
30+
->setTitle(pht('Unprotectable Repository'))
31+
->appendParagraph(
32+
pht(
33+
'This repository can not be protected from dangerous changes '.
34+
'because Phabricator does not control what users are allowed '.
35+
'to push to it.'))
36+
->addCancelButton($edit_uri);
37+
}
1838
}
1939

20-
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
21-
2240
if ($request->isFormPost()) {
2341
$xaction = id(new PhabricatorRepositoryTransaction())
2442
->setTransactionType(PhabricatorRepositoryTransaction::TYPE_DANGEROUS)

‎src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php

+42
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,48 @@ protected function getCreateNewObjectPolicy() {
8585
DiffusionCreateRepositoriesCapability::CAPABILITY);
8686
}
8787

88+
protected function newPages($object) {
89+
$panels = DiffusionRepositoryManagementPanel::getAllPanels();
90+
91+
$pages = array();
92+
$uris = array();
93+
foreach ($panels as $panel_key => $panel) {
94+
$panel->setRepository($object);
95+
96+
$uris[$panel_key] = $panel->getPanelURI();
97+
98+
$page = $panel->newEditEnginePage();
99+
if (!$page) {
100+
continue;
101+
}
102+
$pages[] = $page;
103+
}
104+
105+
$basics_key = DiffusionRepositoryBasicsManagementPanel::PANELKEY;
106+
$basics_uri = $uris[$basics_key];
107+
108+
$more_pages = array(
109+
id(new PhabricatorEditPage())
110+
->setKey('encoding')
111+
->setLabel(pht('Text Encoding'))
112+
->setViewURI($basics_uri)
113+
->setFieldKeys(
114+
array(
115+
'encoding',
116+
)),
117+
id(new PhabricatorEditPage())
118+
->setKey('extensions')
119+
->setLabel(pht('Extensions'))
120+
->setIsDefault(true),
121+
);
122+
123+
foreach ($more_pages as $page) {
124+
$pages[] = $page;
125+
}
126+
127+
return $pages;
128+
}
129+
88130
protected function buildCustomEditFields($object) {
89131
$viewer = $this->getViewer();
90132

‎src/applications/diffusion/management/DiffusionRepositoryActionsManagementPanel.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function getManagementPanelOrder() {
1313
return 1100;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'publish',
19+
'autoclose',
20+
);
21+
}
22+
1623
protected function buildManagementPanelActions() {
1724
$repository = $this->getRepository();
1825
$viewer = $this->getViewer();
@@ -22,7 +29,7 @@ protected function buildManagementPanelActions() {
2229
$repository,
2330
PhabricatorPolicyCapability::CAN_EDIT);
2431

25-
$actions_uri = $repository->getPathURI('edit/actions/');
32+
$actions_uri = $this->getEditPageURI();
2633

2734
return array(
2835
id(new PhabricatorActionView())

‎src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public function getManagementPanelOrder() {
1313
return 800;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'automationBlueprintPHIDs',
19+
);
20+
}
21+
1622
protected function buildManagementPanelActions() {
1723
$repository = $this->getRepository();
1824
$viewer = $this->getViewer();
@@ -24,7 +30,7 @@ protected function buildManagementPanelActions() {
2430

2531
$can_test = $can_edit && $repository->canPerformAutomation();
2632

27-
$automation_uri = $repository->getPathURI('edit/automation/');
33+
$automation_uri = $this->getEditPageURI();
2834
$test_uri = $repository->getPathURI('edit/testautomation/');
2935

3036
return array(

‎src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ public function getManagementPanelOrder() {
1313
return 100;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'name',
19+
'callsign',
20+
'shortName',
21+
'description',
22+
);
23+
}
24+
1625
protected function buildManagementPanelActions() {
1726
$repository = $this->getRepository();
1827
$viewer = $this->getViewer();
@@ -22,10 +31,10 @@ protected function buildManagementPanelActions() {
2231
$repository,
2332
PhabricatorPolicyCapability::CAN_EDIT);
2433

25-
$edit_uri = $repository->getPathURI('manage/');
34+
$edit_uri = $this->getEditPageURI();
2635
$activate_uri = $repository->getPathURI('edit/activate/');
2736
$delete_uri = $repository->getPathURI('edit/delete/');
28-
$encoding_uri = $repository->getPathURI('edit/encoding/');
37+
$encoding_uri = $this->getEditPageURI('encoding');
2938
$dangerous_uri = $repository->getPathURI('edit/dangerous/');
3039

3140
if ($repository->isTracked()) {

‎src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ public function getManagementPanelOrder() {
1313
return 1000;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'defaultBranch',
19+
'trackOnly',
20+
'autocloseOnly',
21+
);
22+
}
23+
1624
protected function buildManagementPanelActions() {
1725
$repository = $this->getRepository();
1826
$viewer = $this->getViewer();
@@ -22,7 +30,7 @@ protected function buildManagementPanelActions() {
2230
$repository,
2331
PhabricatorPolicyCapability::CAN_EDIT);
2432

25-
$branches_uri = $repository->getPathURI('edit/branches/');
33+
$branches_uri = $this->getEditPageURI();
2634

2735
return array(
2836
id(new PhabricatorActionView())

‎src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php

+38
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,42 @@ final protected function newTimeline() {
9898
return $this->controller->newTimeline($this->getRepository());
9999
}
100100

101+
final public function getPanelURI() {
102+
$repository = $this->getRepository();
103+
$key = $this->getManagementPanelKey();
104+
return $repository->getPathURI("manage/{$key}/");
105+
}
106+
107+
final public function newEditEnginePage() {
108+
$field_keys = $this->getEditEngineFieldKeys();
109+
if (!$field_keys) {
110+
return null;
111+
}
112+
113+
$key = $this->getManagementPanelKey();
114+
$label = $this->getManagementPanelLabel();
115+
$panel_uri = $this->getPanelURI();
116+
117+
return id(new PhabricatorEditPage())
118+
->setKey($key)
119+
->setLabel($label)
120+
->setViewURI($panel_uri)
121+
->setFieldKeys($field_keys);
122+
}
123+
124+
protected function getEditEngineFieldKeys() {
125+
return array();
126+
}
127+
128+
protected function getEditPageURI($page = null) {
129+
if ($page === null) {
130+
$page = $this->getManagementPanelKey();
131+
}
132+
133+
$repository = $this->getRepository();
134+
$id = $repository->getID();
135+
return "/diffusion/editpro/{$id}/page/{$page}/";
136+
}
137+
138+
101139
}

‎src/applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ public function getManagementPanelOrder() {
1313
return 300;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'policy.view',
19+
'policy.edit',
20+
'policy.push',
21+
);
22+
}
23+
1624
protected function buildManagementPanelActions() {
1725
$repository = $this->getRepository();
1826
$viewer = $this->getViewer();
@@ -22,7 +30,7 @@ protected function buildManagementPanelActions() {
2230
$repository,
2331
PhabricatorPolicyCapability::CAN_EDIT);
2432

25-
$edit_uri = $repository->getPathURI('manage/');
33+
$edit_uri = $this->getEditPageURI();
2634

2735
return array(
2836
id(new PhabricatorActionView())

‎src/applications/diffusion/management/DiffusionRepositoryStagingManagementPanel.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public function getManagementPanelOrder() {
1313
return 700;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'stagingAreaURI',
19+
);
20+
}
21+
1622
protected function buildManagementPanelActions() {
1723
$repository = $this->getRepository();
1824
$viewer = $this->getViewer();
@@ -22,7 +28,7 @@ protected function buildManagementPanelActions() {
2228
$repository,
2329
PhabricatorPolicyCapability::CAN_EDIT);
2430

25-
$staging_uri = $repository->getPathURI('edit/staging/');
31+
$staging_uri = $this->getEditPageURI();
2632

2733
return array(
2834
id(new PhabricatorActionView())

‎src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function getManagementPanelOrder() {
1313
return 900;
1414
}
1515

16+
protected function getEditEngineFieldKeys() {
17+
return array(
18+
'symbolLanguages',
19+
'symbolRepositoryPHIDs',
20+
);
21+
}
22+
1623
protected function buildManagementPanelActions() {
1724
$repository = $this->getRepository();
1825
$viewer = $this->getViewer();
@@ -22,7 +29,7 @@ protected function buildManagementPanelActions() {
2229
$repository,
2330
PhabricatorPolicyCapability::CAN_EDIT);
2431

25-
$symbols_uri = $repository->getPathURI('edit/symbols/');
32+
$symbols_uri = $this->getEditPageURI();
2633

2734
return array(
2835
id(new PhabricatorActionView())

0 commit comments

Comments
 (0)
Failed to load comments.