Merge pull request #10230 from nextcloud/feature/shareoverview
Feature/shares overview
This commit is contained in:
commit
a155f80485
|
@ -39,24 +39,29 @@ $templateManager->registerTemplate('application/vnd.oasis.opendocument.presentat
|
||||||
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
|
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
|
||||||
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
|
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
|
||||||
|
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () use ($l) {
|
\OCA\Files\App::getNavigationManager()->add([
|
||||||
return [
|
'id' => 'files',
|
||||||
'id' => 'files',
|
'appname' => 'files',
|
||||||
'appname' => 'files',
|
'script' => 'list.php',
|
||||||
'script' => 'list.php',
|
'order' => 0,
|
||||||
'order' => 0,
|
'name' => $l->t('All files')
|
||||||
'name' => $l->t('All files'),
|
]);
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () use ($l) {
|
\OCA\Files\App::getNavigationManager()->add([
|
||||||
return [
|
'id' => 'recent',
|
||||||
'id' => 'recent',
|
'appname' => 'files',
|
||||||
'appname' => 'files',
|
'script' => 'recentlist.php',
|
||||||
'script' => 'recentlist.php',
|
'order' => 2,
|
||||||
'order' => 2,
|
'name' => $l->t('Recent')
|
||||||
'name' => $l->t('Recent'),
|
]);
|
||||||
];
|
|
||||||
});
|
\OCA\Files\App::getNavigationManager()->add([
|
||||||
|
'id' => 'favorites',
|
||||||
|
'appname' => 'files',
|
||||||
|
'script' => 'simplelist.php',
|
||||||
|
'order' => 5,
|
||||||
|
'name' => $l->t('Favorites'),
|
||||||
|
'expandedState' => 'show_Quick_Access'
|
||||||
|
]);
|
||||||
|
|
||||||
\OCP\Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
|
\OCP\Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
|
||||||
|
|
|
@ -77,14 +77,9 @@ $application->registerRoutes(
|
||||||
'verb' => 'GET',
|
'verb' => 'GET',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'API#showQuickAccess',
|
'name' => 'API#toggleShowFolder',
|
||||||
'url' => '/api/v1/quickaccess/set/showList',
|
'url' => '/api/v1/toggleShowFolder/{key}',
|
||||||
'verb' => 'GET',
|
'verb' => 'POST'
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'API#getShowQuickAccess',
|
|
||||||
'url' => '/api/v1/quickaccess/get/showList',
|
|
||||||
'verb' => 'GET',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'API#getShowQuickaccessSettings',
|
'name' => 'API#getShowQuickaccessSettings',
|
||||||
|
|
|
@ -93,7 +93,8 @@
|
||||||
background-image: url('../img/star.svg?v=1');
|
background-image: url('../img/star.svg?v=1');
|
||||||
}
|
}
|
||||||
.nav-icon-sharingin,
|
.nav-icon-sharingin,
|
||||||
.nav-icon-sharingout {
|
.nav-icon-sharingout,
|
||||||
|
.nav-icon-shareoverview {
|
||||||
background-image: url('../img/share.svg?v=1');
|
background-image: url('../img/share.svg?v=1');
|
||||||
}
|
}
|
||||||
.nav-icon-sharinglinks {
|
.nav-icon-sharinglinks {
|
||||||
|
|
|
@ -172,30 +172,18 @@
|
||||||
*/
|
*/
|
||||||
_onClickMenuButton: function (ev) {
|
_onClickMenuButton: function (ev) {
|
||||||
var $target = $(ev.target);
|
var $target = $(ev.target);
|
||||||
|
var $menu = $target.parent('li');
|
||||||
var itemId = $target.closest('button').attr('id');
|
var itemId = $target.closest('button').attr('id');
|
||||||
|
|
||||||
var collapsibleToggles = [];
|
var collapsibleToggles = [];
|
||||||
var dotmenuToggles = [];
|
var dotmenuToggles = [];
|
||||||
|
|
||||||
// The collapsibleToggles-Array consists of a list of Arrays. Every subarray must contain the Button to listen to at the 0th index,
|
if ($menu.hasClass('collapsible') && $menu.data('expandedstate')) {
|
||||||
// and the parent, which should be toggled at the first arrayindex.
|
$menu.toggleClass('open');
|
||||||
collapsibleToggles.push(["#button-collapse-favorites", "#button-collapse-parent-favorites"]);
|
var show = $menu.hasClass('open') ? 1 : 0;
|
||||||
|
var key = $menu.data('expandedstate');
|
||||||
// The dotmenuToggles-Array consists of a list of Arrays. Every subarray must contain the Button to listen to at the 0th index,
|
$.post(OC.generateUrl("/apps/files/api/v1/toggleShowFolder/" + key), {show: show});
|
||||||
// and the parent, which should be toggled at the first arrayindex.
|
}
|
||||||
dotmenuToggles.push(["#dotmenu-button-favorites", "dotmenu-content-favorites"]);
|
|
||||||
|
|
||||||
collapsibleToggles.forEach(function foundToggle (item) {
|
|
||||||
if (item[0] === ("#" + itemId)) {
|
|
||||||
$(item[1]).toggleClass('open');
|
|
||||||
var show = 1;
|
|
||||||
if (!$(item[1]).hasClass('open')) {
|
|
||||||
show = 0;
|
|
||||||
}
|
|
||||||
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showList"), {show: show}, function (data, status) {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dotmenuToggles.forEach(function foundToggle (item) {
|
dotmenuToggles.forEach(function foundToggle (item) {
|
||||||
if (item[0] === ("#" + itemId)) {
|
if (item[0] === ("#" + itemId)) {
|
||||||
|
|
|
@ -68,29 +68,22 @@
|
||||||
* @param {String} appfolder folder to be removed
|
* @param {String} appfolder folder to be removed
|
||||||
*/
|
*/
|
||||||
function removeFavoriteFromList (appfolder) {
|
function removeFavoriteFromList (appfolder) {
|
||||||
|
|
||||||
var quickAccessList = 'sublist-favorites';
|
var quickAccessList = 'sublist-favorites';
|
||||||
var collapsibleButtonId = 'button-collapse-favorites';
|
|
||||||
var listULElements = document.getElementById(quickAccessList);
|
var listULElements = document.getElementById(quickAccessList);
|
||||||
if (!listULElements) {
|
if (!listULElements) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var listLIElements = listULElements.getElementsByTagName('li');
|
|
||||||
|
|
||||||
var apppath=appfolder;
|
var apppath=appfolder;
|
||||||
if(appfolder.startsWith("//")){
|
if(appfolder.startsWith("//")){
|
||||||
apppath=appfolder.substring(1, appfolder.length);
|
apppath=appfolder.substring(1, appfolder.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i <= listLIElements.length - 1; i++) {
|
$(listULElements).find('[data-dir="' + apppath + '"]').remove();
|
||||||
if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + apppath)) {
|
|
||||||
listLIElements[i].remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listULElements.childElementCount === 0) {
|
if (listULElements.childElementCount === 0) {
|
||||||
var collapsibleButton = document.getElementById("button-collapse-favorites");
|
var collapsibleButton = $(listULElements).parent().find('button.collapse');
|
||||||
collapsibleButton.style.display = 'none';
|
collapsibleButton.hide();
|
||||||
$("#button-collapse-parent-favorites").removeClass('collapsible');
|
$("#button-collapse-parent-favorites").removeClass('collapsible');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +95,6 @@
|
||||||
*/
|
*/
|
||||||
function addFavoriteToList (appfolder) {
|
function addFavoriteToList (appfolder) {
|
||||||
var quickAccessList = 'sublist-favorites';
|
var quickAccessList = 'sublist-favorites';
|
||||||
var collapsibleButtonId = 'button-collapse-favorites';
|
|
||||||
var listULElements = document.getElementById(quickAccessList);
|
var listULElements = document.getElementById(quickAccessList);
|
||||||
if (!listULElements) {
|
if (!listULElements) {
|
||||||
return;
|
return;
|
||||||
|
@ -110,12 +102,12 @@
|
||||||
var listLIElements = listULElements.getElementsByTagName('li');
|
var listLIElements = listULElements.getElementsByTagName('li');
|
||||||
|
|
||||||
var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
|
var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
|
||||||
var apppath=appfolder;
|
var apppath = appfolder;
|
||||||
|
|
||||||
if(appfolder.startsWith("//")){
|
if(appfolder.startsWith("//")){
|
||||||
apppath=appfolder.substring(1, appfolder.length);
|
apppath = appfolder.substring(1, appfolder.length);
|
||||||
}
|
}
|
||||||
var url=OC.generateUrl('/apps/files/?dir=')+apppath;
|
var url = OC.generateUrl('/apps/files/?dir=' + apppath + '&view=files');
|
||||||
|
|
||||||
|
|
||||||
var innerTagA = document.createElement('A');
|
var innerTagA = document.createElement('A');
|
||||||
|
@ -125,7 +117,9 @@
|
||||||
|
|
||||||
var length = listLIElements.length + 1;
|
var length = listLIElements.length + 1;
|
||||||
var innerTagLI = document.createElement('li');
|
var innerTagLI = document.createElement('li');
|
||||||
innerTagLI.setAttribute("data-id", url);
|
innerTagLI.setAttribute("data-id", apppath.replace('/', '-'));
|
||||||
|
innerTagLI.setAttribute("data-dir", apppath);
|
||||||
|
innerTagLI.setAttribute("data-view", 'files');
|
||||||
innerTagLI.setAttribute("class", "nav-" + appName);
|
innerTagLI.setAttribute("class", "nav-" + appName);
|
||||||
innerTagLI.setAttribute("folderpos", length.toString());
|
innerTagLI.setAttribute("folderpos", length.toString());
|
||||||
innerTagLI.appendChild(innerTagA);
|
innerTagLI.appendChild(innerTagA);
|
||||||
|
@ -134,10 +128,9 @@
|
||||||
if (data === "dir") {
|
if (data === "dir") {
|
||||||
if (listULElements.childElementCount <= 0) {
|
if (listULElements.childElementCount <= 0) {
|
||||||
listULElements.appendChild(innerTagLI);
|
listULElements.appendChild(innerTagLI);
|
||||||
var collapsibleButton = document.getElementById(collapsibleButtonId);
|
var collapsibleButton = $(listULElements).parent().find('button.collapse');
|
||||||
collapsibleButton.style.display = '';
|
collapsibleButton.show();
|
||||||
|
$(listULElements).parent().addClass('collapsible');
|
||||||
$("#button-collapse-parent-favorites").addClass('collapsible');
|
|
||||||
} else {
|
} else {
|
||||||
listLIElements[listLIElements.length - 1].after(innerTagLI);
|
listLIElements[listLIElements.length - 1].after(innerTagLI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,29 +291,28 @@ class ApiController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle default for showing/hiding QuickAccess folder
|
* Toggle default for showing/hiding xxx folder
|
||||||
*
|
*
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
* @param bool $show
|
* @param bool $show
|
||||||
|
* @param bool $key the key of the folder
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function showQuickAccess($show) {
|
public function toggleShowFolder(int $show, string $key) {
|
||||||
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int)$show);
|
// ensure the edited key exists
|
||||||
return new Response();
|
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
|
||||||
}
|
foreach ($navItems as $item) {
|
||||||
|
// check if data is valid
|
||||||
/**
|
if (($show === 0 || $show === 1) && isset($item['expandedState']) && $key === $item['expandedState']) {
|
||||||
* Toggle default for showing/hiding QuickAccess folder
|
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', $key, (int)$show);
|
||||||
*
|
return new Response();
|
||||||
* @NoAdminRequired
|
}
|
||||||
*
|
}
|
||||||
* @return String
|
$response = new Response();
|
||||||
*/
|
$response->setStatus(Http::STATUS_FORBIDDEN);
|
||||||
public function getShowQuickAccess() {
|
return $response;
|
||||||
|
|
||||||
return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,8 @@ use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||||
use OCP\AppFramework\Http\RedirectResponse;
|
use OCP\AppFramework\Http\RedirectResponse;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\App\IAppManager;
|
||||||
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
@ -41,8 +43,6 @@ use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use OCP\Files\Folder;
|
|
||||||
use OCP\App\IAppManager;
|
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,27 +73,27 @@ class ViewController extends Controller {
|
||||||
protected $activityHelper;
|
protected $activityHelper;
|
||||||
|
|
||||||
public function __construct(string $appName,
|
public function __construct(string $appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
EventDispatcherInterface $eventDispatcherInterface,
|
EventDispatcherInterface $eventDispatcherInterface,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
IAppManager $appManager,
|
IAppManager $appManager,
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
Helper $activityHelper
|
Helper $activityHelper
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->appName = $appName;
|
$this->appName = $appName;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->eventDispatcher = $eventDispatcherInterface;
|
$this->eventDispatcher = $eventDispatcherInterface;
|
||||||
$this->userSession = $userSession;
|
$this->userSession = $userSession;
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
$this->activityHelper = $activityHelper;
|
$this->activityHelper = $activityHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,8 +102,8 @@ class ViewController extends Controller {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function renderScript($appName, $scriptName) {
|
protected function renderScript($appName, $scriptName) {
|
||||||
$content = '';
|
$content = '';
|
||||||
$appPath = \OC_App::getAppPath($appName);
|
$appPath = \OC_App::getAppPath($appName);
|
||||||
$scriptPath = $appPath . '/' . $scriptName;
|
$scriptPath = $appPath . '/' . $scriptName;
|
||||||
if (file_exists($scriptPath)) {
|
if (file_exists($scriptPath)) {
|
||||||
// TODO: sanitize path / script name ?
|
// TODO: sanitize path / script name ?
|
||||||
|
@ -112,6 +112,7 @@ class ViewController extends Controller {
|
||||||
$content = ob_get_contents();
|
$content = ob_get_contents();
|
||||||
@ob_end_clean();
|
@ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ class ViewController extends Controller {
|
||||||
*/
|
*/
|
||||||
protected function getStorageInfo() {
|
protected function getStorageInfo() {
|
||||||
$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
|
$dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
|
||||||
|
|
||||||
return \OC_Helper::getStorageInfo('/', $dirInfo);
|
return \OC_Helper::getStorageInfo('/', $dirInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +158,7 @@ class ViewController extends Controller {
|
||||||
|
|
||||||
$user = $this->userSession->getUser()->getUID();
|
$user = $this->userSession->getUser()->getUID();
|
||||||
|
|
||||||
|
// Get all the user favorites to create a submenu
|
||||||
try {
|
try {
|
||||||
$favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
|
$favElements = $this->activityHelper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
|
@ -170,21 +173,21 @@ class ViewController extends Controller {
|
||||||
$favoritesSublistArray = Array();
|
$favoritesSublistArray = Array();
|
||||||
|
|
||||||
$navBarPositionPosition = 6;
|
$navBarPositionPosition = 6;
|
||||||
$currentCount = 0;
|
$currentCount = 0;
|
||||||
foreach ($favElements['folders'] as $dir) {
|
foreach ($favElements['folders'] as $dir) {
|
||||||
|
|
||||||
$id = substr($dir, strrpos($dir, '/') + 1, strlen($dir));
|
$id = substr($dir, strrpos($dir, '/') + 1, strlen($dir));
|
||||||
$link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
|
$link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']);
|
||||||
$sortingValue = ++$currentCount;
|
$sortingValue = ++$currentCount;
|
||||||
$element = [
|
$element = [
|
||||||
'id' => str_replace('/', '-', $dir),
|
'id' => str_replace('/', '-', $dir),
|
||||||
'view' => 'files',
|
'view' => 'files',
|
||||||
'href' => $link,
|
'href' => $link,
|
||||||
'dir' => $dir,
|
'dir' => $dir,
|
||||||
'order' => $navBarPositionPosition,
|
'order' => $navBarPositionPosition,
|
||||||
'folderPosition' => $sortingValue,
|
'folderPosition' => $sortingValue,
|
||||||
'name' => $id,
|
'name' => $id,
|
||||||
'icon' => 'files',
|
'icon' => 'files',
|
||||||
'quickaccesselement' => 'true'
|
'quickaccesselement' => 'true'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -192,28 +195,18 @@ class ViewController extends Controller {
|
||||||
$navBarPositionPosition++;
|
$navBarPositionPosition++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// show_Quick_Access stored as string
|
|
||||||
$defaultExpandedState = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', '0') === '1';
|
|
||||||
|
|
||||||
\OCA\Files\App::getNavigationManager()->add(
|
|
||||||
[
|
|
||||||
'id' => 'favorites',
|
|
||||||
'appname' => 'files',
|
|
||||||
'script' => 'simplelist.php',
|
|
||||||
'classes' => $collapseClasses,
|
|
||||||
'order' => 5,
|
|
||||||
'name' => $this->l10n->t('Favorites'),
|
|
||||||
'sublist' => $favoritesSublistArray,
|
|
||||||
'defaultExpandedState' => $defaultExpandedState,
|
|
||||||
'enableMenuButton' => 0,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
|
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
|
||||||
usort($navItems, function ($item1, $item2) {
|
|
||||||
return $item1['order'] - $item2['order'];
|
// add the favorites entry in menu
|
||||||
});
|
$navItems['favorites']['sublist'] = $favoritesSublistArray;
|
||||||
|
$navItems['favorites']['classes'] = $collapseClasses;
|
||||||
|
|
||||||
|
// parse every menu and add the expandedState user value
|
||||||
|
foreach ($navItems as $key => $item) {
|
||||||
|
if (isset($item['expandedState'])) {
|
||||||
|
$navItems[$key]['defaultExpandedState'] = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', $item['expandedState'], '0') === '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$nav->assign('navigationItems', $navItems);
|
$nav->assign('navigationItems', $navItems);
|
||||||
|
|
||||||
|
@ -235,29 +228,42 @@ class ViewController extends Controller {
|
||||||
if (isset($item['script'])) {
|
if (isset($item['script'])) {
|
||||||
$content = $this->renderScript($item['appname'], $item['script']);
|
$content = $this->renderScript($item['appname'], $item['script']);
|
||||||
}
|
}
|
||||||
$contentItem = [];
|
// parse submenus
|
||||||
$contentItem['id'] = $item['id'];
|
if (isset($item['sublist'])) {
|
||||||
$contentItem['content'] = $content;
|
foreach ($item['sublist'] as $subitem) {
|
||||||
$contentItems[] = $contentItem;
|
$subcontent = '';
|
||||||
|
if (isset($subitem['script'])) {
|
||||||
|
$subcontent = $this->renderScript($subitem['appname'], $subitem['script']);
|
||||||
|
}
|
||||||
|
$contentItems[$subitem['id']] = [
|
||||||
|
'id' => $subitem['id'],
|
||||||
|
'content' => $subcontent
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$contentItems[$item['id']] = [
|
||||||
|
'id' => $item['id'],
|
||||||
|
'content' => $content
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new GenericEvent(null, ['hiddenFields' => []]);
|
$event = new GenericEvent(null, ['hiddenFields' => []]);
|
||||||
$this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts', $event);
|
$this->eventDispatcher->dispatch('OCA\Files::loadAdditionalScripts', $event);
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
$params['usedSpacePercent'] = (int)$storageInfo['relative'];
|
$params['usedSpacePercent'] = (int) $storageInfo['relative'];
|
||||||
$params['owner'] = $storageInfo['owner'];
|
$params['owner'] = $storageInfo['owner'];
|
||||||
$params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
|
$params['ownerDisplayName'] = $storageInfo['ownerDisplayName'];
|
||||||
$params['isPublic'] = false;
|
$params['isPublic'] = false;
|
||||||
$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
|
$params['allowShareWithLink'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');
|
||||||
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
|
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
|
||||||
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
|
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
|
||||||
$showHidden = (bool)$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
|
$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
|
||||||
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
|
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
|
||||||
$params['fileNotFound'] = $fileNotFound ? 1 : 0;
|
$params['fileNotFound'] = $fileNotFound ? 1 : 0;
|
||||||
$params['appNavigation'] = $nav;
|
$params['appNavigation'] = $nav;
|
||||||
$params['appContents'] = $contentItems;
|
$params['appContents'] = $contentItems;
|
||||||
$params['hiddenFields'] = $event->getArgument('hiddenFields');
|
$params['hiddenFields'] = $event->getArgument('hiddenFields');
|
||||||
|
|
||||||
$response = new TemplateResponse(
|
$response = new TemplateResponse(
|
||||||
$this->appName,
|
$this->appName,
|
||||||
|
@ -268,7 +274,6 @@ class ViewController extends Controller {
|
||||||
$policy->addAllowedFrameDomain('\'self\'');
|
$policy->addAllowedFrameDomain('\'self\'');
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,14 +285,14 @@ class ViewController extends Controller {
|
||||||
* @throws \OCP\Files\NotFoundException
|
* @throws \OCP\Files\NotFoundException
|
||||||
*/
|
*/
|
||||||
private function showFile($fileId) {
|
private function showFile($fileId) {
|
||||||
$uid = $this->userSession->getUser()->getUID();
|
$uid = $this->userSession->getUser()->getUID();
|
||||||
$baseFolder = $this->rootFolder->getUserFolder($uid);
|
$baseFolder = $this->rootFolder->getUserFolder($uid);
|
||||||
$files = $baseFolder->getById($fileId);
|
$files = $baseFolder->getById($fileId);
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
|
if (empty($files) && $this->appManager->isEnabledForUser('files_trashbin')) {
|
||||||
$baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
|
$baseFolder = $this->rootFolder->get($uid . '/files_trashbin/files/');
|
||||||
$files = $baseFolder->getById($fileId);
|
$files = $baseFolder->getById($fileId);
|
||||||
$params['view'] = 'trashbin';
|
$params['view'] = 'trashbin';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +307,7 @@ class ViewController extends Controller {
|
||||||
// and scroll to the entry
|
// and scroll to the entry
|
||||||
$params['scrollto'] = $file->getName();
|
$params['scrollto'] = $file->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
|
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
|
||||||
}
|
}
|
||||||
throw new \OCP\Files\NotFoundException();
|
throw new \OCP\Files\NotFoundException();
|
||||||
|
|
|
@ -66,21 +66,26 @@
|
||||||
function NavigationListElements($item, $l, $pinned) {
|
function NavigationListElements($item, $l, $pinned) {
|
||||||
strpos($item['classes'], 'pinned') !== false ? $pinned++ : '';
|
strpos($item['classes'], 'pinned') !== false ? $pinned++ : '';
|
||||||
?>
|
?>
|
||||||
<li <?php if (isset($item['sublist'])){ ?>id="button-collapse-parent-<?php p($item['id']); ?>"<?php } ?>
|
<li
|
||||||
data-id="<?php p($item['id']) ?>" data-dir="<?php p($item['dir']) ?>" data-view="<?php p($item['view']) ?>"
|
data-id="<?php p($item['id']) ?>"
|
||||||
class="nav-<?php p($item['id']) ?> <?php p($item['classes']) ?> <?php p($pinned === 1 ? 'first-pinned' : '') ?> <?php if ($item['defaultExpandedState']) { ?> open<?php } ?>"
|
<?php if (isset($item['dir'])) { ?> data-dir="<?php p($item['dir']); ?>" <?php } ?>
|
||||||
|
<?php if (isset($item['view'])) { ?> data-view="<?php p($item['view']); ?>" <?php } ?>
|
||||||
|
<?php if (isset($item['expandedState'])) { ?> data-expandedstate="<?php p($item['expandedState']); ?>" <?php } ?>
|
||||||
|
class="nav-<?php p($item['id']) ?>
|
||||||
|
<?php if (isset($item['classes'])) { p($item['classes']); } ?>
|
||||||
|
<?php p($pinned === 1 ? 'first-pinned' : '') ?>
|
||||||
|
<?php if (isset($item['defaultExpandedState']) && $item['defaultExpandedState']) { ?> open<?php } ?>"
|
||||||
<?php if (isset($item['folderPosition'])) { ?> folderposition="<?php p($item['folderPosition']); ?>" <?php } ?>>
|
<?php if (isset($item['folderPosition'])) { ?> folderposition="<?php p($item['folderPosition']); ?>" <?php } ?>>
|
||||||
|
|
||||||
<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
|
<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
|
||||||
class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']); ?></a>
|
class="nav-icon-<?php p(isset($item['icon']) && $item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']); ?></a>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
NavigationElementMenu($item);
|
NavigationElementMenu($item);
|
||||||
if (isset($item['sublist'])) {
|
if (isset($item['sublist'])) {
|
||||||
?>
|
?>
|
||||||
<button id="button-collapse-<?php p($item['id']); ?>"
|
<button class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
|
||||||
class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
|
|
||||||
<ul id="sublist-<?php p($item['id']); ?>">
|
<ul id="sublist-<?php p($item['id']); ?>">
|
||||||
<?php
|
<?php
|
||||||
foreach ($item['sublist'] as $item) {
|
foreach ($item['sublist'] as $item) {
|
||||||
|
@ -104,10 +109,10 @@ function NavigationListElements($item, $l, $pinned) {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function NavigationElementMenu($item) {
|
function NavigationElementMenu($item) {
|
||||||
if ($item['menubuttons'] === 'true') {
|
if (isset($item['menubuttons']) && $item['menubuttons'] === 'true') {
|
||||||
?>
|
?>
|
||||||
<div id="dotmenu-<?php p($item['id']); ?>"
|
<div id="dotmenu-<?php p($item['id']); ?>"
|
||||||
class="app-navigation-entry-utils" <?php if ($item['enableMenuButton'] === 0) { ?> style="display: none"<?php } ?>>
|
class="app-navigation-entry-utils" <?php if (isset($item['enableMenuButton']) && $item['enableMenuButton'] === 0) { ?> style="display: none"<?php } ?>>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="app-navigation-entry-utils-menu-button svg">
|
<li class="app-navigation-entry-utils-menu-button svg">
|
||||||
<button id="dotmenu-button-<?php p($item['id']) ?>"></button>
|
<button id="dotmenu-button-<?php p($item['id']) ?>"></button>
|
||||||
|
|
|
@ -145,7 +145,7 @@ class ViewControllerTest extends TestCase {
|
||||||
$nav->assign('total_space', '100 B');
|
$nav->assign('total_space', '100 B');
|
||||||
//$nav->assign('webdavurl', '');
|
//$nav->assign('webdavurl', '');
|
||||||
$nav->assign('navigationItems', [
|
$nav->assign('navigationItems', [
|
||||||
[
|
'files' => [
|
||||||
'id' => 'files',
|
'id' => 'files',
|
||||||
'appname' => 'files',
|
'appname' => 'files',
|
||||||
'script' => 'list.php',
|
'script' => 'list.php',
|
||||||
|
@ -156,7 +156,7 @@ class ViewControllerTest extends TestCase {
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'classes' => '',
|
'classes' => '',
|
||||||
],
|
],
|
||||||
[
|
'recent' => [
|
||||||
'id' => 'recent',
|
'id' => 'recent',
|
||||||
'appname' => 'files',
|
'appname' => 'files',
|
||||||
'script' => 'recentlist.php',
|
'script' => 'recentlist.php',
|
||||||
|
@ -167,65 +167,21 @@ class ViewControllerTest extends TestCase {
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'classes' => '',
|
'classes' => '',
|
||||||
],
|
],
|
||||||
[
|
'favorites' => [
|
||||||
'id' => 'favorites',
|
'id' => 'favorites',
|
||||||
'appname' => 'files',
|
'appname' => 'files',
|
||||||
'script' => 'simplelist.php',
|
'script' => 'simplelist.php',
|
||||||
'order' => 5,
|
'order' => 5,
|
||||||
'name' => null,
|
'name' => \OC::$server->getL10N('files')->t('Favorites'),
|
||||||
'active' => false,
|
'active' => false,
|
||||||
'icon' => '',
|
'icon' => '',
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'classes' => '',
|
'classes' => '',
|
||||||
'sublist' => [],
|
'sublist' => [],
|
||||||
'defaultExpandedState' => false,
|
'defaultExpandedState' => false,
|
||||||
'enableMenuButton' => 0,
|
'expandedState' => 'show_Quick_Access'
|
||||||
],
|
],
|
||||||
[
|
'systemtagsfilter' => [
|
||||||
'id' => 'sharingin',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 15,
|
|
||||||
'name' => \OC::$server->getL10N('files_sharing')->t('Shared with you'),
|
|
||||||
'active' => false,
|
|
||||||
'icon' => '',
|
|
||||||
'type' => 'link',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'sharingout',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 16,
|
|
||||||
'name' => \OC::$server->getL10N('files_sharing')->t('Shared with others'),
|
|
||||||
'active' => false,
|
|
||||||
'icon' => '',
|
|
||||||
'type' => 'link',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'sharinglinks',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 17,
|
|
||||||
'name' => \OC::$server->getL10N('files_sharing')->t('Shared by link', []),
|
|
||||||
'active' => false,
|
|
||||||
'icon' => '',
|
|
||||||
'type' => 'link',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'deletedshares',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 18,
|
|
||||||
'name' => \OC::$server->getL10N('files_sharing')->t('Deleted shares'),
|
|
||||||
'active' => false,
|
|
||||||
'icon' => '',
|
|
||||||
'type' => 'link',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'systemtagsfilter',
|
'id' => 'systemtagsfilter',
|
||||||
'appname' => 'systemtags',
|
'appname' => 'systemtags',
|
||||||
'script' => 'list.php',
|
'script' => 'list.php',
|
||||||
|
@ -236,7 +192,7 @@ class ViewControllerTest extends TestCase {
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'classes' => '',
|
'classes' => '',
|
||||||
],
|
],
|
||||||
[
|
'trashbin' => [
|
||||||
'id' => 'trashbin',
|
'id' => 'trashbin',
|
||||||
'appname' => 'files_trashbin',
|
'appname' => 'files_trashbin',
|
||||||
'script' => 'list.php',
|
'script' => 'list.php',
|
||||||
|
@ -264,39 +220,23 @@ class ViewControllerTest extends TestCase {
|
||||||
'allowShareWithLink' => 'yes',
|
'allowShareWithLink' => 'yes',
|
||||||
'appNavigation' => $nav,
|
'appNavigation' => $nav,
|
||||||
'appContents' => [
|
'appContents' => [
|
||||||
[
|
'files' => [
|
||||||
'id' => 'files',
|
'id' => 'files',
|
||||||
'content' => null,
|
'content' => null,
|
||||||
],
|
],
|
||||||
[
|
'recent' => [
|
||||||
'id' => 'recent',
|
'id' => 'recent',
|
||||||
'content' => null,
|
'content' => null,
|
||||||
],
|
],
|
||||||
[
|
'favorites' => [
|
||||||
'id' => 'favorites',
|
'id' => 'favorites',
|
||||||
'content' => null,
|
'content' => null,
|
||||||
],
|
],
|
||||||
[
|
'systemtagsfilter' => [
|
||||||
'id' => 'sharingin',
|
|
||||||
'content' => null,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'sharingout',
|
|
||||||
'content' => null,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'sharinglinks',
|
|
||||||
'content' => null,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'deletedshares',
|
|
||||||
'content' => null,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'systemtagsfilter',
|
'id' => 'systemtagsfilter',
|
||||||
'content' => null,
|
'content' => null,
|
||||||
],
|
],
|
||||||
[
|
'trashbin' => [
|
||||||
'id' => 'trashbin',
|
'id' => 'trashbin',
|
||||||
'content' => null,
|
'content' => null,
|
||||||
],
|
],
|
||||||
|
|
|
@ -50,54 +50,62 @@ $eventDispatcher->addListener(
|
||||||
$config = \OC::$server->getConfig();
|
$config = \OC::$server->getConfig();
|
||||||
$shareManager = \OC::$server->getShareManager();
|
$shareManager = \OC::$server->getShareManager();
|
||||||
$userSession = \OC::$server->getUserSession();
|
$userSession = \OC::$server->getUserSession();
|
||||||
|
$l = \OC::$server->getL10N('files_sharing');
|
||||||
|
|
||||||
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
|
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () {
|
|
||||||
$l = \OC::$server->getL10N('files_sharing');
|
|
||||||
return [
|
|
||||||
'id' => 'sharingin',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 15,
|
|
||||||
'name' => $l->t('Shared with you'),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () {
|
$sharingSublistArray = [];
|
||||||
$l = \OC::$server->getL10N('files_sharing');
|
|
||||||
return [
|
|
||||||
'id' => 'deletedshares',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 18,
|
|
||||||
'name' => $l->t('Deleted shares'),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (\OCP\Util::isSharingDisabledForUser() === false) {
|
if (\OCP\Util::isSharingDisabledForUser() === false) {
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () {
|
array_push($sharingSublistArray, [
|
||||||
$l = \OC::$server->getL10N('files_sharing');
|
'id' => 'sharingout',
|
||||||
return [
|
'appname' => 'files_sharing',
|
||||||
'id' => 'sharingout',
|
'script' => 'list.php',
|
||||||
'appname' => 'files_sharing',
|
'order' => 16,
|
||||||
'script' => 'list.php',
|
'name' => $l->t('Shared with others'),
|
||||||
'order' => 16,
|
]);
|
||||||
'name' => $l->t('Shared with others'),
|
}
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
|
array_push($sharingSublistArray, [
|
||||||
|
'id' => 'sharingin',
|
||||||
|
'appname' => 'files_sharing',
|
||||||
|
'script' => 'list.php',
|
||||||
|
'order' => 15,
|
||||||
|
'name' => $l->t('Shared with you'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (\OCP\Util::isSharingDisabledForUser() === false) {
|
||||||
// Check if sharing by link is enabled
|
// Check if sharing by link is enabled
|
||||||
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
|
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
|
||||||
\OCA\Files\App::getNavigationManager()->add(function () {
|
array_push($sharingSublistArray, [
|
||||||
$l = \OC::$server->getL10N('files_sharing');
|
'id' => 'sharinglinks',
|
||||||
return [
|
'appname' => 'files_sharing',
|
||||||
'id' => 'sharinglinks',
|
'script' => 'list.php',
|
||||||
'appname' => 'files_sharing',
|
'order' => 17,
|
||||||
'script' => 'list.php',
|
'name' => $l->t('Shared by link'),
|
||||||
'order' => 17,
|
]);
|
||||||
'name' => $l->t('Shared by link'),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
array_push($sharingSublistArray, [
|
||||||
|
'id' => 'deletedshares',
|
||||||
|
'appname' => 'files_sharing',
|
||||||
|
'script' => 'list.php',
|
||||||
|
'order' => 19,
|
||||||
|
'name' => $l->t('Deleted shares'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// show_Quick_Access stored as string
|
||||||
|
$defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
|
||||||
|
|
||||||
|
\OCA\Files\App::getNavigationManager()->add([
|
||||||
|
'id' => 'shareoverview',
|
||||||
|
'appname' => 'files_sharing',
|
||||||
|
'script' => 'list.php',
|
||||||
|
'order' => 18,
|
||||||
|
'name' => $l->t('Shares'),
|
||||||
|
'classes' => 'collapsible',
|
||||||
|
'sublist' => $sharingSublistArray,
|
||||||
|
'expandedState' => 'show_sharing_menu'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ OCA.Sharing.App = {
|
||||||
|
|
||||||
_inFileList: null,
|
_inFileList: null,
|
||||||
_outFileList: null,
|
_outFileList: null,
|
||||||
|
_overviewFileList: null,
|
||||||
|
|
||||||
initSharingIn: function($el) {
|
initSharingIn: function($el) {
|
||||||
if (this._inFileList) {
|
if (this._inFileList) {
|
||||||
|
@ -116,6 +117,28 @@ OCA.Sharing.App = {
|
||||||
return this._deletedFileList;
|
return this._deletedFileList;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initShareingOverview: function($el) {
|
||||||
|
if (this._overviewFileList) {
|
||||||
|
return this._overviewFileList;
|
||||||
|
}
|
||||||
|
this._overviewFileList = new OCA.Sharing.FileList(
|
||||||
|
$el,
|
||||||
|
{
|
||||||
|
id: 'shares.overview',
|
||||||
|
scrollContainer: $('#app-content'),
|
||||||
|
config: OCA.Files.App.getFilesConfig(),
|
||||||
|
isOverview: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this._extendFileList(this._overviewFileList);
|
||||||
|
this._overviewFileList.appName = t('files_sharing', 'Shares');
|
||||||
|
this._overviewFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' +
|
||||||
|
'<h2>' + t('files_sharing', 'No shares') + '</h2>' +
|
||||||
|
'<p>' + t('files_sharing', 'Shares will show up here') + '</p>');
|
||||||
|
return this._overviewFileList;
|
||||||
|
},
|
||||||
|
|
||||||
removeSharingIn: function() {
|
removeSharingIn: function() {
|
||||||
if (this._inFileList) {
|
if (this._inFileList) {
|
||||||
this._inFileList.$fileList.empty();
|
this._inFileList.$fileList.empty();
|
||||||
|
@ -140,6 +163,12 @@ OCA.Sharing.App = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeSharingOverview: function() {
|
||||||
|
if (this._overviewFileList) {
|
||||||
|
this._overviewFileList.$fileList.empty();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the app
|
* Destroy the app
|
||||||
*/
|
*/
|
||||||
|
@ -152,6 +181,7 @@ OCA.Sharing.App = {
|
||||||
this._inFileList = null;
|
this._inFileList = null;
|
||||||
this._outFileList = null;
|
this._outFileList = null;
|
||||||
this._linkFileList = null;
|
this._linkFileList = null;
|
||||||
|
this._overviewFileList = null;
|
||||||
delete this._globalActionsInitialized;
|
delete this._globalActionsInitialized;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -252,4 +282,10 @@ $(document).ready(function() {
|
||||||
$('#app-content-deletedshares').on('hide', function() {
|
$('#app-content-deletedshares').on('hide', function() {
|
||||||
OCA.Sharing.App.removeSharingDeleted();
|
OCA.Sharing.App.removeSharingDeleted();
|
||||||
});
|
});
|
||||||
|
$('#app-content-shareoverview').on('show', function(e) {
|
||||||
|
OCA.Sharing.App.initShareingOverview($(e.target));
|
||||||
|
});
|
||||||
|
$('#app-content-shareoverview').on('hide', function() {
|
||||||
|
OCA.Sharing.App.removeSharingOverview();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
_showDeleted: false,
|
_showDeleted: false,
|
||||||
_clientSideSort: true,
|
_clientSideSort: true,
|
||||||
_allowSelection: false,
|
_allowSelection: false,
|
||||||
|
_isOverview: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -60,6 +61,9 @@
|
||||||
if (options && options.showDeleted) {
|
if (options && options.showDeleted) {
|
||||||
this._showDeleted = true;
|
this._showDeleted = true;
|
||||||
}
|
}
|
||||||
|
if (options && options.isOverview) {
|
||||||
|
this._isOverview = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderRow: function() {
|
_renderRow: function() {
|
||||||
|
@ -191,55 +195,62 @@
|
||||||
// there is only root
|
// there is only root
|
||||||
this._setCurrentDir('/', false);
|
this._setCurrentDir('/', false);
|
||||||
|
|
||||||
|
|
||||||
if (this._showDeleted) {
|
|
||||||
var shares = $.ajax({
|
|
||||||
url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
|
|
||||||
/* jshint camelcase: false */
|
|
||||||
data: {
|
|
||||||
format: 'json',
|
|
||||||
include_tags: true
|
|
||||||
},
|
|
||||||
type: 'GET',
|
|
||||||
beforeSend: function(xhr) {
|
|
||||||
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var shares = $.ajax({
|
|
||||||
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
|
|
||||||
/* jshint camelcase: false */
|
|
||||||
data: {
|
|
||||||
format: 'json',
|
|
||||||
shared_with_me: !!this._sharedWithUser,
|
|
||||||
include_tags: true
|
|
||||||
},
|
|
||||||
type: 'GET',
|
|
||||||
beforeSend: function(xhr) {
|
|
||||||
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var promises = [];
|
var promises = [];
|
||||||
promises.push(shares);
|
|
||||||
|
|
||||||
if (!!this._sharedWithUser) {
|
var deletedShares = {
|
||||||
var remoteShares = $.ajax({
|
url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
|
||||||
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
|
/* jshint camelcase: false */
|
||||||
/* jshint camelcase: false */
|
data: {
|
||||||
data: {
|
format: 'json',
|
||||||
format: 'json',
|
include_tags: true
|
||||||
include_tags: true
|
},
|
||||||
},
|
type: 'GET',
|
||||||
type: 'GET',
|
beforeSend: function (xhr) {
|
||||||
beforeSend: function(xhr) {
|
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
||||||
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
},
|
||||||
},
|
};
|
||||||
});
|
|
||||||
promises.push(remoteShares);
|
var shares = {
|
||||||
|
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
|
||||||
|
/* jshint camelcase: false */
|
||||||
|
data: {
|
||||||
|
format: 'json',
|
||||||
|
shared_with_me: this._sharedWithUser !== false,
|
||||||
|
include_tags: true
|
||||||
|
},
|
||||||
|
type: 'GET',
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var remoteShares = {
|
||||||
|
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
|
||||||
|
/* jshint camelcase: false */
|
||||||
|
data: {
|
||||||
|
format: 'json',
|
||||||
|
include_tags: true
|
||||||
|
},
|
||||||
|
type: 'GET',
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add the proper ajax requests to the list and run them
|
||||||
|
// and make sure we have 2 promises
|
||||||
|
if (this._showDeleted) {
|
||||||
|
promises.push($.ajax(deletedShares));
|
||||||
} else {
|
} else {
|
||||||
//Push empty promise so callback gets called the same way
|
promises.push($.ajax(shares));
|
||||||
promises.push($.Deferred().resolve());
|
|
||||||
|
if (this._sharedWithUser !== false || this._isOverview) {
|
||||||
|
promises.push($.ajax(remoteShares));
|
||||||
|
}
|
||||||
|
if (this._isOverview) {
|
||||||
|
shares.data.shared_with_me = !shares.data.shared_with_me
|
||||||
|
promises.push($.ajax(shares));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._reloadCall = $.when.apply($, promises);
|
this._reloadCall = $.when.apply($, promises);
|
||||||
|
@ -247,7 +258,7 @@
|
||||||
return this._reloadCall.then(callBack, callBack);
|
return this._reloadCall.then(callBack, callBack);
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadCallback: function(shares, remoteShares) {
|
reloadCallback: function(shares, remoteShares, additionnalShares) {
|
||||||
delete this._reloadCall;
|
delete this._reloadCall;
|
||||||
this.hideMask();
|
this.hideMask();
|
||||||
|
|
||||||
|
@ -257,14 +268,30 @@
|
||||||
|
|
||||||
var files = [];
|
var files = [];
|
||||||
|
|
||||||
if (shares[0].ocs && shares[0].ocs.data) {
|
// make sure to use the same format
|
||||||
files = files.concat(this._makeFilesFromShares(shares[0].ocs.data));
|
if (shares[0] && shares[0].ocs) {
|
||||||
|
shares = shares[0];
|
||||||
|
}
|
||||||
|
if (remoteShares && remoteShares[0] && remoteShares[0].ocs) {
|
||||||
|
remoteShares = remoteShares[0];
|
||||||
|
}
|
||||||
|
if (additionnalShares && additionnalShares[0] && additionnalShares[0].ocs) {
|
||||||
|
additionnalShares = additionnalShares[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remoteShares && remoteShares[0].ocs && remoteShares[0].ocs.data) {
|
if (shares.ocs && shares.ocs.data) {
|
||||||
files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data));
|
files = files.concat(this._makeFilesFromShares(shares.ocs.data, this._sharedWithUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remoteShares && remoteShares.ocs && remoteShares.ocs.data) {
|
||||||
|
files = files.concat(this._makeFilesFromRemoteShares(remoteShares.ocs.data));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionnalShares && additionnalShares && additionnalShares.ocs && additionnalShares.ocs.data) {
|
||||||
|
files = files.concat(this._makeFilesFromShares(additionnalShares.ocs.data, !this._sharedWithUser));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.setFiles(files);
|
this.setFiles(files);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
@ -303,7 +330,7 @@
|
||||||
* @param {Array} data OCS API share array
|
* @param {Array} data OCS API share array
|
||||||
* @return {Array.<OCA.Sharing.SharedFileInfo>} array of shared file info
|
* @return {Array.<OCA.Sharing.SharedFileInfo>} array of shared file info
|
||||||
*/
|
*/
|
||||||
_makeFilesFromShares: function(data) {
|
_makeFilesFromShares: function(data, sharedWithUser) {
|
||||||
/* jshint camelcase: false */
|
/* jshint camelcase: false */
|
||||||
var self = this;
|
var self = this;
|
||||||
var files = data;
|
var files = data;
|
||||||
|
@ -339,7 +366,7 @@
|
||||||
stime: share.stime * 1000,
|
stime: share.stime * 1000,
|
||||||
expiration: share.expiration,
|
expiration: share.expiration,
|
||||||
};
|
};
|
||||||
if (self._sharedWithUser) {
|
if (sharedWithUser) {
|
||||||
file.shareOwner = share.displayname_owner;
|
file.shareOwner = share.displayname_owner;
|
||||||
file.shareOwnerId = share.uid_owner;
|
file.shareOwnerId = share.uid_owner;
|
||||||
file.name = OC.basename(share.file_target);
|
file.name = OC.basename(share.file_target);
|
||||||
|
|
|
@ -100,7 +100,7 @@ class NavigationManager implements INavigationManager {
|
||||||
if(!isset($entry['type'])) {
|
if(!isset($entry['type'])) {
|
||||||
$entry['type'] = 'link';
|
$entry['type'] = 'link';
|
||||||
}
|
}
|
||||||
$this->entries[] = $entry;
|
$this->entries[$entry['id']] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +133,7 @@ class NavigationManager implements INavigationManager {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function proceedNavigation(array $list): array {
|
private function proceedNavigation(array $list): array {
|
||||||
usort($list, function($a, $b) {
|
uasort($list, function($a, $b) {
|
||||||
if (isset($a['order']) && isset($b['order'])) {
|
if (isset($a['order']) && isset($b['order'])) {
|
||||||
return ($a['order'] < $b['order']) ? -1 : 1;
|
return ($a['order'] < $b['order']) ? -1 : 1;
|
||||||
} else if (isset($a['order']) || isset($b['order'])) {
|
} else if (isset($a['order']) || isset($b['order'])) {
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
|
|
||||||
namespace Test;
|
namespace Test;
|
||||||
|
|
||||||
use OC\App\AppManager;
|
|
||||||
use OC\Group\Manager;
|
|
||||||
use OC\NavigationManager;
|
|
||||||
use OC\SubAdmin;
|
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
@ -23,6 +19,10 @@ use OCP\IURLGenerator;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
|
use OC\App\AppManager;
|
||||||
|
use OC\Group\Manager;
|
||||||
|
use OC\NavigationManager;
|
||||||
|
use OC\SubAdmin;
|
||||||
|
|
||||||
class NavigationManagerTest extends TestCase {
|
class NavigationManagerTest extends TestCase {
|
||||||
/** @var AppManager|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var AppManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
@ -44,12 +44,12 @@ class NavigationManagerTest extends TestCase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->appManager = $this->createMock(AppManager::class);
|
$this->appManager = $this->createMock(AppManager::class);
|
||||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
$this->l10nFac = $this->createMock(IFactory::class);
|
$this->l10nFac = $this->createMock(IFactory::class);
|
||||||
$this->userSession = $this->createMock(IUserSession::class);
|
$this->userSession = $this->createMock(IUserSession::class);
|
||||||
$this->groupManager = $this->createMock(Manager::class);
|
$this->groupManager = $this->createMock(Manager::class);
|
||||||
$this->config = $this->createMock(IConfig::class);
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->navigationManager = new NavigationManager(
|
$this->navigationManager = new NavigationManager(
|
||||||
$this->appManager,
|
$this->appManager,
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
|
@ -65,46 +65,46 @@ class NavigationManagerTest extends TestCase {
|
||||||
public function addArrayData() {
|
public function addArrayData() {
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
[
|
'entry id' => [
|
||||||
'id' => 'entry id',
|
'id' => 'entry id',
|
||||||
'name' => 'link text',
|
'name' => 'link text',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'icon' => 'optional',
|
'icon' => 'optional',
|
||||||
'href' => 'url',
|
'href' => 'url',
|
||||||
'type' => 'settings',
|
'type' => 'settings',
|
||||||
'classes' => '',
|
'classes' => ''
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'entry id',
|
|
||||||
'name' => 'link text',
|
|
||||||
'order' => 1,
|
|
||||||
'icon' => 'optional',
|
|
||||||
'href' => 'url',
|
|
||||||
'active' => false,
|
|
||||||
'type' => 'settings',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
],
|
||||||
|
'entry id2' => [
|
||||||
|
'id' => 'entry id',
|
||||||
|
'name' => 'link text',
|
||||||
|
'order' => 1,
|
||||||
|
'icon' => 'optional',
|
||||||
|
'href' => 'url',
|
||||||
|
'active' => false,
|
||||||
|
'type' => 'settings',
|
||||||
|
'classes' => ''
|
||||||
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[
|
'entry id' => [
|
||||||
'id' => 'entry id',
|
'id' => 'entry id',
|
||||||
'name' => 'link text',
|
'name' => 'link text',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
//'icon' => 'optional',
|
//'icon' => 'optional',
|
||||||
'href' => 'url',
|
'href' => 'url',
|
||||||
'active' => true,
|
'active' => true
|
||||||
],
|
],
|
||||||
[
|
'entry id2' => [
|
||||||
'id' => 'entry id',
|
'id' => 'entry id',
|
||||||
'name' => 'link text',
|
'name' => 'link text',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'icon' => '',
|
'icon' => '',
|
||||||
'href' => 'url',
|
'href' => 'url',
|
||||||
'active' => false,
|
'active' => false,
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'classes' => '',
|
'classes' => ''
|
||||||
],
|
]
|
||||||
],
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class NavigationManagerTest extends TestCase {
|
||||||
|
|
||||||
$navigationEntries = $this->navigationManager->getAll('all');
|
$navigationEntries = $this->navigationManager->getAll('all');
|
||||||
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
||||||
$this->assertEquals($expectedEntry, $navigationEntries[0]);
|
$this->assertEquals($expectedEntry, $navigationEntries['entry id']);
|
||||||
|
|
||||||
$this->navigationManager->clear(false);
|
$this->navigationManager->clear(false);
|
||||||
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
|
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
|
||||||
|
@ -148,12 +148,12 @@ class NavigationManagerTest extends TestCase {
|
||||||
$navigationEntries = $this->navigationManager->getAll('all');
|
$navigationEntries = $this->navigationManager->getAll('all');
|
||||||
$this->assertEquals(1, $testAddClosureNumberOfCalls, 'Expected that the closure is called by getAll()');
|
$this->assertEquals(1, $testAddClosureNumberOfCalls, 'Expected that the closure is called by getAll()');
|
||||||
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
||||||
$this->assertEquals($expectedEntry, $navigationEntries[0]);
|
$this->assertEquals($expectedEntry, $navigationEntries['entry id']);
|
||||||
|
|
||||||
$navigationEntries = $this->navigationManager->getAll('all');
|
$navigationEntries = $this->navigationManager->getAll('all');
|
||||||
$this->assertEquals(1, $testAddClosureNumberOfCalls, 'Expected that the closure is only called once for getAll()');
|
$this->assertEquals(1, $testAddClosureNumberOfCalls, 'Expected that the closure is only called once for getAll()');
|
||||||
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
$this->assertCount(1, $navigationEntries, 'Expected that 1 navigation entry exists');
|
||||||
$this->assertEquals($expectedEntry, $navigationEntries[0]);
|
$this->assertEquals($expectedEntry, $navigationEntries['entry id']);
|
||||||
|
|
||||||
$this->navigationManager->clear(false);
|
$this->navigationManager->clear(false);
|
||||||
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
|
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
|
||||||
|
@ -161,11 +161,11 @@ class NavigationManagerTest extends TestCase {
|
||||||
|
|
||||||
public function testAddArrayClearGetAll() {
|
public function testAddArrayClearGetAll() {
|
||||||
$entry = [
|
$entry = [
|
||||||
'id' => 'entry id',
|
'id' => 'entry id',
|
||||||
'name' => 'link text',
|
'name' => 'link text',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'icon' => 'optional',
|
'icon' => 'optional',
|
||||||
'href' => 'url',
|
'href' => 'url'
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertEmpty($this->navigationManager->getAll(), 'Expected no navigation entry exists');
|
$this->assertEmpty($this->navigationManager->getAll(), 'Expected no navigation entry exists');
|
||||||
|
@ -178,11 +178,11 @@ class NavigationManagerTest extends TestCase {
|
||||||
$this->assertEmpty($this->navigationManager->getAll(), 'Expected no navigation entry exists');
|
$this->assertEmpty($this->navigationManager->getAll(), 'Expected no navigation entry exists');
|
||||||
|
|
||||||
$entry = [
|
$entry = [
|
||||||
'id' => 'entry id',
|
'id' => 'entry id',
|
||||||
'name' => 'link text',
|
'name' => 'link text',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'icon' => 'optional',
|
'icon' => 'optional',
|
||||||
'href' => 'url',
|
'href' => 'url'
|
||||||
];
|
];
|
||||||
|
|
||||||
global $testAddClosureNumberOfCalls;
|
global $testAddClosureNumberOfCalls;
|
||||||
|
@ -208,36 +208,36 @@ class NavigationManagerTest extends TestCase {
|
||||||
public function testWithAppManager($expected, $navigation, $isAdmin = false) {
|
public function testWithAppManager($expected, $navigation, $isAdmin = false) {
|
||||||
|
|
||||||
$l = $this->createMock(IL10N::class);
|
$l = $this->createMock(IL10N::class);
|
||||||
$l->expects($this->any())->method('t')->willReturnCallback(function($text, $parameters = []) {
|
$l->expects($this->any())->method('t')->willReturnCallback(function ($text, $parameters = []) {
|
||||||
return vsprintf($text, $parameters);
|
return vsprintf($text, $parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
|
$this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
|
||||||
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
|
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
|
||||||
$this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function($appName, $file) {
|
$this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
|
||||||
return "/apps/$appName/img/$file";
|
return "/apps/$appName/img/$file";
|
||||||
});
|
});
|
||||||
$this->urlGenerator->expects($this->any())->method('linkToRoute')->willReturnCallback(function() {
|
$this->urlGenerator->expects($this->any())->method('linkToRoute')->willReturnCallback(function () {
|
||||||
return "/apps/test/";
|
return '/apps/test/';
|
||||||
});
|
});
|
||||||
$this->urlGenerator
|
$this->urlGenerator
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('linkToRouteAbsolute')
|
->method('linkToRouteAbsolute')
|
||||||
->with(
|
->with(
|
||||||
'core.login.logout',
|
'core.login.logout',
|
||||||
[
|
[
|
||||||
'requesttoken' => \OCP\Util::callRegister(),
|
'requesttoken' => \OCP\Util::callRegister()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->willReturn('https://example.com/logout');
|
->willReturn('https://example.com/logout');
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$user->expects($this->any())->method('getUID')->willReturn('user001');
|
$user->expects($this->any())->method('getUID')->willReturn('user001');
|
||||||
$this->userSession->expects($this->any())->method('getUser')->willReturn($user);
|
$this->userSession->expects($this->any())->method('getUser')->willReturn($user);
|
||||||
$this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
|
$this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
|
||||||
$this->appManager->expects($this->once())
|
$this->appManager->expects($this->once())
|
||||||
->method('getEnabledAppsForUser')
|
->method('getEnabledAppsForUser')
|
||||||
->with($user)
|
->with($user)
|
||||||
->willReturn(['test']);
|
->willReturn(['test']);
|
||||||
$this->groupManager->expects($this->any())->method('isAdmin')->willReturn($isAdmin);
|
$this->groupManager->expects($this->any())->method('isAdmin')->willReturn($isAdmin);
|
||||||
$subadmin = $this->createMock(SubAdmin::class);
|
$subadmin = $this->createMock(SubAdmin::class);
|
||||||
$subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false);
|
$subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false);
|
||||||
|
@ -250,72 +250,119 @@ class NavigationManagerTest extends TestCase {
|
||||||
|
|
||||||
public function providesNavigationConfig() {
|
public function providesNavigationConfig() {
|
||||||
$apps = [
|
$apps = [
|
||||||
[
|
'core_apps' => [
|
||||||
'id' => 'core_apps',
|
'id' => 'core_apps',
|
||||||
'order' => 3,
|
'order' => 3,
|
||||||
'href' => '/apps/test/',
|
'href' => '/apps/test/',
|
||||||
'icon' => '/apps/settings/img/apps.svg',
|
'icon' => '/apps/settings/img/apps.svg',
|
||||||
'name' => 'Apps',
|
'name' => 'Apps',
|
||||||
'active' => false,
|
'active' => false,
|
||||||
'type' => 'settings',
|
'type' => 'settings',
|
||||||
'classes' => '',
|
'classes' => ''
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$defaults = [
|
$defaults = [
|
||||||
[
|
'settings' => [
|
||||||
'id' => 'settings',
|
'id' => 'settings',
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'href' => '/apps/test/',
|
'href' => '/apps/test/',
|
||||||
'icon' => '/apps/settings/img/admin.svg',
|
'icon' => '/apps/settings/img/admin.svg',
|
||||||
'name' => 'Settings',
|
'name' => 'Settings',
|
||||||
'active' => false,
|
'active' => false,
|
||||||
'type' => 'settings',
|
'type' => 'settings',
|
||||||
'classes' => '',
|
'classes' => ''
|
||||||
],
|
|
||||||
[
|
|
||||||
'id' => 'logout',
|
|
||||||
'order' => 99999,
|
|
||||||
'href' => 'https://example.com/logout',
|
|
||||||
'icon' => '/apps/core/img/actions/logout.svg',
|
|
||||||
'name' => 'Log out',
|
|
||||||
'active' => false,
|
|
||||||
'type' => 'settings',
|
|
||||||
'classes' => '',
|
|
||||||
],
|
],
|
||||||
|
'logout' => [
|
||||||
|
'id' => 'logout',
|
||||||
|
'order' => 99999,
|
||||||
|
'href' => 'https://example.com/logout',
|
||||||
|
'icon' => '/apps/core/img/actions/logout.svg',
|
||||||
|
'name' => 'Log out',
|
||||||
|
'active' => false,
|
||||||
|
'type' => 'settings',
|
||||||
|
'classes' => ''
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'minimalistic' => [array_merge([$defaults[0]], [[
|
'minimalistic' => [
|
||||||
'id' => 'test',
|
array_merge(
|
||||||
'order' => 100,
|
['settings' => $defaults['settings']],
|
||||||
'href' => '/apps/test/',
|
['test' => [
|
||||||
'icon' => '/apps/test/img/app.svg',
|
'id' => 'test',
|
||||||
'name' => 'Test',
|
'order' => 100,
|
||||||
'active' => false,
|
'href' => '/apps/test/',
|
||||||
'type' => 'link',
|
'icon' => '/apps/test/img/app.svg',
|
||||||
'classes' => '',
|
'name' => 'Test',
|
||||||
]], [$defaults[1]]), ['navigations' => [['route' => 'test.page.index', 'name' => 'Test']]]],
|
'active' => false,
|
||||||
'minimalistic-settings' => [array_merge([$defaults[0]], [[
|
'type' => 'link',
|
||||||
'id' => 'test',
|
'classes' => ''
|
||||||
'order' => 100,
|
]],
|
||||||
'href' => '/apps/test/',
|
['logout' => $defaults['logout']]
|
||||||
'icon' => '/apps/test/img/app.svg',
|
),
|
||||||
'name' => 'Test',
|
['navigations' => [
|
||||||
'active' => false,
|
['route' => 'test.page.index', 'name' => 'Test']
|
||||||
'type' => 'settings',
|
]]
|
||||||
'classes' => '',
|
],
|
||||||
]], [$defaults[1]]), ['navigations' => [['route' => 'test.page.index', 'name' => 'Test', 'type' => 'settings']]]],
|
'minimalistic-settings' => [
|
||||||
'admin' => [array_merge([$defaults[0]], $apps, [[
|
array_merge(
|
||||||
'id' => 'test',
|
['settings' => $defaults['settings']],
|
||||||
'order' => 100,
|
['test' => [
|
||||||
'href' => '/apps/test/',
|
'id' => 'test',
|
||||||
'icon' => '/apps/test/img/app.svg',
|
'order' => 100,
|
||||||
'name' => 'Test',
|
'href' => '/apps/test/',
|
||||||
'active' => false,
|
'icon' => '/apps/test/img/app.svg',
|
||||||
'type' => 'link',
|
'name' => 'Test',
|
||||||
'classes' => '',
|
'active' => false,
|
||||||
]], [$defaults[1]]), ['navigations' => [['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']]], true],
|
'type' => 'settings',
|
||||||
'no name' => [array_merge([$defaults[0]], $apps, [$defaults[1]]), ['navigations' => [['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']]], true],
|
'classes' => ''
|
||||||
'no admin' => [$defaults, ['navigations' => [['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']]]]
|
]],
|
||||||
|
['logout' => $defaults['logout']]
|
||||||
|
),
|
||||||
|
['navigations' => [
|
||||||
|
['route' => 'test.page.index', 'name' => 'Test', 'type' => 'settings']
|
||||||
|
]
|
||||||
|
]],
|
||||||
|
'admin' => [
|
||||||
|
array_merge(
|
||||||
|
['settings' => $defaults['settings']],
|
||||||
|
$apps,
|
||||||
|
['test' => [
|
||||||
|
'id' => 'test',
|
||||||
|
'order' => 100,
|
||||||
|
'href' => '/apps/test/',
|
||||||
|
'icon' => '/apps/test/img/app.svg',
|
||||||
|
'name' => 'Test',
|
||||||
|
'active' => false,
|
||||||
|
'type' => 'link',
|
||||||
|
'classes' => ''
|
||||||
|
]],
|
||||||
|
['logout' => $defaults['logout']]
|
||||||
|
),
|
||||||
|
['navigations' => [
|
||||||
|
['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']
|
||||||
|
]],
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'no name' => [
|
||||||
|
array_merge(
|
||||||
|
['settings' => $defaults['settings']],
|
||||||
|
$apps,
|
||||||
|
['logout' => $defaults['logout']]
|
||||||
|
),
|
||||||
|
['navigations' => [
|
||||||
|
['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']
|
||||||
|
]],
|
||||||
|
true
|
||||||
|
],
|
||||||
|
'no admin' => [
|
||||||
|
$defaults,
|
||||||
|
['navigations' => [[
|
||||||
|
'@attributes' => ['role' => 'admin'],
|
||||||
|
'route' => 'test.page.index',
|
||||||
|
'name' => 'Test'
|
||||||
|
]]]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue