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
9f0983a4
Commit
9f0983a4
authored
Dec 20, 2018
by
Mike Greiling
Committed by
Kushal Pandya
Dec 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Hide cluster features that don't work yet with Group Clusters"
parent
70ba4ba2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
19 deletions
+106
-19
app/assets/javascripts/environments/components/environment_item.vue
.../javascripts/environments/components/environment_item.vue
+11
-0
app/assets/javascripts/environments/components/environment_terminal_button.vue
...s/environments/components/environment_terminal_button.vue
+6
-0
app/models/environment.rb
app/models/environment.rb
+4
-1
app/serializers/environment_entity.rb
app/serializers/environment_entity.rb
+16
-0
changelogs/unreleased/55103-hide-group-cluster-features.yml
changelogs/unreleased/55103-hide-group-cluster-features.yml
+5
-0
spec/javascripts/environments/environment_terminal_button_spec.js
...ascripts/environments/environment_terminal_button_spec.js
+32
-16
spec/lib/gitlab/prometheus/query_variables_spec.rb
spec/lib/gitlab/prometheus/query_variables_spec.rb
+2
-2
spec/serializers/environment_entity_spec.rb
spec/serializers/environment_entity_spec.rb
+30
-0
No files found.
app/assets/javascripts/environments/components/environment_item.vue
View file @
9f0983a4
...
@@ -14,6 +14,7 @@ import MonitoringButtonComponent from './environment_monitoring.vue';
...
@@ -14,6 +14,7 @@ import MonitoringButtonComponent from './environment_monitoring.vue';
import
CommitComponent
from
'
../../vue_shared/components/commit.vue
'
;
import
CommitComponent
from
'
../../vue_shared/components/commit.vue
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
CLUSTER_TYPE
}
from
'
~/clusters/constants
'
;
/**
/**
* Environment Item Component
* Environment Item Component
...
@@ -84,6 +85,15 @@ export default {
...
@@ -84,6 +85,15 @@ export default {
return
this
.
model
&&
this
.
model
.
is_protected
;
return
this
.
model
&&
this
.
model
.
is_protected
;
},
},
/**
* Hide group cluster features which are not currently implemented.
*
* @returns {Boolean}
*/
disableGroupClusterFeatures
()
{
return
this
.
model
&&
this
.
model
.
cluster_type
===
CLUSTER_TYPE
.
GROUP
;
},
/**
/**
* Returns whether the environment can be stopped.
* Returns whether the environment can be stopped.
*
*
...
@@ -547,6 +557,7 @@ export default {
...
@@ -547,6 +557,7 @@ export default {
<terminal-button-component
<terminal-button-component
v-if=
"model && model.terminal_path"
v-if=
"model && model.terminal_path"
:terminal-path=
"model.terminal_path"
:terminal-path=
"model.terminal_path"
:disabled=
"disableGroupClusterFeatures"
/>
/>
<rollback-component
<rollback-component
...
...
app/assets/javascripts/environments/components/environment_terminal_button.vue
View file @
9f0983a4
...
@@ -19,6 +19,11 @@ export default {
...
@@ -19,6 +19,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
disabled
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
},
computed
:
{
computed
:
{
title
()
{
title
()
{
...
@@ -33,6 +38,7 @@ export default {
...
@@ -33,6 +38,7 @@ export default {
:title=
"title"
:title=
"title"
:aria-label=
"title"
:aria-label=
"title"
:href=
"terminalPath"
:href=
"terminalPath"
:class=
"
{ disabled: disabled }"
class="btn terminal-button d-none d-sm-none d-md-block"
class="btn terminal-button d-none d-sm-none d-md-block"
>
>
<icon
name=
"terminal"
/>
<icon
name=
"terminal"
/>
...
...
app/models/environment.rb
View file @
9f0983a4
# frozen_string_literal: true
# frozen_string_literal: true
class
Environment
<
ActiveRecord
::
Base
class
Environment
<
ActiveRecord
::
Base
include
Gitlab
::
Utils
::
StrongMemoize
# Used to generate random suffixes for the slug
# Used to generate random suffixes for the slug
LETTERS
=
'a'
..
'z'
LETTERS
=
'a'
..
'z'
NUMBERS
=
'0'
..
'9'
NUMBERS
=
'0'
..
'9'
...
@@ -231,7 +232,9 @@ class Environment < ActiveRecord::Base
...
@@ -231,7 +232,9 @@ class Environment < ActiveRecord::Base
end
end
def
deployment_platform
def
deployment_platform
project
.
deployment_platform
(
environment:
self
.
name
)
strong_memoize
(
:deployment_platform
)
do
project
.
deployment_platform
(
environment:
self
.
name
)
end
end
end
private
private
...
...
app/serializers/environment_entity.rb
View file @
9f0983a4
...
@@ -23,6 +23,10 @@ class EnvironmentEntity < Grape::Entity
...
@@ -23,6 +23,10 @@ class EnvironmentEntity < Grape::Entity
stop_project_environment_path
(
environment
.
project
,
environment
)
stop_project_environment_path
(
environment
.
project
,
environment
)
end
end
expose
:cluster_type
,
if:
->
(
environment
,
_
)
{
cluster_platform_kubernetes?
}
do
|
environment
|
cluster
.
cluster_type
end
expose
:terminal_path
,
if:
->
(
*
)
{
environment
.
has_terminals?
&&
can_access_terminal?
}
do
|
environment
|
expose
:terminal_path
,
if:
->
(
*
)
{
environment
.
has_terminals?
&&
can_access_terminal?
}
do
|
environment
|
terminal_project_environment_path
(
environment
.
project
,
environment
)
terminal_project_environment_path
(
environment
.
project
,
environment
)
end
end
...
@@ -48,4 +52,16 @@ class EnvironmentEntity < Grape::Entity
...
@@ -48,4 +52,16 @@ class EnvironmentEntity < Grape::Entity
def
can_access_terminal?
def
can_access_terminal?
can?
(
request
.
current_user
,
:create_environment_terminal
,
environment
)
can?
(
request
.
current_user
,
:create_environment_terminal
,
environment
)
end
end
def
cluster_platform_kubernetes?
deployment_platform
&&
deployment_platform
.
is_a?
(
Clusters
::
Platforms
::
Kubernetes
)
end
def
deployment_platform
environment
.
deployment_platform
end
def
cluster
deployment_platform
.
cluster
end
end
end
changelogs/unreleased/55103-hide-group-cluster-features.yml
0 → 100644
View file @
9f0983a4
---
title
:
Hide cluster features that don't work yet with Group Clusters
merge_request
:
23935
author
:
type
:
fixed
spec/javascripts/environments/environment_terminal_button_spec.js
View file @
9f0983a4
...
@@ -2,30 +2,46 @@ import Vue from 'vue';
...
@@ -2,30 +2,46 @@ import Vue from 'vue';
import
terminalComp
from
'
~/environments/components/environment_terminal_button.vue
'
;
import
terminalComp
from
'
~/environments/components/environment_terminal_button.vue
'
;
describe
(
'
Stop Component
'
,
()
=>
{
describe
(
'
Stop Component
'
,
()
=>
{
let
TerminalComponent
;
let
component
;
let
component
;
const
terminalPath
=
'
/path
'
;
const
terminalPath
=
'
/path
'
;
beforeEach
(()
=>
{
const
mountWithProps
=
props
=>
{
TerminalComponent
=
Vue
.
extend
(
terminalComp
);
const
TerminalComponent
=
Vue
.
extend
(
terminalComp
);
component
=
new
TerminalComponent
({
component
=
new
TerminalComponent
({
propsData
:
{
propsData
:
props
,
terminalPath
,
},
}).
$mount
();
}).
$mount
();
});
};
describe
(
'
enabled
'
,
()
=>
{
beforeEach
(()
=>
{
mountWithProps
({
terminalPath
});
});
describe
(
'
computed
'
,
()
=>
{
it
(
'
title
'
,
()
=>
{
expect
(
component
.
title
).
toEqual
(
'
Terminal
'
);
});
});
describe
(
'
computed
'
,
()
=>
{
it
(
'
should render a link to open a web terminal with the provided path
'
,
()
=>
{
it
(
'
title
'
,
()
=>
{
expect
(
component
.
$el
.
tagName
).
toEqual
(
'
A
'
);
expect
(
component
.
title
).
toEqual
(
'
Terminal
'
);
expect
(
component
.
$el
.
getAttribute
(
'
data-original-title
'
)).
toEqual
(
'
Terminal
'
);
expect
(
component
.
$el
.
getAttribute
(
'
aria-label
'
)).
toEqual
(
'
Terminal
'
);
expect
(
component
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
terminalPath
);
});
it
(
'
should render a non-disabled button
'
,
()
=>
{
expect
(
component
.
$el
.
classList
).
not
.
toContain
(
'
disabled
'
);
});
});
});
});
it
(
'
should render a link to open a web terminal with the provided path
'
,
()
=>
{
describe
(
'
disabled
'
,
()
=>
{
expect
(
component
.
$el
.
tagName
).
toEqual
(
'
A
'
);
beforeEach
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
data-original-title
'
)).
toEqual
(
'
Terminal
'
);
mountWithProps
({
terminalPath
,
disabled
:
true
});
expect
(
component
.
$el
.
getAttribute
(
'
aria-label
'
)).
toEqual
(
'
Terminal
'
);
});
expect
(
component
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
terminalPath
);
it
(
'
should render a disabled button
'
,
()
=>
{
expect
(
component
.
$el
.
classList
).
toContain
(
'
disabled
'
);
});
});
});
});
});
spec/lib/gitlab/prometheus/query_variables_spec.rb
View file @
9f0983a4
...
@@ -4,7 +4,7 @@ require 'spec_helper'
...
@@ -4,7 +4,7 @@ require 'spec_helper'
describe
Gitlab
::
Prometheus
::
QueryVariables
do
describe
Gitlab
::
Prometheus
::
QueryVariables
do
describe
'.call'
do
describe
'.call'
do
s
et
(
:environment
)
{
create
(
:environment
)
}
l
et
(
:environment
)
{
create
(
:environment
)
}
let
(
:slug
)
{
environment
.
slug
}
let
(
:slug
)
{
environment
.
slug
}
subject
{
described_class
.
call
(
environment
)
}
subject
{
described_class
.
call
(
environment
)
}
...
@@ -20,7 +20,7 @@ describe Gitlab::Prometheus::QueryVariables do
...
@@ -20,7 +20,7 @@ describe Gitlab::Prometheus::QueryVariables do
it
{
is_expected
.
to
include
(
kube_namespace:
''
)
}
it
{
is_expected
.
to
include
(
kube_namespace:
''
)
}
end
end
context
'with depl
yo
ment platform'
do
context
'with depl
oy
ment platform'
do
let
(
:kube_namespace
)
{
environment
.
deployment_platform
.
actual_namespace
}
let
(
:kube_namespace
)
{
environment
.
deployment_platform
.
actual_namespace
}
before
do
before
do
...
...
spec/serializers/environment_entity_spec.rb
View file @
9f0983a4
...
@@ -40,4 +40,34 @@ describe EnvironmentEntity do
...
@@ -40,4 +40,34 @@ describe EnvironmentEntity do
expect
(
subject
).
to
include
(
:metrics_path
)
expect
(
subject
).
to
include
(
:metrics_path
)
end
end
end
end
context
'with deployment platform'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
context
'when deployment platform is a cluster'
do
before
do
create
(
:cluster
,
:provided_by_gcp
,
:project
,
environment_scope:
'*'
,
projects:
[
project
])
end
it
'should include cluster_type'
do
expect
(
subject
).
to
include
(
:cluster_type
)
expect
(
subject
[
:cluster_type
]).
to
eq
(
'project_type'
)
end
end
context
'when deployment platform is a Kubernetes Service'
do
before
do
create
(
:kubernetes_service
,
project:
project
)
end
it
'should not include cluster_type'
do
expect
(
subject
).
not_to
include
(
:cluster_type
)
end
end
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