Skip to content
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
Include the share in the Files_Sharing::loadAdditionalScripts event
This provides a better context for apps using the event, for example to
load one script or another depending on whether the share is a file or a
folder.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and Backportbot committed Oct 19, 2019
commit c765dc46e7786f17aca0e68782494099f5712dc0
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ public function showShare($path = ''): TemplateResponse {
\OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
\OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);

$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts');
$event = new GenericEvent(null, ['share' => $share]);
$this->eventDispatcher->dispatch('OCA\Files_Sharing::loadAdditionalScripts', $event);

$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
Expand Down
14 changes: 12 additions & 2 deletions apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ public function testShowShare() {

$this->eventDispatcher->expects($this->once())
->method('dispatch')
->with('OCA\Files_Sharing::loadAdditionalScripts');
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
$this->callback(function($event) use ($share) {
return $event->getArgument('share') === $share;
})
);

$this->l10n->expects($this->any())
->method('t')
Expand Down Expand Up @@ -374,7 +379,12 @@ public function testShowShareHideDownload() {

$this->eventDispatcher->expects($this->once())
->method('dispatch')
->with('OCA\Files_Sharing::loadAdditionalScripts');
->with(
'OCA\Files_Sharing::loadAdditionalScripts',
$this->callback(function($event) use ($share) {
return $event->getArgument('share') === $share;
})
);

$this->l10n->expects($this->any())
->method('t')
Expand Down