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
ffa4ceda
Commit
ffa4ceda
authored
Jul 27, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix all eslint violations in user_tabs.js
parent
a6732f59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
80 deletions
+73
-80
app/assets/javascripts/users/user_tabs.js
app/assets/javascripts/users/user_tabs.js
+73
-80
No files found.
app/assets/javascripts/users/user_tabs.js
View file @
ffa4ceda
/* eslint-disable max-len, space-before-function-paren, no-underscore-dangle, consistent-return, comma-dangle, no-unused-vars, dot-notation, no-new, no-return-assign, camelcase, no-param-reassign, class-methods-use-this */
import
ActivityCalendar
from
'
./activity_calendar
'
;
import
ActivityCalendar
from
'
./activity_calendar
'
;
/*
/**
UserTabs
* UserTabs
*
Handles persisting and restoring the current tab selection and lazily-loading
* Handles persisting and restoring the current tab selection and lazily-loading
content on the Users#show page.
* content on the Users#show page.
*
### Example Markup
* ### Example Markup
*
<ul class="nav-links">
* <ul class="nav-links">
<li class="activity-tab active">
* <li class="activity-tab active">
<a data-action="activity" data-target="#activity" data-toggle="tab" href="/u/username">
* <a data-action="activity" data-target="#activity" data-toggle="tab" href="/u/username">
Activity
* Activity
</a>
* </a>
</li>
* </li>
<li class="groups-tab">
* <li class="groups-tab">
<a data-action="groups" data-target="#groups" data-toggle="tab" href="/u/username/groups">
* <a data-action="groups" data-target="#groups" data-toggle="tab" href="/u/username/groups">
Groups
* Groups
</a>
* </a>
</li>
* </li>
<li class="contributed-tab">
* <li class="contributed-tab">
<a data-action="contributed" data-target="#contributed" data-toggle="tab" href="/u/username/contributed">
* ...
Contributed projects
* </li>
</a>
* <li class="projects-tab">
</li>
* ...
<li class="projects-tab">
* </li>
<a data-action="projects" data-target="#projects" data-toggle="tab" href="/u/username/projects">
* <li class="snippets-tab">
Personal projects
* ...
</a>
* </li>
</li>
* </ul>
<li class="snippets-tab">
*
<a data-action="snippets" data-target="#snippets" data-toggle="tab" href="/u/username/snippets">
* <div class="tab-content">
</a>
* <div class="tab-pane" id="activity">
</li>
* Activity Content
</ul>
* </div>
* <div class="tab-pane" id="groups">
<div class="tab-content">
* Groups Content
<div class="tab-pane" id="activity">
* </div>
Activity Content
* <div class="tab-pane" id="contributed">
</div>
* Contributed projects content
<div class="tab-pane" id="groups">
* </div>
Groups Content
* <div class="tab-pane" id="projects">
</div>
* Projects content
<div class="tab-pane" id="contributed">
* </div>
Contributed projects content
* <div class="tab-pane" id="snippets">
</div>
* Snippets content
<div class="tab-pane" id="projects">
* </div>
Projects content
* </div>
</div>
*
<div class="tab-pane" id="snippets">
* <div class="loading-status">
Snippets content
* <div class="loading">
</div>
* Loading Animation
</div>
* </div>
* </div>
<div class="loading-status">
*/
<div class="loading">
Loading Animation
</div>
</div>
*/
const
CALENDAR_TEMPLATE
=
`
const
CALENDAR_TEMPLATE
=
`
<div class="clearfix calendar">
<div class="clearfix calendar">
...
@@ -72,12 +65,12 @@ const CALENDAR_TEMPLATE = `
...
@@ -72,12 +65,12 @@ const CALENDAR_TEMPLATE = `
`
;
`
;
export
default
class
UserTabs
{
export
default
class
UserTabs
{
constructor
({
defaultAction
,
action
,
parentEl
})
{
constructor
({
defaultAction
,
action
,
parentEl
})
{
this
.
loaded
=
{};
this
.
loaded
=
{};
this
.
defaultAction
=
defaultAction
||
'
activity
'
;
this
.
defaultAction
=
defaultAction
||
'
activity
'
;
this
.
action
=
action
||
this
.
defaultAction
;
this
.
action
=
action
||
this
.
defaultAction
;
this
.
$parentEl
=
$
(
parentEl
)
||
$
(
document
);
this
.
$parentEl
=
$
(
parentEl
)
||
$
(
document
);
this
.
_l
ocation
=
window
.
location
;
this
.
windowL
ocation
=
window
.
location
;
this
.
$parentEl
.
find
(
'
.nav-links a
'
)
this
.
$parentEl
.
find
(
'
.nav-links a
'
)
.
each
((
i
,
navLink
)
=>
{
.
each
((
i
,
navLink
)
=>
{
this
.
loaded
[
$
(
navLink
).
attr
(
'
data-action
'
)]
=
false
;
this
.
loaded
[
$
(
navLink
).
attr
(
'
data-action
'
)]
=
false
;
...
@@ -93,12 +86,10 @@ export default class UserTabs {
...
@@ -93,12 +86,10 @@ export default class UserTabs {
}
}
bindEvents
()
{
bindEvents
()
{
this
.
changeProjectsPageWrapper
=
this
.
changeProjectsPage
.
bind
(
this
);
this
.
$parentEl
.
off
(
'
shown.bs.tab
'
,
'
.nav-links a[data-toggle="tab"]
'
)
this
.
$parentEl
.
off
(
'
shown.bs.tab
'
,
'
.nav-links a[data-toggle="tab"]
'
)
.
on
(
'
shown.bs.tab
'
,
'
.nav-links a[data-toggle="tab"]
'
,
event
=>
this
.
tabShown
(
event
))
.
on
(
'
shown.bs.tab
'
,
'
.nav-links a[data-toggle="tab"]
'
,
event
=>
this
.
tabShown
(
event
));
.
on
(
'
click
'
,
'
.gl-pagination a
'
,
event
=>
this
.
changeProjectsPage
(
event
));
this
.
$parentEl
.
on
(
'
click
'
,
'
.gl-pagination a
'
,
this
.
changeProjectsPageWrapper
);
}
}
changeProjectsPage
(
e
)
{
changeProjectsPage
(
e
)
{
...
@@ -133,7 +124,7 @@ export default class UserTabs {
...
@@ -133,7 +124,7 @@ export default class UserTabs {
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
snippets
'
];
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
snippets
'
];
if
(
loadableActions
.
indexOf
(
action
)
>
-
1
)
{
if
(
loadableActions
.
indexOf
(
action
)
>
-
1
)
{
return
this
.
loadTab
(
action
,
endpoint
);
this
.
loadTab
(
action
,
endpoint
);
}
}
}
}
...
@@ -142,14 +133,13 @@ export default class UserTabs {
...
@@ -142,14 +133,13 @@ export default class UserTabs {
beforeSend
:
()
=>
this
.
toggleLoading
(
true
),
beforeSend
:
()
=>
this
.
toggleLoading
(
true
),
complete
:
()
=>
this
.
toggleLoading
(
false
),
complete
:
()
=>
this
.
toggleLoading
(
false
),
dataType
:
'
json
'
,
dataType
:
'
json
'
,
type
:
'
GET
'
,
url
:
endpoint
,
url
:
endpoint
,
success
:
(
data
)
=>
{
success
:
(
data
)
=>
{
const
tabSelector
=
`div#
${
action
}
`
;
const
tabSelector
=
`div#
${
action
}
`
;
this
.
$parentEl
.
find
(
tabSelector
).
html
(
data
.
html
);
this
.
$parentEl
.
find
(
tabSelector
).
html
(
data
.
html
);
this
.
loaded
[
action
]
=
true
;
this
.
loaded
[
action
]
=
true
;
return
gl
.
utils
.
localTimeAgo
(
$
(
'
.js-timeago
'
,
tabSelector
));
gl
.
utils
.
localTimeAgo
(
$
(
'
.js-timeago
'
,
tabSelector
));
}
}
,
});
});
}
}
...
@@ -166,10 +156,13 @@ export default class UserTabs {
...
@@ -166,10 +156,13 @@ export default class UserTabs {
url
:
calendarPath
,
url
:
calendarPath
,
success
:
(
activityData
)
=>
{
success
:
(
activityData
)
=>
{
$calendarWrap
.
html
(
CALENDAR_TEMPLATE
);
$calendarWrap
.
html
(
CALENDAR_TEMPLATE
);
// eslint-disable-next-line no-new
new
ActivityCalendar
(
activityData
,
calendarActivitiesPath
);
new
ActivityCalendar
(
activityData
,
calendarActivitiesPath
);
}
}
,
});
});
// eslint-disable-next-line no-new
new
gl
.
Activities
();
new
gl
.
Activities
();
this
.
loaded
.
activity
=
true
;
this
.
loaded
.
activity
=
true
;
}
}
...
@@ -180,13 +173,13 @@ export default class UserTabs {
...
@@ -180,13 +173,13 @@ export default class UserTabs {
}
}
setCurrentAction
(
source
)
{
setCurrentAction
(
source
)
{
let
new
_s
tate
=
source
;
let
new
S
tate
=
source
;
new
_state
=
new_s
tate
.
replace
(
/
\/
+$/
,
''
);
new
State
=
newS
tate
.
replace
(
/
\/
+$/
,
''
);
new
_state
+=
this
.
_location
.
search
+
this
.
_l
ocation
.
hash
;
new
State
+=
this
.
windowLocation
.
search
+
this
.
windowL
ocation
.
hash
;
history
.
replaceState
({
history
.
replaceState
({
url
:
new
_state
url
:
new
State
,
},
document
.
title
,
new
_s
tate
);
},
document
.
title
,
new
S
tate
);
return
new
_s
tate
;
return
new
S
tate
;
}
}
getCurrentAction
()
{
getCurrentAction
()
{
...
...
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