Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
ee0f8db0
Commit
ee0f8db0
authored
Dec 02, 2017
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix breadcrumb 404 link, close #343
parent
4ff721fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
src/components/PageHeader/index.js
src/components/PageHeader/index.js
+12
-10
No files found.
src/components/PageHeader/index.js
View file @
ee0f8db0
...
@@ -6,23 +6,23 @@ import styles from './index.less';
...
@@ -6,23 +6,23 @@ import styles from './index.less';
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
function
getBreadcrumb
Name
(
breadcrumbNameMap
,
url
)
{
function
getBreadcrumb
(
breadcrumbNameMap
,
url
)
{
if
(
breadcrumbNameMap
[
url
]
&&
breadcrumbNameMap
[
url
].
name
)
{
if
(
breadcrumbNameMap
[
url
])
{
return
breadcrumbNameMap
[
url
]
.
name
;
return
breadcrumbNameMap
[
url
];
}
}
const
urlWithoutSplash
=
url
.
replace
(
/
\/
$/
,
''
);
const
urlWithoutSplash
=
url
.
replace
(
/
\/
$/
,
''
);
if
(
breadcrumbNameMap
[
urlWithoutSplash
]
&&
breadcrumbNameMap
[
urlWithoutSplash
].
name
)
{
if
(
breadcrumbNameMap
[
urlWithoutSplash
])
{
return
breadcrumbNameMap
[
urlWithoutSplash
]
.
name
;
return
breadcrumbNameMap
[
urlWithoutSplash
];
}
}
let
breadcrumb
Name
=
''
;
let
breadcrumb
=
''
;
Object
.
keys
(
breadcrumbNameMap
).
forEach
((
item
)
=>
{
Object
.
keys
(
breadcrumbNameMap
).
forEach
((
item
)
=>
{
const
itemRegExpStr
=
`^
${
item
.
replace
(
/:
[\w
-
]
+/g
,
'
[
\\
w-]+
'
)}
$`
;
const
itemRegExpStr
=
`^
${
item
.
replace
(
/:
[\w
-
]
+/g
,
'
[
\\
w-]+
'
)}
$`
;
const
itemRegExp
=
new
RegExp
(
itemRegExpStr
);
const
itemRegExp
=
new
RegExp
(
itemRegExpStr
);
if
(
itemRegExp
.
test
(
url
))
{
if
(
itemRegExp
.
test
(
url
))
{
breadcrumb
Name
=
breadcrumbNameMap
[
item
].
name
;
breadcrumb
=
breadcrumbNameMap
[
item
]
;
}
}
});
});
return
breadcrumb
Name
||
url
;
return
breadcrumb
;
}
}
export
default
class
PageHeader
extends
PureComponent
{
export
default
class
PageHeader
extends
PureComponent
{
...
@@ -76,12 +76,14 @@ export default class PageHeader extends PureComponent {
...
@@ -76,12 +76,14 @@ export default class PageHeader extends PureComponent {
const
pathSnippets
=
location
.
pathname
.
split
(
'
/
'
).
filter
(
i
=>
i
);
const
pathSnippets
=
location
.
pathname
.
split
(
'
/
'
).
filter
(
i
=>
i
);
const
extraBreadcrumbItems
=
pathSnippets
.
map
((
_
,
index
)
=>
{
const
extraBreadcrumbItems
=
pathSnippets
.
map
((
_
,
index
)
=>
{
const
url
=
`/
${
pathSnippets
.
slice
(
0
,
index
+
1
).
join
(
'
/
'
)}
`
;
const
url
=
`/
${
pathSnippets
.
slice
(
0
,
index
+
1
).
join
(
'
/
'
)}
`
;
const
currentBreadcrumb
=
getBreadcrumb
(
breadcrumbNameMap
,
url
);
const
isLinkable
=
(
index
!==
pathSnippets
.
length
-
1
)
&&
currentBreadcrumb
.
component
;
return
(
return
(
<
Breadcrumb
.
Item
key
=
{
url
}
>
<
Breadcrumb
.
Item
key
=
{
url
}
>
{
createElement
(
{
createElement
(
(
index
===
pathSnippets
.
length
-
1
)
?
'
span
'
:
linkElement
,
isLinkable
?
linkElement
:
'
span
'
,
{
[
linkElement
===
'
a
'
?
'
href
'
:
'
to
'
]:
url
},
{
[
linkElement
===
'
a
'
?
'
href
'
:
'
to
'
]:
url
},
getBreadcrumbName
(
breadcrumbNameMap
,
url
)
,
currentBreadcrumb
.
name
||
url
,
)}
)}
<
/Breadcrumb.Item
>
<
/Breadcrumb.Item
>
);
);
...
...
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