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
e3516387
Commit
e3516387
authored
Mar 13, 2019
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes EE differences for env store
Creates helpers file Cleans up tests
parent
b3535a3c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
42 deletions
+67
-42
app/assets/javascripts/environments/mixins/environments_mixin.js
...ets/javascripts/environments/mixins/environments_mixin.js
+1
-1
app/assets/javascripts/environments/stores/environments_store.js
...ets/javascripts/environments/stores/environments_store.js
+25
-0
app/assets/javascripts/environments/stores/helpers.js
app/assets/javascripts/environments/stores/helpers.js
+8
-0
spec/javascripts/environments/environments_store_spec.js
spec/javascripts/environments/environments_store_spec.js
+33
-41
No files found.
app/assets/javascripts/environments/mixins/environments_mixin.js
View file @
e3516387
...
...
@@ -3,13 +3,13 @@
*/
import
_
from
'
underscore
'
;
import
Visibility
from
'
visibilityjs
'
;
import
EnvironmentsStore
from
'
ee_else_ce/environments/stores/environments_store
'
;
import
Poll
from
'
../../lib/utils/poll
'
;
import
{
getParameterByName
}
from
'
../../lib/utils/common_utils
'
;
import
{
s__
}
from
'
../../locale
'
;
import
Flash
from
'
../../flash
'
;
import
eventHub
from
'
../event_hub
'
;
import
EnvironmentsStore
from
'
../stores/environments_store
'
;
import
EnvironmentsService
from
'
../services/environments_service
'
;
import
tablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
import
environmentTable
from
'
../components/environments_table.vue
'
;
...
...
app/assets/javascripts/environments/stores/environments_store.js
View file @
e3516387
import
{
parseIntPagination
,
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
setDeployBoard
}
from
'
ee_else_ce/environments/stores/helpers
'
;
/**
* Environments Store.
*
...
...
@@ -31,6 +33,14 @@ export default class EnvironmentsStore {
* If the `size` is bigger than 1, it means it should be rendered as a folder.
* In those cases we add `isFolder` key in order to render it properly.
*
* Top level environments - when the size is 1 - with `rollout_status`
* can render a deploy board. We add `isDeployBoardVisible` and `deployBoardData`
* keys to those environments.
* The first key will let's us know if we should or not render the deploy board.
* It will be toggled when the user clicks to seee the deploy board.
*
* The second key will allow us to update the environment with the received deploy board data.
*
* @param {Array} environments
* @returns {Array}
*/
...
...
@@ -63,6 +73,7 @@ export default class EnvironmentsStore {
filtered
=
Object
.
assign
(
filtered
,
env
);
}
filtered
=
setDeployBoard
(
oldEnvironmentState
,
filtered
);
return
filtered
;
});
...
...
@@ -71,6 +82,20 @@ export default class EnvironmentsStore {
return
filteredEnvironments
;
}
/**
* Stores the pagination information needed to render the pagination for the
* table.
*
* Normalizes the headers to uppercase since they can be provided either
* in uppercase or lowercase.
*
* Parses to an integer the normalized ones needed for the pagination component.
*
* Stores the normalized and parsed information.
*
* @param {Object} pagination = {}
* @return {Object}
*/
setPagination
(
pagination
=
{})
{
const
normalizedHeaders
=
normalizeHeaders
(
pagination
);
const
paginationInformation
=
parseIntPagination
(
normalizedHeaders
);
...
...
app/assets/javascripts/environments/stores/helpers.js
0 → 100644
View file @
e3516387
/**
* Deploy boards are EE only.
*
* @param {Object} environment
* @returns {Object}
*/
// eslint-disable-next-line import/prefer-default-export
export
const
setDeployBoard
=
(
oldEnvironmentState
,
environment
)
=>
environment
;
spec/javascripts/environments/environments_store_spec.js
View file @
e3516387
...
...
@@ -34,54 +34,46 @@ describe('Store', () => {
expect
(
store
.
state
.
stoppedCounter
).
toEqual
(
2
);
});
describe
(
'
store environments
'
,
()
=>
{
it
(
'
should store environments
'
,
()
=>
{
store
.
storeEnvironments
(
serverData
);
expect
(
store
.
state
.
environments
.
length
).
toEqual
(
serverData
.
length
);
});
it
(
'
should add folder keys when environment is a folder
'
,
()
=>
{
const
environment
=
{
name
:
'
bar
'
,
size
:
3
,
id
:
2
,
};
it
(
'
should add folder keys when environment is a folder
'
,
()
=>
{
const
environment
=
{
name
:
'
bar
'
,
size
:
3
,
id
:
2
,
};
store
.
storeEnvironments
([
environment
]);
store
.
storeEnvironments
([
environment
]);
expect
(
store
.
state
.
environments
[
0
].
isFolder
).
toEqual
(
true
);
expect
(
store
.
state
.
environments
[
0
].
folderName
).
toEqual
(
'
bar
'
);
});
it
(
'
should extract content of `latest` key when provided
'
,
()
=>
{
const
environment
=
{
name
:
'
bar
'
,
size
:
3
,
id
:
2
,
latest
:
{
last_deployment
:
{},
isStoppable
:
true
,
},
};
store
.
storeEnvironments
([
environment
]);
expect
(
store
.
state
.
environments
[
0
].
isFolder
).
toEqual
(
true
);
expect
(
store
.
state
.
environments
[
0
].
folderName
).
toEqual
(
'
bar
'
);
});
expect
(
store
.
state
.
environments
[
0
].
last_deployment
).
toEqual
({});
expect
(
store
.
state
.
environments
[
0
].
isStoppable
).
toEqual
(
true
);
});
it
(
'
should extract content of `latest` key when provided
'
,
()
=>
{
const
environment
=
{
name
:
'
bar
'
,
size
:
3
,
id
:
2
,
latest
:
{
last_deployment
:
{},
isStoppable
:
true
,
},
};
store
.
storeEnvironments
([
environment
]);
expect
(
store
.
state
.
environments
[
0
].
last_deployment
).
toEqual
({});
expect
(
store
.
state
.
environments
[
0
].
isStoppable
).
toEqual
(
true
);
});
it
(
'
should store latest.name when the environment is not a folder
'
,
()
=>
{
store
.
storeEnvironments
(
serverData
);
it
(
'
should store latest.name when the environment is not a folder
'
,
()
=>
{
store
.
storeEnvironments
(
serverData
);
expect
(
store
.
state
.
environments
[
0
].
name
).
toEqual
(
serverData
[
0
].
latest
.
name
);
});
expect
(
store
.
state
.
environments
[
0
].
name
).
toEqual
(
serverData
[
0
].
latest
.
name
);
});
it
(
'
should store root level name when environment is a folder
'
,
()
=>
{
store
.
storeEnvironments
(
serverData
);
it
(
'
should store root level name when environment is a folder
'
,
()
=>
{
store
.
storeEnvironments
(
serverData
);
expect
(
store
.
state
.
environments
[
1
].
folderName
).
toEqual
(
serverData
[
1
].
name
);
});
expect
(
store
.
state
.
environments
[
1
].
folderName
).
toEqual
(
serverData
[
1
].
name
);
});
describe
(
'
toggleFolder
'
,
()
=>
{
...
...
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