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
0d47c86e
Commit
0d47c86e
authored
Sep 18, 2020
by
Angelo Gulina
Committed by
Nicolò Maria Mezzopera
Sep 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate custom Tabs to GlTabs
parent
99a7757c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
32 deletions
+98
-32
app/assets/javascripts/environments/components/enable_review_app_button.vue
...ipts/environments/components/enable_review_app_button.vue
+1
-1
app/assets/javascripts/environments/components/environments_app.vue
.../javascripts/environments/components/environments_app.vue
+75
-28
app/assets/javascripts/vue_shared/mixins/ci_pagination_api_mixin.js
.../javascripts/vue_shared/mixins/ci_pagination_api_mixin.js
+4
-0
changelogs/unreleased/230719-tabs-vue-migrate-app-assets-javascripts-environments-components-en.yml
...ate-app-assets-javascripts-environments-components-en.yml
+5
-0
spec/features/projects/environments/environments_spec.rb
spec/features/projects/environments/environments_spec.rb
+2
-2
spec/frontend/environments/environments_app_spec.js
spec/frontend/environments/environments_app_spec.js
+11
-1
No files found.
app/assets/javascripts/environments/components/enable_review_app_button.vue
View file @
0d47c86e
...
...
@@ -49,7 +49,7 @@ export default {
variant=
"info"
category=
"secondary"
type=
"button"
class=
"js-enable-review-app-button"
class=
"
gl-w-full
js-enable-review-app-button"
>
{{
s__
(
'
Environments|Enable review app
'
)
}}
</gl-button>
...
...
app/assets/javascripts/environments/components/environments_app.vue
View file @
0d47c86e
<
script
>
import
{
Gl
DeprecatedButton
}
from
'
@gitlab/ui
'
;
import
{
Gl
Badge
,
GlButton
,
GlTab
,
GlTabs
}
from
'
@gitlab/ui
'
;
import
{
deprecatedCreateFlash
as
Flash
}
from
'
~/flash
'
;
import
{
s__
}
from
'
~/locale
'
;
import
emptyState
from
'
./empty_state.vue
'
;
...
...
@@ -16,7 +16,10 @@ export default {
ConfirmRollbackModal
,
emptyState
,
EnableReviewAppButton
,
GlDeprecatedButton
,
GlBadge
,
GlButton
,
GlTab
,
GlTabs
,
StopEnvironmentModal
,
DeleteEnvironmentModal
,
},
...
...
@@ -124,27 +127,70 @@ export default {
};
</
script
>
<
template
>
<div>
<div
class=
"environments-section"
>
<stop-environment-modal
:environment=
"environmentInStopModal"
/>
<delete-environment-modal
:environment=
"environmentInDeleteModal"
/>
<confirm-rollback-modal
:environment=
"environmentInRollbackModal"
/>
<div
class=
"top-area"
>
<tabs
:tabs=
"tabs"
scope=
"environments"
@
onChangeTab=
"onChangeTab"
/>
<div
class=
"nav-controls"
>
<enable-review-app-button
v-if=
"state.reviewAppDetails.can_setup_review_app"
class=
"mr-2"
/>
<gl-deprecated-button
<div
class=
"gl-w-full"
>
<div
class=
"
gl-display-flex
gl-flex-direction-column
gl-mt-3
gl-display-md-none!"
>
<enable-review-app-button
v-if=
"state.reviewAppDetails.can_setup_review_app"
class=
"gl-mb-3 gl-flex-fill-1"
/>
<gl-button
v-if=
"canCreateEnvironment && !isLoading"
:href=
"newEnvironmentPath"
category=
"primary"
variant=
"success"
>
{{
s__
(
'
Environments|New environment
'
)
}}
</gl-
deprecated-
button>
</gl-button>
</div>
<gl-tabs
content-class=
"gl-display-none"
>
<gl-tab
v-for=
"(tab, idx) in tabs"
:key=
"idx"
:title-item-class=
"`js-environments-tab-$
{tab.scope}`"
@click="onChangeTab(tab.scope)"
>
<template
#title
>
<span>
{{
tab
.
name
}}
</span>
<gl-badge
size=
"sm"
class=
"gl-tab-counter-badge"
>
{{
tab
.
count
}}
</gl-badge>
</
template
>
</gl-tab>
<
template
#tabs-end
>
<div
class=
"
gl-display-none
gl-display-md-flex
gl-lg-align-items-center
gl-lg-flex-direction-row
gl-lg-flex-fill-1
gl-lg-justify-content-end
gl-lg-mt-0"
>
<enable-review-app-button
v-if=
"state.reviewAppDetails.can_setup_review_app"
class=
"gl-mb-3 gl-lg-mr-3 gl-lg-mb-0"
/>
<gl-button
v-if=
"canCreateEnvironment && !isLoading"
:href=
"newEnvironmentPath"
category=
"primary"
variant=
"success"
>
{{
s__
(
'
Environments|New environment
'
)
}}
</gl-button>
</div>
</
template
>
</gl-tabs>
<container
:is-loading=
"isLoading"
:environments=
"state.environments"
...
...
@@ -163,4 +209,5 @@ export default {
</
template
>
</container>
</div>
</div>
</template>
app/assets/javascripts/vue_shared/mixins/ci_pagination_api_mixin.js
View file @
0d47c86e
...
...
@@ -10,6 +10,10 @@ import { validateParams } from '~/pipelines/utils';
export
default
{
methods
:
{
onChangeTab
(
scope
)
{
if
(
this
.
scope
===
scope
)
{
return
;
}
let
params
=
{
scope
,
page
:
'
1
'
,
...
...
changelogs/unreleased/230719-tabs-vue-migrate-app-assets-javascripts-environments-components-en.yml
0 → 100644
View file @
0d47c86e
---
title
:
Migrate custom Tabs to GlTabs
merge_request
:
42236
author
:
type
:
changed
spec/features/projects/environments/environments_spec.rb
View file @
0d47c86e
...
...
@@ -372,7 +372,7 @@ RSpec.describe 'Environments page', :js do
let
(
:role
)
{
:developer
}
it
'developer creates a new environment with a valid name'
do
within
(
".
top-area
"
)
{
click_link
'New environment'
}
within
(
".
environments-section
"
)
{
click_link
'New environment'
}
fill_in
(
'Name'
,
with:
'production'
)
click_on
'Save'
...
...
@@ -380,7 +380,7 @@ RSpec.describe 'Environments page', :js do
end
it
'developer creates a new environmetn with invalid name'
do
within
(
".
top-area
"
)
{
click_link
'New environment'
}
within
(
".
environments-section
"
)
{
click_link
'New environment'
}
fill_in
(
'Name'
,
with:
'name,with,commas'
)
click_on
'Save'
...
...
spec/frontend/environments/environments_app_spec.js
View file @
0d47c86e
...
...
@@ -40,6 +40,9 @@ describe('Environment', () => {
return
axios
.
waitForAll
();
};
const
findEnvironmentsTabAvailable
=
()
=>
wrapper
.
find
(
'
.js-environments-tab-available > a
'
);
const
findEnvironmentsTabStopped
=
()
=>
wrapper
.
find
(
'
.js-environments-tab-stopped > a
'
);
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
});
...
...
@@ -108,9 +111,16 @@ describe('Environment', () => {
it
(
'
should make an API request when using tabs
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
updateContent
'
).
mockImplementation
(()
=>
{});
wrapper
.
find
(
'
.js-environments-tab-stopped
'
).
trigger
(
'
click
'
);
findEnvironmentsTabStopped
(
).
trigger
(
'
click
'
);
expect
(
wrapper
.
vm
.
updateContent
).
toHaveBeenCalledWith
({
scope
:
'
stopped
'
,
page
:
'
1
'
});
});
it
(
'
should not make the same API request when clicking on the current scope tab
'
,
()
=>
{
// component starts at available
jest
.
spyOn
(
wrapper
.
vm
,
'
updateContent
'
).
mockImplementation
(()
=>
{});
findEnvironmentsTabAvailable
().
trigger
(
'
click
'
);
expect
(
wrapper
.
vm
.
updateContent
).
toHaveBeenCalledTimes
(
0
);
});
});
});
});
...
...
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