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
75706da4
Commit
75706da4
authored
Oct 22, 2021
by
Jacques
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add toc dropdown to refactored blob viewer
Added the TOC vue component to the refactored code
parent
c4b2356f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
12 deletions
+48
-12
app/assets/javascripts/blob/components/blob_content.vue
app/assets/javascripts/blob/components/blob_content.vue
+1
-1
app/assets/javascripts/blob/components/blob_header.vue
app/assets/javascripts/blob/components/blob_header.vue
+10
-5
app/assets/javascripts/blob/components/table_contents.vue
app/assets/javascripts/blob/components/table_contents.vue
+3
-2
spec/frontend/blob/components/__snapshots__/blob_header_spec.js.snap
...nd/blob/components/__snapshots__/blob_header_spec.js.snap
+11
-3
spec/frontend/blob/components/blob_header_spec.js
spec/frontend/blob/components/blob_header_spec.js
+2
-0
spec/frontend/blob/components/table_contents_spec.js
spec/frontend/blob/components/table_contents_spec.js
+21
-1
No files found.
app/assets/javascripts/blob/components/blob_content.vue
View file @
75706da4
...
...
@@ -65,7 +65,7 @@ export default {
};
</
script
>
<
template
>
<div
class=
"blob-viewer"
:data-type=
"activeViewer.type"
>
<div
class=
"blob-viewer"
:data-type=
"activeViewer.type"
:data-loaded=
"!loading"
>
<gl-loading-icon
v-if=
"loading"
size=
"md"
color=
"dark"
class=
"my-4 mx-auto"
/>
<template
v-else
>
...
...
app/assets/javascripts/blob/components/blob_header.vue
View file @
75706da4
...
...
@@ -3,12 +3,14 @@ import DefaultActions from './blob_header_default_actions.vue';
import
BlobFilepath
from
'
./blob_header_filepath.vue
'
;
import
ViewerSwitcher
from
'
./blob_header_viewer_switcher.vue
'
;
import
{
SIMPLE_BLOB_VIEWER
}
from
'
./constants
'
;
import
TableOfContents
from
'
./table_contents.vue
'
;
export
default
{
components
:
{
ViewerSwitcher
,
DefaultActions
,
BlobFilepath
,
TableOfContents
,
},
props
:
{
blob
:
{
...
...
@@ -70,11 +72,14 @@ export default {
</
script
>
<
template
>
<div
class=
"js-file-title file-title-flex-parent"
>
<blob-filepath
:blob=
"blob"
>
<template
#filepath-prepend
>
<slot
name=
"prepend"
></slot>
</
template
>
</blob-filepath>
<div
class=
"gl-display-flex"
>
<table-of-contents
class=
"gl-pr-2"
/>
<blob-filepath
:blob=
"blob"
>
<template
#filepath-prepend
>
<slot
name=
"prepend"
></slot>
</
template
>
</blob-filepath>
</div>
<div
class=
"gl-display-none gl-sm-display-flex"
>
<viewer-switcher
v-if=
"showViewerSwitcher"
v-model=
"viewer"
/>
...
...
app/assets/javascripts/blob/components/table_contents.vue
View file @
75706da4
...
...
@@ -18,11 +18,12 @@ export default {
},
mounted
()
{
this
.
blobViewer
=
document
.
querySelector
(
'
.blob-viewer[data-type="rich"]
'
);
const
blobViewerAttr
=
(
attr
)
=>
this
.
blobViewer
.
getAttribute
(
attr
);
this
.
observer
=
new
MutationObserver
(()
=>
{
if
(
this
.
blobViewer
.
classList
.
contains
(
'
hidden
'
))
{
if
(
this
.
blobViewer
.
classList
.
contains
(
'
hidden
'
)
||
blobViewerAttr
(
'
data-type
'
)
!==
'
rich
'
)
{
this
.
isHidden
=
true
;
}
else
if
(
this
.
blobViewer
.
getAttribute
(
'
data-loaded
'
)
===
'
true
'
)
{
}
else
if
(
blobViewerAttr
(
'
data-loaded
'
)
===
'
true
'
)
{
this
.
isHidden
=
false
;
this
.
generateHeaders
();
}
...
...
spec/frontend/blob/components/__snapshots__/blob_header_spec.js.snap
View file @
75706da4
...
...
@@ -4,9 +4,17 @@ exports[`Blob Header Default Actions rendering matches the snapshot 1`] = `
<div
class="js-file-title file-title-flex-parent"
>
<blob-filepath-stub
blob="[object Object]"
/>
<div
class="gl-display-flex"
>
<table-of-contents-stub
class="gl-pr-2"
/>
<blob-filepath-stub
blob="[object Object]"
/>
</div>
<div
class="gl-display-none gl-sm-display-flex"
...
...
spec/frontend/blob/components/blob_header_spec.js
View file @
75706da4
...
...
@@ -3,6 +3,7 @@ import BlobHeader from '~/blob/components/blob_header.vue';
import
DefaultActions
from
'
~/blob/components/blob_header_default_actions.vue
'
;
import
BlobFilepath
from
'
~/blob/components/blob_header_filepath.vue
'
;
import
ViewerSwitcher
from
'
~/blob/components/blob_header_viewer_switcher.vue
'
;
import
TableContents
from
'
~/blob/components/table_contents.vue
'
;
import
{
Blob
}
from
'
./mock_data
'
;
...
...
@@ -43,6 +44,7 @@ describe('Blob Header Default Actions', () => {
it
(
'
renders all components
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
find
(
TableContents
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
ViewerSwitcher
).
exists
()).
toBe
(
true
);
expect
(
findDefaultActions
().
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
BlobFilepath
).
exists
()).
toBe
(
true
);
...
...
spec/frontend/blob/components/table_contents_spec.js
View file @
75706da4
...
...
@@ -32,10 +32,30 @@ describe('Markdown table of contents component', () => {
});
describe
(
'
not loaded
'
,
()
=>
{
const
findDropdownItem
=
()
=>
wrapper
.
findComponent
(
GlDropdownItem
);
it
(
'
does not populate dropdown
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
findComponent
(
GlDropdownItem
).
exists
()).
toBe
(
false
);
expect
(
findDropdownItem
().
exists
()).
toBe
(
false
);
});
it
(
'
does not show dropdown when loading blob content
'
,
async
()
=>
{
createComponent
();
await
setLoaded
(
false
);
expect
(
findDropdownItem
().
exists
()).
toBe
(
false
);
});
it
(
'
does not show dropdown when viewing non-rich content
'
,
async
()
=>
{
createComponent
();
document
.
querySelector
(
'
.blob-viewer
'
).
setAttribute
(
'
data-type
'
,
'
simple
'
);
await
setLoaded
(
true
);
expect
(
findDropdownItem
().
exists
()).
toBe
(
false
);
});
});
...
...
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