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
Jérome Perrin
gitlab-ce
Commits
9a0f96f9
Commit
9a0f96f9
authored
Mar 31, 2017
by
Kushal Pandya
Committed by
Filipa Lacerda
Mar 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add metrics button to Environment Overview page
parent
75fe1277
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
163 additions
and
16 deletions
+163
-16
app/assets/javascripts/environments/components/environment_actions.js
...avascripts/environments/components/environment_actions.js
+10
-1
app/assets/javascripts/environments/components/environment_external_url.js
...ripts/environments/components/environment_external_url.js
+11
-3
app/assets/javascripts/environments/components/environment_item.js
...s/javascripts/environments/components/environment_item.js
+16
-3
app/assets/javascripts/environments/components/environment_monitoring.js
...scripts/environments/components/environment_monitoring.js
+31
-0
app/assets/javascripts/environments/components/environment_stop.js
...s/javascripts/environments/components/environment_stop.js
+10
-2
app/assets/javascripts/environments/components/environment_terminal_button.js
...ts/environments/components/environment_terminal_button.js
+13
-3
app/assets/stylesheets/pages/environments.scss
app/assets/stylesheets/pages/environments.scss
+10
-1
app/serializers/environment_entity.rb
app/serializers/environment_entity.rb
+7
-0
changelogs/unreleased/29341-add-metrics-button-env-overview.yml
...logs/unreleased/29341-add-metrics-button-env-overview.yml
+4
-0
spec/javascripts/environments/environment_actions_spec.js
spec/javascripts/environments/environment_actions_spec.js
+6
-1
spec/javascripts/environments/environment_monitoring_spec.js
spec/javascripts/environments/environment_monitoring_spec.js
+23
-0
spec/javascripts/environments/environment_stop_spec.js
spec/javascripts/environments/environment_stop_spec.js
+1
-1
spec/javascripts/environments/environment_terminal_button_spec.js
...ascripts/environments/environment_terminal_button_spec.js
+1
-1
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+20
-0
No files found.
app/assets/javascripts/environments/components/environment_actions.js
View file @
9a0f96f9
...
...
@@ -25,6 +25,12 @@ export default {
};
},
computed
:
{
title
()
{
return
'
Deploy to...
'
;
},
},
methods
:
{
onClickAction
(
endpoint
)
{
this
.
isLoading
=
true
;
...
...
@@ -44,8 +50,11 @@ export default {
template
:
`
<div class="btn-group" role="group">
<button
class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container"
class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container has-tooltip"
data-container="body"
data-toggle="dropdown"
:title="title"
:aria-label="title"
:disabled="isLoading">
<span>
<span v-html="playIconSvg"></span>
...
...
app/assets/javascripts/environments/components/environment_external_url.js
View file @
9a0f96f9
...
...
@@ -9,13 +9,21 @@ export default {
},
},
computed
:
{
title
()
{
return
'
Open
'
;
},
},
template
:
`
<a
class="btn external_url"
class="btn external-url has-tooltip"
data-container="body"
:href="externalUrl"
target="_blank"
rel="noopener noreferrer"
title="Environment external URL">
rel="noopener noreferrer nofollow"
:title="title"
:aria-label="title">
<i class="fa fa-external-link" aria-hidden="true"></i>
</a>
`
,
...
...
app/assets/javascripts/environments/components/environment_item.js
View file @
9a0f96f9
...
...
@@ -5,6 +5,7 @@ import ExternalUrlComponent from './environment_external_url';
import
StopComponent
from
'
./environment_stop
'
;
import
RollbackComponent
from
'
./environment_rollback
'
;
import
TerminalButtonComponent
from
'
./environment_terminal_button
'
;
import
MonitoringButtonComponent
from
'
./environment_monitoring
'
;
import
CommitComponent
from
'
../../vue_shared/components/commit
'
;
/**
...
...
@@ -22,6 +23,7 @@ export default {
'
stop-component
'
:
StopComponent
,
'
rollback-component
'
:
RollbackComponent
,
'
terminal-button-component
'
:
TerminalButtonComponent
,
'
monitoring-button-component
'
:
MonitoringButtonComponent
,
},
props
:
{
...
...
@@ -392,6 +394,14 @@ export default {
return
''
;
},
monitoringUrl
()
{
if
(
this
.
model
&&
this
.
model
.
metrics_path
)
{
return
this
.
model
.
metrics_path
;
}
return
''
;
},
/**
* Constructs folder URL based on the current location and the folder id.
*
...
...
@@ -496,13 +506,16 @@ export default {
<external-url-component v-if="externalURL && canReadEnvironment"
:external-url="externalURL"/>
<stop-component v-if="hasStopAction && canCreateDeployment"
:stop-url="model.stop_path"
:service="service"/>
<monitoring-button-component v-if="monitoringUrl && canReadEnvironment"
:monitoring-url="monitoringUrl"/>
<terminal-button-component v-if="model && model.terminal_path"
:terminal-path="model.terminal_path"/>
<stop-component v-if="hasStopAction && canCreateDeployment"
:stop-url="model.stop_path"
:service="service"/>
<rollback-component v-if="canRetry && canCreateDeployment"
:is-last-deployment="isLastDeployment"
:retry-url="retryUrl"
...
...
app/assets/javascripts/environments/components/environment_monitoring.js
0 → 100644
View file @
9a0f96f9
/**
* Renders the Monitoring (Metrics) link in environments table.
*/
export
default
{
props
:
{
monitoringUrl
:
{
type
:
String
,
default
:
''
,
required
:
true
,
},
},
computed
:
{
title
()
{
return
'
Monitoring
'
;
},
},
template
:
`
<a
class="btn monitoring-url has-tooltip"
data-container="body"
:href="monitoringUrl"
target="_blank"
rel="noopener noreferrer nofollow"
:title="title"
:aria-label="title">
<i class="fa fa-area-chart" aria-hidden="true"></i>
</a>
`
,
};
app/assets/javascripts/environments/components/environment_stop.js
View file @
9a0f96f9
...
...
@@ -25,6 +25,12 @@ export default {
};
},
computed
:
{
title
()
{
return
'
Stop
'
;
},
},
methods
:
{
onClick
()
{
if
(
confirm
(
'
Are you sure you want to stop this environment?
'
))
{
...
...
@@ -45,10 +51,12 @@ export default {
template
:
`
<button type="button"
class="btn stop-env-link"
class="btn stop-env-link has-tooltip"
data-container="body"
@click="onClick"
:disabled="isLoading"
title="Stop Environment">
:title="title"
:aria-label="title">
<i class="fa fa-stop stop-env-icon" aria-hidden="true"></i>
<i v-if="isLoading" class="fa fa-spinner fa-spin" aria-hidden="true"></i>
</button>
...
...
app/assets/javascripts/environments/components/environment_terminal_button.js
View file @
9a0f96f9
...
...
@@ -14,12 +14,22 @@ export default {
},
data
()
{
return
{
terminalIconSvg
};
return
{
terminalIconSvg
,
};
},
computed
:
{
title
()
{
return
'
Terminal
'
;
},
},
template
:
`
<a class="btn terminal-button"
title="Open web terminal"
<a class="btn terminal-button has-tooltip"
data-container="body"
:title="title"
:aria-label="title"
:href="terminalPath">
${
terminalIconSvg
}
</a>
...
...
app/assets/stylesheets/pages/environments.scss
View file @
9a0f96f9
...
...
@@ -26,7 +26,7 @@
.table.ci-table
{
.environments-actions
{
min-width
:
2
00px
;
min-width
:
3
00px
;
}
.environments-commit
,
...
...
@@ -222,3 +222,12 @@
stroke
:
$black
;
stroke-width
:
1
;
}
.environments-actions
{
.external-url
,
.monitoring-url
,
.terminal-button
,
.stop-env-link
{
width
:
38px
;
}
}
app/serializers/environment_entity.rb
View file @
9a0f96f9
...
...
@@ -9,6 +9,13 @@ class EnvironmentEntity < Grape::Entity
expose
:last_deployment
,
using:
DeploymentEntity
expose
:stop_action?
expose
:metrics_path
,
if:
->
(
environment
,
_
)
{
environment
.
has_metrics?
}
do
|
environment
|
metrics_namespace_project_environment_path
(
environment
.
project
.
namespace
,
environment
.
project
,
environment
)
end
expose
:environment_path
do
|
environment
|
namespace_project_environment_path
(
environment
.
project
.
namespace
,
...
...
changelogs/unreleased/29341-add-metrics-button-env-overview.yml
0 → 100644
View file @
9a0f96f9
---
title
:
Add metrics button to environments overview page
merge_request
:
10234
author
:
spec/javascripts/environments/environment_actions_spec.js
View file @
9a0f96f9
...
...
@@ -32,7 +32,12 @@ describe('Actions Component', () => {
}).
$mount
();
});
it
(
'
should render a dropdown with the provided actions
'
,
()
=>
{
it
(
'
should render a dropdown button with icon and title attribute
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.fa-caret-down
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
.dropdown-new
'
).
getAttribute
(
'
title
'
)).
toEqual
(
'
Deploy to...
'
);
});
it
(
'
should render a dropdown with the provided list of actions
'
,
()
=>
{
expect
(
component
.
$el
.
querySelectorAll
(
'
.dropdown-menu li
'
).
length
,
).
toEqual
(
actionsMock
.
length
);
...
...
spec/javascripts/environments/environment_monitoring_spec.js
0 → 100644
View file @
9a0f96f9
import
Vue
from
'
vue
'
;
import
monitoringComp
from
'
~/environments/components/environment_monitoring
'
;
describe
(
'
Monitoring Component
'
,
()
=>
{
let
MonitoringComponent
;
beforeEach
(()
=>
{
MonitoringComponent
=
Vue
.
extend
(
monitoringComp
);
});
it
(
'
should render a link to environment monitoring page
'
,
()
=>
{
const
monitoringUrl
=
'
https://gitlab.com
'
;
const
component
=
new
MonitoringComponent
({
propsData
:
{
monitoringUrl
,
},
}).
$mount
();
expect
(
component
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
monitoringUrl
);
expect
(
component
.
$el
.
querySelector
(
'
.fa-area-chart
'
)).
toBeDefined
();
expect
(
component
.
$el
.
getAttribute
(
'
title
'
)).
toEqual
(
'
Monitoring
'
);
});
});
spec/javascripts/environments/environment_stop_spec.js
View file @
9a0f96f9
...
...
@@ -24,7 +24,7 @@ describe('Stop Component', () => {
it
(
'
should render a button to stop the environment
'
,
()
=>
{
expect
(
component
.
$el
.
tagName
).
toEqual
(
'
BUTTON
'
);
expect
(
component
.
$el
.
getAttribute
(
'
title
'
)).
toEqual
(
'
Stop
Environment
'
);
expect
(
component
.
$el
.
getAttribute
(
'
title
'
)).
toEqual
(
'
Stop
'
);
});
it
(
'
should call the service when an action is clicked
'
,
()
=>
{
...
...
spec/javascripts/environments/environment_terminal_button_spec.js
View file @
9a0f96f9
...
...
@@ -18,7 +18,7 @@ describe('Stop Component', () => {
it
(
'
should render a link to open a web terminal with the provided path
'
,
()
=>
{
expect
(
component
.
$el
.
tagName
).
toEqual
(
'
A
'
);
expect
(
component
.
$el
.
getAttribute
(
'
title
'
)).
toEqual
(
'
Open web t
erminal
'
);
expect
(
component
.
$el
.
getAttribute
(
'
title
'
)).
toEqual
(
'
T
erminal
'
);
expect
(
component
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
terminalPath
);
});
});
spec/serializers/environment_entity_spec.rb
View file @
9a0f96f9
...
...
@@ -15,4 +15,24 @@ describe EnvironmentEntity do
it
'exposes core elements of environment'
do
expect
(
subject
).
to
include
(
:id
,
:name
,
:state
,
:environment_path
)
end
context
'metrics disabled'
do
before
do
allow
(
environment
).
to
receive
(
:has_metrics?
).
and_return
(
false
)
end
it
"doesn't expose metrics path"
do
expect
(
subject
).
not_to
include
(
:metrics_path
)
end
end
context
'metrics enabled'
do
before
do
allow
(
environment
).
to
receive
(
:has_metrics?
).
and_return
(
true
)
end
it
'exposes metrics path'
do
expect
(
subject
).
to
include
(
:metrics_path
)
end
end
end
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