Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5a2b3c65
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a2b3c65
编写于
3月 30, 2017
作者:
A
Alfredo Sumaran
提交者:
Alfredo Sumaran
4月 21, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Append .json to ajax endpoint to prevent browser to display raw json
Add CHANGELOG entry
上级
60a6389a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
15 deletion
+22
-15
app/assets/javascripts/user_tabs.js
app/assets/javascripts/user_tabs.js
+12
-10
app/views/users/show.html.haml
app/views/users/show.html.haml
+5
-5
changelogs/unreleased/fix-user-profile-tabs-showing-raw-json-instead.yml
...leased/fix-user-profile-tabs-showing-raw-json-instead.yml
+5
-0
未找到文件。
app/assets/javascripts/user_tabs.js
浏览文件 @
5a2b3c65
...
...
@@ -94,15 +94,17 @@ content on the Users#show page.
e
.
preventDefault
();
$
(
'
.tab-pane.active
'
).
empty
();
this
.
loadTab
(
$
(
e
.
target
).
attr
(
'
href
'
),
this
.
getCurrentAction
());
const
endpoint
=
$
(
e
.
target
).
attr
(
'
href
'
);
this
.
loadTab
(
this
.
getCurrentAction
(),
endpoint
);
}
tabShown
(
event
)
{
const
$target
=
$
(
event
.
target
);
const
action
=
$target
.
data
(
'
action
'
);
const
source
=
$target
.
attr
(
'
href
'
);
this
.
setTab
(
source
,
action
);
return
this
.
setCurrentAction
(
source
,
action
);
const
endpoint
=
$target
.
data
(
'
endpoint
'
);
this
.
setTab
(
action
,
endpoint
);
return
this
.
setCurrentAction
(
source
);
}
activateTab
(
action
)
{
...
...
@@ -110,27 +112,27 @@ content on the Users#show page.
.
tab
(
'
show
'
);
}
setTab
(
source
,
action
)
{
setTab
(
action
,
endpoint
)
{
if
(
this
.
loaded
[
action
])
{
return
;
}
if
(
action
===
'
activity
'
)
{
this
.
loadActivities
(
source
);
this
.
loadActivities
();
}
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
snippets
'
];
if
(
loadableActions
.
indexOf
(
action
)
>
-
1
)
{
return
this
.
loadTab
(
source
,
action
);
return
this
.
loadTab
(
action
,
endpoint
);
}
}
loadTab
(
source
,
action
)
{
loadTab
(
action
,
endpoint
)
{
return
$
.
ajax
({
beforeSend
:
()
=>
this
.
toggleLoading
(
true
),
complete
:
()
=>
this
.
toggleLoading
(
false
),
dataType
:
'
json
'
,
type
:
'
GET
'
,
url
:
source
,
url
:
endpoint
,
success
:
(
data
)
=>
{
const
tabSelector
=
`div#
${
action
}
`
;
this
.
$parentEl
.
find
(
tabSelector
).
html
(
data
.
html
);
...
...
@@ -140,7 +142,7 @@ content on the Users#show page.
});
}
loadActivities
(
source
)
{
loadActivities
()
{
if
(
this
.
loaded
[
'
activity
'
])
{
return
;
}
...
...
@@ -155,7 +157,7 @@ content on the Users#show page.
.
toggle
(
status
);
}
setCurrentAction
(
source
,
action
)
{
setCurrentAction
(
source
)
{
let
new_state
=
source
;
new_state
=
new_state
.
replace
(
/
\/
+$/
,
''
);
new_state
+=
this
.
_location
.
search
+
this
.
_location
.
hash
;
...
...
app/views/users/show.html.haml
浏览文件 @
5a2b3c65
...
...
@@ -84,19 +84,19 @@
.fade-right
=
icon
(
'angle-right'
)
%ul
.nav-links.center.user-profile-nav.scrolling-tabs
%li
.js-activity-tab
=
link_to
user_path
,
data:
{
target:
'div#activity'
,
action:
'activity'
,
toggle:
'tab'
}
do
=
link_to
user_path
,
data:
{
target:
'div#activity'
,
action:
'activity'
,
toggle:
'tab'
}
do
Activity
%li
.js-groups-tab
=
link_to
user_groups_path
,
data:
{
target:
'div#groups'
,
action:
'groups'
,
toggle:
'tab'
}
do
=
link_to
user_groups_path
,
data:
{
target:
'div#groups'
,
action:
'groups'
,
toggle:
'tab'
,
endpoint:
user_groups_path
(
format: :json
)
}
do
Groups
%li
.js-contributed-tab
=
link_to
user_contributed_projects_path
,
data:
{
target:
'div#contributed'
,
action:
'contributed'
,
toggle:
'tab'
}
do
=
link_to
user_contributed_projects_path
,
data:
{
target:
'div#contributed'
,
action:
'contributed'
,
toggle:
'tab'
,
endpoint:
user_contributed_projects_path
(
format: :json
)
}
do
Contributed projects
%li
.js-projects-tab
=
link_to
user_projects_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
}
do
=
link_to
user_projects_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
,
endpoint:
user_projects_path
(
format: :json
)
}
do
Personal projects
%li
.js-snippets-tab
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
}
do
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
,
endpoint:
user_snippets_path
(
format: :json
)
}
do
Snippets
%div
{
class:
container_class
}
...
...
changelogs/unreleased/fix-user-profile-tabs-showing-raw-json-instead.yml
0 → 100644
浏览文件 @
5a2b3c65
---
title
:
Prevent user profile tabs to display raw json when going back and forward in
browser history
merge_request
:
author
:
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录