From a89b4ff5b8bc5524c59629abfad080631f06be5e Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Tue, 25 Apr 2023 20:52:51 +0200 Subject: [PATCH] Members page of Parent Subproject: less dead-end Summary: When you visit the Members page of a Parent Subproject, some actions are greyed out by design. And, if you click on them, nothing really useful happens to continue with what you want to do. For example, see this page and click on "Join Project": https://we.phorge.it/project/members/1/ After this change, the interface at least provides a link to proceed to the next step of what you wanted to do - that is - allowing to quickly list direct Subprojects and do something more meaningful than that. A/B for the "Join Project" view: | Before | After | |-----------|-----------| | {F282337} | {F282331} | A/B for the "Add Members" view: | Before | After | |-----------|-----------| | {F282338} | {F282332} | Just to be nice, this change adds some inline documentation on some methods of AphrontDialogView used here. Closes T15258 Test Plan: - Create a Project (A) with a Subproject (B) - Visit Members page of (A) - Click on Join Project and click on the Blue Button - Click on the Add Member and click on Blue Button - in both cases it should get you to Subprojects list Reviewers: O1 Blessed Committers, Matthew Reviewed By: O1 Blessed Committers, Matthew Subscribers: speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15258 Differential Revision: https://we.phorge.it/D25127 --- ...PhabricatorProjectMembersAddController.php | 5 ++++ .../PhabricatorProjectUpdateController.php | 5 ++++ src/view/AphrontDialogView.php | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/applications/project/controller/PhabricatorProjectMembersAddController.php b/src/applications/project/controller/PhabricatorProjectMembersAddController.php index 79c66dc5b1..572e71f51a 100644 --- a/src/applications/project/controller/PhabricatorProjectMembersAddController.php +++ b/src/applications/project/controller/PhabricatorProjectMembersAddController.php @@ -27,9 +27,14 @@ final class PhabricatorProjectMembersAddController $copy = pht('Parent projects and milestones do not support adding '. 'members. You can add members directly to any non-parent subproject.'); + $subprojects_uri = "/project/subprojects/{$id}/"; + return $this->newDialog() ->setTitle(pht('Unsupported Project')) ->appendParagraph($copy) + ->setSubmitURI($subprojects_uri) + ->addSubmitButton(pht('See Subprojects')) + ->setDisableWorkflowOnSubmit(true) ->addCancelButton($done_uri); } diff --git a/src/applications/project/controller/PhabricatorProjectUpdateController.php b/src/applications/project/controller/PhabricatorProjectUpdateController.php index 7cbd77b4cb..5707693654 100644 --- a/src/applications/project/controller/PhabricatorProjectUpdateController.php +++ b/src/applications/project/controller/PhabricatorProjectUpdateController.php @@ -38,9 +38,14 @@ final class PhabricatorProjectUpdateController $copy = pht('Parent projects and milestones do not support adding '. 'members. You can add members directly to any non-parent subproject.'); + $subprojects_uri = "/project/subprojects/{$id}/"; + return $this->newDialog() ->setTitle(pht('Unsupported Project')) ->appendParagraph($copy) + ->setSubmitURI($subprojects_uri) + ->addSubmitButton(pht('See Subprojects')) + ->setDisableWorkflowOnSubmit(true) ->addCancelButton($done_uri); } diff --git a/src/view/AphrontDialogView.php b/src/view/AphrontDialogView.php index b8b00a6b3e..14aa4a19b6 100644 --- a/src/view/AphrontDialogView.php +++ b/src/view/AphrontDialogView.php @@ -51,6 +51,15 @@ final class AphrontDialogView return $this->isStandalone; } + /** + * Set the URI associated to the Submit Button + * + * If you want a normal link and not any form submission, + * see also: setDisableWorkflowOnSubmit(false). + * + * @param string $uri + * @return self + */ public function setSubmitURI($uri) { $this->submitURI = $uri; return $this; @@ -92,6 +101,15 @@ final class AphrontDialogView return $this->resizeX; } + /** + * Add a Submit Button and specify its text + * + * If you want to associate an URI for this Button, + * see also: setSubmitURI(). + * + * @param string $text Text shown for that button + * @return self + */ public function addSubmitButton($text = null) { if (!$text) { $text = pht('Okay'); @@ -228,6 +246,14 @@ final class AphrontDialogView return $this->appendChild($form->buildLayoutView()); } + /** + * Enable or Disable a Workflow on Submit + * + * For example, if your Submit Button should be a normal link, + * without activating any Workflow, you can set false. + * @param bool $disable_workflow_on_submit + * @return self + */ public function setDisableWorkflowOnSubmit($disable_workflow_on_submit) { $this->disableWorkflowOnSubmit = $disable_workflow_on_submit; return $this;