aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-01-04 11:47:36 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-01-04 16:46:16 +0100
commit7339355dde6e946bbc151397ea91ba5bf19047f6 (patch)
tree742e97042d74d7f28b08979e2df839516d46fd39 /apps/files
parente2da30a0c5315273936232e3ad28ca0c8653ed33 (diff)
downloadnextcloud-server-7339355dde6e946bbc151397ea91ba5bf19047f6.tar.gz
nextcloud-server-7339355dde6e946bbc151397ea91ba5bf19047f6.zip
Fix favourite opening
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/Controller/ViewController.php10
-rw-r--r--apps/files/lib/Service/UserConfig.php2
-rw-r--r--apps/files/src/legacy/navigationMapper.js7
-rw-r--r--apps/files/src/views/Navigation.vue34
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php28
5 files changed, 48 insertions, 33 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index ea589807767..0594b63f56b 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -211,19 +211,17 @@ class ViewController extends Controller {
$favoritesSublistArray = [];
$navBarPositionPosition = 6;
- $currentCount = 0;
foreach ($favElements['folders'] as $favElement) {
- $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $favElement, 'view' => 'files']);
- $sortingValue = ++$currentCount;
$element = [
'id' => str_replace('/', '-', $favElement),
- 'view' => 'files',
- 'href' => $link,
'dir' => $favElement,
'order' => $navBarPositionPosition,
- 'folderPosition' => $sortingValue,
'name' => basename($favElement),
'icon' => 'folder',
+ 'params' => [
+ 'view' => 'files',
+ 'dir' => $favElement,
+ ],
];
array_push($favoritesSublistArray, $element);
diff --git a/apps/files/lib/Service/UserConfig.php b/apps/files/lib/Service/UserConfig.php
index 3a498805910..e405b02c07a 100644
--- a/apps/files/lib/Service/UserConfig.php
+++ b/apps/files/lib/Service/UserConfig.php
@@ -30,11 +30,13 @@ use OCP\IUserSession;
class UserConfig {
const ALLOWED_CONFIGS = [
[
+ // Whether to crop the files previews or not in the files list
'key' => 'crop_image_previews',
'default' => true,
'allowed' => [true, false],
],
[
+ // Whether to show the hidden files or not in the files list
'key' => 'show_hidden',
'default' => false,
'allowed' => [true, false],
diff --git a/apps/files/src/legacy/navigationMapper.js b/apps/files/src/legacy/navigationMapper.js
index a78faf0af52..764a7cb6cd9 100644
--- a/apps/files/src/legacy/navigationMapper.js
+++ b/apps/files/src/legacy/navigationMapper.js
@@ -40,15 +40,16 @@ export default function() {
}
}
-const registerLegacyView = function({ id, name, order, icon, parent, classes = '', expanded }) {
+const registerLegacyView = function({ id, name, order, icon, parent, classes = '', expanded, params }) {
OCP.Files.Navigation.register({
id,
name,
- iconClass: icon ? `icon-${icon}` : 'nav-icon-' + id,
order,
+ params,
parent,
+ expanded: expanded === true,
+ iconClass: icon ? `icon-${icon}` : 'nav-icon-' + id,
legacy: true,
sticky: classes.includes('pinned'),
- expanded: expanded === true,
})
}
diff --git a/apps/files/src/views/Navigation.vue b/apps/files/src/views/Navigation.vue
index 0a7edc3bef9..a907fe4fbf3 100644
--- a/apps/files/src/views/Navigation.vue
+++ b/apps/files/src/views/Navigation.vue
@@ -30,14 +30,15 @@
:open="view.expanded"
:pinned="view.sticky"
:title="view.name"
- :to="{name: 'filelist', params: { view: view.id }}"
- @update:open="onToggleExpand(view)">
+ :to="generateToNavigation(view)"
+ @update:open="onToggleExpand($event, view)">
<NcAppNavigationItem v-for="child in childViews[view.id]"
:key="child.id"
:data-cy-files-navigation-item="child.id"
+ :exact="true"
:icon="child.iconClass"
:title="child.name"
- :to="{name: 'filelist', params: { view: child.id }}" />
+ :to="generateToNavigation(child)" />
</NcAppNavigationItem>
</template>
@@ -167,16 +168,13 @@ export default {
})
newAppContent.classList.remove('hidden')
- // Trigger init if not already done
- window.jQuery(newAppContent).trigger(new window.jQuery.Event('show'))
+ // Triggering legacy navigation events
+ const { dir = '/' } = OC.Util.History.parseUrlQuery()
+ const params = { itemId: view.id, dir }
- // After show, properly send the right data
- this.$nextTick(() => {
- const { dir = '/' } = OC.Util.History.parseUrlQuery()
- const params = { itemId: view.id, dir }
- window.jQuery(newAppContent).trigger(new window.jQuery.Event('show', params))
- window.jQuery(newAppContent).trigger(new window.jQuery.Event('urlChanged', params))
- })
+ logger.debug('Triggering legacy navigation event', params)
+ window.jQuery(newAppContent).trigger(new window.jQuery.Event('show', params))
+ window.jQuery(newAppContent).trigger(new window.jQuery.Event('urlChanged', params))
}
@@ -214,6 +212,18 @@ export default {
},
/**
+ * Generate the route to a view
+ * @param {Navigation} view the view to toggle
+ */
+ generateToNavigation(view) {
+ if (view.params) {
+ const { dir, fileid } = view.params
+ return { name: 'filelist', params: view.params, query: { dir, fileid } }
+ }
+ return { name: 'filelist', params: { view: view.id } }
+ },
+
+ /**
* Open the settings modal
*/
openSettings() {
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index a9aab4fbf4b..6ab09011e1f 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -211,43 +211,47 @@ class ViewControllerTest extends TestCase {
'sublist' => [
[
'id' => '-test1',
- 'view' => 'files',
- 'href' => '',
'dir' => '/test1',
'order' => 6,
- 'folderPosition' => 1,
'name' => 'test1',
'icon' => 'folder',
+ 'params' => [
+ 'view' => 'files',
+ 'dir' => '/test1',
+ ],
],
[
'name' => 'test2',
'id' => '-test2-',
- 'view' => 'files',
- 'href' => '',
'dir' => '/test2/',
'order' => 7,
- 'folderPosition' => 2,
'icon' => 'folder',
+ 'params' => [
+ 'view' => 'files',
+ 'dir' => '/test2/',
+ ],
],
[
'name' => 'sub4',
'id' => '-test3-sub4',
- 'view' => 'files',
- 'href' => '',
'dir' => '/test3/sub4',
'order' => 8,
- 'folderPosition' => 3,
'icon' => 'folder',
+ 'params' => [
+ 'view' => 'files',
+ 'dir' => '/test3/sub4',
+ ],
],
[
'name' => 'sub6',
'id' => '-test5-sub6-',
- 'view' => 'files',
- 'href' => '',
'dir' => '/test5/sub6/',
'order' => 9,
- 'folderPosition' => 4,
'icon' => 'folder',
+ 'params' => [
+ 'view' => 'files',
+ 'dir' => '/test5/sub6/',
+ ],
],
],
'expanded' => false,