@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "make the workboard the default view" checkbox when creating a workboard

Summary: Ref T10054. Since we no longer have the "workboard default if it exists" rule, provide a quick way to make it the default.

Test Plan: Created a new workboard with the box checked, saw menu change appropriately.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10054

Differential Revision: https://secure.phabricator.com/D15092

+90 -39
+21 -3
src/applications/project/controller/PhabricatorProjectBoardViewController.php
··· 761 761 $board_uri = $this->getApplicationURI("board/{$id}/"); 762 762 $import_uri = $this->getApplicationURI("board/{$id}/import/"); 763 763 764 - switch ($type) { 765 - case 'backlog-only': 764 + $set_default = $request->getBool('default'); 765 + if ($set_default) { 766 + $this 767 + ->getProfilePanelEngine() 768 + ->adjustDefault(PhabricatorProject::PANEL_WORKBOARD); 769 + } 770 + 771 + if ($request->isFormPost()) { 772 + if ($type == 'backlog-only') { 766 773 $column = PhabricatorProjectColumn::initializeNewColumn($viewer) 767 774 ->setSequence(0) 768 775 ->setProperty('isDefault', true) ··· 773 780 774 781 return id(new AphrontRedirectResponse()) 775 782 ->setURI($board_uri); 776 - case 'import': 783 + } else { 777 784 return id(new AphrontRedirectResponse()) 778 785 ->setURI($import_uri); 786 + } 779 787 } 780 788 781 789 $new_selector = id(new AphrontFormRadioButtonControl()) 790 + ->setLabel(pht('Columns')) 782 791 ->setName('initialize-type') 783 792 ->setValue('backlog-only') 784 793 ->addButton( ··· 790 799 pht('Import Columns'), 791 800 pht('Import board columns from another project.')); 792 801 802 + $default_checkbox = id(new AphrontFormCheckboxControl()) 803 + ->setLabel(pht('Make Default')) 804 + ->addCheckbox( 805 + 'default', 806 + 1, 807 + pht('Make the workboard the default view for this project.'), 808 + true); 809 + 793 810 $form = id(new AphrontFormView()) 794 811 ->setUser($viewer) 795 812 ->appendRemarkupInstructions( 796 813 pht('The workboard for this project has not been created yet.')) 797 814 ->appendControl($new_selector) 815 + ->appendControl($default_checkbox) 798 816 ->appendControl( 799 817 id(new AphrontFormSubmitControl()) 800 818 ->addCancelButton($profile_uri)
+1
src/applications/project/controller/PhabricatorProjectController.php
··· 133 133 if ($project) { 134 134 $engine = id(new PhabricatorProjectProfilePanelEngine()) 135 135 ->setViewer($viewer) 136 + ->setController($this) 136 137 ->setProfileObject($project); 137 138 $this->profilePanelEngine = $engine; 138 139 }
+68 -36
src/applications/search/engine/PhabricatorProfilePanelEngine.php
··· 891 891 ->addCancelButton($done_uri); 892 892 } 893 893 894 + if ($request->isFormPost()) { 895 + $key = $configuration->getID(); 896 + if (!$key) { 897 + $key = $configuration->getBuiltinKey(); 898 + } 899 + 900 + $this->adjustDefault($key); 901 + 902 + return id(new AphrontRedirectResponse()) 903 + ->setURI($done_uri); 904 + } 905 + 906 + return $controller->newDialog() 907 + ->setTitle(pht('Make Default')) 908 + ->appendParagraph( 909 + pht( 910 + 'Set this item as the default for this menu? Users arriving on '. 911 + 'this page will be shown the content of this item by default.')) 912 + ->addCancelButton($done_uri) 913 + ->addSubmitButton(pht('Make Default')); 914 + } 915 + 916 + protected function newPanel() { 917 + return PhabricatorProfilePanelConfiguration::initializeNewBuiltin(); 918 + } 919 + 920 + public function adjustDefault($key) { 921 + $controller = $this->getController(); 922 + $request = $controller->getRequest(); 923 + $viewer = $request->getViewer(); 924 + 925 + $panels = $this->loadPanels(); 926 + 927 + // To adjust the default panel, we first change any existing panels that 928 + // are marked as defaults to "visible", then make the new default panel 929 + // the default. 930 + 931 + $default = array(); 932 + $visible = array(); 933 + 934 + foreach ($panels as $panel) { 935 + $builtin_key = $panel->getBuiltinKey(); 936 + $id = $panel->getID(); 937 + 938 + $is_target = 939 + (($builtin_key !== null) && ($builtin_key === $key)) || 940 + (($id !== null) && ($id === (int)$key)); 941 + 942 + if ($is_target) { 943 + if (!$panel->isDefault()) { 944 + $default[] = $panel; 945 + } 946 + } else { 947 + if ($panel->isDefault()) { 948 + $visible[] = $panel; 949 + } 950 + } 951 + } 952 + 894 953 $type_visibility = 895 954 PhabricatorProfilePanelConfigurationTransaction::TYPE_VISIBILITY; 896 955 897 956 $v_visible = PhabricatorProfilePanelConfiguration::VISIBILITY_VISIBLE; 898 957 $v_default = PhabricatorProfilePanelConfiguration::VISIBILITY_DEFAULT; 899 958 900 - if ($request->isFormPost()) { 901 - // First, mark any existing default panels as merely visible. 902 - foreach ($panels as $panel) { 903 - if (!$panel->isDefault()) { 904 - continue; 905 - } 959 + $apply = array( 960 + array($v_visible, $visible), 961 + array($v_default, $default), 962 + ); 906 963 964 + foreach ($apply as $group) { 965 + list($value, $panels) = $group; 966 + foreach ($panels as $panel) { 907 967 $xactions = array(); 908 968 909 969 $xactions[] = id(new PhabricatorProfilePanelConfigurationTransaction()) 910 970 ->setTransactionType($type_visibility) 911 - ->setNewValue($v_visible); 971 + ->setNewValue($value); 912 972 913 973 $editor = id(new PhabricatorProfilePanelEditor()) 914 974 ->setContentSourceFromRequest($request) ··· 917 977 ->setContinueOnNoEffect(true) 918 978 ->applyTransactions($panel, $xactions); 919 979 } 920 - 921 - // Now, make this panel the default. 922 - $xactions = array(); 923 - 924 - $xactions[] = id(new PhabricatorProfilePanelConfigurationTransaction()) 925 - ->setTransactionType($type_visibility) 926 - ->setNewValue($v_default); 927 - 928 - $editor = id(new PhabricatorProfilePanelEditor()) 929 - ->setContentSourceFromRequest($request) 930 - ->setActor($viewer) 931 - ->setContinueOnMissingFields(true) 932 - ->setContinueOnNoEffect(true) 933 - ->applyTransactions($configuration, $xactions); 934 - 935 - return id(new AphrontRedirectResponse()) 936 - ->setURI($done_uri); 937 980 } 938 981 939 - return $controller->newDialog() 940 - ->setTitle(pht('Make Default')) 941 - ->appendParagraph( 942 - pht( 943 - 'Set this item as the default for this menu? Users arriving on '. 944 - 'this page will be shown the content of this item by default.')) 945 - ->addCancelButton($done_uri) 946 - ->addSubmitButton(pht('Make Default')); 947 - } 948 - 949 - protected function newPanel() { 950 - return PhabricatorProfilePanelConfiguration::initializeNewBuiltin(); 982 + return $this; 951 983 } 952 984 953 985 }