Compare commits

...

2 Commits

Author SHA1 Message Date
Louis Chemineau 99ab3b2bac Trigger click event when scrollTo is set
Signed-off-by: Louis Chemineau <louis@chmn.me>
2021-06-03 10:58:42 +02:00
Louis Chemineau 724592d468 Emit sidebar events
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
Signed-off-by: Louis Chemineau <louis@chmn.me>
2021-06-03 10:28:55 +02:00
79 changed files with 64305 additions and 414 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -91,6 +91,7 @@
fileActions: fileActions, fileActions: fileActions,
allowLegacyActions: true, allowLegacyActions: true,
scrollTo: urlParams.scrollto, scrollTo: urlParams.scrollto,
openFile: urlParams.openfile,
filesClient: OC.Files.getClient(), filesClient: OC.Files.getClient(),
multiSelectMenu: [ multiSelectMenu: [
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -679,12 +679,19 @@
permissions: OC.PERMISSION_READ, permissions: OC.PERMISSION_READ,
icon: '', icon: '',
actionHandler: function (filename, context) { actionHandler: function (filename, context) {
var dir = context.$file.attr('data-path') || context.fileList.getCurrentDirectory(); let dir, id
if (context.$file) {
dir = context.$file.attr('data-path')
id = context.$file.attr('data-id')
} else{
dir = context.fileList.getCurrentDirectory()
id = context.objectId
}
if (OCA.Files.App && OCA.Files.App.getActiveView() !== 'files') { if (OCA.Files.App && OCA.Files.App.getActiveView() !== 'files') {
OCA.Files.App.setActiveView('files', {silent: true}); OCA.Files.App.setActiveView('files', {silent: true});
OCA.Files.App.fileList.changeDirectory(OC.joinPaths(dir, filename), true, true); OCA.Files.App.fileList.changeDirectory(OC.joinPaths(dir, filename), true, true);
} else { } else {
context.fileList.changeDirectory(OC.joinPaths(dir, filename), true, false, parseInt(context.$file.attr('data-id'), 10)); context.fileList.changeDirectory(OC.joinPaths(dir, filename), true, false, parseInt(id, 10));
} }
}, },
displayName: t('files', 'Open') displayName: t('files', 'Open')

View File

@ -414,6 +414,32 @@
}); });
} }
if(options.openFile) {
// Wait for some initialisation process to be over before triggering the default action.
_.defer(() => {
try {
const fileInfo = JSON.parse(atob($('#initial-state-files-openFileInfo').val()))
var spec = this.fileActions.getDefaultFileAction(fileInfo.mime, fileInfo.type, fileInfo.permissions)
if (spec && spec.action) {
spec.action(fileInfo.name, {
objectId: fileInfo.id,
fileList: this,
fileActions: this.fileActions,
dir: fileInfo.directory
});
}
else {
var url = this.getDownloadUrl(fileInfo.name, fileInfo.dir, true);
OCA.Files.Files.handleDownload(url);
}
OCA.Files.Sidebar.open(fileInfo.path);
} catch (error) {
console.error(`Failed to trigger default action on the file for URL: ${location.href}`, error)
}
})
}
this._operationProgressBar = new OCA.Files.OperationProgressBar(); this._operationProgressBar = new OCA.Files.OperationProgressBar();
this._operationProgressBar.render(); this._operationProgressBar.render();
this.$el.find('#uploadprogresswrapper').replaceWith(this._operationProgressBar.$el); this.$el.find('#uploadprogresswrapper').replaceWith(this._operationProgressBar.$el);
@ -1320,31 +1346,6 @@
}, 0); }, 0);
} }
if(!this.triedActionOnce) {
var id = OC.Util.History.parseUrlQuery().openfile;
if (id) {
var $tr = this.$fileList.children().filterAttr('data-id', '' + id);
var filename = $tr.attr('data-file');
this.fileActions.currentFile = $tr.find('td');
var dir = $tr.attr('data-path') || this.getCurrentDirectory();
var spec = this.fileActions.getCurrentDefaultFileAction();
if (spec && spec.action) {
spec.action(filename, {
$file: $tr,
fileList: this,
fileActions: this.fileActions,
dir: dir
});
}
else {
var url = this.getDownloadUrl(filename, dir, true);
OCA.Files.Files.handleDownload(url);
}
}
this.triedActionOnce = true;
}
return newTrs; return newTrs;
}, },

View File

@ -56,6 +56,7 @@ use OCP\IRequest;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Share\IManager; use OCP\Share\IManager;
use OC\Files\View;
/** /**
* Class ViewController * Class ViewController
@ -89,6 +90,8 @@ class ViewController extends Controller {
private $templateManager; private $templateManager;
/** @var IManager */ /** @var IManager */
private $shareManager; private $shareManager;
/** @var View */
protected $fileView;
public function __construct(string $appName, public function __construct(string $appName,
IRequest $request, IRequest $request,
@ -102,7 +105,8 @@ class ViewController extends Controller {
Helper $activityHelper, Helper $activityHelper,
IInitialState $initialState, IInitialState $initialState,
ITemplateManager $templateManager, ITemplateManager $templateManager,
IManager $shareManager IManager $shareManager,
View $view
) { ) {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->appName = $appName; $this->appName = $appName;
@ -118,6 +122,7 @@ class ViewController extends Controller {
$this->initialState = $initialState; $this->initialState = $initialState;
$this->templateManager = $templateManager; $this->templateManager = $templateManager;
$this->shareManager = $shareManager; $this->shareManager = $shareManager;
$this->fileView = $view;
} }
/** /**
@ -181,7 +186,7 @@ class ViewController extends Controller {
* @return TemplateResponse|RedirectResponse * @return TemplateResponse|RedirectResponse
* @throws NotFoundException * @throws NotFoundException
*/ */
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false) { public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) {
if ($fileid !== null) { if ($fileid !== null) {
try { try {
return $this->redirectToFile($fileid); return $this->redirectToFile($fileid);
@ -330,6 +335,34 @@ class ViewController extends Controller {
$policy->addAllowedFrameDomain('\'self\''); $policy->addAllowedFrameDomain('\'self\'');
$response->setContentSecurityPolicy($policy); $response->setContentSecurityPolicy($policy);
$user = $this->userSession->getUser();
if ($openfile !== null && $user != null) {
$uid = $user->getUID();
$userFolder = $this->rootFolder->getUserFolder($uid);
$node = $userFolder->getById($openfile)[0];
// properly format full path and make sure
// we're relative to the user home folder
$isRoot = $node === $userFolder;
$path = $userFolder->getRelativePath($node->getPath());
$directory = $userFolder->getRelativePath($node->getParent()->getPath());
// Prevent opening a file from another folder.
if ($dir === $directory) {
$this->initialState->provideInitialState(
'openFileInfo', [
'id' => $node->getId(),
'name' => $isRoot ? '' : $node->getName(),
'path' => $path,
'directory' => $directory,
'mime' => $node->getMimetype(),
'type' => $node->getType(),
'permissions' => $node->getPermissions(),
]
);
}
}
return $response; return $response;
} }

View File

@ -123,6 +123,7 @@ class FilesSearchProvider implements IProvider {
[ [
'dir' => dirname($path), 'dir' => dirname($path),
'scrollto' => $result->getName(), 'scrollto' => $result->getName(),
'openfile' => $result->getId(),
] ]
); );

View File

@ -58,4 +58,5 @@ window.addEventListener('DOMContentLoaded', function() {
AppSidebar.$mount('#app-sidebar') AppSidebar.$mount('#app-sidebar')
window.OCA.Files.Sidebar.open = AppSidebar.open window.OCA.Files.Sidebar.open = AppSidebar.open
window.OCA.Files.Sidebar.close = AppSidebar.close window.OCA.Files.Sidebar.close = AppSidebar.close
window.OCA.Files.Sidebar.setFullScreenMode = AppSidebar.setFullScreenMode
}) })

View File

@ -29,7 +29,11 @@
@close="close" @close="close"
@update:active="setActiveTab" @update:active="setActiveTab"
@update:starred="toggleStarred" @update:starred="toggleStarred"
@[defaultActionListener].stop.prevent="onDefaultAction"> @[defaultActionListener].stop.prevent="onDefaultAction"
@opening="handleOpening"
@opened="handleOpened"
@closing="handleClosing"
@closed="handleClosed">
<!-- TODO: create a standard to allow multiple elements here? --> <!-- TODO: create a standard to allow multiple elements here? -->
<template v-if="fileInfo" #description> <template v-if="fileInfo" #description>
<LegacyView v-for="view in views" <LegacyView v-for="view in views"
@ -78,6 +82,7 @@
import { encodePath } from '@nextcloud/paths' import { encodePath } from '@nextcloud/paths'
import $ from 'jquery' import $ from 'jquery'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { emit } from '@nextcloud/event-bus'
import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar' import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent' import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
@ -105,6 +110,7 @@ export default {
loading: true, loading: true,
fileInfo: null, fileInfo: null,
starLoading: false, starLoading: false,
isFullScreen: false,
} }
}, },
@ -197,7 +203,10 @@ export default {
'star-loading': this.starLoading, 'star-loading': this.starLoading,
active: this.activeTab, active: this.activeTab,
background: this.background, background: this.background,
class: { 'has-preview': this.fileInfo.hasPreview }, class: {
'has-preview': this.fileInfo.hasPreview,
'app-sidebar--full': this.isFullScreen,
},
compact: !this.fileInfo.hasPreview, compact: !this.fileInfo.hasPreview,
loading: this.loading, loading: this.loading,
starred: this.fileInfo.isFavourited, starred: this.fileInfo.isFavourited,
@ -422,6 +431,30 @@ export default {
this.Sidebar.file = '' this.Sidebar.file = ''
this.resetData() this.resetData()
}, },
/**
* Allow to set the Sidebar as fullscreen from OCA.Files.Sidebar
* @param {boolean} isFullScreen - Wether or not to render the Sidebar in fullscreen.
*/
setFullScreenMode(isFullScreen) {
this.isFullScreen = isFullScreen
},
/**
* Emit SideBar events.
*/
handleOpening() {
emit('files:sidebar:opening')
},
handleOpened() {
emit('files:sidebar:opened')
},
handleClosing() {
emit('files:sidebar:closing')
},
handleClosed() {
emit('files:sidebar:closed')
},
}, },
} }
</script> </script>
@ -439,5 +472,12 @@ export default {
} }
} }
} }
&--full {
position: fixed !important;
z-index: 2025 !important;
top: 0 !important;
height: 100% !important;
}
} }
</style> </style>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

44
package-lock.json generated
View File

@ -2995,9 +2995,9 @@
}, },
"dependencies": { "dependencies": {
"core-js": { "core-js": {
"version": "2.6.11", "version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==" "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ=="
}, },
"regenerator-runtime": { "regenerator-runtime": {
"version": "0.12.1", "version": "0.12.1",
@ -4158,9 +4158,9 @@
} }
}, },
"@nextcloud/vue": { "@nextcloud/vue": {
"version": "3.10.0", "version": "3.10.1",
"resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-3.10.0.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-3.10.1.tgz",
"integrity": "sha512-U9gsRs/vxMtDYsF1LOb3pnobkOfc6S7pNB77poZJasLRkjFHPFLTYHvrzq4/cXE+RE/KL18Tw7qWVctfsCZ6UQ==", "integrity": "sha512-DdnnEFxt5FuZOtAD1x7hSDFVQF9KVVgQtFKwzs2ySNbyIx8rfRfc6noC7JbMAPR1LyPegCst0bVwQIfqsASGog==",
"requires": { "requires": {
"@nextcloud/auth": "^1.2.3", "@nextcloud/auth": "^1.2.3",
"@nextcloud/axios": "^1.3.2", "@nextcloud/axios": "^1.3.2",
@ -6354,15 +6354,10 @@
"whatwg-url": "^8.0.0" "whatwg-url": "^8.0.0"
} }
}, },
"date-fns": {
"version": "2.16.1",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.16.1.tgz",
"integrity": "sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ=="
},
"date-format-parse": { "date-format-parse": {
"version": "0.2.5", "version": "0.2.6",
"resolved": "https://registry.npmjs.org/date-format-parse/-/date-format-parse-0.2.5.tgz", "resolved": "https://registry.npmjs.org/date-format-parse/-/date-format-parse-0.2.6.tgz",
"integrity": "sha512-PzvB3p9bTxrGQbz3ZlO/kxgXzKZhMo4l0OQfPqVYjuwixHRS9yHH6cUJI9JG2Hh6iUQgh17T7w95lzQ131dS/g==" "integrity": "sha512-sdxnYAWmLopeb+6Hmw+vo3or4OCJOnh4+YoJ9p+Id3o2EnNP0INpTqx7wr8UregfMpgaSZAH473R/ytiaB3gVg=="
}, },
"davclient.js": { "davclient.js": {
"version": "git+https://github.com/owncloud/davclient.js.git#1ab200d099a3c2cd2ef919c3a56353ce26865994", "version": "git+https://github.com/owncloud/davclient.js.git#1ab200d099a3c2cd2ef919c3a56353ce26865994",
@ -10912,12 +10907,6 @@
} }
} }
}, },
"jsdom-global": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/jsdom-global/-/jsdom-global-3.0.2.tgz",
"integrity": "sha1-a9KZwTsMRiay2iwDk81DhdYGrLk=",
"dev": true
},
"jsesc": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -14193,9 +14182,9 @@
} }
}, },
"vue-color": { "vue-color": {
"version": "2.7.1", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.7.1.tgz", "resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.8.1.tgz",
"integrity": "sha512-u3yl46B2eEej9zfAOIRRSphX1QfeNQzMwO82EIA+aoi0AKX3o1KcfsmMzm4BFkkj2ukCxLVfQ41k7g1gSI7SlA==", "integrity": "sha512-BoLCEHisXi2QgwlhZBg9UepvzZZmi4176vbr+31Shen5WWZwSLVgdScEPcB+yrAtuHAz42309C0A4+WiL9lNBw==",
"requires": { "requires": {
"clamp": "^1.0.1", "clamp": "^1.0.1",
"lodash.throttle": "^4.0.0", "lodash.throttle": "^4.0.0",
@ -14330,12 +14319,11 @@
"integrity": "sha512-yaX2its9XAJKGuQqf7LsiZHHSkxsIK8rmCOQOvEGEoF41blKRK8qr9my4qYoD6ikdLss4n8tKqYBecmaY0+WJg==" "integrity": "sha512-yaX2its9XAJKGuQqf7LsiZHHSkxsIK8rmCOQOvEGEoF41blKRK8qr9my4qYoD6ikdLss4n8tKqYBecmaY0+WJg=="
}, },
"vue2-datepicker": { "vue2-datepicker": {
"version": "3.7.0", "version": "3.9.0",
"resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-3.7.0.tgz", "resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-3.9.0.tgz",
"integrity": "sha512-XB5slJZLXf3sbPIOMxjYPw2UlOI/utX4cHGQwGvRQqyiKzwpsGlPI6M3zUGw412Sm2tv2jMkXd9+k+yOSRf2OQ==", "integrity": "sha512-nRqIZx5Ks0TDHFyzyHYIlfmuszEsEvRhwJ6HGuGGHQpjOfrIgkJ9B0pnEEJaVS3LKX6IWCVQMUq0H7I2UKmHqA==",
"requires": { "requires": {
"date-fns": "^2.0.1", "date-format-parse": "^0.2.6"
"date-format-parse": "^0.2.5"
} }
}, },
"vuedraggable": { "vuedraggable": {

View File

@ -30,7 +30,7 @@
"@nextcloud/axios": "^1.6.0", "@nextcloud/axios": "^1.6.0",
"@nextcloud/capabilities": "^1.0.4", "@nextcloud/capabilities": "^1.0.4",
"@nextcloud/dialogs": "^3.1.2", "@nextcloud/dialogs": "^3.1.2",
"@nextcloud/event-bus": "^1.2.0", "@nextcloud/event-bus": "^1.3.0",
"@nextcloud/files": "^1.1.0", "@nextcloud/files": "^1.1.0",
"@nextcloud/initial-state": "^1.2.0", "@nextcloud/initial-state": "^1.2.0",
"@nextcloud/l10n": "^1.4.1", "@nextcloud/l10n": "^1.4.1",
@ -39,7 +39,7 @@
"@nextcloud/password-confirmation": "^1.0.1", "@nextcloud/password-confirmation": "^1.0.1",
"@nextcloud/paths": "^1.1.2", "@nextcloud/paths": "^1.1.2",
"@nextcloud/router": "^1.1.0", "@nextcloud/router": "^1.1.0",
"@nextcloud/vue": "^3.10.0", "@nextcloud/vue": "^3.10.1",
"@nextcloud/vue-dashboard": "^2.0.1", "@nextcloud/vue-dashboard": "^2.0.1",
"autosize": "^4.0.2", "autosize": "^4.0.2",
"backbone": "^1.4.0", "backbone": "^1.4.0",