Skip to content

Commit cf346d3

Browse files
vedharajuepriestley
authored andcommitted
T2385: Add "Delete Document" action to Phriction pages
Summary: If a page has not been deleted, this adds an action button to delete the document in the menu on the Phriction Page. Test Plan: 1. Created a document, checked whether "Delete Document" button was visible. 2. Clicked on "Delete Document" button, checked that the document had been deleted. 3. Went back to document page, checked that the "Delete Document" button no longer existed. Reviewers: epriestley CC: aran, Korvin Maniphest Tasks: T2385 Differential Revision: https://secure.phabricator.com/D4636
1 parent cf7534f commit cf346d3

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/applications/phriction/controller/PhrictionDocumentController.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,30 @@ private function buildActionView(
215215

216216
$slug = PhabricatorSlug::normalize($this->slug);
217217

218-
return id(new PhabricatorActionListView())
218+
$action_view = id(new PhabricatorActionListView())
219219
->setUser($user)
220220
->setObject($document)
221221
->addAction(
222222
id(new PhabricatorActionView())
223223
->setName(pht('Edit Document'))
224224
->setIcon('edit')
225-
->setHref('/phriction/edit/'.$document->getID().'/'))
226-
->addAction(
225+
->setHref('/phriction/edit/'.$document->getID().'/'));
226+
227+
if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) {
228+
$action_view->addAction(
229+
id(new PhabricatorActionView())
230+
->setName(pht('Delete Document'))
231+
->setIcon('delete')
232+
->setHref('/phriction/delete/'.$document->getID().'/')
233+
->setWorkflow(true));
234+
}
235+
236+
return
237+
$action_view->addAction(
227238
id(new PhabricatorActionView())
228-
->setName(pht('View History'))
229-
->setIcon('history')
230-
->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
239+
->setName(pht('View History'))
240+
->setIcon('history')
241+
->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
231242
}
232243

233244
private function renderChildren($slug) {

src/applications/phriction/controller/PhrictionEditController.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,9 @@ public function processRequest() {
154154
->setErrors($errors);
155155
}
156156

157-
$delete_button = null;
158157
if ($document->getID()) {
159158
$panel_header = 'Edit Phriction Document';
160159
$submit_button = 'Save Changes';
161-
if ($document->getStatus() != PhrictionDocumentStatus::STATUS_DELETED) {
162-
$delete_button = phutil_render_tag(
163-
'a',
164-
array(
165-
'href' => '/phriction/delete/'.$document->getID().'/',
166-
'class' => 'grey button',
167-
),
168-
'Delete Document');
169-
}
170160
} else {
171161
$panel_header = 'Create New Phriction Document';
172162
$submit_button = 'Create Document';
@@ -240,10 +230,6 @@ public function processRequest() {
240230
->setHeader($panel_header)
241231
->appendChild($form);
242232

243-
if ($delete_button) {
244-
$panel->addButton($delete_button);
245-
}
246-
247233
$preview_panel =
248234
'<div class="aphront-panel-preview aphront-panel-preview-wide">
249235
<div class="phriction-document-preview-header">

0 commit comments

Comments
 (0)