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
8cebb71e
Commit
8cebb71e
authored
Nov 10, 2016
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add template to environment vue instance
parent
9be7aa0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
85 deletions
+122
-85
app/assets/javascripts/environments/components/environment_item.js.es6
...vascripts/environments/components/environment_item.js.es6
+4
-27
app/assets/javascripts/environments/environments_bundle.js.es6
...ssets/javascripts/environments/environments_bundle.js.es6
+105
-1
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+13
-57
No files found.
app/assets/javascripts/environments/components/environment_item.js.es6
View file @
8cebb71e
...
@@ -265,16 +265,6 @@
...
@@ -265,16 +265,6 @@
isLastDeployment() {
isLastDeployment() {
return this.model.last_deployment && this.model.last_deployment['last?'];
return this.model.last_deployment && this.model.last_deployment['last?'];
},
},
canReadEnvironmentParsed() {
return true;
return this.$options.convertPermissionToBoolean(this.canReadEnvironment);
},
canCreateDeploymentParsed() {
return true;
return this.$options.convertPermissionToBoolean(this.canCreateDeployment);
},
},
},
/**
/**
...
@@ -289,19 +279,6 @@
...
@@ -289,19 +279,6 @@
return {}.hasOwnProperty.call(obj, key);
return {}.hasOwnProperty.call(obj, key);
},
},
/**
* Converts permission provided as strings to booleans.
* @param {String} string
* @returns {Boolean}
*/
convertPermissionToBoolean(string) {
if (string === 'true') {
return true;
}
return false;
},
methods: {
methods: {
/**
/**
* Toggles the visibility of a folders' children.
* Toggles the visibility of a folders' children.
...
@@ -381,25 +358,25 @@
...
@@ -381,25 +358,25 @@
<td class="hidden-xs col-sm-3">
<td class="hidden-xs col-sm-3">
<div v-if="!isFolder">
<div v-if="!isFolder">
<div v-if="hasManualActions && canCreateDeployment
Parsed
" class="inline">
<div v-if="hasManualActions && canCreateDeployment" class="inline">
<actions-component
<actions-component
:actions="manualActions">
:actions="manualActions">
</actions-component>
</actions-component>
</div>
</div>
<div v-if="model.external_url && canReadEnvironment
Parsed
" class="inline">
<div v-if="model.external_url && canReadEnvironment" class="inline">
<external-url-component
<external-url-component
:external_url="model.external_url">
:external_url="model.external_url">
</external_url-component>
</external_url-component>
</div>
</div>
<div v-if="isStoppable && canCreateDeployment
Parsed
" class="inline">
<div v-if="isStoppable && canCreateDeployment" class="inline">
<stop-component
<stop-component
:stop_url="model.environment_url">
:stop_url="model.environment_url">
</stop-component>
</stop-component>
</div>
</div>
<div v-if="canRetry && canCreateDeployment
Parsed
" class="inline">
<div v-if="canRetry && canCreateDeployment" class="inline">
<rollback-component
<rollback-component
:is_last_deployment="isLastDeployment"
:is_last_deployment="isLastDeployment"
:retry_url="retryUrl">
:retry_url="retryUrl">
...
...
app/assets/javascripts/environments/environments_bundle.js.es6
View file @
8cebb71e
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
//= require_tree ./stores
//= require_tree ./stores
//= require_tree ./services
//= require_tree ./services
//= require ./components/environment_item
//= require ./components/environment_item
//= require .
./boards
/vue_resource_interceptor
//= require ./vue_resource_interceptor
/* globals Vue, EnvironmentsService */
/* globals Vue, EnvironmentsService */
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign */
...
@@ -44,6 +44,11 @@ $(() => {
...
@@ -44,6 +44,11 @@ $(() => {
endpoint: environmentsListApp.dataset.environmentsDataEndpoint,
endpoint: environmentsListApp.dataset.environmentsDataEndpoint,
canCreateDeployment: environmentsListApp.dataset.canCreateDeployment,
canCreateDeployment: environmentsListApp.dataset.canCreateDeployment,
canReadEnvironment: environmentsListApp.dataset.canReadEnvironment,
canReadEnvironment: environmentsListApp.dataset.canReadEnvironment,
canCreateEnvironment: environmentsListApp.dataset.canCreateEnvironment,
projectEnvironmentsPath: environmentsListApp.dataset.projectEnvironmentsPath,
projectClosedEnvironmentsPath: environmentsListApp.dataset.projectClosedEnvironmentsPath,
newEnvironmentPath: environmentsListApp.dataset.newEnvironmentPath,
helpPagePath: environmentsListApp.dataset.helpPagePath,
loading: true,
loading: true,
visibility: 'available',
visibility: 'available',
},
},
...
@@ -52,6 +57,18 @@ $(() => {
...
@@ -52,6 +57,18 @@ $(() => {
filteredEnvironments() {
filteredEnvironments() {
return recursiveMap(filterState(this.visibility), this.state.environments);
return recursiveMap(filterState(this.visibility), this.state.environments);
},
},
scope() {
return this.$options.getQueryParameter('scope');
},
canReadEnvironmentParsed() {
return this.$options.convertPermissionToBoolean(this.canReadEnvironment);
},
canCreateDeploymentParsed() {
return this.$options.convertPermissionToBoolean(this.canCreateDeployment);
},
},
},
init: Store.create.bind(Store),
init: Store.create.bind(Store),
...
@@ -90,5 +107,92 @@ $(() => {
...
@@ -90,5 +107,92 @@ $(() => {
return acc;
return acc;
}, {})[parameter];
}, {})[parameter];
},
},
/**
* Converts permission provided as strings to booleans.
* @param {String} string
* @returns {Boolean}
*/
convertPermissionToBoolean(string) {
if (string === 'true') {
return true;
}
return false;
},
template: `
<div>
<div class="top-area">
<ul v-if="!isLoading" class="nav-links">
<li v-bind:class="{ 'active': scope === undefined}">
<a :href="projectEnvironmentsPath">
Available
<span class="badge js-available-environments-count">
{{state.availableCounter}}
</span>
</a>
</li>
<li v-bind:class="{ 'active': scope === 'stopped'}">
<a :href="projectClosedEnvironmentsPath">
Stopped
<span class="badge js-stopped-environments-count">
{{state.stoppedCounter}}
</span>
</a>
</li>
</ul>
<div v-if="canCreateEnvironment && !loading" class="nav-controls">
<a :href="newEnvironmentPath" class="btn btn-create">
New envrionment
</a>
</div>
</div>
<div class="environments-container">
<div class="environments-list-loading text-center" v-if="loading">
<i class="fa fa-spinner spin"></i>
</div>
<div class="blank-state blank-state-no-icon" v-if="!loading && state.environments.length === 0">
<h2 class="blank-state-title">
You don't have any environments right now.
</h2>
<p class="blank-state-text">
Environments are places where code gets deployed, such as staging or production.
<br />
<a :href="helpPagePath">
Read more about environments
</a>
<a v-if="canCreateEnvironment" :href="newEnvironmentPath" class="btn btn-create">
New Environment
</a>
</p>
</div>
<div class="table-holder" v-if="!loading && state.environments.length > 0">
<table class="table ci-table environments">
<thead>
<th>Environment</th>
<th>Last deployment</th>
<th>Build</th>
<th>Commit</th>
<th></th>
<th class="hidden-xs"></th>
</thead>
<tbody>
<tr is="environment-item"
v-for="model in filteredEnvironments"
:model="model"
:can-create-deployment="canCreateDeploymentParsed"
:can-read-environment="canReadEnvironmentParsed">
</tbody>
</table>
</div>
</div>
</div>
`,
});
});
});
});
app/views/projects/environments/index.html.haml
View file @
8cebb71e
...
@@ -5,60 +5,16 @@
...
@@ -5,60 +5,16 @@
-
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"
)
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
"can-create-deployment"
=>
can?
(
current_user
,
:create_deployment
,
@environment
),
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
)},
class:
container_class
}
.commit-icon-svg.hidden
.top-area
=
custom_icon
(
"icon_commit"
)
%ul
.nav-links
{
"v-if"
=>
"!loading"
}
.play-icon-svg.hidden
%li
{
class:
(
'active'
if
@scope
.
nil?
)}
=
custom_icon
(
"icon_play"
)
=
link_to
project_environments_path
(
@project
)
do
Available
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
%span
.badge.js-available-environments-count
"can-create-deployment"
=>
can?
(
current_user
,
:create_deployment
,
@environment
),
{{state.availableCounter}}
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
),
"can-create-environmnet"
=>
can?
(
current_user
,
:create_environment
,
@project
),
%li
{
class:
(
'active'
if
@scope
==
'stopped'
)}
"project-environments-path"
=>
project_environments_path
(
@project
),
=
link_to
project_environments_path
(
@project
,
scope: :stopped
)
do
"project-closed-environments-path"
=>
project_environments_path
(
@project
,
scope: :stopped
),
Stopped
"new-environment-path"
=>
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
%span
.badge.js-stopped-environments-count
"help-page-path"
=>
help_page_path
(
"ci/environments"
)},
class:
container_class
}
{{state.stoppedCounter}}
-
if
can?
(
current_user
,
:create_environment
,
@project
)
.nav-controls
{
"v-if"
=>
"!loading"
}
=
link_to
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
class:
"btn btn-create"
do
New environment
.environments-container
.environments-list-loading.text-center
{
"v-if"
=>
"loading"
}
=
icon
(
"spinner spin"
)
.blank-state.blank-state-no-icon
{
"v-if"
=>
"!loading && !state.environments.length"
}
%h2
.blank-state-title
You don't have any environments right now.
%p
.blank-state-text
Environments are places where code gets deployed, such as staging or production.
%br
=
succeed
"."
do
=
link_to
"Read more about environments"
,
help_page_path
(
"ci/environments"
)
-
if
can?
(
current_user
,
:create_environment
,
@project
)
=
link_to
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
class:
'btn btn-create'
do
New environment
.commit-icon-svg.hidden
=
custom_icon
(
"icon_commit"
)
.play-icon-svg.hidden
=
custom_icon
(
"icon_play"
)
.table-holder
{
"v-if"
=>
"!loading && state.environments.length"
}
%table
.table.ci-table.environments
%thead
%th
Environment
%th
Last Deployment
%th
Build
%th
Commit
%th
%th
.hidden-xs
%tbody
%tr
{
"is"
=>
"environment-item"
,
"v-for"
=>
"model in filteredEnvironments"
,
":model"
=>
"model"
,
"can-create-deployment"
=>
can?
(
current_user
,
:create_deployment
,
@environment
),
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
)}
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