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
b26f30ae
Commit
b26f30ae
authored
Oct 21, 2018
by
Nicolas Giard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: navigation save / load
parent
b870a472
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
17 deletions
+54
-17
admin-navigation.vue
client/components/admin/admin-navigation.vue
+24
-4
navigation.js
server/graph/resolvers/navigation.js
+5
-11
navigation.js
server/models/navigation.js
+8
-2
setup.js
server/setup.js
+17
-0
No files found.
client/components/admin/admin-navigation.vue
View file @
b26f30ae
...
...
@@ -8,6 +8,8 @@
.headline.primary--text
{{
$t
(
'navigation.title'
)
}}
.subheading.grey--text
{{
$t
(
'navigation.subtitle'
)
}}
v-spacer
v-btn(outline, color='grey', @click='refresh', large)
v-icon refresh
v-btn(color='success', depressed, @click='save', large)
v-icon(left) check
span
{{
$t
(
'common:actions.apply'
)
}}
...
...
@@ -185,20 +187,38 @@ export default {
async
save
()
{
this
.
$store
.
commit
(
`loadingStart`
,
'admin-navigation-save'
)
try
{
await
this
.
$apollo
.
mutate
({
const
resp
=
await
this
.
$apollo
.
mutate
({
mutation
:
treeSaveMutation
,
variables
:
{
tree
:
this
.
navTree
}
}
)
if
(
_
.
get
(
resp
,
'data.navigation.updateTree.responseResult.succeeded'
,
false
))
{
this
.
$store
.
commit
(
'showNotification'
,
{
message
:
this
.
$t
(
'navigation.saveSuccess'
),
style
:
'success'
,
icon
:
'check'
}
)
}
else
{
throw
new
Error
(
_
.
get
(
resp
,
'data.navigation.updateTree.responseResult.message'
,
'An unexpected error occured.'
))
}
}
catch
(
err
)
{
this
.
$store
.
commit
(
'showNotification'
,
{
message
:
this
.
$t
(
'navigation.saveSuccess'
)
,
style
:
'
success
'
,
icon
:
'
check
'
message
:
err
.
message
,
style
:
'
red
'
,
icon
:
'
warning
'
}
)
}
this
.
$store
.
commit
(
`loadingStop`
,
'admin-navigation-save'
)
}
,
async
refresh
()
{
await
this
.
$apollo
.
queries
.
navTree
.
refetch
()
this
.
current
=
{
}
this
.
$store
.
commit
(
'showNotification'
,
{
message
:
'Navigation has been refreshed.'
,
style
:
'success'
,
icon
:
'cached'
}
)
}
}
,
apollo
:
{
...
...
server/graph/resolvers/navigation.js
View file @
b26f30ae
...
...
@@ -12,22 +12,16 @@ module.exports = {
},
NavigationQuery
:
{
async
tree
(
obj
,
args
,
context
,
info
)
{
// let renderers = await WIKI.models.renderers.getRenderers()
return
[]
return
WIKI
.
models
.
navigation
.
getTree
()
}
},
NavigationMutation
:
{
async
updateTree
(
obj
,
args
,
context
)
{
try
{
// for (let rdr of args.renderers) {
// await WIKI.models.storage.query().patch({
// isEnabled: rdr.isEnabled,
// config: _.reduce(rdr.config, (result, value, key) => {
// _.set(result, `${value.key}`, value.value)
// return result
// }, {})
// }).where('key', rdr.key)
// }
await
WIKI
.
models
.
navigation
.
query
().
patch
({
config
:
args
.
tree
}).
where
(
'key'
,
'site'
)
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Navigation updated successfully'
)
}
...
...
server/models/navigation.js
View file @
b26f30ae
...
...
@@ -16,12 +16,18 @@ module.exports = class Navigation extends Model {
properties
:
{
key
:
{
type
:
'string'
},
config
:
{
type
:
'
object'
}
config
:
{
type
:
'
array'
,
items
:
{
type
:
'object'
}
}
}
}
}
static
async
getTree
()
{
return
WIKI
.
models
.
navigation
.
query
()
const
navTree
=
await
WIKI
.
models
.
navigation
.
query
().
findOne
(
'key'
,
'site'
)
if
(
navTree
)
{
return
navTree
.
config
}
else
{
WIKI
.
logger
.
warn
(
'Site Navigation is missing or corrupted.'
)
return
[]
}
}
}
server/setup.js
View file @
b26f30ae
...
...
@@ -201,6 +201,23 @@ module.exports = () => {
})
await
guestUser
.
$relatedQuery
(
'groups'
).
relate
(
guestGroup
.
id
)
// Create site nav
WIKI
.
logger
.
info
(
'Creating default site navigation'
)
await
WIKI
.
models
.
navigation
.
query
().
delete
().
where
({
key
:
'site'
})
await
WIKI
.
models
.
navigation
.
query
().
insert
({
key
:
'site'
,
config
:
JSON
.
stringify
([
{
icon
:
'home'
,
kind
:
'link'
,
label
:
'Home'
,
target
:
'/'
,
targetType
:
'home'
}
])
})
WIKI
.
logger
.
info
(
'Setup is complete!'
)
res
.
json
({
ok
:
true
,
...
...
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