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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
d2b4109b
Commit
d2b4109b
authored
Aug 15, 2017
by
Winnie Hellmann
Committed by
Phil Hughes
Aug 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display GPG status loading spinner only when Ajax request is made
parent
155de419
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
2 deletions
+79
-2
app/assets/javascripts/gpg_badges.js
app/assets/javascripts/gpg_badges.js
+3
-1
app/assets/stylesheets/pages/commits.scss
app/assets/stylesheets/pages/commits.scss
+4
-0
app/views/projects/commit/_ajax_signature.html.haml
app/views/projects/commit/_ajax_signature.html.haml
+0
-1
spec/javascripts/gpg_badges_spec.js
spec/javascripts/gpg_badges_spec.js
+48
-0
spec/support/gpg_helpers.rb
spec/support/gpg_helpers.rb
+2
-0
spec/views/projects/commits/_commit.html.haml_spec.rb
spec/views/projects/commits/_commit.html.haml_spec.rb
+22
-0
No files found.
app/assets/javascripts/gpg_badges.js
View file @
d2b4109b
export
default
class
GpgBadges
{
export
default
class
GpgBadges
{
static
fetch
()
{
static
fetch
()
{
const
badges
=
$
(
'
.js-loading-gpg-badge
'
);
const
form
=
$
(
'
.commits-search-form
'
);
const
form
=
$
(
'
.commits-search-form
'
);
badges
.
html
(
'
<i class="fa fa-spinner fa-spin"></i>
'
);
$
.
get
({
$
.
get
({
url
:
form
.
data
(
'
signatures-path
'
),
url
:
form
.
data
(
'
signatures-path
'
),
data
:
form
.
serialize
(),
data
:
form
.
serialize
(),
}).
done
((
response
)
=>
{
}).
done
((
response
)
=>
{
const
badges
=
$
(
'
.js-loading-gpg-badge
'
);
response
.
signatures
.
forEach
((
signature
)
=>
{
response
.
signatures
.
forEach
((
signature
)
=>
{
badges
.
filter
(
`[data-commit-sha="
${
signature
.
commit_sha
}
"]`
).
replaceWith
(
signature
.
html
);
badges
.
filter
(
`[data-commit-sha="
${
signature
.
commit_sha
}
"]`
).
replaceWith
(
signature
.
html
);
});
});
...
...
app/assets/stylesheets/pages/commits.scss
View file @
d2b4109b
...
@@ -286,6 +286,10 @@
...
@@ -286,6 +286,10 @@
.gpg-status-box
{
.gpg-status-box
{
&
:empty
{
display
:
none
;
}
&
.valid
{
&
.valid
{
@include
green-status-color
;
@include
green-status-color
;
}
}
...
...
app/views/projects/commit/_ajax_signature.html.haml
View file @
d2b4109b
-
if
commit
.
has_signature?
-
if
commit
.
has_signature?
%button
{
class:
commit_signature_badge_classes
(
'js-loading-gpg-badge'
),
data:
{
toggle:
'tooltip'
,
placement:
'auto top'
,
title:
'GPG signature (loading...)'
,
'commit-sha'
=>
commit
.
sha
}
}
%button
{
class:
commit_signature_badge_classes
(
'js-loading-gpg-badge'
),
data:
{
toggle:
'tooltip'
,
placement:
'auto top'
,
title:
'GPG signature (loading...)'
,
'commit-sha'
=>
commit
.
sha
}
}
%i
.fa.fa-spinner.fa-spin
spec/javascripts/gpg_badges_spec.js
0 → 100644
View file @
d2b4109b
import
GpgBadges
from
'
~/gpg_badges
'
;
describe
(
'
GpgBadges
'
,
()
=>
{
const
dummyCommitSha
=
'
n0m0rec0ffee
'
;
const
dummyBadgeHtml
=
'
dummy html
'
;
const
dummyResponse
=
{
signatures
:
[{
commit_sha
:
dummyCommitSha
,
html
:
dummyBadgeHtml
,
}],
};
beforeEach
(()
=>
{
setFixtures
(
`
<div class="parent-container">
<div class="js-loading-gpg-badge" data-commit-sha="
${
dummyCommitSha
}
"></div>
</div>
`
);
});
it
(
'
displays a loading spinner
'
,
()
=>
{
spyOn
(
$
,
'
get
'
).
and
.
returnValue
({
done
()
{
// intentionally left blank
},
});
GpgBadges
.
fetch
();
expect
(
document
.
querySelector
(
'
.js-loading-gpg-badge:empty
'
)).
toBe
(
null
);
const
spinners
=
document
.
querySelectorAll
(
'
.js-loading-gpg-badge i.fa.fa-spinner.fa-spin
'
);
expect
(
spinners
.
length
).
toBe
(
1
);
});
it
(
'
replaces the loading spinner
'
,
()
=>
{
spyOn
(
$
,
'
get
'
).
and
.
returnValue
({
done
(
callback
)
{
callback
(
dummyResponse
);
},
});
GpgBadges
.
fetch
();
expect
(
document
.
querySelector
(
'
.js-loading-gpg-badge
'
)).
toBe
(
null
);
const
parentContainer
=
document
.
querySelector
(
'
.parent-container
'
);
expect
(
parentContainer
.
innerHTML
.
trim
()).
toEqual
(
dummyBadgeHtml
);
});
});
spec/support/gpg_helpers.rb
View file @
d2b4109b
module
GpgHelpers
module
GpgHelpers
SIGNED_COMMIT_SHA
=
'8a852d50dda17cc8fd1408d2fd0c5b0f24c76ca4'
.
freeze
module
User1
module
User1
extend
self
extend
self
...
...
spec/views/projects/commits/_commit.html.haml_spec.rb
0 → 100644
View file @
d2b4109b
require
'spec_helper'
describe
'projects/commits/_commit.html.haml'
do
context
'with a singed commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:ref
)
{
GpgHelpers
::
SIGNED_COMMIT_SHA
}
let
(
:commit
)
{
repository
.
commit
(
ref
)
}
it
'does not display a loading spinner for GPG status'
do
render
partial:
'projects/commits/commit'
,
locals:
{
project:
project
,
ref:
ref
,
commit:
commit
}
within
'.gpg-status-box'
do
expect
(
page
).
not_to
have_css
(
'i.fa.fa-spinner.fa-spin'
)
end
end
end
end
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