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
Hide 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 {
...
@@ -279,7 +279,7 @@ export default {
<div
class=
"pipelines-container"
>
<div
class=
"pipelines-container"
>
<div
<div
v-if=
"shouldRenderTabs || shouldRenderButtons"
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-left"
><gl-icon
name=
"chevron-lg-left"
:size=
"12"
/></div>
<div
class=
"fade-right"
><gl-icon
name=
"chevron-lg-right"
: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
>
<
script
>
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
GlBadge
,
GlTabs
,
GlTab
}
from
'
@gitlab/ui
'
;
/**
/**
* Given an array of tabs, renders non linked bootstrap tabs.
* Given an array of tabs, renders non linked bootstrap tabs.
...
@@ -23,6 +24,11 @@ import $ from 'jquery';
...
@@ -23,6 +24,11 @@ import $ from 'jquery';
*/
*/
export
default
{
export
default
{
name
:
'
NavigationTabs
'
,
name
:
'
NavigationTabs
'
,
components
:
{
GlBadge
,
GlTabs
,
GlTab
,
},
props
:
{
props
:
{
tabs
:
{
tabs
:
{
type
:
Array
,
type
:
Array
,
...
@@ -50,24 +56,21 @@ export default {
...
@@ -50,24 +56,21 @@ export default {
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<
ul
class=
"nav-links scrolling-tabs separator
"
>
<
gl-tabs
class=
"gl-display-flex gl-w-full"
nav-class=
"gl-border-0!
"
>
<
li
<
gl-tab
v-for=
"(tab, i) in tabs"
v-for=
"(tab, i) in tabs"
:key=
"i"
:key=
"i"
:class=
"
{
:title-link-class=
"`js-$
{scope}-tab-${tab.scope} gl-display-inline-flex`"
active: tab.isActive,
:title-link-attributes="{ 'data-testid': `${scope}-tab-${tab.scope}` }"
}"
:active="tab.isActive"
@click="onTabClick(tab)"
>
>
<a
<template
#title
>
:class=
"`js-$
{scope}-tab-${tab.scope}`"
<span
class=
"gl-mr-2"
>
{{
tab
.
name
}}
</span>
:data-testid="`${scope}-tab-${tab.scope}`"
<gl-badge
v-if=
"shouldRenderBadge(tab.count)"
size=
"sm"
class=
"gl-tab-counter-badge"
>
{{
role="button"
tab
.
count
@click="onTabClick(tab)"
}}
</gl-badge>
>
</
template
>
{{
tab
.
name
}}
</gl-tab>
</gl-tabs>
<span
v-if=
"shouldRenderBadge(tab.count)"
class=
"badge badge-pill"
>
{{
tab
.
count
}}
</span>
</a>
</li>
</ul>
</template>
</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', () => {
...
@@ -35,7 +35,7 @@ describe('Deploy keys app component', () => {
});
});
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
'
.gl-spinner
'
);
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
'
,
()
=>
{
it
(
'
renders loading icon while waiting for request
'
,
()
=>
{
mock
.
onGet
(
TEST_ENDPOINT
).
reply
(()
=>
new
Promise
());
mock
.
onGet
(
TEST_ENDPOINT
).
reply
(()
=>
new
Promise
());
...
@@ -54,17 +54,14 @@ describe('Deploy keys app component', () => {
...
@@ -54,17 +54,14 @@ describe('Deploy keys app component', () => {
});
});
it
.
each
`
it
.
each
`
selector
| label | count
selector
${
'
.js-deployKeys-tab-enabled_keys
'
}
|
${
'
Enabled deploy keys
'
}
|
${
1
}
${
'
.js-deployKeys-tab-enabled_keys
'
}
${
'
.js-deployKeys-tab-available_project_keys
'
}
|
${
'
Privately accessible deploy keys
'
}
|
${
0
}
${
'
.js-deployKeys-tab-available_project_keys
'
}
${
'
.js-deployKeys-tab-public_keys
'
}
|
${
'
Publicly accessible deploy keys
'
}
|
${
1
}
${
'
.js-deployKeys-tab-public_keys
'
}
`
(
'
$selector title
is $label with keys count equal to $count
'
,
({
selector
,
label
,
count
})
=>
{
`
(
'
$selector title
exists
'
,
({
selector
})
=>
{
return
mountComponent
().
then
(()
=>
{
return
mountComponent
().
then
(()
=>
{
const
element
=
wrapper
.
find
(
selector
);
const
element
=
wrapper
.
find
(
selector
);
expect
(
element
.
exists
()).
toBe
(
true
);
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
{
mount
}
from
'
@vue/test-utils
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
GlTab
}
from
'
@gitlab/ui
'
;
import
n
avigationTabs
from
'
~/vue_shared/components/navigation_tabs.vue
'
;
import
N
avigationTabs
from
'
~/vue_shared/components/navigation_tabs.vue
'
;
describe
(
'
navigation tabs component
'
,
()
=>
{
describe
(
'
navigation tabs component
'
,
()
=>
{
let
vm
;
let
wrapper
;
let
Component
;
let
data
;
beforeEach
(()
=>
{
const
data
=
[
data
=
[
{
{
name
:
'
All
'
,
name
:
'
All
'
,
scope
:
'
all
'
,
scope
:
'
all
'
,
count
:
1
,
count
:
1
,
isActive
:
true
,
isActive
:
true
,
},
},
{
{
name
:
'
Pending
'
,
name
:
'
Pending
'
,
scope
:
'
pending
'
,
scope
:
'
pending
'
,
count
:
0
,
count
:
0
,
isActive
:
false
,
isActive
:
false
,
},
},
{
{
name
:
'
Running
'
,
name
:
'
Running
'
,
scope
:
'
running
'
,
scope
:
'
running
'
,
isActive
:
false
,
isActive
:
false
,
},
];
const
createComponent
=
()
=>
{
wrapper
=
mount
(
NavigationTabs
,
{
propsData
:
{
tabs
:
data
,
scope
:
'
pipelines
'
,
},
},
];
});
};
Component
=
Vue
.
extend
(
navigationTabs
);
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
tabs
:
data
,
scope
:
'
pipelines
'
}
);
createComponent
(
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
it
(
'
should render tabs
'
,
()
=>
{
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
'
,
()
=>
{
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
'
,
()
=>
{
it
(
'
should render badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-all .badge
'
).
textContent
.
trim
()).
toEqual
(
'
1
'
);
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-all
'
).
text
()).
toContain
(
'
1
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-pending .badge
'
).
textContent
.
trim
()).
toEqual
(
expect
(
wrapper
.
find
(
'
.js-pipelines-tab-pending
'
).
text
()).
toContain
(
'
0
'
);
'
0
'
,
);
});
});
it
(
'
should not render badge
'
,
()
=>
{
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
'
,
()
=>
{
it
(
'
should trigger onTabClick
'
,
async
()
=>
{
jest
.
spyOn
(
vm
,
'
$emit
'
).
mockImplementation
(()
=>
{});
await
wrapper
.
find
(
'
.js-pipelines-tab-pending
'
).
trigger
(
'
click
'
);
vm
.
$el
.
querySelector
(
'
.js-pipelines-tab-pending
'
).
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