Streamline Files interfaces

Summary:
  - There's no way you can figure out the ID of a file right now. Expose that
more prominently.
  - Put the drag-and-drop uploader on the main page so you don't have to click
through.
  - Restore the basic uploader so IE users can theoretically use the suite I
guess? Added author info to basic uploader.
  - Show author information in the table.
  - Show date information in the table.
  - Link file names.
  - Rename table for filter views.
  - When you upload one file, just jump to it. When you upload multiple files,
jump to your uploads and highlight them.
  - Add an "arc download" hint.

Test Plan: Uploaded single files, groups of files, and files via simple
uploader.
Reviewers: codeblock, jungejason, tuomaspelkonen, aran
Commenters: codeblock
CC: aran, codeblock, epriestley
Differential Revision: 746
This commit is contained in:
epriestley
2011-07-29 16:01:59 -07:00
parent b70b9bb6d7
commit 90cbf8459c
10 changed files with 303 additions and 88 deletions

View File

@@ -37,8 +37,10 @@ class PhabricatorFileDropUploadController extends PhabricatorFileController {
return id(new AphrontAjaxResponse())->setContent(
array(
'id' => $file->getID(),
'phid' => $file->getPHID(),
'html' => $view->render(),
'uri' => $file->getBestURI(),
));
}

View File

@@ -21,6 +21,9 @@ class PhabricatorFileListController extends PhabricatorFileController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$upload_panel = $this->renderUploadPanel();
$author = null;
$author_username = $request->getStr('author');
@@ -32,6 +35,10 @@ class PhabricatorFileListController extends PhabricatorFileController {
if (!$author) {
return id(new Aphront404Response());
}
$title = 'Files Uploaded by '.phutil_escape_html($author->getUsername());
} else {
$title = 'Files';
}
$pager = new AphrontPagerView();
@@ -53,7 +60,15 @@ class PhabricatorFileListController extends PhabricatorFileController {
$files = $pager->sliceResults($files);
$pager->setURI($request->getRequestURI(), 'page');
$phids = mpull($files, 'getAuthorPHID');
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$highlighted = $request->getStr('h');
$highlighted = explode('-', $highlighted);
$highlighted = array_fill_keys($highlighted, true);
$rows = array();
$rowc = array();
foreach ($files as $file) {
if ($file->isViewableInBrowser()) {
$view_button = phutil_render_tag(
@@ -66,10 +81,25 @@ class PhabricatorFileListController extends PhabricatorFileController {
} else {
$view_button = null;
}
if (isset($highlighted[$file->getID()])) {
$rowc[] = 'highlighted';
} else {
$rowc[] = '';
}
$rows[] = array(
phutil_escape_html($file->getPHID()),
phutil_escape_html($file->getName()),
phutil_escape_html($file->getByteSize()),
phutil_escape_html('F'.$file->getID()),
$file->getAuthorPHID()
? $handles[$file->getAuthorPHID()]->renderLink()
: null,
phutil_render_tag(
'a',
array(
'href' => $file->getViewURI(),
),
phutil_escape_html($file->getName())),
phutil_escape_html(number_format($file->getByteSize()).' bytes'),
phutil_render_tag(
'a',
array(
@@ -85,38 +115,91 @@ class PhabricatorFileListController extends PhabricatorFileController {
'href' => '/file/download/'.$file->getPHID().'/',
),
'Download'),
phabricator_date($file->getDateCreated(), $user),
phabricator_time($file->getDateCreated(), $user),
);
}
$table = new AphrontTableView($rows);
$table->setRowClasses($rowc);
$table->setHeaders(
array(
'PHID',
'File ID',
'Author',
'Name',
'Size',
'',
'',
'',
'Created',
'',
));
$table->setColumnClasses(
array(
null,
'wide',
null,
'',
'wide pri',
'right',
'action',
'action',
'action',
'',
'right',
));
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('Files');
$panel->setCreateButton('Upload File', '/file/upload/');
$panel->setHeader($title);
$panel->appendChild($pager);
return $this->buildStandardPageResponse($panel, array(
'title' => 'Files',
'tab' => 'files',
return $this->buildStandardPageResponse(
array(
$upload_panel,
$panel,
),
array(
'title' => 'Files',
'tab' => 'files',
));
}
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();
$upload_panel = new AphrontPanelView();
$upload_panel->setHeader('Upload Files');
$upload_panel->setCreateButton(
'Basic Uploader', '/file/upload/');
$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(
'uri' => '/file/dropupload/',
'browseURI' => '/file/?author='.$user->getUsername(),
'control' => $upload_id,
'target' => $panel_id,
'activatedClass' => 'aphront-panel-view-drag-and-drop',
));
return $upload_panel;
}
}

View File

@@ -10,9 +10,13 @@ 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/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');

View File

@@ -24,44 +24,42 @@ class PhabricatorFileUploadController extends PhabricatorFileController {
$user = $request->getUser();
if ($request->isFormPost()) {
$files = $request->getArr('file');
$file = PhabricatorFile::newFromPHPUpload(
idx($_FILES, 'file'),
array(
'name' => $request->getStr('name'),
'authorPHID' => $user->getPHID(),
));
if (count($files) > 1) {
return id(new AphrontRedirectResponse())
->setURI('/file/?author='.phutil_escape_uri($user->getUserName()));
} else {
return id(new AphrontRedirectResponse())
->setURI('/file/info/'.end($files).'/');
}
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
}
$panel_id = celerity_generate_unique_node_id();
$form = new AphrontFormView();
$form->setAction('/file/upload/');
$form->setUser($request->getUser());
$form
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormDragAndDropUploadControl())
->setLabel('Files')
->setName('file')
->setError(true)
->setDragAndDropTarget($panel_id)
->setActivatedClass('aphront-panel-view-drag-and-drop'))
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('Done here!'));
->setValue('Upload')
->addCancelButton('/file/'));
$panel = new AphrontPanelView();
$panel->setHeader('Upload File');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setID($panel_id);
return $this->buildStandardPageResponse(
array($panel),

View File

@@ -8,13 +8,13 @@
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/draganddropupload');
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', 'markup');
phutil_require_module('phutil', 'utils');

View File

@@ -94,6 +94,9 @@ class PhabricatorFileViewController extends PhabricatorFileController {
$form->setAction('/file/download/'.$file->getPHID().'/');
$button_name = 'Download File';
}
$file_id = 'F'.$file->getID();
$form->setUser($user);
$form
->appendChild(
@@ -101,6 +104,14 @@ class PhabricatorFileViewController extends PhabricatorFileController {
->setLabel('Name')
->setName('name')
->setValue($file->getName()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setName('id')
->setValue($file_id)
->setCaption(
'Download this file with: <tt>arc download '.
phutil_escape_html($file_id).'</tt>'))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('PHID')