Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
admin-fe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eugenij
admin-fe
Commits
1b368c77
Commit
1b368c77
authored
Jan 08, 2020
by
Angelina Filippova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move checking partial update to normalizers and fix bugs
parent
edc8fe58
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
20 deletions
+27
-20
src/store/modules/normalizers.js
src/store/modules/normalizers.js
+24
-1
src/store/modules/settings.js
src/store/modules/settings.js
+3
-19
No files found.
src/store/modules/normalizers.js
View file @
1b368c77
export
const
checkPartialUpdate
=
(
settings
,
updatedSettings
,
description
)
=>
{
return
Object
.
keys
(
updatedSettings
).
reduce
((
acc
,
group
)
=>
{
acc
[
group
]
=
Object
.
keys
(
updatedSettings
[
group
]).
reduce
((
acc
,
key
)
=>
{
debugger
if
(
!
partialUpdate
(
group
,
key
))
{
const
updated
=
Object
.
keys
(
settings
[
group
][
key
]).
reduce
((
acc
,
settingName
)
=>
{
const
setting
=
description
.
find
(
element
=>
element
.
group
===
group
&&
element
.
key
===
key
).
children
.
find
(
child
=>
child
.
key
===
settingName
)
const
type
=
setting
?
setting
.
type
:
''
acc
[
settingName
]
=
[
type
,
settings
[
group
][
key
][
settingName
]]
return
acc
},
{})
acc
[
key
]
=
updated
return
acc
}
acc
[
key
]
=
updatedSettings
[
group
][
key
]
return
acc
},
{})
return
acc
},
{})
}
const
getCurrentValue
=
(
object
,
keys
)
=>
{
if
(
keys
.
length
===
0
)
{
return
object
...
...
@@ -103,7 +126,7 @@ const parseProxyUrl = value => {
return
{
socks5
:
false
,
host
:
null
,
port
:
null
}
}
export
const
partialUpdate
=
(
group
,
key
)
=>
{
const
partialUpdate
=
(
group
,
key
)
=>
{
if
(
group
===
'
:auto_linker
'
&&
key
===
'
:opts
'
)
{
return
false
}
...
...
src/store/modules/settings.js
View file @
1b368c77
import
{
fetchDescription
,
fetchSettings
,
removeSettings
,
updateSettings
,
uploadMedia
}
from
'
@/api/settings
'
import
{
parseNonTuples
,
parseTuples
,
partialUpdate
,
valueHasTuples
,
wrapUpdatedSettings
}
from
'
./normalizers
'
import
{
checkPartialUpdate
,
parseNonTuples
,
parseTuples
,
valueHasTuples
,
wrapUpdatedSettings
}
from
'
./normalizers
'
const
settings
=
{
state
:
{
...
...
@@ -70,27 +70,11 @@ const settings = {
await
removeSettings
(
configs
,
getters
.
authHost
,
getters
.
token
)
},
async
SubmitChanges
({
getters
,
commit
,
state
})
{
const
updatedData
=
Object
.
keys
(
state
.
updatedSettings
).
reduce
((
acc
,
group
)
=>
{
acc
[
group
]
=
Object
.
keys
(
state
.
updatedSettings
[
group
]).
reduce
((
acc
,
key
)
=>
{
if
(
!
partialUpdate
(
group
,
key
))
{
const
updated
=
Object
.
keys
(
state
.
settings
[
group
][
key
]).
reduce
((
acc
,
settingName
)
=>
{
const
settingType
=
state
.
description
.
find
(
element
=>
element
.
group
===
group
&&
element
.
key
===
key
).
children
.
find
(
child
=>
child
.
key
===
settingName
).
type
acc
[
settingName
]
=
[
settingType
,
state
.
settings
[
group
][
key
][
settingName
]]
return
acc
},
{})
acc
[
key
]
=
updated
return
acc
}
acc
[
key
]
=
state
.
updatedSettings
[
group
][
key
]
return
acc
},
{})
return
acc
},
{})
const
updatedData
=
checkPartialUpdate
(
state
.
settings
,
state
.
updatedSettings
,
state
.
description
)
const
configs
=
Object
.
keys
(
updatedData
).
reduce
((
acc
,
group
)
=>
{
return
[...
acc
,
...
wrapUpdatedSettings
(
group
,
updatedData
[
group
],
state
.
settings
)]
},
[])
const
response
=
await
updateSettings
(
configs
,
getters
.
authHost
,
getters
.
token
)
commit
(
'
SET_SETTINGS
'
,
response
.
data
.
configs
)
commit
(
'
CLEAR_UPDATED_SETTINGS
'
)
...
...
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