Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OCA.Files.Sidebar and migrate sharing #15719

Merged
merged 14 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .babelrc.js

This file was deleted.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ lint-fix-watch:
clean:
rm -rf apps/accessibility/js/
rm -rf apps/comments/js/
rm -rf apps/files/js/dist/
rm -rf apps/files_sharing/js/dist/
rm -rf apps/files_trashbin/js/
rm -rf apps/files_versions/js/
Expand All @@ -47,6 +48,7 @@ clean-dev:
clean-git: clean
git checkout -- apps/accessibility/js/
git checkout -- apps/comments/js/
git checkout -- apps/files/js/dist/
git checkout -- apps/files_sharing/js/dist/
git checkout -- apps/files_trashbin/js/
git checkout -- apps/files_versions/js/
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/js/comments.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/src/filesplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
actionHandler: function(fileName, context) {
context.$file.find('.action-comment').tooltip('hide')
// open sidebar in comments section
context.fileList.showDetailsView(fileName, 'commentsTabView')
context.fileList.showDetailsView(fileName, 'comments')
}
})

Expand Down
2 changes: 1 addition & 1 deletion apps/comments/tests/js/filespluginSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('OCA.Comments.FilesPlugin tests', function() {

expect(sidebarStub.calledOnce).toEqual(true);
expect(sidebarStub.lastCall.args[0]).toEqual('One.txt');
expect(sidebarStub.lastCall.args[1]).toEqual('commentsTabView');
expect(sidebarStub.lastCall.args[1]).toEqual('comments');
});
});
describe('elementToFile', function() {
Expand Down
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'OCA\\Files\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php',
'OCA\\Files\\Controller\\ViewController' => $baseDir . '/../lib/Controller/ViewController.php',
'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => $baseDir . '/../lib/Event/LoadAdditionalScriptsEvent.php',
'OCA\\Files\\Event\\LoadSidebar' => $baseDir . '/../lib/Event/LoadSidebar.php',
'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php',
Expand Down
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php',
'OCA\\Files\\Controller\\ViewController' => __DIR__ . '/..' . '/../lib/Controller/ViewController.php',
'OCA\\Files\\Event\\LoadAdditionalScriptsEvent' => __DIR__ . '/..' . '/../lib/Event/LoadAdditionalScriptsEvent.php',
'OCA\\Files\\Event\\LoadSidebar' => __DIR__ . '/..' . '/../lib/Event/LoadSidebar.php',
'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php',
Expand Down
3 changes: 2 additions & 1 deletion apps/files/css/files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@
}

/* fit app list view heights */
.app-files #app-content>.viewcontainer {
.app-files #app-content > .viewcontainer {
min-height: 0%;
width: 100%;
}

.app-files #app-content {
Expand Down
286 changes: 286 additions & 0 deletions apps/files/js/dist/sidebar.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/files/js/dist/sidebar.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@
}
context.fileList.do_delete(fileName, context.dir);
$('.tipsy').remove();

// close sidebar on delete
const path = context.dir + '/' + fileName
if (OCA.Files.Sidebar && OCA.Files.Sidebar.file === path) {
OCA.Files.Sidebar.file = undefined
}
}
});

Expand Down
72 changes: 31 additions & 41 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,11 @@
* @param {string} [tabId] optional tab id to select
*/
showDetailsView: function(fileName, tabId) {
console.warn('showDetailsView is deprecated! Use OCA.Files.Sidebar.activeTab. It will be removed in nextcloud 20.');
this._updateDetailsView(fileName);
if (tabId) {
this._detailsView.selectTab(tabId);
OCA.Files.Sidebar.activeTab = tabId;
}
OC.Apps.showAppSidebar(this._detailsView.$el);
},

/**
Expand All @@ -623,48 +623,28 @@
* @param {string|OCA.Files.FileInfoModel} fileName file name from the current list or a FileInfoModel object
* @param {boolean} [show=true] whether to open the sidebar if it was closed
*/
_updateDetailsView: function(fileName, show) {
if (!this._detailsView) {
_updateDetailsView: function(fileName) {
if (!(OCA.Files && OCA.Files.Sidebar)) {
console.error('No sidebar available');
return;
}

// show defaults to true
show = _.isUndefined(show) || !!show;
var oldFileInfo = this._detailsView.getFileInfo();
if (oldFileInfo) {
// TODO: use more efficient way, maybe track the highlight
this.$fileList.children().filterAttr('data-id', '' + oldFileInfo.get('id')).removeClass('highlighted');
oldFileInfo.off('change', this._onSelectedModelChanged, this);
}

if (!fileName) {
this._detailsView.setFileInfo(null);
if (this._currentFileModel) {
this._currentFileModel.off();
}
this._currentFileModel = null;
OC.Apps.hideAppSidebar(this._detailsView.$el);
return;
}

if (show && this._detailsView.$el.hasClass('disappear')) {
OC.Apps.showAppSidebar(this._detailsView.$el);
OCA.Files.Sidebar.file = null
return
} else if (typeof fileName !== 'string') {
fileName = ''
}

if (fileName instanceof OCA.Files.FileInfoModel) {
var model = fileName;
} else {
var $tr = this.findFileEl(fileName);
var model = this.getModelForFile($tr);
$tr.addClass('highlighted');
}

this._currentFileModel = model;
// this is the old (terrible) way of getting the context.
// don't use it anywhere else. Just provide the full path
// of the file to the sidebar service
var tr = this.findFileEl(fileName)
var model = this.getModelForFile(tr)
var path = model.attributes.path + '/' + model.attributes.name

this._replaceDetailsViewElementIfNeeded();

this._detailsView.setFileInfo(model);
this._detailsView.$el.scrollTop(0);
// open sidebar and set file
OCA.Files.Sidebar.file = path.replace('//', '/')
},

/**
Expand Down Expand Up @@ -1404,6 +1384,13 @@
return OC.MimeType.getIconUrl('dir-external');
} else if (fileInfo.mountType !== undefined && fileInfo.mountType !== '') {
return OC.MimeType.getIconUrl('dir-' + fileInfo.mountType);
} else if (fileInfo.shareTypes && (
fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_LINK) > -1
|| fileInfo.shareTypes.indexOf(OC.Share.SHARE_TYPE_EMAIL) > -1)
) {
return OC.MimeType.getIconUrl('dir-public')
} else if (fileInfo.shareTypes && fileInfo.shareTypes.length > 0) {
return OC.MimeType.getIconUrl('dir-shared')
}
return OC.MimeType.getIconUrl('dir');
}
Expand Down Expand Up @@ -3654,17 +3641,20 @@
* Register a tab view to be added to all views
*/
registerTabView: function(tabView) {
if (this._detailsView) {
this._detailsView.addTabView(tabView);
console.warn('registerTabView is deprecated! It will be removed in nextcloud 20.');
const name = tabView.getLabel()
if (name) {
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab(name, tabView, true))
}
},

/**
* Register a detail view to be added to all views
*/
registerDetailView: function(detailView) {
if (this._detailsView) {
this._detailsView.addDetailView(detailView);
console.warn('registerDetailView is deprecated! It will be removed in nextcloud 20.');
if (detailView.el) {
OCA.Files.Sidebar.registerSecondaryView(detailView)
}
},

Expand Down
47 changes: 24 additions & 23 deletions apps/files/js/merged-index.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
[
"dist/sidebar.js",
"app.js",
"templates.js",
"file-upload.js",
"newfilemenu.js",
"jquery.fileupload.js",
"jquery-visibility.js",
"fileinfomodel.js",
"filesummary.js",
"filemultiselectmenu.js",
"breadcrumb.js",
"filelist.js",
"search.js",
"favoritesfilelist.js",
"recentfilelist.js",
"tagsplugin.js",
"gotoplugin.js",
"favoritesplugin.js",
"recentplugin.js",
"detailfileinfoview.js",
"sidebarpreviewmanager.js",
"sidebarpreviewtext.js",
"detailtabview.js",
"semaphore.js",
"mainfileinfodetailview.js",
"operationprogressbar.js",
"detailsview.js",
"detailtabview.js",
"favoritesfilelist.js",
"favoritesplugin.js",
"file-upload.js",
"fileactions.js",
"fileactionsmenu.js",
"fileinfomodel.js",
"filelist.js",
"filemultiselectmenu.js",
"files.js",
"filesummary.js",
"gotoplugin.js",
"jquery-visibility.js",
"jquery.fileupload.js",
"keyboardshortcuts.js",
"navigation.js"
"mainfileinfodetailview.js",
"navigation.js",
"newfilemenu.js",
"operationprogressbar.js",
"recentfilelist.js",
"recentplugin.js",
"search.js",
"semaphore.js",
"sidebarpreviewmanager.js",
"sidebarpreviewtext.js",
"tagsplugin.js",
"templates.js"
]
4 changes: 4 additions & 0 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @author Thomas Müller <[email protected]>
* @author Vincent Petry <[email protected]>
* @author Felix Nüsse <[email protected]>
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0
*
Expand All @@ -30,6 +31,7 @@

use OCA\Files\Activity\Helper;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
Expand Down Expand Up @@ -269,6 +271,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$event = new LoadAdditionalScriptsEvent();
$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);

$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved

$params = [];
$params['usedSpacePercent'] = (int) $storageInfo['relative'];
$params['owner'] = $storageInfo['owner'];
Expand Down
31 changes: 31 additions & 0 deletions apps/files/lib/Event/LoadSidebar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <[email protected]>
*
* @author Roeland Jago Douma <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Files\Event;

use OCP\EventDispatcher\Event;

class LoadSidebar extends Event {

}
Loading