Merge pull request #22442 from nextcloud/backport/22421/stable19
[stable19] show better quota warning for group folders and external storage
This commit is contained in:
commit
757a35bd01
|
@ -32,6 +32,7 @@ use OC\Files\FileInfo;
|
||||||
use OC\Files\Storage\Wrapper\Quota;
|
use OC\Files\Storage\Wrapper\Quota;
|
||||||
use OCA\DAV\Connector\Sabre\Directory;
|
use OCA\DAV\Connector\Sabre\Directory;
|
||||||
use OCP\Files\ForbiddenException;
|
use OCP\Files\ForbiddenException;
|
||||||
|
use OCP\Files\Mount\IMountPoint;
|
||||||
|
|
||||||
class TestViewDirectory extends \OC\Files\View {
|
class TestViewDirectory extends \OC\Files\View {
|
||||||
private $updatables;
|
private $updatables;
|
||||||
|
@ -269,9 +270,12 @@ class DirectoryTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetQuotaInfoUnlimited() {
|
public function testGetQuotaInfoUnlimited() {
|
||||||
|
$mountPoint = $this->createMock(IMountPoint::class);
|
||||||
$storage = $this->getMockBuilder(Quota::class)
|
$storage = $this->getMockBuilder(Quota::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
$mountPoint->method('getStorage')
|
||||||
|
->willReturn($storage);
|
||||||
|
|
||||||
$storage->expects($this->any())
|
$storage->expects($this->any())
|
||||||
->method('instanceOfStorage')
|
->method('instanceOfStorage')
|
||||||
|
@ -292,8 +296,8 @@ class DirectoryTest extends \Test\TestCase {
|
||||||
->willReturn(200);
|
->willReturn(200);
|
||||||
|
|
||||||
$this->info->expects($this->once())
|
$this->info->expects($this->once())
|
||||||
->method('getStorage')
|
->method('getMountPoint')
|
||||||
->willReturn($storage);
|
->willReturn($mountPoint);
|
||||||
|
|
||||||
$this->view->expects($this->once())
|
$this->view->expects($this->once())
|
||||||
->method('getFileInfo')
|
->method('getFileInfo')
|
||||||
|
@ -304,9 +308,12 @@ class DirectoryTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetQuotaInfoSpecific() {
|
public function testGetQuotaInfoSpecific() {
|
||||||
|
$mountPoint = $this->createMock(IMountPoint::class);
|
||||||
$storage = $this->getMockBuilder(Quota::class)
|
$storage = $this->getMockBuilder(Quota::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
$mountPoint->method('getStorage')
|
||||||
|
->willReturn($storage);
|
||||||
|
|
||||||
$storage->expects($this->any())
|
$storage->expects($this->any())
|
||||||
->method('instanceOfStorage')
|
->method('instanceOfStorage')
|
||||||
|
@ -328,8 +335,8 @@ class DirectoryTest extends \Test\TestCase {
|
||||||
->willReturn(200);
|
->willReturn(200);
|
||||||
|
|
||||||
$this->info->expects($this->once())
|
$this->info->expects($this->once())
|
||||||
->method('getStorage')
|
->method('getMountPoint')
|
||||||
->willReturn($storage);
|
->willReturn($mountPoint);
|
||||||
|
|
||||||
$this->view->expects($this->once())
|
$this->view->expects($this->once())
|
||||||
->method('getFileInfo')
|
->method('getFileInfo')
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
$('#free_space').val(response.data.freeSpace);
|
$('#free_space').val(response.data.freeSpace);
|
||||||
$('#upload.button').attr('data-original-title', response.data.maxHumanFilesize);
|
$('#upload.button').attr('data-original-title', response.data.maxHumanFilesize);
|
||||||
$('#usedSpacePercent').val(response.data.usedSpacePercent);
|
$('#usedSpacePercent').val(response.data.usedSpacePercent);
|
||||||
|
$('#usedSpacePercent').data('mount-type', response.data.mountType);
|
||||||
$('#owner').val(response.data.owner);
|
$('#owner').val(response.data.owner);
|
||||||
$('#ownerDisplayName').val(response.data.ownerDisplayName);
|
$('#ownerDisplayName').val(response.data.ownerDisplayName);
|
||||||
Files.displayStorageWarnings();
|
Files.displayStorageWarnings();
|
||||||
|
@ -155,21 +156,30 @@
|
||||||
|
|
||||||
var usedSpacePercent = $('#usedSpacePercent').val(),
|
var usedSpacePercent = $('#usedSpacePercent').val(),
|
||||||
owner = $('#owner').val(),
|
owner = $('#owner').val(),
|
||||||
ownerDisplayName = $('#ownerDisplayName').val();
|
ownerDisplayName = $('#ownerDisplayName').val(),
|
||||||
|
mountType = $('#usedSpacePercent').data('mount-type');
|
||||||
if (usedSpacePercent > 98) {
|
if (usedSpacePercent > 98) {
|
||||||
if (owner !== OC.getCurrentUser().uid) {
|
if (owner !== OC.getCurrentUser().uid) {
|
||||||
OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!',
|
OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!',
|
||||||
{owner: ownerDisplayName}), {type: 'error'}
|
{owner: ownerDisplayName}), {type: 'error'}
|
||||||
);
|
);
|
||||||
return;
|
} else if (mountType === 'group') {
|
||||||
|
OC.Notification.show(t('files',
|
||||||
|
'This group folder is full, files can not be updated or synced anymore!'),
|
||||||
|
{type: 'error'}
|
||||||
|
);
|
||||||
|
} else if (mountType === 'external') {
|
||||||
|
OC.Notification.show(t('files',
|
||||||
|
'This external storage is full, files can not be updated or synced anymore!'),
|
||||||
|
{type : 'error'}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
OC.Notification.show(t('files',
|
||||||
|
'Your storage is full, files can not be updated or synced anymore!'),
|
||||||
|
{type: 'error'}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
OC.Notification.show(t('files',
|
} else if (usedSpacePercent > 90) {
|
||||||
'Your storage is full, files can not be updated or synced anymore!'),
|
|
||||||
{type : 'error'}
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (usedSpacePercent > 90) {
|
|
||||||
if (owner !== OC.getCurrentUser().uid) {
|
if (owner !== OC.getCurrentUser().uid) {
|
||||||
OC.Notification.show(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)',
|
OC.Notification.show(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)',
|
||||||
{
|
{
|
||||||
|
@ -180,12 +190,24 @@
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
} else if (mountType === 'group') {
|
||||||
|
OC.Notification.show(t('files',
|
||||||
|
'This group folder is almost full ({usedSpacePercent}%)',
|
||||||
|
{usedSpacePercent: usedSpacePercent}),
|
||||||
|
{type : 'error'}
|
||||||
|
);
|
||||||
|
} else if (mountType === 'external') {
|
||||||
|
OC.Notification.show(t('files',
|
||||||
|
'This external storage is almost full ({usedSpacePercent}%)',
|
||||||
|
{usedSpacePercent: usedSpacePercent}),
|
||||||
|
{type : 'error'}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)',
|
||||||
|
{usedSpacePercent: usedSpacePercent}),
|
||||||
|
{type : 'error'}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)',
|
|
||||||
{usedSpacePercent: usedSpacePercent}),
|
|
||||||
{type : 'error'}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ class Helper {
|
||||||
'usedSpacePercent' => (int)$storageInfo['relative'],
|
'usedSpacePercent' => (int)$storageInfo['relative'],
|
||||||
'owner' => $storageInfo['owner'],
|
'owner' => $storageInfo['owner'],
|
||||||
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
|
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
|
||||||
|
'mountType' => $storageInfo['mountType'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -495,7 +495,8 @@ class OC_Helper {
|
||||||
$used = 0;
|
$used = 0;
|
||||||
}
|
}
|
||||||
$quota = \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
$quota = \OCP\Files\FileInfo::SPACE_UNLIMITED;
|
||||||
$storage = $rootInfo->getStorage();
|
$mount = $rootInfo->getMountPoint();
|
||||||
|
$storage = $mount->getStorage();
|
||||||
$sourceStorage = $storage;
|
$sourceStorage = $storage;
|
||||||
if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
|
if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
|
||||||
$includeExtStorage = false;
|
$includeExtStorage = false;
|
||||||
|
@ -553,6 +554,7 @@ class OC_Helper {
|
||||||
'relative' => $relative,
|
'relative' => $relative,
|
||||||
'owner' => $ownerId,
|
'owner' => $ownerId,
|
||||||
'ownerDisplayName' => $ownerDisplayName,
|
'ownerDisplayName' => $ownerDisplayName,
|
||||||
|
'mountType' => $mount->getMountType()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue