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
d956f68a
Commit
d956f68a
authored
Sep 11, 2019
by
Winnie Hellmann
Committed by
Mike Greiling
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replacing vue-resource with axios in Markdown field
parent
1a5c262a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
22 deletions
+26
-22
app/assets/javascripts/vue_shared/components/markdown/field.vue
...sets/javascripts/vue_shared/components/markdown/field.vue
+3
-3
changelogs/unreleased/61385-replace-vue-resource.yml
changelogs/unreleased/61385-replace-vue-resource.yml
+5
-0
spec/javascripts/vue_shared/components/markdown/field_spec.js
.../javascripts/vue_shared/components/markdown/field_spec.js
+18
-19
No files found.
app/assets/javascripts/vue_shared/components/markdown/field.vue
View file @
d956f68a
...
@@ -9,6 +9,7 @@ import markdownHeader from './header.vue';
...
@@ -9,6 +9,7 @@ import markdownHeader from './header.vue';
import
markdownToolbar
from
'
./toolbar.vue
'
;
import
markdownToolbar
from
'
./toolbar.vue
'
;
import
icon
from
'
../icon.vue
'
;
import
icon
from
'
../icon.vue
'
;
import
Suggestions
from
'
~/vue_shared/components/markdown/suggestions.vue
'
;
import
Suggestions
from
'
~/vue_shared/components/markdown/suggestions.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -167,10 +168,9 @@ export default {
...
@@ -167,10 +168,9 @@ export default {
if
(
text
)
{
if
(
text
)
{
this
.
markdownPreviewLoading
=
true
;
this
.
markdownPreviewLoading
=
true
;
this
.
markdownPreview
=
__
(
'
Loading…
'
);
this
.
markdownPreview
=
__
(
'
Loading…
'
);
this
.
$http
axios
.
post
(
this
.
markdownPreviewPath
,
{
text
})
.
post
(
this
.
markdownPreviewPath
,
{
text
})
.
then
(
resp
=>
resp
.
json
())
.
then
(
response
=>
this
.
renderMarkdown
(
response
.
data
))
.
then
(
data
=>
this
.
renderMarkdown
(
data
))
.
catch
(()
=>
new
Flash
(
__
(
'
Error loading markdown preview
'
)));
.
catch
(()
=>
new
Flash
(
__
(
'
Error loading markdown preview
'
)));
}
else
{
}
else
{
this
.
renderMarkdown
();
this
.
renderMarkdown
();
...
...
changelogs/unreleased/61385-replace-vue-resource.yml
0 → 100644
View file @
d956f68a
---
title
:
Replaced vue resource to axios in the Markdown field preview component
merge_request
:
32742
author
:
Prakash Chokalingam @prakash_Chokalingam
type
:
fixed
spec/javascripts/vue_shared/components/markdown/field_spec.js
View file @
d956f68a
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
'
~/behaviors/markdown/render_gfm
'
;
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
fieldComponent
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
fieldComponent
from
'
~/vue_shared/components/markdown/field.vue
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
function
assertMarkdownTabs
(
isWrite
,
writeLink
,
previewLink
,
vm
)
{
function
assertMarkdownTabs
(
isWrite
,
writeLink
,
previewLink
,
vm
)
{
expect
(
writeLink
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toEqual
(
isWrite
);
expect
(
writeLink
.
parentNode
.
classList
.
contains
(
'
active
'
)).
toEqual
(
isWrite
);
...
@@ -9,9 +13,13 @@ function assertMarkdownTabs(isWrite, writeLink, previewLink, vm) {
...
@@ -9,9 +13,13 @@ function assertMarkdownTabs(isWrite, writeLink, previewLink, vm) {
}
}
describe
(
'
Markdown field component
'
,
()
=>
{
describe
(
'
Markdown field component
'
,
()
=>
{
const
markdownPreviewPath
=
`
${
TEST_HOST
}
/preview`
;
const
markdownDocsPath
=
`
${
TEST_HOST
}
/docs`
;
let
axiosMock
;
let
vm
;
let
vm
;
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
axiosMock
=
new
AxiosMockAdapter
(
axios
);
vm
=
new
Vue
({
vm
=
new
Vue
({
components
:
{
components
:
{
fieldComponent
,
fieldComponent
,
...
@@ -23,8 +31,8 @@ describe('Markdown field component', () => {
...
@@ -23,8 +31,8 @@ describe('Markdown field component', () => {
},
},
template
:
`
template
:
`
<field-component
<field-component
markdown-preview-path="
/preview
"
markdown-preview-path="
${
markdownPreviewPath
}
"
markdown-docs-path="
/docs
"
markdown-docs-path="
${
markdownDocsPath
}
"
>
>
<textarea
<textarea
slot="textarea"
slot="textarea"
...
@@ -37,7 +45,13 @@ describe('Markdown field component', () => {
...
@@ -37,7 +45,13 @@ describe('Markdown field component', () => {
Vue
.
nextTick
(
done
);
Vue
.
nextTick
(
done
);
});
});
afterEach
(()
=>
{
axiosMock
.
restore
();
});
describe
(
'
mounted
'
,
()
=>
{
describe
(
'
mounted
'
,
()
=>
{
const
previewHTML
=
'
<p>markdown preview</p>
'
;
it
(
'
renders textarea inside backdrop
'
,
()
=>
{
it
(
'
renders textarea inside backdrop
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.zen-backdrop textarea
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.zen-backdrop textarea
'
)).
not
.
toBeNull
();
});
});
...
@@ -47,20 +61,7 @@ describe('Markdown field component', () => {
...
@@ -47,20 +61,7 @@ describe('Markdown field component', () => {
let
writeLink
;
let
writeLink
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
Vue
.
http
,
'
post
'
).
and
.
callFake
(
axiosMock
.
onPost
(
markdownPreviewPath
).
replyOnce
(
200
,
{
body
:
previewHTML
});
()
=>
new
Promise
(
resolve
=>
{
setTimeout
(()
=>
{
resolve
({
json
()
{
return
{
body
:
'
<p>markdown preview</p>
'
,
};
},
});
});
}),
);
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links .js-preview-link
'
);
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links .js-preview-link
'
);
writeLink
=
vm
.
$el
.
querySelector
(
'
.nav-links .js-write-link
'
);
writeLink
=
vm
.
$el
.
querySelector
(
'
.nav-links .js-write-link
'
);
...
@@ -92,9 +93,7 @@ describe('Markdown field component', () => {
...
@@ -92,9 +93,7 @@ describe('Markdown field component', () => {
previewLink
.
click
();
previewLink
.
click
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.md-preview-holder
'
).
innerHTML
).
toContain
(
expect
(
vm
.
$el
.
querySelector
(
'
.md-preview-holder
'
).
innerHTML
).
toContain
(
previewHTML
);
'
<p>markdown preview</p>
'
,
);
done
();
done
();
});
});
...
...
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