Skip to content

Commit

Permalink
Apply new routes to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 3, 2022
1 parent 8e547ce commit 3f86aa9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/web-app-files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Personal from './views/Personal.vue'
import SharedWithMe from './views/SharedWithMe.vue'
import SharedWithOthers from './views/SharedWithOthers.vue'
import SharedViaLink from './views/SharedViaLink.vue'
import Spaces from './spaces/views/Spaces.vue'
import Trashbin from './views/Trashbin.vue'
import translations from '../l10n/translations.json'
import quickActions from './quickActions'
Expand Down Expand Up @@ -76,8 +77,7 @@ const navItems = [
name: $gettext('Spaces'),
iconMaterial: 'space',
route: {
name: 'files-spaces',
path: `/${appInfo.id}/list/spaces`
path: `/${appInfo.id}/spaces/projects`
}
},
{
Expand Down Expand Up @@ -107,6 +107,7 @@ export default {
SharedViaLink,
SharedWithMe,
SharedWithOthers,
Spaces,
Trashbin
}),
navItems,
Expand Down
1 change: 1 addition & 0 deletions packages/web-app-files/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export interface RouteComponents {
SharedWithMe: any
SharedWithOthers: any
SharedViaLink: any
Spaces: any
Trashbin: any
}
36 changes: 31 additions & 5 deletions packages/web-app-files/src/router/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Location, RouteConfig } from 'vue-router'
import { RouteComponents } from './router'
import { createLocation, isLocationActiveDirector, $gettext } from './utils'

type shareTypes = 'files-spaces-personal-home'
type spaceTypes = 'files-spaces-personal-home' | 'files-spaces-projects'

export const createLocationSpaces = (name: shareTypes, location = {}): Location =>
export const createLocationSpaces = (name: spaceTypes, location = {}): Location =>
createLocation(
name,
{
Expand All @@ -15,15 +15,41 @@ export const createLocationSpaces = (name: shareTypes, location = {}): Location
},
location
)
export const isLocationSpacesActive = isLocationActiveDirector<shareTypes>(
createLocationSpaces('files-spaces-personal-home')

export const createLocationSpacesProjects = (name: spaceTypes, location = {}): Location =>
createLocation(name, location)

const locationSpacesPersonalHome = createLocationSpaces('files-spaces-personal-home')
const locationSpacesProjects = createLocationSpacesProjects('files-spaces-projects')

export const isLocationSpacesActive = isLocationActiveDirector<spaceTypes>(
locationSpacesPersonalHome,
locationSpacesProjects
)

export const buildRoutes = (components: RouteComponents): RouteConfig[] => [
{
path: '/spaces',
redirect: (to) => createLocationSpaces('files-spaces-personal-home', to)
},
{
path: '/spaces/projects',
components: {
app: components.App
},
children: [
{
name: locationSpacesProjects.name,
path: '',
component: components.Spaces,
meta: {
hideFilelistActions: true,
hasBulkActions: true,
title: $gettext('Spaces')
}
}
]
},
{
path: '/spaces/:namespace',
components: {
Expand All @@ -32,7 +58,7 @@ export const buildRoutes = (components: RouteComponents): RouteConfig[] => [
redirect: (to) => createLocationSpaces('files-spaces-personal-home', to),
children: [
{
name: createLocationSpaces('files-spaces-personal-home').name,
name: locationSpacesPersonalHome.name,
path: ':storage/:item*',
component: components.Personal,
meta: {
Expand Down

0 comments on commit 3f86aa9

Please sign in to comment.