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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
9c41191a
Commit
9c41191a
authored
Oct 24, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds tab behavior to vue component
parent
d697b9c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
17 deletions
+55
-17
app/assets/javascripts/environments/environments_bundle.js.es6
...ssets/javascripts/environments/environments_bundle.js.es6
+45
-1
app/assets/javascripts/environments/stores/environmnets_store.js.es6
...javascripts/environments/stores/environmnets_store.js.es6
+1
-1
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+2
-8
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+7
-7
No files found.
app/assets/javascripts/environments/environments_bundle.js.es6
View file @
9c41191a
...
@@ -15,6 +15,15 @@ $(() => {
...
@@ -15,6 +15,15 @@ $(() => {
gl.EnvironmentsListApp.$destroy(true);
gl.EnvironmentsListApp.$destroy(true);
}
}
const filters = {
stopped (environments) {
return environments.filter((env) => env.state === 'stopped')
},
available (environments) {
return environments.filter((env) => env.state === 'available')
}
};
gl.EnvironmentsListApp = new Vue({
gl.EnvironmentsListApp = new Vue({
el: '#environments-list-view',
el: '#environments-list-view',
...
@@ -26,13 +35,33 @@ $(() => {
...
@@ -26,13 +35,33 @@ $(() => {
data: {
data: {
state: Store.state,
state: Store.state,
endpoint: environmentsListApp.dataset.endpoint,
endpoint: environmentsListApp.dataset.endpoint,
loading: true
loading: true,
visibility: 'available'
},
computed: {
filteredEnvironments () {
return filters[this.visibility](this.state.environments);
},
countStopped () {
return filters['stopped'](this.state.environments).length;
},
counAvailable () {
return filters['available'](this.state.environments).length;
}
},
},
init: Store.create.bind(Store),
init: Store.create.bind(Store),
created() {
created() {
gl.environmentsService = new EnvironmentsService(this.endpoint);
gl.environmentsService = new EnvironmentsService(this.endpoint);
const scope = this.$options.getQueryParameter('scope');
if (scope) {
this.visibility = scope;
}
},
},
/**
/**
...
@@ -45,6 +74,21 @@ $(() => {
...
@@ -45,6 +74,21 @@ $(() => {
this.loading = false;
this.loading = false;
});
});
},
/**
* Transforms the url parameter into an object and
* returns the one requested.
*
* @param {String} param
* @returns {String} The value of the requested parameter.
*/
getQueryParameter(param) {
return window.location.search.substring(1).split('&').reduce((acc, param) => {
acc[param.split('=')[0]] = param.split('=')[1];
return acc;
}, {})[param];
}
}
});
});
});
});
app/assets/javascripts/environments/stores/environmnets_store.js.es6
View file @
9c41191a
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
return acc;
return acc;
}, []).sort(this.sortByName);
}, []).sort(this.sortByName);
this.state.environments = environmentsTree;
this.state.environments = environmentsTree;
return environmentsTree;
return environmentsTree;
...
...
app/controllers/projects/environments_controller.rb
View file @
9c41191a
...
@@ -8,14 +8,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -8,14 +8,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def
index
def
index
@scope
=
params
[
:scope
]
@scope
=
params
[
:scope
]
@all_environments
=
project
.
environments
@environments
=
project
.
environments
@environments
=
if
@scope
==
'stopped'
@all_environments
.
stopped
else
@all_environments
.
available
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
...
...
app/views/projects/environments/index.html.haml
View file @
9c41191a
...
@@ -4,28 +4,28 @@
...
@@ -4,28 +4,28 @@
-
content_for
:page_specific_javascripts
do
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_tag
(
"environments/environments_bundle.js"
)
=
page_specific_javascript_tag
(
"environments/environments_bundle.js"
)
%div
{
class:
container_class
}
#environments-list-view
{
data:
environments_list_data
,
class:
container_class
}
.top-area
.top-area
%ul
.nav-links
%ul
.nav-links
{
"v-if"
=>
"!loading"
}
%li
{
class:
(
'active'
if
@scope
.
nil?
)}
%li
{
class:
(
'active'
if
@scope
.
nil?
)}
=
link_to
project_environments_path
(
@project
)
do
=
link_to
project_environments_path
(
@project
)
do
Available
Available
%span
.badge.js-available-environments-count
%span
.badge.js-available-environments-count
=
number_with_delimiter
(
@all_environments
.
available
.
count
)
{{counAvailable}}
%li
{
class:
(
'active'
if
@scope
==
'stopped'
)}
%li
{
class:
(
'active'
if
@scope
==
'stopped'
)}
=
link_to
project_environments_path
(
@project
,
scope: :stopped
)
do
=
link_to
project_environments_path
(
@project
,
scope: :stopped
)
do
Stopped
Stopped
%span
.badge.js-stopped-environments-count
%span
.badge.js-stopped-environments-count
=
number_with_delimiter
(
@all_environments
.
stopped
.
count
)
{{countStopped}}
-
if
can?
(
current_user
,
:create_environment
,
@project
)
&&
!
@all_environments
.
blank?
-
if
can?
(
current_user
,
:create_environment
,
@project
)
&&
!
@all_environments
.
blank?
.nav-controls
.nav-controls
=
link_to
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
class:
"btn btn-create"
do
=
link_to
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
class:
"btn btn-create"
do
New environment
New environment
#environments-list-view
{
data:
environments_list_data
,
class:
"environments-container"
}
.environments-container
.environments-list-loading.text-center
{
"v-if"
=>
"loading"
}
.environments-list-loading.text-center
{
"v-if"
=>
"loading"
}
=
icon
(
"spinner spin"
)
=
icon
(
"spinner spin"
)
...
@@ -51,6 +51,6 @@
...
@@ -51,6 +51,6 @@
%th
%th
%th
.hidden-xs
%th
.hidden-xs
%tbody
%tbody
%tr
{
"is"
=>
"environment-item"
,
"v-for"
=>
"model in
state.e
nvironments"
,
":model"
=>
"model"
}
%tr
{
"is"
=>
"environment-item"
,
"v-for"
=>
"model in
filteredE
nvironments"
,
":model"
=>
"model"
}
=
render
"projects/environments/components/environment"
=
render
"projects/environments/components/environment"
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