Skip to content

Commit

Permalink
Fix routing for driveAliasAndItem containing #
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Jan 15, 2023
1 parent 7f952b8 commit ae0d560
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
8 changes: 4 additions & 4 deletions packages/web-app-preview/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ import {
import AppTopBar from 'web-pkg/src/components/AppTopBar.vue'
import { loadPreview } from 'web-pkg/src/helpers'
import { configurationManager } from 'web-pkg/src/configuration'
import { createFileRouteOptions, mergeFileRouteOptions } from 'web-pkg/src/helpers/router'
import { createFileRouteOptions } from 'web-pkg/src/helpers/router'
export const appId = 'preview'
Expand Down Expand Up @@ -424,9 +424,9 @@ export default defineComponent({
},
// update route and url
updateLocalHistory() {
const routeOptions = mergeFileRouteOptions(
this.$route,
createFileRouteOptions(unref(this.currentFileContext.space), this.activeFilteredFile)
const routeOptions = createFileRouteOptions(
unref(this.currentFileContext.space),
this.activeFilteredFile
)
history.pushState({}, document.title, this.$router.resolve(routeOptions).href)
},
Expand Down
12 changes: 4 additions & 8 deletions packages/web-pkg/src/composables/router/useFileRouteReplace.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useRouter } from './useRouter'
import { useConfigurationManager } from '../configuration'
import { Resource, SpaceResource } from 'web-client/src/helpers'
import { createFileRouteOptions, mergeFileRouteOptions } from '../../helpers/router'
import { createFileRouteOptions } from '../../helpers/router'
import { Router } from 'vue-router'
import { ConfigurationManager } from '../../configuration'
import { unref } from 'vue'

export interface FileRouteReplaceOptions {
router?: Router
Expand Down Expand Up @@ -33,12 +32,9 @@ export const useFileRouteReplace = (options: FileRouteReplaceOptions = {}) => {
return false
}

const routeOptions = mergeFileRouteOptions(
unref(router.currentRoute),
createFileRouteOptions(space, resource, {
configurationManager
})
)
const routeOptions = createFileRouteOptions(space, resource, {
configurationManager
})
router.replace(routeOptions)
return true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-pkg/src/composables/router/useRouteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const useRouteQuery = (name: string, defaultValue?: QueryValue): Ref<Quer
if (unref(router.currentRoute).query[name] === v) {
return
}

await router.replace({
...unref(router.currentRoute),
query: {
...unref(router.currentRoute).query,
[name]: v
Expand Down
18 changes: 1 addition & 17 deletions packages/web-pkg/src/helpers/router/routeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isShareSpaceResource, Resource, SpaceResource } from 'web-client/src/helpers'
import { configurationManager, ConfigurationManager } from '../../configuration'
import { LocationQuery } from '../../composables'
import { RouteParams } from 'vue-router'
import { isUndefined } from 'lodash-es'
import { RouteLocation, RouteParams } from 'vue-router'

/**
* Creates route options for routing into a file location:
Expand Down Expand Up @@ -33,19 +33,3 @@ export const createFileRouteOptions = (
}
}
}

export const mergeFileRouteOptions = (
originalRoute: RouteLocation,
routeOptions: { params: RouteParams; query: LocationQuery }
): RouteLocation => {
return Object.assign({}, originalRoute, {
params: {
...originalRoute.params,
...routeOptions.params
},
query: {
...originalRoute.query,
...routeOptions.query
}
})
}

0 comments on commit ae0d560

Please sign in to comment.