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
Boxiang Sun
gitlab-ce
Commits
3616e063
Commit
3616e063
authored
Oct 05, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert AbuseReports class to a module
parent
cbc7d62c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
47 deletions
+42
-47
app/assets/javascripts/abuse_reports.js
app/assets/javascripts/abuse_reports.js
+1
-4
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-1
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
spec/javascripts/abuse_reports_spec.js
spec/javascripts/abuse_reports_spec.js
+39
-41
No files found.
app/assets/javascripts/abuse_reports.js
View file @
3616e063
const
MAX_MESSAGE_LENGTH
=
500
;
const
MESSAGE_CELL_SELECTOR
=
'
.abuse-reports .message
'
;
class
AbuseReports
{
export
default
class
AbuseReports
{
constructor
()
{
$
(
MESSAGE_CELL_SELECTOR
).
each
(
this
.
truncateLongMessage
);
$
(
document
)
...
...
@@ -32,6 +32,3 @@ class AbuseReports {
}
}
}
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
AbuseReports
=
AbuseReports
;
app/assets/javascripts/dispatcher.js
View file @
3616e063
...
...
@@ -76,6 +76,7 @@ import initProjectVisibilitySelector from './project_visibility';
import
GpgBadges
from
'
./gpg_badges
'
;
import
UserFeatureHelper
from
'
./helpers/user_feature_helper
'
;
import
initChangesDropdown
from
'
./init_changes_dropdown
'
;
import
AbuseReports
from
'
./abuse_reports
'
;
import
{
ajaxGet
,
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
(
function
()
{
...
...
@@ -557,7 +558,7 @@ import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils';
new
Labels
();
}
case
'
abuse_reports
'
:
new
gl
.
AbuseReports
();
new
AbuseReports
();
break
;
}
break
;
...
...
app/assets/javascripts/main.js
View file @
3616e063
...
...
@@ -57,7 +57,6 @@ import './u2f/register';
import
'
./u2f/util
'
;
// everything else
import
'
./abuse_reports
'
;
import
'
./activities
'
;
import
'
./admin
'
;
import
'
./ajax_loading_spinner
'
;
...
...
spec/javascripts/abuse_reports_spec.js
View file @
3616e063
import
'
~/lib/utils/text_utility
'
;
import
'
~/abuse_reports
'
;
((
global
)
=>
{
describe
(
'
Abuse Reports
'
,
()
=>
{
const
FIXTURE
=
'
abuse_reports/abuse_reports_list.html.raw
'
;
const
MAX_MESSAGE_LENGTH
=
500
;
let
$messages
;
const
assertMaxLength
=
$message
=>
expect
(
$message
.
text
().
length
).
toEqual
(
MAX_MESSAGE_LENGTH
);
const
findMessage
=
searchText
=>
$messages
.
filter
(
(
index
,
element
)
=>
element
.
innerText
.
indexOf
(
searchText
)
>
-
1
,
).
first
();
preloadFixtures
(
FIXTURE
);
beforeEach
(
function
()
{
loadFixtures
(
FIXTURE
);
this
.
abuseReports
=
new
global
.
AbuseReports
();
$messages
=
$
(
'
.abuse-reports .message
'
);
});
it
(
'
should truncate long messages
'
,
()
=>
{
const
$longMessage
=
findMessage
(
'
LONG MESSAGE
'
);
expect
(
$longMessage
.
data
(
'
original-message
'
)).
toEqual
(
jasmine
.
anything
());
assertMaxLength
(
$longMessage
);
});
it
(
'
should not truncate short messages
'
,
()
=>
{
const
$shortMessage
=
findMessage
(
'
SHORT MESSAGE
'
);
expect
(
$shortMessage
.
data
(
'
original-message
'
)).
not
.
toEqual
(
jasmine
.
anything
());
});
it
(
'
should allow clicking a truncated message to expand and collapse the full message
'
,
()
=>
{
const
$longMessage
=
findMessage
(
'
LONG MESSAGE
'
);
$longMessage
.
click
();
expect
(
$longMessage
.
data
(
'
original-message
'
).
length
).
toEqual
(
$longMessage
.
text
().
length
);
$longMessage
.
click
();
assertMaxLength
(
$longMessage
);
});
import
AbuseReports
from
'
~/abuse_reports
'
;
describe
(
'
Abuse Reports
'
,
()
=>
{
const
FIXTURE
=
'
abuse_reports/abuse_reports_list.html.raw
'
;
const
MAX_MESSAGE_LENGTH
=
500
;
let
$messages
;
const
assertMaxLength
=
$message
=>
expect
(
$message
.
text
().
length
).
toEqual
(
MAX_MESSAGE_LENGTH
);
const
findMessage
=
searchText
=>
$messages
.
filter
(
(
index
,
element
)
=>
element
.
innerText
.
indexOf
(
searchText
)
>
-
1
,
).
first
();
preloadFixtures
(
FIXTURE
);
beforeEach
(
function
()
{
loadFixtures
(
FIXTURE
);
this
.
abuseReports
=
new
AbuseReports
();
$messages
=
$
(
'
.abuse-reports .message
'
);
});
it
(
'
should truncate long messages
'
,
()
=>
{
const
$longMessage
=
findMessage
(
'
LONG MESSAGE
'
);
expect
(
$longMessage
.
data
(
'
original-message
'
)).
toEqual
(
jasmine
.
anything
());
assertMaxLength
(
$longMessage
);
});
it
(
'
should not truncate short messages
'
,
()
=>
{
const
$shortMessage
=
findMessage
(
'
SHORT MESSAGE
'
);
expect
(
$shortMessage
.
data
(
'
original-message
'
)).
not
.
toEqual
(
jasmine
.
anything
());
});
it
(
'
should allow clicking a truncated message to expand and collapse the full message
'
,
()
=>
{
const
$longMessage
=
findMessage
(
'
LONG MESSAGE
'
);
$longMessage
.
click
();
expect
(
$longMessage
.
data
(
'
original-message
'
).
length
).
toEqual
(
$longMessage
.
text
().
length
);
$longMessage
.
click
();
assertMaxLength
(
$longMessage
);
});
})
(
window
.
gl
)
;
});
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