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
1524192f
Commit
1524192f
authored
Nov 24, 2020
by
Nicolò Maria Mezzopera
Committed by
Nathan Friend
Nov 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use v-html to build the breadcrumb
parent
7d91cbfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
app/assets/javascripts/registry/explorer/components/registry_breadcrumb.vue
...ipts/registry/explorer/components/registry_breadcrumb.vue
+11
-6
No files found.
app/assets/javascripts/registry/explorer/components/registry_breadcrumb.vue
View file @
1524192f
<
script
>
<
script
>
/* eslint-disable vue/no-v-html */
// We are forced to use `v-html` untill this gitlab-ui MR is merged: https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/1869
// then we can re-write this to use gl-breadcrumb
import
{
initial
,
first
,
last
}
from
'
lodash
'
;
import
{
initial
,
first
,
last
}
from
'
lodash
'
;
import
{
GlSafeHtmlDirective
as
SafeHtml
}
from
'
@gitlab/ui
'
;
import
{
sanitize
}
from
'
~/lib/dompurify
'
;
export
default
{
export
default
{
directives
:
{
SafeHtml
},
props
:
{
props
:
{
crumbs
:
{
crumbs
:
{
type
:
Array
,
type
:
Array
,
...
@@ -11,6 +13,9 @@ export default {
...
@@ -11,6 +13,9 @@ export default {
},
},
},
},
computed
:
{
computed
:
{
parsedCrumbs
()
{
return
this
.
crumbs
.
map
(
c
=>
({
...
c
,
innerHTML
:
sanitize
(
c
.
innerHTML
)
}));
},
rootRoute
()
{
rootRoute
()
{
return
this
.
$router
.
options
.
routes
.
find
(
r
=>
r
.
meta
.
root
);
return
this
.
$router
.
options
.
routes
.
find
(
r
=>
r
.
meta
.
root
);
},
},
...
@@ -18,11 +23,11 @@ export default {
...
@@ -18,11 +23,11 @@ export default {
return
this
.
$route
.
name
===
this
.
rootRoute
.
name
;
return
this
.
$route
.
name
===
this
.
rootRoute
.
name
;
},
},
rootCrumbs
()
{
rootCrumbs
()
{
return
initial
(
this
.
c
rumbs
);
return
initial
(
this
.
parsedC
rumbs
);
},
},
divider
()
{
divider
()
{
const
{
classList
,
tagName
,
innerHTML
}
=
first
(
this
.
crumbs
).
querySelector
(
'
svg
'
);
const
{
classList
,
tagName
,
innerHTML
}
=
first
(
this
.
crumbs
).
querySelector
(
'
svg
'
);
return
{
classList
:
[...
classList
],
tagName
,
innerHTML
};
return
{
classList
:
[...
classList
],
tagName
,
innerHTML
:
sanitize
(
innerHTML
)
};
},
},
lastCrumb
()
{
lastCrumb
()
{
const
{
children
}
=
last
(
this
.
crumbs
);
const
{
children
}
=
last
(
this
.
crumbs
);
...
@@ -43,14 +48,14 @@ export default {
...
@@ -43,14 +48,14 @@ export default {
<li
<li
v-for=
"(crumb, index) in rootCrumbs"
v-for=
"(crumb, index) in rootCrumbs"
:key=
"index"
:key=
"index"
v-safe-html=
"crumb.innerHTML"
:class=
"crumb.className"
:class=
"crumb.className"
v-html=
"crumb.innerHTML"
></li>
></li>
<li
v-if=
"!isRootRoute"
>
<li
v-if=
"!isRootRoute"
>
<router-link
ref=
"rootRouteLink"
:to=
"rootRoute.path"
>
<router-link
ref=
"rootRouteLink"
:to=
"rootRoute.path"
>
{{
rootRoute
.
meta
.
nameGenerator
(
$store
.
state
)
}}
{{
rootRoute
.
meta
.
nameGenerator
(
$store
.
state
)
}}
</router-link>
</router-link>
<component
:is=
"divider.tagName"
v-safe-html=
"divider.innerHTML"
:class=
"divider.classList
"
/>
<component
:is=
"divider.tagName"
:class=
"divider.classList"
v-html=
"divider.innerHTML
"
/>
</li>
</li>
<li>
<li>
<component
:is=
"lastCrumb.tagName"
ref=
"lastCrumb"
:class=
"lastCrumb.className"
>
<component
:is=
"lastCrumb.tagName"
ref=
"lastCrumb"
:class=
"lastCrumb.className"
>
...
...
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