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
391add99
Commit
391add99
authored
Sep 04, 2019
by
Lee Tickett
Committed by
Mike Greiling
Sep 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove vue-resource from drafts
parent
b068f72b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
46 deletions
+39
-46
ee/app/assets/javascripts/batch_comments/services/drafts_service.js
...ets/javascripts/batch_comments/services/drafts_service.js
+11
-16
ee/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js
...s/batch_comments/stores/modules/batch_comments/actions.js
+4
-4
ee/changelogs/unreleased/remove-vue-resource-from-drafts.yml
ee/changelogs/unreleased/remove-vue-resource-from-drafts.yml
+5
-0
ee/spec/javascripts/batch_comments/stores/modules/batch_comments/actions_spec.js
...ch_comments/stores/modules/batch_comments/actions_spec.js
+19
-26
No files found.
ee/app/assets/javascripts/batch_comments/services/drafts_service.js
View file @
391add99
import
Vue
from
'
vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
VueResource
from
'
vue-resource
'
;
Vue
.
use
(
VueResource
);
export
default
{
export
default
{
createNewDraft
(
endpoint
,
data
)
{
createNewDraft
(
endpoint
,
data
)
{
const
postData
=
Object
.
assign
({},
data
,
{
draft_note
:
data
.
note
});
const
postData
=
Object
.
assign
({},
data
,
{
draft_note
:
data
.
note
});
delete
postData
.
note
;
delete
postData
.
note
;
return
Vue
.
http
.
post
(
endpoint
,
postData
,
{
emulateJSON
:
true
}
);
return
axios
.
post
(
endpoint
,
postData
);
},
},
deleteDraft
(
endpoint
,
draftId
)
{
deleteDraft
(
endpoint
,
draftId
)
{
return
Vue
.
http
.
delete
(
`
${
endpoint
}
/
${
draftId
}
`
,
{
emulateJSON
:
true
}
);
return
axios
.
delete
(
`
${
endpoint
}
/
${
draftId
}
`
);
},
},
publishDraft
(
endpoint
,
draftId
)
{
publishDraft
(
endpoint
,
draftId
)
{
return
Vue
.
http
.
post
(
endpoint
,
{
id
:
draftId
},
{
emulateJSON
:
true
});
return
axios
.
post
(
endpoint
,
{
id
:
draftId
});
},
},
addDraftToDiscussion
(
endpoint
,
data
)
{
addDraftToDiscussion
(
endpoint
,
data
)
{
return
Vue
.
http
.
post
(
endpoint
,
data
,
{
emulateJSON
:
true
}
);
return
axios
.
post
(
endpoint
,
data
);
},
},
fetchDrafts
(
endpoint
)
{
fetchDrafts
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
);
return
axios
.
get
(
endpoint
);
},
},
publish
(
endpoint
)
{
publish
(
endpoint
)
{
return
Vue
.
http
.
post
(
endpoint
);
return
axios
.
post
(
endpoint
);
},
},
discard
(
endpoint
)
{
discard
(
endpoint
)
{
return
Vue
.
http
.
delete
(
endpoint
);
return
axios
.
delete
(
endpoint
);
},
},
update
(
endpoint
,
{
draftId
,
note
,
resolveDiscussion
})
{
update
(
endpoint
,
{
draftId
,
note
,
resolveDiscussion
})
{
return
Vue
.
http
.
put
(
return
axios
.
put
(
`
${
endpoint
}
/
${
draftId
}
`
,
{
`
${
endpoint
}
/
${
draftId
}
`
,
draft_note
:
{
note
,
resolve_discussion
:
resolveDiscussion
},
{
draft_note
:
{
note
,
resolve_discussion
:
resolveDiscussion
}
},
});
{
emulateJSON
:
true
},
);
},
},
};
};
ee/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js
View file @
391add99
...
@@ -15,7 +15,7 @@ export const saveDraft = ({ dispatch }, draft) =>
...
@@ -15,7 +15,7 @@ export const saveDraft = ({ dispatch }, draft) =>
export
const
addDraftToDiscussion
=
({
commit
},
{
endpoint
,
data
})
=>
export
const
addDraftToDiscussion
=
({
commit
},
{
endpoint
,
data
})
=>
service
service
.
addDraftToDiscussion
(
endpoint
,
data
)
.
addDraftToDiscussion
(
endpoint
,
data
)
.
then
(
res
=>
res
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
(
res
=>
{
.
then
(
res
=>
{
commit
(
types
.
ADD_NEW_DRAFT
,
res
);
commit
(
types
.
ADD_NEW_DRAFT
,
res
);
return
res
;
return
res
;
...
@@ -27,7 +27,7 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
...
@@ -27,7 +27,7 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
export
const
createNewDraft
=
({
commit
},
{
endpoint
,
data
})
=>
export
const
createNewDraft
=
({
commit
},
{
endpoint
,
data
})
=>
service
service
.
createNewDraft
(
endpoint
,
data
)
.
createNewDraft
(
endpoint
,
data
)
.
then
(
res
=>
res
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
(
res
=>
{
.
then
(
res
=>
{
commit
(
types
.
ADD_NEW_DRAFT
,
res
);
commit
(
types
.
ADD_NEW_DRAFT
,
res
);
return
res
;
return
res
;
...
@@ -47,7 +47,7 @@ export const deleteDraft = ({ commit, getters }, draft) =>
...
@@ -47,7 +47,7 @@ export const deleteDraft = ({ commit, getters }, draft) =>
export
const
fetchDrafts
=
({
commit
,
getters
})
=>
export
const
fetchDrafts
=
({
commit
,
getters
})
=>
service
service
.
fetchDrafts
(
getters
.
getNotesData
.
draftsPath
)
.
fetchDrafts
(
getters
.
getNotesData
.
draftsPath
)
.
then
(
res
=>
res
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
commit
(
types
.
SET_BATCH_COMMENTS_DRAFTS
,
data
))
.
then
(
data
=>
commit
(
types
.
SET_BATCH_COMMENTS_DRAFTS
,
data
))
.
catch
(()
=>
flash
(
__
(
'
An error occurred while fetching pending comments
'
)));
.
catch
(()
=>
flash
(
__
(
'
An error occurred while fetching pending comments
'
)));
...
@@ -95,7 +95,7 @@ export const updateDraft = ({ commit, getters }, { note, noteText, resolveDiscus
...
@@ -95,7 +95,7 @@ export const updateDraft = ({ commit, getters }, { note, noteText, resolveDiscus
note
:
noteText
,
note
:
noteText
,
resolveDiscussion
,
resolveDiscussion
,
})
})
.
then
(
res
=>
res
.
json
()
)
.
then
(
res
=>
res
.
data
)
.
then
(
data
=>
commit
(
types
.
RECEIVE_DRAFT_UPDATE_SUCCESS
,
data
))
.
then
(
data
=>
commit
(
types
.
RECEIVE_DRAFT_UPDATE_SUCCESS
,
data
))
.
then
(
callback
)
.
then
(
callback
)
.
catch
(()
=>
flash
(
__
(
'
An error occurred while updating the comment
'
)));
.
catch
(()
=>
flash
(
__
(
'
An error occurred while updating the comment
'
)));
...
...
ee/changelogs/unreleased/remove-vue-resource-from-drafts.yml
0 → 100644
View file @
391add99
---
title
:
Remove vue-resource from drafts
merge_request
:
author
:
Lee Tickett
type
:
other
ee/spec/javascripts/batch_comments/stores/modules/batch_comments/actions_spec.js
View file @
391add99
import
Vue
from
'
vue
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
VueResource
from
'
vue-resource
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
_
from
'
underscore
'
;
import
testAction
from
'
spec/helpers/vuex_action_helper
'
;
import
testAction
from
'
spec/helpers/vuex_action_helper
'
;
import
*
as
actions
from
'
ee/batch_comments/stores/modules/batch_comments/actions
'
;
import
*
as
actions
from
'
ee/batch_comments/stores/modules/batch_comments/actions
'
;
Vue
.
use
(
VueResource
);
describe
(
'
Batch comments store actions
'
,
()
=>
{
describe
(
'
Batch comments store actions
'
,
()
=>
{
let
interceptor
;
let
res
=
{};
let
res
=
{};
let
status
=
200
;
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
interceptor
=
(
request
,
next
)
=>
{
mock
=
new
MockAdapter
(
axios
);
next
(
request
.
respondWith
(
JSON
.
stringify
(
res
),
{
status
,
}),
);
};
Vue
.
http
.
interceptors
.
push
(
interceptor
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
res
=
{};
res
=
{};
status
=
200
;
mock
.
restore
();
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
interceptor
);
});
});
describe
(
'
enableBatchComments
'
,
()
=>
{
describe
(
'
enableBatchComments
'
,
()
=>
{
...
@@ -56,6 +42,7 @@ describe('Batch comments store actions', () => {
...
@@ -56,6 +42,7 @@ describe('Batch comments store actions', () => {
describe
(
'
addDraftToDiscussion
'
,
()
=>
{
describe
(
'
addDraftToDiscussion
'
,
()
=>
{
it
(
'
commits ADD_NEW_DRAFT if no errors returned
'
,
done
=>
{
it
(
'
commits ADD_NEW_DRAFT if no errors returned
'
,
done
=>
{
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
testAction
(
testAction
(
actions
.
addDraftToDiscussion
,
actions
.
addDraftToDiscussion
,
...
@@ -68,7 +55,7 @@ describe('Batch comments store actions', () => {
...
@@ -68,7 +55,7 @@ describe('Batch comments store actions', () => {
});
});
it
(
'
does not commit ADD_NEW_DRAFT if errors returned
'
,
done
=>
{
it
(
'
does not commit ADD_NEW_DRAFT if errors returned
'
,
done
=>
{
status
=
500
;
mock
.
onAny
().
reply
(
500
)
;
testAction
(
testAction
(
actions
.
addDraftToDiscussion
,
actions
.
addDraftToDiscussion
,
...
@@ -84,6 +71,7 @@ describe('Batch comments store actions', () => {
...
@@ -84,6 +71,7 @@ describe('Batch comments store actions', () => {
describe
(
'
createNewDraft
'
,
()
=>
{
describe
(
'
createNewDraft
'
,
()
=>
{
it
(
'
commits ADD_NEW_DRAFT if no errors returned
'
,
done
=>
{
it
(
'
commits ADD_NEW_DRAFT if no errors returned
'
,
done
=>
{
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
testAction
(
testAction
(
actions
.
createNewDraft
,
actions
.
createNewDraft
,
...
@@ -96,7 +84,7 @@ describe('Batch comments store actions', () => {
...
@@ -96,7 +84,7 @@ describe('Batch comments store actions', () => {
});
});
it
(
'
does not commit ADD_NEW_DRAFT if errors returned
'
,
done
=>
{
it
(
'
does not commit ADD_NEW_DRAFT if errors returned
'
,
done
=>
{
status
=
500
;
mock
.
onAny
().
reply
(
500
)
;
testAction
(
testAction
(
actions
.
createNewDraft
,
actions
.
createNewDraft
,
...
@@ -127,6 +115,7 @@ describe('Batch comments store actions', () => {
...
@@ -127,6 +115,7 @@ describe('Batch comments store actions', () => {
commit
,
commit
,
};
};
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
);
actions
actions
.
deleteDraft
(
context
,
{
id
:
1
})
.
deleteDraft
(
context
,
{
id
:
1
})
...
@@ -143,8 +132,7 @@ describe('Batch comments store actions', () => {
...
@@ -143,8 +132,7 @@ describe('Batch comments store actions', () => {
getters
,
getters
,
commit
,
commit
,
};
};
res
=
''
;
mock
.
onAny
().
reply
(
500
);
status
=
'
500
'
;
actions
actions
.
deleteDraft
(
context
,
{
id
:
1
})
.
deleteDraft
(
context
,
{
id
:
1
})
...
@@ -174,6 +162,7 @@ describe('Batch comments store actions', () => {
...
@@ -174,6 +162,7 @@ describe('Batch comments store actions', () => {
commit
,
commit
,
};
};
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
actions
actions
.
fetchDrafts
(
context
)
.
fetchDrafts
(
context
)
...
@@ -201,6 +190,8 @@ describe('Batch comments store actions', () => {
...
@@ -201,6 +190,8 @@ describe('Batch comments store actions', () => {
});
});
it
(
'
dispatches actions & commits
'
,
done
=>
{
it
(
'
dispatches actions & commits
'
,
done
=>
{
mock
.
onAny
().
reply
(
200
);
actions
actions
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -214,7 +205,7 @@ describe('Batch comments store actions', () => {
...
@@ -214,7 +205,7 @@ describe('Batch comments store actions', () => {
});
});
it
(
'
dispatches error commits
'
,
done
=>
{
it
(
'
dispatches error commits
'
,
done
=>
{
status
=
500
;
mock
.
onAny
().
reply
(
500
)
;
actions
actions
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
.
publishReview
({
dispatch
,
commit
,
getters
,
rootGetters
})
...
@@ -233,6 +224,7 @@ describe('Batch comments store actions', () => {
...
@@ -233,6 +224,7 @@ describe('Batch comments store actions', () => {
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
};
};
const
commit
=
jasmine
.
createSpy
(
'
commit
'
);
const
commit
=
jasmine
.
createSpy
(
'
commit
'
);
mock
.
onAny
().
reply
(
200
);
actions
actions
.
discardReview
({
getters
,
commit
})
.
discardReview
({
getters
,
commit
})
...
@@ -249,8 +241,7 @@ describe('Batch comments store actions', () => {
...
@@ -249,8 +241,7 @@ describe('Batch comments store actions', () => {
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
getNotesData
:
{
draftsDiscardPath
:
gl
.
TEST_HOST
},
};
};
const
commit
=
jasmine
.
createSpy
(
'
commit
'
);
const
commit
=
jasmine
.
createSpy
(
'
commit
'
);
mock
.
onAny
().
reply
(
500
);
status
=
500
;
actions
actions
.
discardReview
({
getters
,
commit
})
.
discardReview
({
getters
,
commit
})
...
@@ -281,6 +272,7 @@ describe('Batch comments store actions', () => {
...
@@ -281,6 +272,7 @@ describe('Batch comments store actions', () => {
commit
,
commit
,
};
};
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
actions
actions
.
updateDraft
(
context
,
{
note
:
{
id
:
1
},
noteText
:
'
test
'
,
callback
()
{}
})
.
updateDraft
(
context
,
{
note
:
{
id
:
1
},
noteText
:
'
test
'
,
callback
()
{}
})
...
@@ -299,6 +291,7 @@ describe('Batch comments store actions', () => {
...
@@ -299,6 +291,7 @@ describe('Batch comments store actions', () => {
};
};
const
callback
=
jasmine
.
createSpy
(
'
callback
'
);
const
callback
=
jasmine
.
createSpy
(
'
callback
'
);
res
=
{
id
:
1
};
res
=
{
id
:
1
};
mock
.
onAny
().
reply
(
200
,
res
);
actions
actions
.
updateDraft
(
context
,
{
note
:
{
id
:
1
},
noteText
:
'
test
'
,
callback
})
.
updateDraft
(
context
,
{
note
:
{
id
:
1
},
noteText
:
'
test
'
,
callback
})
...
...
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