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
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/apps/accessibility/js/accessibility.js.map binary
/apps/comments/js/*.js binary
/apps/comments/js/*.js.map binary
/apps/files_sharing/js/additionalScripts.js binary
/apps/files_sharing/js/additionalScripts.js.map binary
/apps/files_sharing/js/dist/*.js binary
/apps/files_sharing/js/dist/*.js.map binary
/apps/files_versions/js/files_versions.js binary
/apps/files_versions/js/files_versions.js.map binary
/apps/oauth2/js/oauth2.js binary
Expand Down
75 changes: 34 additions & 41 deletions apps/files/lib/Collaboration/Resources/ResourceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Joas Schilling <[email protected]>
*
Expand Down Expand Up @@ -27,24 +28,29 @@
use OCP\Collaboration\Resources\ResourceException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IPreview;
use OCP\IURLGenerator;
use OCP\IUser;

class ResourceProvider implements IProvider {

const RESOURCE_TYPE = 'files';
public const RESOURCE_TYPE = 'file';

/** @var IRootFolder */
protected $rootFolder;

/** @var IPreview */
private $preview;
/** @var IURLGenerator */
private $urlGenerator;

/** @var array */
protected $nodes = [];

public function __construct(IRootFolder $rootFolder, IURLGenerator $urlGenerator) {
public function __construct(IRootFolder $rootFolder,
IPreview $preview,
IURLGenerator $urlGenerator) {
$this->rootFolder = $rootFolder;
$this->preview = $preview;
$this->urlGenerator = $urlGenerator;
}

Expand All @@ -61,21 +67,34 @@ private function getNode(IResource $resource): ?Node {
}

/**
* Get the display name of a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
* @return array
* @since 16.0.0
*/
public function getName(IResource $resource): string {
public function getResourceRichObject(IResource $resource): array {
if (isset($this->nodes[(int) $resource->getId()])) {
return $this->nodes[(int) $resource->getId()]->getPath();
$node = $this->nodes[(int) $resource->getId()]->getPath();
} else {
$node = $this->getNode($resource);
}
$node = $this->getNode($resource);
if ($node) {
return $node->getName();

if ($node instanceof Node) {
$link = $this->urlGenerator->linkToRouteAbsolute(
'files.viewcontroller.showFile',
['fileid' => $resource->getId()]
);
return [
'type' => 'file',
'id' => $resource->getId(),
'name' => $node->getName(),
'path' => $node->getInternalPath(),
'link' => $link,
'mimetype' => $node->getMimetype(),
'preview-available' => $this->preview->isAvailable($node),
];
}
return '';

throw new ResourceException('File not found');
}

/**
Expand All @@ -84,7 +103,7 @@ public function getName(IResource $resource): string {
* @param IResource $resource
* @param IUser $user
* @return bool
* @since 15.0.0
* @since 16.0.0
*/
public function canAccessResource(IResource $resource, IUser $user = null): bool {
if (!$user instanceof IUser) {
Expand All @@ -102,39 +121,13 @@ public function canAccessResource(IResource $resource, IUser $user = null): bool
return false;
}

/**
* Get the icon class of a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
*/
public function getIconClass(IResource $resource): string {
$node = $this->getNode($resource);
if ($node && $node->getMimetype() === 'httpd/unix-directory') {
return 'icon-files-dark';
}
return 'icon-filetype-file';
}

/**
* Get the resource type of the provider
*
* @return string
* @since 15.0.0
* @since 16.0.0
*/
public function getType(): string {
return self::RESOURCE_TYPE;
}

/**
* Get the link to a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
*/
public function getLink(IResource $resource): string {
return $this->urlGenerator->linkToRoute('files.viewcontroller.showFile', ['fileid' => $resource->getId()]);
}
}
3 changes: 3 additions & 0 deletions apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function() {
\OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
}
);
\OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
\OCP\Util::addScript('files_sharing', 'dist/collaboration');
});

$config = \OC::$server->getConfig();
$shareManager = \OC::$server->getShareManager();
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/js/dist/additionalScripts.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/additionalScripts.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/files_sharing/js/dist/collaboration.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/files_sharing/js/dist/collaboration.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

566 changes: 563 additions & 3 deletions apps/files_sharing/js/dist/files_sharing.3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing.3.js.map

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions apps/files_sharing/js/dist/files_sharing.4.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/files_sharing/js/dist/files_sharing.4.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading