From 48fd3f1c40def49cdfec3ad342e32225adc31a79 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Wed, 4 Dec 2024 07:51:45 +0100 Subject: [PATCH] Delete Repository button: disable if not admin, but show popup to all Summary: The "Delete Repository" button should be disabled, just like any other admin button in the page, if you cannot edit the repository, so to do not cause anxiety situations to users without editing permissions. Moreover, probably, if you still want to click that disabled button, you should still be allowed to see the super-nice related information message, just because it's super-lovely, super-informative and it does nothing wrong. Closes T15964 Test Plan: Be normal user. See the button finally disabled. Click it, you finally see its related info popup instead "You shall not pass", so you unlock extra documentation to read. Be admin user. See the button still enabled. Click it, you still can see the info popup. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15964 Differential Revision: https://we.phorge.it/D25843 --- .../controller/DiffusionRepositoryEditDeleteController.php | 5 ++++- .../management/DiffusionRepositoryBasicsManagementPanel.php | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php index 72e18d17e8..d78083a0fe 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php @@ -4,7 +4,10 @@ final class DiffusionRepositoryEditDeleteController extends DiffusionRepositoryManageController { public function handleRequest(AphrontRequest $request) { - $response = $this->loadDiffusionContextForEdit(); + // This is just an information box, telling admins to use CLI for destroy. + // To increase shared knowledge about how Phorge works, we can safely show + // it to those who see the repository, not just those who can edit it. + $response = $this->loadDiffusionContext(); if ($response) { return $response; } diff --git a/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php index 6ad26a399a..d4eb6f393d 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php @@ -154,7 +154,8 @@ final class DiffusionRepositoryBasicsManagementPanel ->setName(pht('Delete Repository')) ->setHref($delete_uri) ->setIcon('fa-times') - ->setWorkflow(true)); + ->setWorkflow(true) + ->setDisabled(!$can_edit)); return $this->newCurtainView() ->setActionList($action_list);