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
1ed01697
Commit
1ed01697
authored
Nov 16, 2020
by
Annabel Dunstone Gray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert tabs in navigation_tabs.vue to gl-tabs
- Use gl-tabs in pipeline navigation_tabs.vue
parent
bbf8d5fc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
66 deletions
+75
-66
app/assets/javascripts/pipelines/components/pipelines_list/pipelines.vue
...scripts/pipelines/components/pipelines_list/pipelines.vue
+1
-1
app/assets/javascripts/vue_shared/components/navigation_tabs.vue
...ets/javascripts/vue_shared/components/navigation_tabs.vue
+20
-17
changelogs/unreleased/230728-nav-tabs-migration.yml
changelogs/unreleased/230728-nav-tabs-migration.yml
+5
-0
spec/frontend/deploy_keys/components/app_spec.js
spec/frontend/deploy_keys/components/app_spec.js
+6
-9
spec/frontend/vue_shared/components/navigation_tabs_spec.js
spec/frontend/vue_shared/components/navigation_tabs_spec.js
+43
-39
No files found.
app/assets/javascripts/pipelines/components/pipelines_list/pipelines.vue
View file @
1ed01697
...
...
@@ -279,7 +279,7 @@ export default {
<div
class=
"pipelines-container"
>
<div
v-if=
"shouldRenderTabs || shouldRenderButtons"
class=
"top-area scrolling-tabs-container inner-page-scroll-tabs"
class=
"top-area scrolling-tabs-container inner-page-scroll-tabs
gl-border-none
"
>
<div
class=
"fade-left"
><gl-icon
name=
"chevron-lg-left"
:size=
"12"
/></div>
<div
class=
"fade-right"
><gl-icon
name=
"chevron-lg-right"
:size=
"12"
/></div>
...
...
app/assets/javascripts/vue_shared/components/navigation_tabs.vue
View file @
1ed01697
<
script
>
import
$
from
'
jquery
'
;
import
{
GlBadge
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
/**
* Given an array of tabs, renders non linked bootstrap tabs.
...
...
@@ -23,6 +24,11 @@ import $ from 'jquery';
*/
export
default
{
name
:
'
NavigationTabs
'
,
components
:
{
GlBadge
,
GlTabs
,
GlTab
,
},
props
:
{
tabs
:
{
type
:
Array
,
...
...
@@ -50,24 +56,21 @@ export default {
};
</
script
>
<
template
>
<
ul
class=
"nav-links scrolling-tabs separator
"
>
<
li
<
gl-tabs
class=
"gl-display-flex gl-w-full"
nav-class=
"gl-border-0!
"
>
<
gl-tab
v-for=
"(tab, i) in tabs"
:key=
"i"
:class=
"
{
active: tab.isActive,
}"
>
<a
:class=
"`js-$
{scope}-tab-${tab.scope}`"
:data-testid="`${scope}-tab-${tab.scope}`"
role="button"
:title-link-class=
"`js-$
{scope}-tab-${tab.scope} gl-display-inline-flex`"
:title-link-attributes="{ 'data-testid': `${scope}-tab-${tab.scope}` }"
:active="tab.isActive"
@click="onTabClick(tab)"
>
{{
tab
.
name
}}
<span
v-if=
"shouldRenderBadge(tab.count)"
class=
"badge badge-pill"
>
{{
tab
.
count
}}
</span>
</a>
</li>
</ul>
<template
#title
>
<span
class=
"gl-mr-2"
>
{{
tab
.
name
}}
</span>
<gl-badge
v-if=
"shouldRenderBadge(tab.count)"
size=
"sm"
class=
"gl-tab-counter-badge"
>
{{
tab
.
count
}}
</gl-badge>
</
template
>
</gl-tab>
</gl-tabs>
</template>
changelogs/unreleased/230728-nav-tabs-migration.yml
0 → 100644
View file @
1ed01697
---
title
:
Convert navigation_tabs.vue to gl-tabs
merge_request
:
47841
author
:
type
:
other
spec/frontend/deploy_keys/components/app_spec.js
View file @
1ed01697
...
...
@@ -35,7 +35,7 @@ describe('Deploy keys app component', () => {
});
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
'
.gl-spinner
'
);
const
findKeyPanels
=
()
=>
wrapper
.
findAll
(
'
.deploy-keys .
nav-links
li
'
);
const
findKeyPanels
=
()
=>
wrapper
.
findAll
(
'
.deploy-keys .
gl-tabs-nav
li
'
);
it
(
'
renders loading icon while waiting for request
'
,
()
=>
{
mock
.
onGet
(
TEST_ENDPOINT
).
reply
(()
=>
new
Promise
());
...
...
@@ -54,17 +54,14 @@ describe('Deploy keys app component', () => {
});
it
.
each
`
selector
| label | count
${
'
.js-deployKeys-tab-enabled_keys
'
}
|
${
'
Enabled deploy keys
'
}
|
${
1
}
${
'
.js-deployKeys-tab-available_project_keys
'
}
|
${
'
Privately accessible deploy keys
'
}
|
${
0
}
${
'
.js-deployKeys-tab-public_keys
'
}
|
${
'
Publicly accessible deploy keys
'
}
|
${
1
}
`
(
'
$selector title
is $label with keys count equal to $count
'
,
({
selector
,
label
,
count
})
=>
{
selector
${
'
.js-deployKeys-tab-enabled_keys
'
}
${
'
.js-deployKeys-tab-available_project_keys
'
}
${
'
.js-deployKeys-tab-public_keys
'
}
`
(
'
$selector title
exists
'
,
({
selector
})
=>
{
return
mountComponent
().
then
(()
=>
{
const
element
=
wrapper
.
find
(
selector
);
expect
(
element
.
exists
()).
toBe
(
true
);
expect
(
element
.
text
().
trim
()).
toContain
(
label
);
expect
(
element
.
find
(
'
.badge
'
).
text
().
trim
()).
toBe
(
count
.
toString
());
});
});
...
...
spec/frontend/vue_shared/components/navigation_tabs_spec.js
View file @
1ed01697
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
n
avigationTabs
from
'
~/vue_shared/components/navigation_tabs.vue
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlTab
}
from
'
@gitlab/ui
'
;
import
N
avigationTabs
from
'
~/vue_shared/components/navigation_tabs.vue
'
;
describe
(
'
navigation tabs component
'
,
()
=>
{
let
vm
;
let
Component
;
let
data
;
let
wrapper
;
beforeEach
(()
=>
{
data
=
[
const
data
=
[
{
name
:
'
All
'
,
scope
:
'
all
'
,
...
...
@@ -28,37 +25,44 @@ describe('navigation tabs component', () => {
},
];
Component
=
Vue
.
extend
(
navigationTabs
);
vm
=
mountComponent
(
Component
,
{
tabs
:
data
,
scope
:
'
pipelines
'
});
const
createComponent
=
()
=>
{
wrapper
=
mount
(
NavigationTabs
,
{
propsData
:
{
tabs
:
data
,
scope
:
'
pipelines
'
,
},
});
};
beforeEach
(()
=>
{
createComponent
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
should render tabs
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
li
'
).
length
).
toEqual
(
data
.
length
);
expect
(
wrapper
.
findAll
(
GlTab
)).
toHaveLength
(
data
.
length
);
});
it
(
'
should render active tab
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.active .js-pipelines-tab-all
'
)).
toBeDefined
(
);
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-all
'
).
classes
(
'
active
'
)).
toBe
(
true
);
});
it
(
'
should render badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-all .badge
'
).
textContent
.
trim
()).
toEqual
(
'
1
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-pending .badge
'
).
textContent
.
trim
()).
toEqual
(
'
0
'
,
);
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-all
'
).
text
()).
toContain
(
'
1
'
);
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-pending
'
).
text
()).
toContain
(
'
0
'
);
});
it
(
'
should not render badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-running .badge
'
)).
toEqual
(
null
);
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-running .badge
'
).
exists
()).
toBe
(
false
);
});
it
(
'
should trigger onTabClick
'
,
()
=>
{
jest
.
spyOn
(
vm
,
'
$emit
'
).
mockImplementation
(()
=>
{});
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-pending
'
).
click
();
it
(
'
should trigger onTabClick
'
,
async
()
=>
{
await
wrapper
.
find
(
'
.js-pipelines-tab-pending
'
).
trigger
(
'
click
'
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
onChangeTab
'
,
'
pending
'
);
expect
(
wrapper
.
emitted
(
'
onChangeTab
'
)).
toEqual
([[
'
pending
'
]]
);
});
});
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