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
a659e955
Commit
a659e955
authored
Sep 10, 2020
by
Jackie Fraser
Committed by
Olena Horal-Koretska
Sep 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cookie to dismiss button on invite group banner
parent
a7116428
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
23 deletions
+51
-23
app/assets/javascripts/groups/components/invite_members_banner.vue
...s/javascripts/groups/components/invite_members_banner.vue
+6
-4
app/assets/javascripts/groups/init_invite_members_banner.js
app/assets/javascripts/groups/init_invite_members_banner.js
+2
-1
app/views/groups/show.html.haml
app/views/groups/show.html.haml
+1
-0
spec/frontend/groups/components/invite_members_banner_spec.js
.../frontend/groups/components/invite_members_banner_spec.js
+42
-18
No files found.
app/assets/javascripts/groups/components/invite_members_banner.vue
View file @
a659e955
<
script
>
import
{
GlBanner
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
parseBoolean
,
setCookie
,
getCookie
}
from
'
~/lib/utils/common_utils
'
;
export
default
{
components
:
{
GlBanner
,
},
inject
:
[
'
svgPath
'
,
'
inviteMembersPath
'
],
inject
:
[
'
svgPath
'
,
'
inviteMembersPath
'
,
'
isDismissedKey
'
],
data
()
{
return
{
visible
:
true
,
isDismissed
:
parseBoolean
(
getCookie
(
this
.
isDismissedKey
))
,
};
},
methods
:
{
handleClose
()
{
this
.
visible
=
false
;
setCookie
(
this
.
isDismissedKey
,
true
);
this
.
isDismissed
=
true
;
},
},
i18n
:
{
...
...
@@ -29,7 +31,7 @@ export default {
<
template
>
<gl-banner
v-if=
"
visible
"
v-if=
"
!isDismissed
"
ref=
"banner"
:title=
"$options.i18n.title"
:button-text=
"$options.i18n.button_text"
...
...
app/assets/javascripts/groups/init_invite_members_banner.js
View file @
a659e955
...
...
@@ -8,13 +8,14 @@ export default function initInviteMembersBanner() {
return
false
;
}
const
{
svgPath
,
inviteMembersPath
}
=
el
.
dataset
;
const
{
svgPath
,
inviteMembersPath
,
isDismissedKey
}
=
el
.
dataset
;
return
new
Vue
({
el
,
provide
:
{
svgPath
,
inviteMembersPath
,
isDismissedKey
,
},
render
:
createElement
=>
createElement
(
InviteMembersBanner
),
});
...
...
app/views/groups/show.html.haml
View file @
a659e955
...
...
@@ -6,6 +6,7 @@
=
content_for
:group_invite_members_banner
do
.container-fluid.container-limited
{
class:
"gl-pb-2! gl-pt-6! #{@content_class}"
}
.js-group-invite-members-banner
{
data:
{
svg_path:
image_path
(
'illustrations/merge_requests.svg'
),
is_dismissed_key:
"invite_#{@group.id}_#{current_user.id}"
,
invite_members_path:
group_group_members_path
(
@group
)
}
}
=
content_for
:meta_tags
do
...
...
spec/frontend/groups/components/invite_members_banner_spec.js
View file @
a659e955
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlBanner
}
from
'
@gitlab/ui
'
;
import
InviteMembersBanner
from
'
~/groups/components/invite_members_banner.vue
'
;
import
{
setCookie
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
const
expectedTitle
=
'
Collaborate with your team
'
;
const
expectedBody
=
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
const
isDismissedKey
=
'
invite_99_1
'
;
const
title
=
'
Collaborate with your team
'
;
const
body
=
"
We noticed that you haven't invited anyone to this group. Invite your colleagues so you can discuss issues, collaborate on merge requests, and share your knowledge
"
;
const
expectedS
vgPath
=
'
/illustrations/background
'
;
const
expectedI
nviteMembersPath
=
'
groups/members
'
;
const
expectedB
uttonText
=
'
Invite your colleagues
'
;
const
s
vgPath
=
'
/illustrations/background
'
;
const
i
nviteMembersPath
=
'
groups/members
'
;
const
b
uttonText
=
'
Invite your colleagues
'
;
const
createComponent
=
(
stubs
=
{})
=>
{
return
shallowMount
(
InviteMembersBanner
,
{
provide
:
{
svgPath
:
expectedSvgPath
,
inviteMembersPath
:
expectedInviteMembersPath
,
svgPath
,
inviteMembersPath
,
isDismissedKey
,
},
stubs
,
});
...
...
@@ -37,23 +42,23 @@ describe('InviteMembersBanner', () => {
});
it
(
'
uses the svgPath for the banner svgpath
'
,
()
=>
{
expect
(
findBanner
().
attributes
(
'
svgpath
'
)).
toBe
(
expectedS
vgPath
);
expect
(
findBanner
().
attributes
(
'
svgpath
'
)).
toBe
(
s
vgPath
);
});
it
(
'
uses the title from options for title
'
,
()
=>
{
expect
(
findBanner
().
attributes
(
'
title
'
)).
toBe
(
expectedT
itle
);
expect
(
findBanner
().
attributes
(
'
title
'
)).
toBe
(
t
itle
);
});
it
(
'
includes the body text from options
'
,
()
=>
{
expect
(
findBanner
().
html
()).
toContain
(
expectedB
ody
);
expect
(
findBanner
().
html
()).
toContain
(
b
ody
);
});
it
(
'
uses the button_text text from options for buttontext
'
,
()
=>
{
expect
(
findBanner
().
attributes
(
'
buttontext
'
)).
toBe
(
expectedB
uttonText
);
expect
(
findBanner
().
attributes
(
'
buttontext
'
)).
toBe
(
b
uttonText
);
});
it
(
'
uses the href from inviteMembersPath for buttonlink
'
,
()
=>
{
expect
(
findBanner
().
attributes
(
'
buttonlink
'
)).
toBe
(
expectedI
nviteMembersPath
);
expect
(
findBanner
().
attributes
(
'
buttonlink
'
)).
toBe
(
i
nviteMembersPath
);
});
});
...
...
@@ -61,16 +66,35 @@ describe('InviteMembersBanner', () => {
const
findButton
=
()
=>
{
return
wrapper
.
find
(
'
button
'
);
};
const
stubs
=
{
GlBanner
,
};
it
(
'
sets visible to false
'
,
()
=>
{
wrapper
=
createComponent
(
stubs
);
beforeEach
(
()
=>
{
wrapper
=
createComponent
(
{
GlBanner
}
);
findButton
().
trigger
(
'
click
'
);
});
it
(
'
sets iDismissed to true
'
,
()
=>
{
expect
(
wrapper
.
vm
.
isDismissed
).
toBe
(
true
);
});
it
(
'
sets the cookie with the isDismissedKey
'
,
()
=>
{
expect
(
setCookie
).
toHaveBeenCalledWith
(
isDismissedKey
,
true
);
});
});
describe
(
'
when a dismiss cookie exists
'
,
()
=>
{
beforeEach
(()
=>
{
parseBoolean
.
mockReturnValue
(
true
);
wrapper
=
createComponent
({
GlBanner
});
});
it
(
'
sets isDismissed to true
'
,
()
=>
{
expect
(
wrapper
.
vm
.
isDismissed
).
toBe
(
true
);
});
expect
(
wrapper
.
vm
.
visible
).
toBe
(
false
);
it
(
'
does not render the banner
'
,
()
=>
{
expect
(
wrapper
.
contains
(
GlBanner
)).
toBe
(
false
);
});
});
});
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