mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Files - kill tabs
Summary: kill tabs for Files application. Technique is the "filter list" on the left hand side, with separation for "Files" versus "Image Macros". UI quirks include: - the page title does not change for the 3 files filters while it does change for each of the two image macro filters. - standalone "file" pages do not have the filter view - you can visit /file/upload/ standalone and it doesn't have the pretty filter list on it Please do give direction on these quirks if you like. :) This change also neuters the ?author= functionality for files. The code is written such that it can easily be brought back. Test Plan: clicked around on the filters, liked what I saw. uploaded files fancy-like and basic-like and it worked! made image macros and it worked! Reviewers: epriestley Reviewed By: epriestley CC: aran, btrahan, epriestley Maniphest Tasks: T631 Differential Revision: 1219
This commit is contained in:
parent
0e7049e8aa
commit
128b7584da
15 changed files with 430 additions and 114 deletions
|
@ -457,6 +457,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFileMacroListController' => 'applications/files/controller/macrolist',
|
'PhabricatorFileMacroListController' => 'applications/files/controller/macrolist',
|
||||||
'PhabricatorFileProxyController' => 'applications/files/controller/proxy',
|
'PhabricatorFileProxyController' => 'applications/files/controller/proxy',
|
||||||
'PhabricatorFileProxyImage' => 'applications/files/storage/proxyimage',
|
'PhabricatorFileProxyImage' => 'applications/files/storage/proxyimage',
|
||||||
|
'PhabricatorFileSideNavView' => 'applications/files/view/sidenav',
|
||||||
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
|
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
|
||||||
'PhabricatorFileStorageEngine' => 'applications/files/engine/base',
|
'PhabricatorFileStorageEngine' => 'applications/files/engine/base',
|
||||||
'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/base',
|
'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/base',
|
||||||
|
@ -464,6 +465,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFileURI' => 'applications/files/uri',
|
'PhabricatorFileURI' => 'applications/files/uri',
|
||||||
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
|
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
|
||||||
'PhabricatorFileUploadException' => 'applications/files/exception/upload',
|
'PhabricatorFileUploadException' => 'applications/files/exception/upload',
|
||||||
|
'PhabricatorFileUploadView' => 'applications/files/view/upload',
|
||||||
'PhabricatorFileViewController' => 'applications/files/controller/view',
|
'PhabricatorFileViewController' => 'applications/files/controller/view',
|
||||||
'PhabricatorGarbageCollectorDaemon' => 'infrastructure/daemon/garbagecollector',
|
'PhabricatorGarbageCollectorDaemon' => 'infrastructure/daemon/garbagecollector',
|
||||||
'PhabricatorGoodForNothingWorker' => 'infrastructure/daemon/workers/worker/goodfornothing',
|
'PhabricatorGoodForNothingWorker' => 'infrastructure/daemon/workers/worker/goodfornothing',
|
||||||
|
@ -1110,9 +1112,11 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFileMacroListController' => 'PhabricatorFileController',
|
'PhabricatorFileMacroListController' => 'PhabricatorFileController',
|
||||||
'PhabricatorFileProxyController' => 'PhabricatorFileController',
|
'PhabricatorFileProxyController' => 'PhabricatorFileController',
|
||||||
'PhabricatorFileProxyImage' => 'PhabricatorFileDAO',
|
'PhabricatorFileProxyImage' => 'PhabricatorFileDAO',
|
||||||
|
'PhabricatorFileSideNavView' => 'AphrontView',
|
||||||
'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO',
|
'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO',
|
||||||
'PhabricatorFileTransformController' => 'PhabricatorFileController',
|
'PhabricatorFileTransformController' => 'PhabricatorFileController',
|
||||||
'PhabricatorFileUploadController' => 'PhabricatorFileController',
|
'PhabricatorFileUploadController' => 'PhabricatorFileController',
|
||||||
|
'PhabricatorFileUploadView' => 'AphrontView',
|
||||||
'PhabricatorFileViewController' => 'PhabricatorFileController',
|
'PhabricatorFileViewController' => 'PhabricatorFileController',
|
||||||
'PhabricatorGarbageCollectorDaemon' => 'PhabricatorDaemon',
|
'PhabricatorGarbageCollectorDaemon' => 'PhabricatorDaemon',
|
||||||
'PhabricatorGoodForNothingWorker' => 'PhabricatorWorker',
|
'PhabricatorGoodForNothingWorker' => 'PhabricatorWorker',
|
||||||
|
|
|
@ -51,6 +51,7 @@ class AphrontDefaultApplicationConfiguration
|
||||||
),
|
),
|
||||||
'/file/' => array(
|
'/file/' => array(
|
||||||
'$' => 'PhabricatorFileListController',
|
'$' => 'PhabricatorFileListController',
|
||||||
|
'filter/(?P<filter>\w+)/$' => 'PhabricatorFileListController',
|
||||||
'upload/$' => 'PhabricatorFileUploadController',
|
'upload/$' => 'PhabricatorFileUploadController',
|
||||||
'dropupload/$' => 'PhabricatorFileDropUploadController',
|
'dropupload/$' => 'PhabricatorFileDropUploadController',
|
||||||
'(?P<view>info)/(?P<phid>[^/]+)/' => 'PhabricatorFileViewController',
|
'(?P<view>info)/(?P<phid>[^/]+)/' => 'PhabricatorFileViewController',
|
||||||
|
|
|
@ -25,18 +25,6 @@ abstract class PhabricatorFileController extends PhabricatorController {
|
||||||
$page->setBaseURI('/file/');
|
$page->setBaseURI('/file/');
|
||||||
$page->setTitle(idx($data, 'title'));
|
$page->setTitle(idx($data, 'title'));
|
||||||
$page->setGlyph("\xE2\x87\xAA");
|
$page->setGlyph("\xE2\x87\xAA");
|
||||||
$page->setTabs(
|
|
||||||
array(
|
|
||||||
'files' => array(
|
|
||||||
'name' => 'Files',
|
|
||||||
'href' => '/file/',
|
|
||||||
),
|
|
||||||
'macros' => array(
|
|
||||||
'name' => 'Image Macros',
|
|
||||||
'href' => '/file/macro/',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
idx($data, 'tab'));
|
|
||||||
$page->appendChild($view);
|
$page->appendChild($view);
|
||||||
|
|
||||||
$response = new AphrontWebpageResponse();
|
$response = new AphrontWebpageResponse();
|
||||||
|
|
|
@ -17,33 +17,181 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PhabricatorFileListController extends PhabricatorFileController {
|
class PhabricatorFileListController extends PhabricatorFileController {
|
||||||
|
private $filter;
|
||||||
|
|
||||||
|
private $showUploader;
|
||||||
|
private $useBasicUploader = false;
|
||||||
|
|
||||||
|
private $listAuthor;
|
||||||
|
private $listRows;
|
||||||
|
private $listRowClasses;
|
||||||
|
private $listHeader;
|
||||||
|
private $showListPager = true;
|
||||||
|
private $listPager;
|
||||||
|
private $pagerOffset;
|
||||||
|
private $pagerPageSize;
|
||||||
|
|
||||||
|
private function setFilter($filter) {
|
||||||
|
$this->filter = $filter;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
private function getFilter() {
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function showUploader() {
|
||||||
|
return $this->getShowUploader();
|
||||||
|
}
|
||||||
|
private function getShowUploader() {
|
||||||
|
return $this->showUploader;
|
||||||
|
}
|
||||||
|
private function setShowUploader($show_uploader) {
|
||||||
|
$this->showUploader = $show_uploader;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function useBasicUploader() {
|
||||||
|
return $this->getUseBasicUploader();
|
||||||
|
}
|
||||||
|
private function getUseBasicUploader() {
|
||||||
|
return $this->useBasicUploader;
|
||||||
|
}
|
||||||
|
private function setUseBasicUploader($use_basic_uploader) {
|
||||||
|
$this->useBasicUploader = $use_basic_uploader;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setListAuthor(PhabricatorUser $list_author) {
|
||||||
|
$this->listAuthor = $list_author;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
private function getListAuthor() {
|
||||||
|
return $this->listAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListRows() {
|
||||||
|
return $this->listRows;
|
||||||
|
}
|
||||||
|
private function setListRows($list_rows) {
|
||||||
|
$this->listRows = $list_rows;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListRowClasses() {
|
||||||
|
return $this->listRowClasses;
|
||||||
|
}
|
||||||
|
private function setListRowClasses($list_row_classes) {
|
||||||
|
$this->listRowClasses = $list_row_classes;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListHeader() {
|
||||||
|
return $this->listHeader;
|
||||||
|
}
|
||||||
|
private function setListHeader($list_header) {
|
||||||
|
$this->listHeader = $list_header;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function showListPager() {
|
||||||
|
return $this->getShowListPager();
|
||||||
|
}
|
||||||
|
private function getShowListPager() {
|
||||||
|
return $this->showListPager;
|
||||||
|
}
|
||||||
|
private function setShowListPager($show_list_pager) {
|
||||||
|
$this->showListPager = $show_list_pager;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getListPager() {
|
||||||
|
return $this->listPager;
|
||||||
|
}
|
||||||
|
private function setListPager($list_pager) {
|
||||||
|
$this->listPager = $list_pager;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setPagerOffset($pager_offset) {
|
||||||
|
$this->pagerOffset = $pager_offset;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
private function getPagerOffset() {
|
||||||
|
return $this->pagerOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setPagerPageSize($pager_page_size) {
|
||||||
|
$this->pagerPageSize = $pager_page_size;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
private function getPagerPageSize() {
|
||||||
|
return $this->pagerPageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->setFilter(idx($data, 'filter', 'upload'));
|
||||||
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$upload_panel = $this->renderUploadPanel();
|
switch ($this->getFilter()) {
|
||||||
|
case 'upload':
|
||||||
|
default:
|
||||||
|
$this->setShowUploader(true);
|
||||||
|
$this->setUseBasicUploader($request->getExists('basic_uploader'));
|
||||||
|
$see_all = phutil_render_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => '/file/filter/all',
|
||||||
|
),
|
||||||
|
'See all Files');
|
||||||
|
$this->setListHeader("Recently Uploaded Files · {$see_all}");
|
||||||
|
$this->setShowListPager(false);
|
||||||
|
$this->setPagerOffset(0);
|
||||||
|
$this->setPagerPageSize(10);
|
||||||
|
break;
|
||||||
|
case 'my':
|
||||||
|
$this->setShowUploader(false);
|
||||||
|
$this->setListHeader('Files You Uploaded');
|
||||||
|
$this->setListAuthor($user);
|
||||||
|
$this->setPagerOffset($request->getInt('page', 0));
|
||||||
|
break;
|
||||||
|
case 'all':
|
||||||
|
$this->setShowUploader(false);
|
||||||
|
$this->setListHeader('All Files');
|
||||||
|
$this->setPagerOffset($request->getInt('page', 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$this->loadListData();
|
||||||
|
|
||||||
$author = null;
|
$side_nav = new PhabricatorFileSideNavView();
|
||||||
$author_username = $request->getStr('author');
|
$side_nav->setSelectedFilter($this->getFilter());
|
||||||
if ($author_username) {
|
if ($this->showUploader()) {
|
||||||
$author = id(new PhabricatorUser())->loadOneWhere(
|
$side_nav->appendChild($this->renderUploadPanel());
|
||||||
'userName = %s',
|
}
|
||||||
$author_username);
|
$side_nav->appendChild($this->renderList());
|
||||||
|
|
||||||
if (!$author) {
|
return $this->buildStandardPageResponse(
|
||||||
return id(new Aphront404Response());
|
$side_nav,
|
||||||
|
array(
|
||||||
|
'title' => 'Files',
|
||||||
|
'tab' => 'files',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = 'Files Uploaded by '.phutil_escape_html($author->getUsername());
|
private function loadListData() {
|
||||||
} else {
|
$request = $this->getRequest();
|
||||||
$title = 'Files';
|
$user = $request->getUser();
|
||||||
}
|
|
||||||
|
|
||||||
$pager = new AphrontPagerView();
|
$pager = new AphrontPagerView();
|
||||||
$pager->setOffset($request->getInt('page'));
|
$pager->setOffset($this->getPagerOffset());
|
||||||
|
if ($this->getPagerPageSize()) {
|
||||||
|
$pager->setPageSize($this->getPagerPageSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
$author = $this->getListAuthor();
|
||||||
if ($author) {
|
if ($author) {
|
||||||
$files = id(new PhabricatorFile())->loadAllWhere(
|
$files = id(new PhabricatorFile())->loadAllWhere(
|
||||||
'authorPHID = %s ORDER BY id DESC LIMIT %d, %d',
|
'authorPHID = %s ORDER BY id DESC LIMIT %d, %d',
|
||||||
|
@ -59,6 +207,7 @@ class PhabricatorFileListController extends PhabricatorFileController {
|
||||||
|
|
||||||
$files = $pager->sliceResults($files);
|
$files = $pager->sliceResults($files);
|
||||||
$pager->setURI($request->getRequestURI(), 'page');
|
$pager->setURI($request->getRequestURI(), 'page');
|
||||||
|
$this->setListPager($pager);
|
||||||
|
|
||||||
$phids = mpull($files, 'getAuthorPHID');
|
$phids = mpull($files, 'getAuthorPHID');
|
||||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||||
|
@ -112,9 +261,13 @@ class PhabricatorFileListController extends PhabricatorFileController {
|
||||||
phabricator_time($file->getDateCreated(), $user),
|
phabricator_time($file->getDateCreated(), $user),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$this->setListRows($rows);
|
||||||
|
$this->setListRowClasses($rowc);
|
||||||
|
}
|
||||||
|
|
||||||
$table = new AphrontTableView($rows);
|
private function renderList() {
|
||||||
$table->setRowClasses($rowc);
|
$table = new AphrontTableView($this->getListRows());
|
||||||
|
$table->setRowClasses($this->getListRowClasses());
|
||||||
$table->setHeaders(
|
$table->setHeaders(
|
||||||
array(
|
array(
|
||||||
'File ID',
|
'File ID',
|
||||||
|
@ -140,32 +293,34 @@ class PhabricatorFileListController extends PhabricatorFileController {
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
$panel->appendChild($table);
|
$panel->appendChild($table);
|
||||||
$panel->setHeader($title);
|
$panel->setHeader($this->getListHeader());
|
||||||
$panel->appendChild($pager);
|
if ($this->showListPager()) {
|
||||||
|
$panel->appendChild($this->getListPager());
|
||||||
|
}
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $panel;
|
||||||
array(
|
|
||||||
$upload_panel,
|
|
||||||
$panel,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'title' => 'Files',
|
|
||||||
'tab' => 'files',
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderUploadPanel() {
|
private function renderUploadPanel() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
if ($this->useBasicUploader()) {
|
||||||
|
|
||||||
|
$upload_panel = new PhabricatorFileUploadView();
|
||||||
|
$upload_panel->setUser($user);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
require_celerity_resource('files-css');
|
require_celerity_resource('files-css');
|
||||||
$upload_id = celerity_generate_unique_node_id();
|
$upload_id = celerity_generate_unique_node_id();
|
||||||
$panel_id = celerity_generate_unique_node_id();
|
$panel_id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
$upload_panel = new AphrontPanelView();
|
$upload_panel = new AphrontPanelView();
|
||||||
$upload_panel->setHeader('Upload Files');
|
$upload_panel->setHeader('Upload Files');
|
||||||
$upload_panel->setCreateButton(
|
$upload_panel->setCreateButton('Basic Uploader',
|
||||||
'Basic Uploader', '/file/upload/');
|
$request->getRequestURI()->setQueryParam('basic_uploader', true)
|
||||||
|
);
|
||||||
|
|
||||||
$upload_panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
$upload_panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||||
$upload_panel->setID($panel_id);
|
$upload_panel->setID($panel_id);
|
||||||
|
@ -184,13 +339,13 @@ class PhabricatorFileListController extends PhabricatorFileController {
|
||||||
'files-drag-and-drop',
|
'files-drag-and-drop',
|
||||||
array(
|
array(
|
||||||
'uri' => '/file/dropupload/',
|
'uri' => '/file/dropupload/',
|
||||||
'browseURI' => '/file/?author='.$user->getUsername(),
|
'browseURI' => '/file/filter/my/',
|
||||||
'control' => $upload_id,
|
'control' => $upload_id,
|
||||||
'target' => $panel_id,
|
'target' => $panel_id,
|
||||||
'activatedClass' => 'aphront-panel-view-drag-and-drop',
|
'activatedClass' => 'aphront-panel-view-drag-and-drop',
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
return $upload_panel;
|
return $upload_panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
|
||||||
phutil_require_module('phabricator', 'applications/files/controller/base');
|
phutil_require_module('phabricator', 'applications/files/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
phutil_require_module('phabricator', 'applications/files/view/sidenav');
|
||||||
|
phutil_require_module('phabricator', 'applications/files/view/upload');
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||||
|
|
|
@ -108,19 +108,23 @@ class PhabricatorFileMacroEditController extends PhabricatorFileController {
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
if ($macro->getID()) {
|
if ($macro->getID()) {
|
||||||
$panel->setHeader('Edit Image Macro');
|
$title = 'Edit Image Macro';
|
||||||
} else {
|
} else {
|
||||||
$panel->setHeader('Create Image Macro');
|
$title = 'Create Image Macro';
|
||||||
}
|
}
|
||||||
|
$panel->setHeader($title);
|
||||||
$panel->appendChild($form);
|
$panel->appendChild($form);
|
||||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||||
|
|
||||||
|
$side_nav = new PhabricatorFileSideNavView();
|
||||||
|
$side_nav->setSelectedFilter('create_macro');
|
||||||
|
$side_nav->appendChild($error_view);
|
||||||
|
$side_nav->appendChild($panel);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
array($error_view, $panel),
|
$side_nav,
|
||||||
array(
|
array(
|
||||||
'title' => 'Edit Image Macro',
|
'title' => $title,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||||
phutil_require_module('phabricator', 'applications/files/controller/base');
|
phutil_require_module('phabricator', 'applications/files/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
|
phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
|
||||||
|
phutil_require_module('phabricator', 'applications/files/view/sidenav');
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
phutil_require_module('phabricator', 'view/form/control/file');
|
phutil_require_module('phabricator', 'view/form/control/file');
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PhabricatorFileMacroListController extends PhabricatorFileController {
|
class PhabricatorFileMacroListController extends PhabricatorFileController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
@ -116,8 +115,12 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
|
||||||
$panel->setCreateButton('New Image Macro', '/file/macro/edit/');
|
$panel->setCreateButton('New Image Macro', '/file/macro/edit/');
|
||||||
$panel->appendChild($pager);
|
$panel->appendChild($pager);
|
||||||
|
|
||||||
|
$side_nav = new PhabricatorFileSideNavView();
|
||||||
|
$side_nav->setSelectedFilter('all_macros');
|
||||||
|
$side_nav->appendChild($panel);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
$side_nav,
|
||||||
array(
|
array(
|
||||||
'title' => 'Image Macros',
|
'title' => 'Image Macros',
|
||||||
'tab' => 'macros',
|
'tab' => 'macros',
|
||||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/files/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
|
phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
|
||||||
phutil_require_module('phabricator', 'applications/files/uri');
|
phutil_require_module('phabricator', 'applications/files/uri');
|
||||||
|
phutil_require_module('phabricator', 'applications/files/view/sidenav');
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
|
|
@ -34,32 +34,8 @@ class PhabricatorFileUploadController extends PhabricatorFileController {
|
||||||
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
|
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new AphrontFormView();
|
$panel = new PhabricatorFileUploadView();
|
||||||
$form->setAction('/file/upload/');
|
$panel->setUser($user);
|
||||||
$form->setUser($request->getUser());
|
|
||||||
|
|
||||||
$form
|
|
||||||
->setEncType('multipart/form-data')
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormFileControl())
|
|
||||||
->setLabel('File')
|
|
||||||
->setName('file')
|
|
||||||
->setError(true))
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormTextControl())
|
|
||||||
->setLabel('Name')
|
|
||||||
->setName('name')
|
|
||||||
->setCaption('Optional file display name.'))
|
|
||||||
->appendChild(
|
|
||||||
id(new AphrontFormSubmitControl())
|
|
||||||
->setValue('Upload')
|
|
||||||
->addCancelButton('/file/'));
|
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
|
||||||
$panel->setHeader('Upload File');
|
|
||||||
|
|
||||||
$panel->appendChild($form);
|
|
||||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
array($panel),
|
array($panel),
|
||||||
|
@ -67,5 +43,4 @@ class PhabricatorFileUploadController extends PhabricatorFileController {
|
||||||
'title' => 'Upload File',
|
'title' => 'Upload File',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,7 @@
|
||||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||||
phutil_require_module('phabricator', 'applications/files/controller/base');
|
phutil_require_module('phabricator', 'applications/files/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||||
phutil_require_module('phabricator', 'view/form/base');
|
phutil_require_module('phabricator', 'applications/files/view/upload');
|
||||||
phutil_require_module('phabricator', 'view/form/control/file');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
|
||||||
phutil_require_module('phabricator', 'view/form/control/text');
|
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class PhabricatorFileSideNavView extends AphrontView {
|
||||||
|
private $selectedFilter;
|
||||||
|
|
||||||
|
public function setSelectedFilter($selected_filter) {
|
||||||
|
$this->selectedFilter = $selected_filter;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
private function getSelectedFilter() {
|
||||||
|
return $this->selectedFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$selected_filter = $this->getSelectedFilter();
|
||||||
|
if (!$selected_filter) {
|
||||||
|
throw new Exception("Call setFilter() before render()!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters = array(
|
||||||
|
'Files' => array(),
|
||||||
|
'upload' => array(
|
||||||
|
'name' => 'Upload File',
|
||||||
|
'href' => '/file/filter/upload/'
|
||||||
|
),
|
||||||
|
'my' => array(
|
||||||
|
'name' => 'My Files',
|
||||||
|
'href' => '/file/filter/my/'
|
||||||
|
),
|
||||||
|
'all' => array(
|
||||||
|
'name' => 'All Files',
|
||||||
|
'href' => '/file/filter/all/'
|
||||||
|
),
|
||||||
|
'<hr />' => array(),
|
||||||
|
'Image Macros' => array(),
|
||||||
|
'create_macro' => array(
|
||||||
|
'name' => 'Create Image Macro',
|
||||||
|
'href' => '/file/macro/edit/'
|
||||||
|
),
|
||||||
|
'all_macros' => array(
|
||||||
|
'name' => 'All Image Macros',
|
||||||
|
'href' => '/file/macro/'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$side_nav = new AphrontSideNavView();
|
||||||
|
foreach ($filters as $filter_key => $filter) {
|
||||||
|
// more of a label than a filter
|
||||||
|
if (empty($filter)) {
|
||||||
|
$side_nav->addNavItem(phutil_render_tag(
|
||||||
|
'span',
|
||||||
|
array(),
|
||||||
|
$filter_key));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$selected = $filter_key == $selected_filter;
|
||||||
|
$side_nav->addNavItem(
|
||||||
|
phutil_render_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $filter['href'],
|
||||||
|
'class' => $selected ? 'aphront-side-nav-selected': null,
|
||||||
|
),
|
||||||
|
$filter['name'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$side_nav->appendChild($this->renderChildren());
|
||||||
|
|
||||||
|
return $side_nav->render();
|
||||||
|
}
|
||||||
|
}
|
15
src/applications/files/view/sidenav/__init__.php
Normal file
15
src/applications/files/view/sidenav/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'view/base');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/sidenav');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorFileSideNavView.php');
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class PhabricatorFileUploadView extends AphrontView {
|
||||||
|
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
private function getUser() {
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
public function setUser(PhabricatorUser $user) {
|
||||||
|
$this->user = $user;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$user = $this->getUser();
|
||||||
|
if (!$user) {
|
||||||
|
throw new Exception("Call setUser() before render()!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new AphrontFormView();
|
||||||
|
$form->setAction('/file/upload/');
|
||||||
|
$form->setUser($user);
|
||||||
|
|
||||||
|
$form
|
||||||
|
->setEncType('multipart/form-data')
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormFileControl())
|
||||||
|
->setLabel('File')
|
||||||
|
->setName('file')
|
||||||
|
->setError(true))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setLabel('Name')
|
||||||
|
->setName('name')
|
||||||
|
->setCaption('Optional file display name.'))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue('Upload')
|
||||||
|
->addCancelButton('/file/'));
|
||||||
|
|
||||||
|
$panel = new AphrontPanelView();
|
||||||
|
$panel->setHeader('Upload File');
|
||||||
|
|
||||||
|
$panel->appendChild($form);
|
||||||
|
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
||||||
|
|
||||||
|
return $panel->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
src/applications/files/view/upload/__init__.php
Normal file
19
src/applications/files/view/upload/__init__.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'view/base');
|
||||||
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
|
phutil_require_module('phabricator', 'view/form/control/file');
|
||||||
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
|
phutil_require_module('phabricator', 'view/form/control/text');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorFileUploadView.php');
|
Loading…
Reference in a new issue