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
402bc003
Commit
402bc003
authored
Oct 14, 2019
by
Tim Zallmann
Committed by
Filipa Lacerda
Oct 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes a JS error on Private snippets as there is no share or embed button
parent
549252cc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
18 deletions
+47
-18
app/assets/javascripts/snippet/snippet_embed.js
app/assets/javascripts/snippet/snippet_embed.js
+23
-18
spec/features/snippets/private_snippets_spec.rb
spec/features/snippets/private_snippets_spec.rb
+22
-0
spec/features/snippets/public_snippets_spec.rb
spec/features/snippets/public_snippets_spec.rb
+2
-0
No files found.
app/assets/javascripts/snippet/snippet_embed.js
View file @
402bc003
import
{
__
}
from
'
~/locale
'
;
export
default
()
=>
{
const
{
protocol
,
host
,
pathname
}
=
window
.
location
;
const
shareBtn
=
document
.
querySelector
(
'
.js-share-btn
'
);
if
(
shareBtn
)
{
const
{
protocol
,
host
,
pathname
}
=
window
.
location
;
const
embedBtn
=
document
.
querySelector
(
'
.js-embed-btn
'
);
const
snippetUrlArea
=
document
.
querySelector
(
'
.js-snippet-url-area
'
);
const
embedAction
=
document
.
querySelector
(
'
.js-embed-action
'
);
const
url
=
`
${
protocol
}
//
${
host
+
pathname
}
`
;
...
...
@@ -22,4 +26,5 @@ export default () => {
snippetUrlArea
.
value
=
scriptTag
;
embedAction
.
innerText
=
__
(
'
Embed
'
);
});
}
};
spec/features/snippets/private_snippets_spec.rb
0 → 100644
View file @
402bc003
# frozen_string_literal: true
require
'spec_helper'
describe
'Private Snippets'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
end
it
'Private Snippet renders for creator'
do
private_snippet
=
create
(
:personal_snippet
,
:private
,
author:
user
)
visit
snippet_path
(
private_snippet
)
wait_for_requests
expect
(
page
).
to
have_content
(
private_snippet
.
content
)
expect
(
page
).
not_to
have_css
(
'.js-embed-btn'
)
expect
(
page
).
not_to
have_css
(
'.js-share-btn'
)
end
end
spec/features/snippets/public_snippets_spec.rb
View file @
402bc003
...
...
@@ -10,6 +10,8 @@ describe 'Public Snippets', :js do
wait_for_requests
expect
(
page
).
to
have_content
(
public_snippet
.
content
)
expect
(
page
).
to
have_css
(
'.js-embed-btn'
,
visible:
false
)
expect
(
page
).
to
have_css
(
'.js-share-btn'
,
visible:
false
)
end
it
'Unauthenticated user should see raw public snippets'
do
...
...
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