1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +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:
Bob Trahan 2011-12-14 22:37:23 -08:00
parent 0e7049e8aa
commit 128b7584da
15 changed files with 430 additions and 114 deletions

View file

@ -457,6 +457,7 @@ phutil_register_library_map(array(
'PhabricatorFileMacroListController' => 'applications/files/controller/macrolist',
'PhabricatorFileProxyController' => 'applications/files/controller/proxy',
'PhabricatorFileProxyImage' => 'applications/files/storage/proxyimage',
'PhabricatorFileSideNavView' => 'applications/files/view/sidenav',
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
'PhabricatorFileStorageEngine' => 'applications/files/engine/base',
'PhabricatorFileStorageEngineSelector' => 'applications/files/engineselector/base',
@ -464,6 +465,7 @@ phutil_register_library_map(array(
'PhabricatorFileURI' => 'applications/files/uri',
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
'PhabricatorFileUploadException' => 'applications/files/exception/upload',
'PhabricatorFileUploadView' => 'applications/files/view/upload',
'PhabricatorFileViewController' => 'applications/files/controller/view',
'PhabricatorGarbageCollectorDaemon' => 'infrastructure/daemon/garbagecollector',
'PhabricatorGoodForNothingWorker' => 'infrastructure/daemon/workers/worker/goodfornothing',
@ -1110,9 +1112,11 @@ phutil_register_library_map(array(
'PhabricatorFileMacroListController' => 'PhabricatorFileController',
'PhabricatorFileProxyController' => 'PhabricatorFileController',
'PhabricatorFileProxyImage' => 'PhabricatorFileDAO',
'PhabricatorFileSideNavView' => 'AphrontView',
'PhabricatorFileStorageBlob' => 'PhabricatorFileDAO',
'PhabricatorFileTransformController' => 'PhabricatorFileController',
'PhabricatorFileUploadController' => 'PhabricatorFileController',
'PhabricatorFileUploadView' => 'AphrontView',
'PhabricatorFileViewController' => 'PhabricatorFileController',
'PhabricatorGarbageCollectorDaemon' => 'PhabricatorDaemon',
'PhabricatorGoodForNothingWorker' => 'PhabricatorWorker',

View file

@ -51,6 +51,7 @@ class AphrontDefaultApplicationConfiguration
),
'/file/' => array(
'$' => 'PhabricatorFileListController',
'filter/(?P<filter>\w+)/$' => 'PhabricatorFileListController',
'upload/$' => 'PhabricatorFileUploadController',
'dropupload/$' => 'PhabricatorFileDropUploadController',
'(?P<view>info)/(?P<phid>[^/]+)/' => 'PhabricatorFileViewController',

View file

@ -25,18 +25,6 @@ abstract class PhabricatorFileController extends PhabricatorController {
$page->setBaseURI('/file/');
$page->setTitle(idx($data, 'title'));
$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);
$response = new AphrontWebpageResponse();

View file

@ -17,33 +17,181 @@
*/
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() {
$request = $this->getRequest();
$user = $request->getUser();
$upload_panel = $this->renderUploadPanel();
$author = null;
$author_username = $request->getStr('author');
if ($author_username) {
$author = id(new PhabricatorUser())->loadOneWhere(
'userName = %s',
$author_username);
if (!$author) {
return id(new Aphront404Response());
}
$title = 'Files Uploaded by '.phutil_escape_html($author->getUsername());
} else {
$title = 'Files';
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 &middot; {$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();
$side_nav = new PhabricatorFileSideNavView();
$side_nav->setSelectedFilter($this->getFilter());
if ($this->showUploader()) {
$side_nav->appendChild($this->renderUploadPanel());
}
$side_nav->appendChild($this->renderList());
return $this->buildStandardPageResponse(
$side_nav,
array(
'title' => 'Files',
'tab' => 'files',
));
}
private function loadListData() {
$request = $this->getRequest();
$user = $request->getUser();
$pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page'));
$pager->setOffset($this->getPagerOffset());
if ($this->getPagerPageSize()) {
$pager->setPageSize($this->getPagerPageSize());
}
$author = $this->getListAuthor();
if ($author) {
$files = id(new PhabricatorFile())->loadAllWhere(
'authorPHID = %s ORDER BY id DESC LIMIT %d, %d',
@ -59,6 +207,7 @@ class PhabricatorFileListController extends PhabricatorFileController {
$files = $pager->sliceResults($files);
$pager->setURI($request->getRequestURI(), 'page');
$this->setListPager($pager);
$phids = mpull($files, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
@ -112,9 +261,13 @@ class PhabricatorFileListController extends PhabricatorFileController {
phabricator_time($file->getDateCreated(), $user),
);
}
$this->setListRows($rows);
$this->setListRowClasses($rowc);
}
$table = new AphrontTableView($rows);
$table->setRowClasses($rowc);
private function renderList() {
$table = new AphrontTableView($this->getListRows());
$table->setRowClasses($this->getListRowClasses());
$table->setHeaders(
array(
'File ID',
@ -140,57 +293,59 @@ class PhabricatorFileListController extends PhabricatorFileController {
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader($title);
$panel->appendChild($pager);
$panel->setHeader($this->getListHeader());
if ($this->showListPager()) {
$panel->appendChild($this->getListPager());
}
return $this->buildStandardPageResponse(
array(
$upload_panel,
$panel,
),
array(
'title' => 'Files',
'tab' => 'files',
));
return $panel;
}
private function renderUploadPanel() {
$request = $this->getRequest();
$user = $request->getUser();
require_celerity_resource('files-css');
$upload_id = celerity_generate_unique_node_id();
$panel_id = celerity_generate_unique_node_id();
if ($this->useBasicUploader()) {
$upload_panel = new AphrontPanelView();
$upload_panel->setHeader('Upload Files');
$upload_panel->setCreateButton(
'Basic Uploader', '/file/upload/');
$upload_panel = new PhabricatorFileUploadView();
$upload_panel->setUser($user);
$upload_panel->setWidth(AphrontPanelView::WIDTH_FULL);
$upload_panel->setID($panel_id);
} else {
$upload_panel->appendChild(
phutil_render_tag(
'div',
require_celerity_resource('files-css');
$upload_id = celerity_generate_unique_node_id();
$panel_id = celerity_generate_unique_node_id();
$upload_panel = new AphrontPanelView();
$upload_panel->setHeader('Upload Files');
$upload_panel->setCreateButton('Basic Uploader',
$request->getRequestURI()->setQueryParam('basic_uploader', true)
);
$upload_panel->setWidth(AphrontPanelView::WIDTH_FULL);
$upload_panel->setID($panel_id);
$upload_panel->appendChild(
phutil_render_tag(
'div',
array(
'id' => $upload_id,
'style' => 'display: none;',
'class' => 'files-drag-and-drop',
),
''));
Javelin::initBehavior(
'files-drag-and-drop',
array(
'id' => $upload_id,
'style' => 'display: none;',
'class' => 'files-drag-and-drop',
),
''));
Javelin::initBehavior(
'files-drag-and-drop',
array(
'uri' => '/file/dropupload/',
'browseURI' => '/file/?author='.$user->getUsername(),
'control' => $upload_id,
'target' => $panel_id,
'activatedClass' => 'aphront-panel-view-drag-and-drop',
));
'uri' => '/file/dropupload/',
'browseURI' => '/file/filter/my/',
'control' => $upload_id,
'target' => $panel_id,
'activatedClass' => 'aphront-panel-view-drag-and-drop',
));
}
return $upload_panel;
}
}

View file

@ -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/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', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api');

View file

@ -108,19 +108,23 @@ class PhabricatorFileMacroEditController extends PhabricatorFileController {
$panel = new AphrontPanelView();
if ($macro->getID()) {
$panel->setHeader('Edit Image Macro');
$title = 'Edit Image Macro';
} else {
$panel->setHeader('Create Image Macro');
$title = 'Create Image Macro';
}
$panel->setHeader($title);
$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(
array($error_view, $panel),
$side_nav,
array(
'title' => 'Edit Image Macro',
'title' => $title,
));
}
}

View file

@ -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/storage/file');
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/control/file');
phutil_require_module('phabricator', 'view/form/control/submit');

View file

@ -17,7 +17,6 @@
*/
class PhabricatorFileMacroListController extends PhabricatorFileController {
public function processRequest() {
$request = $this->getRequest();
@ -116,8 +115,12 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$panel->setCreateButton('New Image Macro', '/file/macro/edit/');
$panel->appendChild($pager);
$side_nav = new PhabricatorFileSideNavView();
$side_nav->setSelectedFilter('all_macros');
$side_nav->appendChild($panel);
return $this->buildStandardPageResponse(
$panel,
$side_nav,
array(
'title' => 'Image Macros',
'tab' => 'macros',

View file

@ -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/imagemacro');
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', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'storage/queryfx');

View file

@ -34,32 +34,8 @@ class PhabricatorFileUploadController extends PhabricatorFileController {
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
}
$form = new AphrontFormView();
$form->setAction('/file/upload/');
$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);
$panel = new PhabricatorFileUploadView();
$panel->setUser($user);
return $this->buildStandardPageResponse(
array($panel),
@ -67,5 +43,4 @@ class PhabricatorFileUploadController extends PhabricatorFileController {
'title' => 'Upload File',
));
}
}

View file

@ -9,11 +9,7 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file');
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('phabricator', 'applications/files/view/upload');
phutil_require_module('phutil', 'utils');

View file

@ -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();
}
}

View 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');

View file

@ -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();
}
}

View 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');