Merge pull request #14664 from nextcloud/bugfix/noid/absolute-paths-of-images-for-linked-collaboration-resources
Replace the icon-class with an absolute link to an image
This commit is contained in:
commit
2fcb6ddc22
28 changed files with 96 additions and 189 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
@ -27,24 +28,29 @@ use OCP\Collaboration\Resources\IResource;
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -61,21 +67,34 @@ class ResourceProvider implements IProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +103,7 @@ class ResourceProvider implements IProvider {
|
|||
* @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) {
|
||||
|
@ -102,39 +121,13 @@ class ResourceProvider implements IProvider {
|
|||
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()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ $eventDispatcher->addListener(
|
|||
\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();
|
||||
|
|
BIN
apps/files_sharing/js/dist/additionalScripts.js
vendored
BIN
apps/files_sharing/js/dist/additionalScripts.js
vendored
Binary file not shown.
BIN
apps/files_sharing/js/dist/additionalScripts.js.map
vendored
BIN
apps/files_sharing/js/dist/additionalScripts.js.map
vendored
Binary file not shown.
BIN
apps/files_sharing/js/dist/collaboration.js
vendored
Normal file
BIN
apps/files_sharing/js/dist/collaboration.js
vendored
Normal file
Binary file not shown.
BIN
apps/files_sharing/js/dist/collaboration.js.map
vendored
Normal file
BIN
apps/files_sharing/js/dist/collaboration.js.map
vendored
Normal file
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.3.js
vendored
BIN
apps/files_sharing/js/dist/files_sharing.3.js
vendored
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.3.js.map
vendored
BIN
apps/files_sharing/js/dist/files_sharing.3.js.map
vendored
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.4.js
vendored
Normal file
BIN
apps/files_sharing/js/dist/files_sharing.4.js
vendored
Normal file
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.4.js.map
vendored
Normal file
BIN
apps/files_sharing/js/dist/files_sharing.4.js.map
vendored
Normal file
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.js
vendored
BIN
apps/files_sharing/js/dist/files_sharing.js
vendored
Binary file not shown.
BIN
apps/files_sharing/js/dist/files_sharing.js.map
vendored
BIN
apps/files_sharing/js/dist/files_sharing.js.map
vendored
Binary file not shown.
|
@ -33,5 +33,6 @@ $tmpl = new OCP\Template('files_sharing', 'list', '');
|
|||
$tmpl->assign('showgridview', $showgridview && !$isIE);
|
||||
|
||||
OCP\Util::addScript('files_sharing', 'dist/files_sharing');
|
||||
\OC::$server->getEventDispatcher()->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts');
|
||||
|
||||
$tmpl->printPage();
|
||||
|
|
|
@ -8,22 +8,6 @@ import './sharebreadcrumbview'
|
|||
import './style/sharetabview.scss'
|
||||
import './style/sharebreadcrumb.scss'
|
||||
|
||||
window.OCP.Collaboration.registerType('files', {
|
||||
action: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
OC.dialogs.filepicker('Link to a file', function (f) {
|
||||
const client = OC.Files.getClient();
|
||||
client.getFileInfo(f).then((status, fileInfo) => {
|
||||
resolve(fileInfo.id);
|
||||
}, () => {
|
||||
reject();
|
||||
});
|
||||
}, false);
|
||||
});
|
||||
},
|
||||
/** used in "Link to a {typeString}" */
|
||||
typeString: t('files_sharing', 'file'),
|
||||
typeIconClass: 'icon-files-dark'
|
||||
});
|
||||
import './collaborationresourceshandler.js'
|
||||
|
||||
window.OCA.Sharing = OCA.Sharing;
|
||||
|
|
20
apps/files_sharing/src/collaborationresourceshandler.js
Normal file
20
apps/files_sharing/src/collaborationresourceshandler.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/');
|
||||
__webpack_nonce__ = btoa(OC.requestToken);
|
||||
|
||||
window.OCP.Collaboration.registerType('file', {
|
||||
action: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
OC.dialogs.filepicker('Link to a file', function (f) {
|
||||
const client = OC.Files.getClient();
|
||||
client.getFileInfo(f).then((status, fileInfo) => {
|
||||
resolve(fileInfo.id);
|
||||
}, () => {
|
||||
reject();
|
||||
});
|
||||
}, false);
|
||||
});
|
||||
},
|
||||
/** used in "Link to a {typeString}" */
|
||||
typeString: t('files_sharing', 'file'),
|
||||
typeIconClass: 'icon-files-dark'
|
||||
});
|
|
@ -21,7 +21,7 @@
|
|||
-->
|
||||
|
||||
<template>
|
||||
<collection-list v-if="fileId" type="files" :id="fileId" :name="filename"></collection-list>
|
||||
<collection-list v-if="fileId" type="file" :id="fileId" :name="filename"></collection-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -5,6 +5,7 @@ module.exports = {
|
|||
entry: {
|
||||
'additionalScripts': path.join(__dirname, 'src', 'additionalScripts.js'),
|
||||
'files_sharing': path.join(__dirname, 'src', 'files_sharing.js'),
|
||||
'collaboration': path.join(__dirname, 'src', 'collaborationresourceshandler.js'),
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, './js/dist/'),
|
||||
|
|
|
@ -166,7 +166,7 @@ class CollaborationResourcesController extends OCSController {
|
|||
try {
|
||||
$resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser());
|
||||
} catch (ResourceException $e) {
|
||||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
$resource = $this->manager->createResource($resourceType, $resourceId);
|
||||
}
|
||||
|
||||
if (!$resource->canAccess($this->userSession->getUser())) {
|
||||
|
@ -241,12 +241,6 @@ class CollaborationResourcesController extends OCSController {
|
|||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $resource->getType(),
|
||||
'id' => $resource->getId(),
|
||||
'name' => $resource->getName(),
|
||||
'iconClass' => $resource->getIconClass(),
|
||||
'link' => $resource->getLink(),
|
||||
];
|
||||
return $resource->getRichObject();
|
||||
}
|
||||
}
|
||||
|
|
BIN
core/js/dist/main.js
vendored
BIN
core/js/dist/main.js
vendored
Binary file not shown.
BIN
core/js/dist/main.js.map
vendored
BIN
core/js/dist/main.js.map
vendored
Binary file not shown.
|
@ -39,7 +39,6 @@ export default {
|
|||
* @param {TypeDefinition} typeDefinition
|
||||
*/
|
||||
registerType(type, typeDefinition) {
|
||||
console.log('Type ' + type + ' registered')
|
||||
types[type] = typeDefinition;
|
||||
},
|
||||
trigger(type) {
|
||||
|
|
|
@ -285,41 +285,23 @@ class Manager implements IManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the display name of a resource
|
||||
* Get the rich object data of a resource
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
* @return array
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getName(IResource $resource): string {
|
||||
public function getResourceRichObject(IResource $resource): array {
|
||||
foreach ($this->getProviders() as $provider) {
|
||||
if ($provider->getType() === $resource->getType()) {
|
||||
try {
|
||||
return $provider->getName($resource);
|
||||
return $provider->getResourceRichObject($resource);
|
||||
} catch (ResourceException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
*/
|
||||
public function getIconClass(IResource $resource): string {
|
||||
foreach ($this->getProviders() as $provider) {
|
||||
if ($provider->getType() === $resource->getType()) {
|
||||
try {
|
||||
return $provider->getIconClass($resource);
|
||||
} catch (ResourceException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,24 +523,4 @@ class Manager implements IManager {
|
|||
public function getType(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link to a resource
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getLink(IResource $resource): string {
|
||||
foreach ($this->getProviders() as $provider) {
|
||||
if ($provider->getType() === $resource->getType()) {
|
||||
try {
|
||||
return $provider->getLink($resource);
|
||||
} catch (ResourceException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,8 @@ class Resource implements IResource {
|
|||
/** @var bool|null */
|
||||
protected $access;
|
||||
|
||||
/** @var string|null */
|
||||
protected $name;
|
||||
|
||||
/** @var string|null */
|
||||
protected $iconClass;
|
||||
|
||||
/** @var string|null */
|
||||
protected $link;
|
||||
/** @var array|null */
|
||||
protected $data;
|
||||
|
||||
public function __construct(
|
||||
IManager $manager,
|
||||
|
@ -91,35 +85,15 @@ class Resource implements IResource {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return array
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getName(): string {
|
||||
if ($this->name === null) {
|
||||
$this->name = $this->manager->getName($this);
|
||||
public function getRichObject(): array {
|
||||
if ($this->data === null) {
|
||||
$this->data = $this->manager->getResourceRichObject($this);
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getIconClass(): string {
|
||||
if ($this->iconClass === null) {
|
||||
$this->iconClass = $this->manager->getIconClass($this);
|
||||
}
|
||||
|
||||
return $this->iconClass;
|
||||
}
|
||||
|
||||
public function getLink(): string {
|
||||
if ($this->link === null) {
|
||||
$this->link = $this->manager->getLink($this);
|
||||
}
|
||||
|
||||
return $this->link;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,31 +38,13 @@ interface IProvider {
|
|||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* Get the display name of a resource
|
||||
* Get the rich object data of a resource
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
* @return array
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getName(IResource $resource): string;
|
||||
|
||||
/**
|
||||
* Get the icon class of a resource
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getIconClass(IResource $resource): string;
|
||||
|
||||
/**
|
||||
* Get the link to a resource
|
||||
*
|
||||
* @param IResource $resource
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getLink(IResource $resource): string;
|
||||
public function getResourceRichObject(IResource $resource): array;
|
||||
|
||||
/**
|
||||
* Can a user/guest access the collection
|
||||
|
|
|
@ -42,22 +42,10 @@ interface IResource {
|
|||
public function getId(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return array
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getIconClass(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 16.0.0
|
||||
*/
|
||||
public function getLink(): string;
|
||||
public function getRichObject(): array;
|
||||
|
||||
/**
|
||||
* Can a user/guest access the resource
|
||||
|
|
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -4812,12 +4812,12 @@
|
|||
}
|
||||
},
|
||||
"nextcloud-vue-collections": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-vue-collections/-/nextcloud-vue-collections-0.1.2.tgz",
|
||||
"integrity": "sha512-GoGvQSbBQWJQCjIPQVyKXvY2C289rZnqOo6LhpI8c7J9SuviHrbfUe5nAUZoyY5L6nsUHy5BUXtP6ppa+oiwbw==",
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-vue-collections/-/nextcloud-vue-collections-0.2.0.tgz",
|
||||
"integrity": "sha512-LDbJyUZffu8ZIkkXAMXkfqkUK36GaUiuS4IdgoOLe/z9prV/Iic7uwrDME015FsCv9GmfheOs7cfiU6xBIidGA==",
|
||||
"requires": {
|
||||
"nextcloud-axios": "^0.1.2",
|
||||
"nextcloud-vue": "^0.7.0",
|
||||
"nextcloud-vue": "^0.9.0",
|
||||
"v-tooltip": "^2.0.0-rc.33",
|
||||
"vue": "^2.6.6",
|
||||
"vue-click-outside": "^1.0.7",
|
||||
|
@ -4825,9 +4825,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"nextcloud-vue": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-vue/-/nextcloud-vue-0.7.1.tgz",
|
||||
"integrity": "sha512-7KtOuZh2hGlppN8zyxGU+tg/8SxO/DYxed7NG4m6YpaCpFJXg/OKADlKTy44meHXnnCW/+TPeDTh+KvPKxU/Sw==",
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/nextcloud-vue/-/nextcloud-vue-0.9.1.tgz",
|
||||
"integrity": "sha512-8Lmout8Y6+zNPHqZ8rV7GcuKRbFpM8EserkvhkXAJYymq9mblz2NkfmOzhOGxhRICfPHnZ/xFUTxUuaSus4p+Q==",
|
||||
"requires": {
|
||||
"hammerjs": "^2.0.8",
|
||||
"md5": "^2.2.1",
|
||||
|
@ -4836,6 +4836,7 @@
|
|||
"vue": "^2.6.7",
|
||||
"vue-click-outside": "^1.0.7",
|
||||
"vue-multiselect": "^2.1.3",
|
||||
"vue-visible": "^1.0.2",
|
||||
"vue2-datepicker": "^2.10.0"
|
||||
}
|
||||
}
|
||||
|
@ -7190,6 +7191,11 @@
|
|||
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
|
||||
"dev": true
|
||||
},
|
||||
"vue-visible": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/vue-visible/-/vue-visible-1.0.2.tgz",
|
||||
"integrity": "sha512-yaX2its9XAJKGuQqf7LsiZHHSkxsIK8rmCOQOvEGEoF41blKRK8qr9my4qYoD6ikdLss4n8tKqYBecmaY0+WJg=="
|
||||
},
|
||||
"vue2-datepicker": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/vue2-datepicker/-/vue2-datepicker-2.10.0.tgz",
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"nextcloud-axios": "^0.1.3",
|
||||
"nextcloud-password-confirmation": "^0.4.1",
|
||||
"nextcloud-vue": "^0.8.0",
|
||||
"nextcloud-vue-collections": "^0.1.2",
|
||||
"nextcloud-vue-collections": "^0.2.0",
|
||||
"snap.js": "^2.0.9",
|
||||
"strengthify": "git+https://github.com/MorrisJobke/strengthify.git",
|
||||
"underscore": "^1.9.1",
|
||||
|
|
Loading…
Reference in a new issue