-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(files): Add missing directory variable to error message
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
2 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*! | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { computed } from 'vue' | ||
import { useRoute } from 'vue-router/composables' | ||
|
||
/** | ||
* Get information about the current route | ||
*/ | ||
export function useRouteParameters() { | ||
|
||
const route = useRoute() | ||
|
||
/** | ||
* Get the path of the current active directory | ||
*/ | ||
const directory = computed<string>( | ||
() => String(route.query.dir || '/') | ||
// Remove any trailing slash but leave root slash | ||
.replace(/^(.+)\/$/, '$1'), | ||
) | ||
|
||
/** | ||
* Get the current fileId used on the route | ||
*/ | ||
const fileId = computed<number | null>(() => { | ||
const fileId = Number.parseInt(route.params.fileid ?? '0') || null | ||
return Number.isNaN(fileId) ? null : fileId | ||
}) | ||
|
||
/** | ||
* State of `openFile` route param | ||
*/ | ||
const openFile = computed<boolean>( | ||
// if `openfile` is set it is considered truthy, but allow to explicitly set it to 'false' | ||
() => 'openfile' in route.query && (typeof route.query.openfile !== 'string' || route.query.openfile.toLocaleLowerCase() !== 'false'), | ||
) | ||
|
||
return { | ||
/** Path of currently open directory */ | ||
directory, | ||
|
||
/** Current active fileId */ | ||
fileId, | ||
|
||
/** Should the active node should be opened (`openFile` route param) */ | ||
openFile, | ||
} | ||
} |