dont offer to edit external config settings if we can't edit them
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
81302f78e5
commit
518e91b008
|
@ -94,7 +94,8 @@ OCA.Files_External.StatusManager = {
|
||||||
id: mountData.id,
|
id: mountData.id,
|
||||||
error: statusMessage,
|
error: statusMessage,
|
||||||
userProvided: response.userProvided,
|
userProvided: response.userProvided,
|
||||||
authMechanism: response.authMechanism
|
authMechanism: response.authMechanism,
|
||||||
|
canEdit: response.can_edit,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
afterCallback(mountData, self.mountStatus[mountData.mount_point]);
|
afterCallback(mountData, self.mountStatus[mountData.mount_point]);
|
||||||
|
@ -182,12 +183,14 @@ OCA.Files_External.StatusManager = {
|
||||||
if (mountData.userProvided || mountData.authMechanism === 'password::global::user') {
|
if (mountData.userProvided || mountData.authMechanism === 'password::global::user') {
|
||||||
// personal mount whit credentials problems
|
// personal mount whit credentials problems
|
||||||
this.showCredentialsDialog(name, mountData);
|
this.showCredentialsDialog(name, mountData);
|
||||||
} else {
|
} else if (mountData.canEdit) {
|
||||||
OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in admin settings page?', t('files_external', 'External mount error'), function (e) {
|
OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in admin settings page?', t('files_external', 'External mount error'), function (e) {
|
||||||
if (e === true) {
|
if (e === true) {
|
||||||
OC.redirect(OC.generateUrl('/settings/admin/externalstorages'));
|
OC.redirect(OC.generateUrl('/settings/admin/externalstorages'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
OC.dialogs.info(t('files_external', 'There was an error with message: ') + mountData.error + '. Please contact your system administrator.', t('files_external', 'External mount error'), () => {});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in personal settings page?', t('files_external', 'External mount error'), function (e) {
|
OC.dialogs.confirm(t('files_external', 'There was an error with message: ') + mountData.error + '. Do you want to review mount point config in personal settings page?', t('files_external', 'External mount error'), function (e) {
|
||||||
|
|
|
@ -32,9 +32,11 @@ use OCA\Files_External\NotFoundException;
|
||||||
use OCA\Files_External\Service\GlobalStoragesService;
|
use OCA\Files_External\Service\GlobalStoragesService;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use OCP\IUserSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global storages controller
|
* Global storages controller
|
||||||
|
@ -48,20 +50,26 @@ class GlobalStoragesController extends StoragesController {
|
||||||
* @param IL10N $l10n l10n service
|
* @param IL10N $l10n l10n service
|
||||||
* @param GlobalStoragesService $globalStoragesService storage service
|
* @param GlobalStoragesService $globalStoragesService storage service
|
||||||
* @param ILogger $logger
|
* @param ILogger $logger
|
||||||
|
* @param IUserSession $userSession
|
||||||
|
* @param IGroupManager $groupManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
GlobalStoragesService $globalStoragesService,
|
GlobalStoragesService $globalStoragesService,
|
||||||
ILogger $logger
|
ILogger $logger,
|
||||||
|
IUserSession $userSession,
|
||||||
|
IGroupManager $groupManager
|
||||||
) {
|
) {
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
$request,
|
$request,
|
||||||
$l10n,
|
$l10n,
|
||||||
$globalStoragesService,
|
$globalStoragesService,
|
||||||
$logger
|
$logger,
|
||||||
|
$userSession,
|
||||||
|
$groupManager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,11 @@ use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\Files\StorageNotAvailableException;
|
use OCP\Files\StorageNotAvailableException;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use OCP\IUserSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for storages controllers
|
* Base class for storages controllers
|
||||||
|
@ -68,6 +70,16 @@ abstract class StoragesController extends Controller {
|
||||||
*/
|
*/
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IUserSession
|
||||||
|
*/
|
||||||
|
protected $userSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IGroupManager
|
||||||
|
*/
|
||||||
|
protected $groupManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new storages controller.
|
* Creates a new storages controller.
|
||||||
*
|
*
|
||||||
|
@ -82,12 +94,16 @@ abstract class StoragesController extends Controller {
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
StoragesService $storagesService,
|
StoragesService $storagesService,
|
||||||
ILogger $logger
|
ILogger $logger,
|
||||||
|
IUserSession $userSession,
|
||||||
|
IGroupManager $groupManager
|
||||||
) {
|
) {
|
||||||
parent::__construct($AppName, $request);
|
parent::__construct($AppName, $request);
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->service = $storagesService;
|
$this->service = $storagesService;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
$this->groupManager = $groupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -337,8 +353,12 @@ abstract class StoragesController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = $this->formatStorageForUI($storage)->jsonSerialize();
|
||||||
|
$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
|
||||||
|
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
|
||||||
|
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
$this->formatStorageForUI($storage),
|
$data,
|
||||||
Http::STATUS_OK
|
Http::STATUS_OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ use OCA\Files_External\NotFoundException;
|
||||||
use OCA\Files_External\Service\UserGlobalStoragesService;
|
use OCA\Files_External\Service\UserGlobalStoragesService;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
@ -46,11 +47,6 @@ use OCP\IUserSession;
|
||||||
* User global storages controller
|
* User global storages controller
|
||||||
*/
|
*/
|
||||||
class UserGlobalStoragesController extends StoragesController {
|
class UserGlobalStoragesController extends StoragesController {
|
||||||
/**
|
|
||||||
* @var IUserSession
|
|
||||||
*/
|
|
||||||
private $userSession;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new user global storages controller.
|
* Creates a new user global storages controller.
|
||||||
*
|
*
|
||||||
|
@ -58,24 +54,28 @@ class UserGlobalStoragesController extends StoragesController {
|
||||||
* @param IRequest $request request object
|
* @param IRequest $request request object
|
||||||
* @param IL10N $l10n l10n service
|
* @param IL10N $l10n l10n service
|
||||||
* @param UserGlobalStoragesService $userGlobalStoragesService storage service
|
* @param UserGlobalStoragesService $userGlobalStoragesService storage service
|
||||||
|
* @param ILogger $logger
|
||||||
* @param IUserSession $userSession
|
* @param IUserSession $userSession
|
||||||
|
* @param IGroupManager $groupManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
UserGlobalStoragesService $userGlobalStoragesService,
|
UserGlobalStoragesService $userGlobalStoragesService,
|
||||||
|
ILogger $logger,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
ILogger $logger
|
IGroupManager $groupManager
|
||||||
) {
|
) {
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
$request,
|
$request,
|
||||||
$l10n,
|
$l10n,
|
||||||
$userGlobalStoragesService,
|
$userGlobalStoragesService,
|
||||||
$logger
|
$logger,
|
||||||
|
$userSession,
|
||||||
|
$groupManager
|
||||||
);
|
);
|
||||||
$this->userSession = $userSession;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,8 +133,12 @@ class UserGlobalStoragesController extends StoragesController {
|
||||||
|
|
||||||
$this->sanitizeStorage($storage);
|
$this->sanitizeStorage($storage);
|
||||||
|
|
||||||
|
$data = $this->formatStorageForUI($storage)->jsonSerialize();
|
||||||
|
$isAdmin = $this->groupManager->isAdmin($this->userSession->getUser()->getUID());
|
||||||
|
$data['can_edit'] = $storage->getType() === StorageConfig::MOUNT_TYPE_PERSONAl || $isAdmin;
|
||||||
|
|
||||||
return new DataResponse(
|
return new DataResponse(
|
||||||
$this->formatStorageForUI($storage),
|
$data,
|
||||||
Http::STATUS_OK
|
Http::STATUS_OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ use OCA\Files_External\NotFoundException;
|
||||||
use OCA\Files_External\Service\UserStoragesService;
|
use OCA\Files_External\Service\UserStoragesService;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
@ -44,11 +45,6 @@ use OCP\IUserSession;
|
||||||
* User storages controller
|
* User storages controller
|
||||||
*/
|
*/
|
||||||
class UserStoragesController extends StoragesController {
|
class UserStoragesController extends StoragesController {
|
||||||
/**
|
|
||||||
* @var IUserSession
|
|
||||||
*/
|
|
||||||
private $userSession;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new user storages controller.
|
* Creates a new user storages controller.
|
||||||
*
|
*
|
||||||
|
@ -56,25 +52,28 @@ class UserStoragesController extends StoragesController {
|
||||||
* @param IRequest $request request object
|
* @param IRequest $request request object
|
||||||
* @param IL10N $l10n l10n service
|
* @param IL10N $l10n l10n service
|
||||||
* @param UserStoragesService $userStoragesService storage service
|
* @param UserStoragesService $userStoragesService storage service
|
||||||
* @param IUserSession $userSession
|
|
||||||
* @param ILogger $logger
|
* @param ILogger $logger
|
||||||
|
* @param IUserSession $userSession
|
||||||
|
* @param IGroupManager $groupManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
UserStoragesService $userStoragesService,
|
UserStoragesService $userStoragesService,
|
||||||
|
ILogger $logger,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
ILogger $logger
|
IGroupManager $groupManager
|
||||||
) {
|
) {
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
$request,
|
$request,
|
||||||
$l10n,
|
$l10n,
|
||||||
$userStoragesService,
|
$userStoragesService,
|
||||||
$logger
|
$logger,
|
||||||
|
$userSession,
|
||||||
|
$groupManager
|
||||||
);
|
);
|
||||||
$this->userSession = $userSession;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function manipulateStorageConfig(StorageConfig $storage) {
|
protected function manipulateStorageConfig(StorageConfig $storage) {
|
||||||
|
|
Loading…
Reference in New Issue