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
af66f1a6
Commit
af66f1a6
authored
Sep 08, 2021
by
Daniel Schömer
Committed by
Michael Lunøe
Sep 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue shared comonents settings block h4 expand
parent
c9547240
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
+41
-7
app/assets/javascripts/vue_shared/components/settings/settings_block.vue
...scripts/vue_shared/components/settings/settings_block.vue
+17
-2
spec/frontend/vue_shared/components/settings/__snapshots__/settings_block_spec.js.snap
...onents/settings/__snapshots__/settings_block_spec.js.snap
+10
-3
spec/frontend/vue_shared/components/settings/settings_block_spec.js
...end/vue_shared/components/settings/settings_block_spec.js
+14
-2
No files found.
app/assets/javascripts/vue_shared/components/settings/settings_block.vue
View file @
af66f1a6
...
...
@@ -29,14 +29,29 @@ export default {
return
this
.
expanded
?
__
(
'
Collapse
'
)
:
__
(
'
Expand
'
);
},
},
methods
:
{
toggleSectionExpanded
()
{
this
.
sectionExpanded
=
!
this
.
sectionExpanded
;
},
},
};
</
script
>
<
template
>
<section
class=
"settings"
:class=
"
{ 'no-animate': !slideAnimated, expanded }">
<div
class=
"settings-header"
>
<h4><slot
name=
"title"
></slot></h4>
<gl-button
@
click=
"sectionExpanded = !sectionExpanded"
>
<h4>
<span
role=
"button"
tabindex=
"0"
class=
"gl-cursor-pointer"
data-testid=
"section-title"
@
click=
"toggleSectionExpanded"
>
<slot
name=
"title"
></slot>
</span>
</h4>
<gl-button
@
click=
"toggleSectionExpanded"
>
{{
toggleText
}}
</gl-button>
<p>
...
...
spec/frontend/vue_shared/components/settings/__snapshots__/settings_block_spec.js.snap
View file @
af66f1a6
...
...
@@ -8,9 +8,16 @@ exports[`Settings Block renders the correct markup 1`] = `
class="settings-header"
>
<h4>
<span
class="gl-cursor-pointer"
data-testid="section-title"
role="button"
tabindex="0"
>
<div
data-testid="title-slot"
/>
</span>
</h4>
<gl-button-stub
...
...
spec/frontend/vue_shared/components/settings/settings_block_spec.js
View file @
af66f1a6
...
...
@@ -18,13 +18,13 @@ describe('Settings Block', () => {
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
const
findDefaultSlot
=
()
=>
wrapper
.
find
(
'
[data-testid="default-slot"]
'
);
const
findTitleSlot
=
()
=>
wrapper
.
find
(
'
[data-testid="title-slot"]
'
);
const
findDescriptionSlot
=
()
=>
wrapper
.
find
(
'
[data-testid="description-slot"]
'
);
const
findExpandButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
findExpandButton
=
()
=>
wrapper
.
findComponent
(
GlButton
);
const
findSectionTitle
=
()
=>
wrapper
.
find
(
'
[data-testid="section-title"]
'
);
it
(
'
renders the correct markup
'
,
()
=>
{
mountComponent
();
...
...
@@ -90,6 +90,18 @@ describe('Settings Block', () => {
expect
(
findExpandButton
().
text
()).
toBe
(
'
Collapse
'
);
});
it
(
'
adds expanded class when the section title is clicked
'
,
async
()
=>
{
mountComponent
();
expect
(
wrapper
.
classes
(
'
expanded
'
)).
toBe
(
false
);
expect
(
findExpandButton
().
text
()).
toBe
(
'
Expand
'
);
await
findSectionTitle
().
trigger
(
'
click
'
);
expect
(
wrapper
.
classes
(
'
expanded
'
)).
toBe
(
true
);
expect
(
findExpandButton
().
text
()).
toBe
(
'
Collapse
'
);
});
it
(
'
is expanded when `defaultExpanded` is true no matter what
'
,
async
()
=>
{
mountComponent
({
defaultExpanded
:
true
});
...
...
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