Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
300987bb
Commit
300987bb
authored
Mar 06, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to remove & format node object
parent
8d8a9563
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
+31
-2
spec/javascripts/geo_nodes/store/geo_nodes_store_spec.js
spec/javascripts/geo_nodes/store/geo_nodes_store_spec.js
+23
-1
No files found.
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
View file @
300987bb
...
...
@@ -8,7 +8,9 @@ export default class GeoNodesStore {
}
setNodes
(
nodes
)
{
this
.
state
.
nodes
=
nodes
;
this
.
state
.
nodes
=
nodes
.
map
(
node
=>
GeoNodesStore
.
formatNode
(
node
),
);
}
getNodes
()
{
...
...
@@ -19,6 +21,16 @@ export default class GeoNodesStore {
this
.
state
.
nodeDetails
[
nodeId
]
=
GeoNodesStore
.
formatNodeDetails
(
nodeDetails
);
}
removeNode
(
node
)
{
const
indexOfRemovedNode
=
this
.
state
.
nodes
.
indexOf
(
node
);
if
(
indexOfRemovedNode
>
-
1
)
{
this
.
state
.
nodes
.
splice
(
indexOfRemovedNode
,
1
);
if
(
this
.
state
.
nodeDetails
[
node
.
id
])
{
delete
this
.
state
.
nodeDetails
[
node
.
id
];
}
}
}
getPrimaryNodeVersion
()
{
return
{
version
:
this
.
state
.
primaryVersion
,
...
...
@@ -30,6 +42,22 @@ export default class GeoNodesStore {
return
this
.
state
.
nodeDetails
[
nodeId
];
}
static
formatNode
(
rawNode
)
{
const
{
id
,
url
,
primary
,
current
,
enabled
}
=
rawNode
;
return
{
id
,
url
,
primary
,
current
,
enabled
,
nodeActionActive
:
false
,
basePath
:
rawNode
.
_links
.
self
,
repairPath
:
rawNode
.
_links
.
repair
,
editPath
:
rawNode
.
web_edit_url
,
statusPath
:
rawNode
.
_links
.
status
,
};
}
static
formatNodeDetails
(
rawNodeDetails
)
{
return
{
id
:
rawNodeDetails
.
geo_node_id
,
...
...
@@ -41,8 +69,9 @@ export default class GeoNodesStore {
primaryVersion
:
rawNodeDetails
.
primaryVersion
,
primaryRevision
:
rawNodeDetails
.
primaryRevision
,
replicationSlotWAL
:
rawNodeDetails
.
replication_slots_max_retained_wal_bytes
,
missingOAuthApplication
:
rawNodeDetails
.
missing_oauth_application
,
missingOAuthApplication
:
rawNodeDetails
.
missing_oauth_application
||
false
,
storageShardsMatch
:
rawNodeDetails
.
storage_shards_match
,
syncStatusUnavailable
:
rawNodeDetails
.
sync_status_unavailable
||
false
,
replicationSlots
:
{
totalCount
:
rawNodeDetails
.
replication_slots_count
||
0
,
successCount
:
rawNodeDetails
.
replication_slots_used_count
||
0
,
...
...
spec/javascripts/geo_nodes/store/geo_nodes_store_spec.js
View file @
300987bb
...
...
@@ -22,7 +22,7 @@ describe('GeoNodesStore', () => {
describe
(
'
setNodes
'
,
()
=>
{
it
(
'
sets nodes list to state
'
,
()
=>
{
store
.
setNodes
(
mockNodes
);
expect
(
store
.
getNodes
()
).
toBe
(
mockNodes
);
expect
(
store
.
getNodes
()
.
length
).
toBe
(
mockNodes
.
length
);
});
});
...
...
@@ -33,6 +33,28 @@ describe('GeoNodesStore', () => {
});
});
describe
(
'
removeNode
'
,
()
=>
{
it
(
'
removes node from store state
'
,
()
=>
{
store
.
setNodes
(
mockNodes
);
const
nodeToBeRemoved
=
store
.
getNodes
()[
1
];
store
.
removeNode
(
nodeToBeRemoved
);
store
.
getNodes
().
forEach
((
node
)
=>
{
expect
(
node
.
id
).
not
.
toBe
(
nodeToBeRemoved
);
});
});
});
describe
(
'
formatNode
'
,
()
=>
{
it
(
'
returns formatted raw node object
'
,
()
=>
{
const
node
=
GeoNodesStore
.
formatNode
(
mockNodes
[
0
]);
expect
(
node
.
id
).
toBe
(
mockNodes
[
0
].
id
);
expect
(
node
.
url
).
toBe
(
mockNodes
[
0
].
url
);
expect
(
node
.
basePath
).
toBe
(
mockNodes
[
0
].
_links
.
self
);
expect
(
node
.
repairPath
).
toBe
(
mockNodes
[
0
].
_links
.
repair
);
expect
(
node
.
nodeActionActive
).
toBe
(
false
);
});
});
describe
(
'
formatNodeDetails
'
,
()
=>
{
it
(
'
returns formatted raw node details object
'
,
()
=>
{
const
nodeDetails
=
GeoNodesStore
.
formatNodeDetails
(
rawMockNodeDetails
);
...
...
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