Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
2a4b8985
Commit
2a4b8985
authored
Oct 07, 2019
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: fetch page tree resolver
parent
38c33c58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
page.js
server/graph/resolvers/page.js
+28
-0
page.graphql
server/graph/schemas/page.graphql
+25
-0
rebuild-tree.js
server/jobs/rebuild-tree.js
+3
-0
No files found.
server/graph/resolvers/page.js
View file @
2a4b8985
...
...
@@ -115,6 +115,34 @@ module.exports = {
},
async
tags
(
obj
,
args
,
context
,
info
)
{
return
WIKI
.
models
.
tags
.
query
().
orderBy
(
'tag'
,
'asc'
)
},
async
tree
(
obj
,
args
,
context
,
info
)
{
let
results
=
[]
let
conds
=
{
localeCode
:
args
.
locale
,
parent
:
(
args
.
parent
<
1
)
?
null
:
args
.
parent
}
switch
(
args
.
mode
)
{
case
'FOLDERS'
:
conds
.
isFolder
=
true
results
=
await
WIKI
.
models
.
knex
(
'pageTree'
).
where
(
conds
)
break
case
'PAGES'
:
await
WIKI
.
models
.
knex
(
'pageTree'
).
where
(
conds
).
andWhereNotNull
(
'pageId'
)
break
default
:
results
=
await
WIKI
.
models
.
knex
(
'pageTree'
).
where
(
conds
)
break
}
return
results
.
filter
(
r
=>
{
return
WIKI
.
auth
.
checkAccess
(
context
.
req
.
user
,
[
'read:pages'
],
{
path
:
r
.
path
,
locale
:
r
.
localeCode
})
}).
map
(
r
=>
({
...
r
,
locale
:
r
.
localeCode
}))
}
},
PageMutation
:
{
...
...
server/graph/schemas/page.graphql
View file @
2a4b8985
...
...
@@ -40,6 +40,12 @@ type PageQuery {
):
Page
@
auth
(
requires
:
[
"
manage
:
pages
"
,
"
delete
:
pages
"
,
"
manage
:
system
"
])
tags
:
[
PageTag
]!
@
auth
(
requires
:
[
"
manage
:
system
"
,
"
read
:
pages
"
])
tree
(
parent
:
Int
!
mode
:
PageTreeMode
!
locale
:
String
!
):
[
PageTreeItem
]
@
auth
(
requires
:
[
"
manage
:
system
"
,
"
read
:
pages
"
])
}
# -----------------------------------------------
...
...
@@ -182,6 +188,19 @@ type PageListItem {
tags
:
[
String
]
}
type
PageTreeItem
{
id
:
Int
!
path
:
String
!
depth
:
Int
!
title
:
String
!
isPrivate
:
Boolean
!
isFolder
:
Boolean
!
privateNS
:
String
parent
:
Int
pageId
:
Int
locale
:
String
!
}
enum
PageOrderBy
{
CREATED
ID
...
...
@@ -194,3 +213,9 @@ enum PageOrderByDirection {
ASC
DESC
}
enum
PageTreeMode
{
FOLDERS
PAGES
ALL
}
server/jobs/rebuild-tree.js
View file @
2a4b8985
...
...
@@ -43,6 +43,9 @@ module.exports = async (pageId) => {
pageId
:
isFolder
?
null
:
page
.
id
})
parentId
=
pik
}
else
if
(
isFolder
&&
!
found
.
isFolder
)
{
found
.
isFolder
=
true
parentId
=
found
.
id
}
else
{
parentId
=
found
.
id
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment