mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
Fix favourite opening
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
e2da30a0c5
commit
7339355dde
7 changed files with 51 additions and 36 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -213,6 +211,18 @@ export default {
|
|||
axios.post(generateUrl(`/apps/files/api/v1/toggleShowFolder/${view.id}`), { show: view.expanded })
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue