Merge pull request #4521 from nextcloud/custom-mount-types
allow apps to set custom mount types
This commit is contained in:
commit
3e8c5441f7
|
@ -65,6 +65,7 @@ class FilesPlugin extends ServerPlugin {
|
||||||
const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
|
const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
|
||||||
const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
|
const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
|
||||||
const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
|
const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
|
||||||
|
const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to main server object
|
* Reference to main server object
|
||||||
|
@ -159,6 +160,7 @@ class FilesPlugin extends ServerPlugin {
|
||||||
$server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
|
$server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
|
||||||
$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
|
$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
|
||||||
$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
|
$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
|
||||||
|
$server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME;
|
||||||
|
|
||||||
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
|
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
|
||||||
$allowedProperties = ['{DAV:}getetag'];
|
$allowedProperties = ['{DAV:}getetag'];
|
||||||
|
@ -381,6 +383,10 @@ class FilesPlugin extends ServerPlugin {
|
||||||
return $node->getSize();
|
return $node->getSize();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
|
||||||
|
return $node->getFileInfo()->getMountPoint()->getMountType();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1069,6 +1069,8 @@
|
||||||
return OC.MimeType.getIconUrl('dir-shared');
|
return OC.MimeType.getIconUrl('dir-shared');
|
||||||
} else if (fileInfo.mountType === 'external-root') {
|
} else if (fileInfo.mountType === 'external-root') {
|
||||||
return OC.MimeType.getIconUrl('dir-external');
|
return OC.MimeType.getIconUrl('dir-external');
|
||||||
|
} else if (fileInfo.mountType !== undefined && fileInfo.mountType !== '') {
|
||||||
|
return OC.MimeType.getIconUrl('dir-' + fileInfo.mountType);
|
||||||
}
|
}
|
||||||
return OC.MimeType.getIconUrl('dir');
|
return OC.MimeType.getIconUrl('dir');
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,12 +157,9 @@ class Helper {
|
||||||
$entry['isShareMountPoint'] = $i['is_share_mount_point'];
|
$entry['isShareMountPoint'] = $i['is_share_mount_point'];
|
||||||
}
|
}
|
||||||
$mountType = null;
|
$mountType = null;
|
||||||
if ($i->isShared()) {
|
$mount = $i->getMountPoint();
|
||||||
$mountType = 'shared';
|
$mountType = $mount->getMountType();
|
||||||
} else if ($i->isMounted()) {
|
if ($mountType !== '') {
|
||||||
$mountType = 'external';
|
|
||||||
}
|
|
||||||
if ($mountType !== null) {
|
|
||||||
if ($i->getInternalPath() === '') {
|
if ($i->getInternalPath() === '') {
|
||||||
$mountType .= '-root';
|
$mountType .= '-root';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||||
|
*
|
||||||
|
* @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_External\Config;
|
||||||
|
|
||||||
|
use OC\Files\Mount\MountPoint;
|
||||||
|
|
||||||
|
class ExternalMountPoint extends MountPoint {
|
||||||
|
public function getMountType() {
|
||||||
|
return 'external';
|
||||||
|
}
|
||||||
|
}
|
|
@ -258,4 +258,8 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMountType() {
|
||||||
|
return 'shared';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,11 @@
|
||||||
/**
|
/**
|
||||||
* Preview availability
|
* Preview availability
|
||||||
*/
|
*/
|
||||||
[Client.NS_NEXTCLOUD, 'has-preview']
|
[Client.NS_NEXTCLOUD, 'has-preview'],
|
||||||
|
/**
|
||||||
|
* Mount type
|
||||||
|
*/
|
||||||
|
[Client.NS_NEXTCLOUD, 'mount-type'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,6 +365,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mounTypeProp = props['{' + Client.NS_NEXTCLOUD + '}mount-type'];
|
||||||
|
if (!_.isUndefined(mounTypeProp)) {
|
||||||
|
data.mountType = mounTypeProp;
|
||||||
|
}
|
||||||
|
|
||||||
// extend the parsed data using the custom parsers
|
// extend the parsed data using the custom parsers
|
||||||
_.each(this._fileInfoParsers, function(parserFunction) {
|
_.each(this._fileInfoParsers, function(parserFunction) {
|
||||||
_.extend(data, parserFunction(response) || {});
|
_.extend(data, parserFunction(response) || {});
|
||||||
|
|
|
@ -274,4 +274,8 @@ class MountPoint implements IMountPoint {
|
||||||
public function getMountId() {
|
public function getMountId() {
|
||||||
return $this->mountId;
|
return $this->mountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMountType() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,4 +119,13 @@ interface IMountPoint {
|
||||||
* @since 9.1.0
|
* @since 9.1.0
|
||||||
*/
|
*/
|
||||||
public function getMountId();
|
public function getMountId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of mount point, used to distinguish things like shares and external storages
|
||||||
|
* in the web interface
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 12.0.0
|
||||||
|
*/
|
||||||
|
public function getMountType();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue