Skip to content

Commit 955e4e9

Browse files
committed
Merge branch '2747-protected-environments-frontend' into 'master'
Port of protected environments frontend changes from EE to CE See merge request gitlab-org/gitlab-ce!21018
2 parents d40c5fa + 03c4c46 commit 955e4e9

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

app/assets/javascripts/environments/components/environment_item.vue

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ export default {
8686
);
8787
},
8888
89+
/**
90+
* Checkes whether the user is allowed to deploy to this environment.
91+
* (`can_deploy` currently only set in EE)
92+
*
93+
* @returns {Boolean}
94+
*/
95+
isDeployableByUser() {
96+
return this.model && 'can_deploy' in this.model
97+
? this.model.can_deploy
98+
: this.canCreateDeployment;
99+
},
100+
101+
/**
102+
* Checkes whether the environment is protected.
103+
* (`is_protected` currently only set in EE)
104+
*
105+
* @returns {Boolean}
106+
*/
107+
isProtected() {
108+
return this.model && this.model.is_protected;
109+
},
110+
89111
/**
90112
* Returns whether the environment can be stopped.
91113
*
@@ -455,7 +477,7 @@ export default {
455477
class="gl-responsive-table-row"
456478
role="row">
457479
<div
458-
class="table-section section-10"
480+
class="table-section section-wrap section-15"
459481
role="gridcell"
460482
>
461483
<div
@@ -465,16 +487,17 @@ export default {
465487
>
466488
{{ s__("Environments|Environment") }}
467489
</div>
468-
<a
490+
<span
469491
v-if="!model.isFolder"
470-
:href="environmentPath"
471-
class="environment-name flex-truncate-parent table-mobile-content">
472-
<span
492+
class="environment-name table-mobile-content">
493+
<a
473494
v-tooltip
495+
:href="environmentPath"
474496
:title="model.name"
475-
class="flex-truncate-child"
476-
>{{ model.name }}</span>
477-
</a>
497+
>
498+
{{ model.name }}
499+
</a>
500+
</span>
478501
<span
479502
v-else
480503
class="folder-name"
@@ -548,7 +571,7 @@ export default {
548571

549572
<div
550573
v-if="!model.isFolder"
551-
class="table-section section-25"
574+
class="table-section section-20"
552575
role="gridcell"
553576
>
554577
<div
@@ -612,7 +635,7 @@ export default {
612635
/>
613636

614637
<actions-component
615-
v-if="hasManualActions && canCreateDeployment"
638+
v-if="hasManualActions && isDeployableByUser"
616639
:actions="manualActions"
617640
/>
618641

@@ -622,7 +645,7 @@ export default {
622645
/>
623646

624647
<rollback-component
625-
v-if="canRetry && canCreateDeployment"
648+
v-if="canRetry && isDeployableByUser"
626649
:is-last-deployment="isLastDeployment"
627650
:retry-url="retryUrl"
628651
/>

app/assets/javascripts/environments/components/environments_table.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
environments: {
1616
type: Array,
1717
required: true,
18-
default: () => ([]),
18+
default: () => [],
1919
},
2020
2121
canReadEnvironment: {
@@ -35,10 +35,7 @@ export default {
3535
return `${window.location.pathname}/folders/${model.folderName}`;
3636
},
3737
shouldRenderFolderContent(env) {
38-
return env.isFolder &&
39-
env.isOpen &&
40-
env.children &&
41-
env.children.length > 0;
38+
return env.isFolder && env.isOpen && env.children && env.children.length > 0;
4239
},
4340
},
4441
};
@@ -53,7 +50,7 @@ export default {
5350
role="row"
5451
>
5552
<div
56-
class="table-section section-10 environments-name"
53+
class="table-section section-15 environments-name"
5754
role="columnheader"
5855
>
5956
{{ s__("Environments|Environment") }}
@@ -71,7 +68,7 @@ export default {
7168
{{ s__("Environments|Job") }}
7269
</div>
7370
<div
74-
class="table-section section-25 environments-commit"
71+
class="table-section section-20 environments-commit"
7572
role="columnheader"
7673
>
7774
{{ s__("Environments|Commit") }}
@@ -91,7 +88,7 @@ export default {
9188
:model="model"
9289
:can-create-deployment="canCreateDeployment"
9390
:can-read-environment="canReadEnvironment"
94-
:key="i"
91+
:key="`environment-item-${i}`"
9592
/>
9693

9794
<template

app/views/projects/settings/ci_cd/show.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
.settings-content
2929
= render 'autodevops_form'
3030

31+
= render_if_exists 'projects/settings/ci_cd/protected_environments', expanded: expanded
32+
3133
%section.qa-runners-settings.settings.no-animate#js-runners-settings{ class: ('expanded' if expanded) }
3234
.settings-header
3335
%h4

0 commit comments

Comments
 (0)