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
610867df
Commit
610867df
authored
Jan 13, 2020
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GraphQL mutation to toggle Epic subscription
Use `epicSetSubscription` mutation to update epic subscription.
parent
206d1980
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
7 deletions
+49
-7
ee/app/assets/javascripts/epic/queries/epicSetSubscription.mutation.graphql
...scripts/epic/queries/epicSetSubscription.mutation.graphql
+6
-0
ee/app/assets/javascripts/epic/store/actions.js
ee/app/assets/javascripts/epic/store/actions.js
+21
-6
ee/app/assets/javascripts/epic/store/state.js
ee/app/assets/javascripts/epic/store/state.js
+0
-1
ee/spec/javascripts/epic/store/actions_spec.js
ee/spec/javascripts/epic/store/actions_spec.js
+22
-0
No files found.
ee/app/assets/javascripts/epic/queries/epicSetSubscription.mutation.graphql
0 → 100644
View file @
610867df
mutation
epicSetSubscription
(
$epicSetSubscriptionInput
:
EpicSetSubscriptionInput
!)
{
epicSetSubscription
(
input
:
$epicSetSubscriptionInput
)
{
clientMutationId
errors
}
}
ee/app/assets/javascripts/epic/store/actions.js
View file @
610867df
...
...
@@ -8,6 +8,7 @@ import epicUtils from '../utils/epic_utils';
import
{
statusType
,
statusEvent
,
dateTypes
}
from
'
../constants
'
;
import
updateEpic
from
'
../queries/updateEpic.mutation.graphql
'
;
import
epicSetSubscription
from
'
../queries/epicSetSubscription.mutation.graphql
'
;
import
*
as
types
from
'
./mutation_types
'
;
...
...
@@ -182,12 +183,26 @@ export const requestEpicSubscriptionToggleFailure = ({ commit, state }) => {
};
export
const
toggleEpicSubscription
=
({
state
,
dispatch
})
=>
{
dispatch
(
'
requestEpicSubscriptionToggle
'
);
axios
.
post
(
state
.
toggleSubscriptionPath
)
.
then
(()
=>
{
epicUtils
.
gqClient
.
mutate
({
mutation
:
epicSetSubscription
,
variables
:
{
epicSetSubscriptionInput
:
{
iid
:
`
${
state
.
epicId
}
`
,
groupPath
:
state
.
groupPath
,
subscribedState
:
!
state
.
subscribed
,
},
},
})
.
then
(({
data
})
=>
{
if
(
!
data
?.
epicSetSubscription
?.
errors
.
length
)
{
dispatch
(
'
requestEpicSubscriptionToggleSuccess
'
,
{
subscribed
:
!
state
.
subscribed
,
});
}
else
{
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
throw
new
Error
(
'
An error occurred while toggling to notifications.
'
);
}
})
.
catch
(()
=>
{
dispatch
(
'
requestEpicSubscriptionToggleFailure
'
);
...
...
ee/app/assets/javascripts/epic/store/state.js
View file @
610867df
...
...
@@ -8,7 +8,6 @@ export default () => ({
labelsPath
:
''
,
todoPath
:
''
,
todoDeletePath
:
''
,
toggleSubscriptionPath
:
''
,
// URLs to use with links
epicsWebUrl
:
''
,
...
...
ee/spec/javascripts/epic/store/actions_spec.js
View file @
610867df
...
...
@@ -769,6 +769,13 @@ describe('Epic Store Actions', () => {
describe
(
'
toggleEpicSubscription
'
,
()
=>
{
let
mock
;
const
mockEpicSetSubscriptionRes
=
{
epicSetSubscription
:
{
clientMutationId
:
null
,
errors
:
[],
__typename
:
'
EpicSetSubscriptionPayload
'
,
},
};
const
stateSubscribed
=
{
subscribed
:
false
,
};
...
...
@@ -784,6 +791,11 @@ describe('Epic Store Actions', () => {
describe
(
'
success
'
,
()
=>
{
it
(
'
dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleSuccess with param `subscribed` when request is complete
'
,
done
=>
{
mock
.
onPost
(
/
(
.*
)
/
).
replyOnce
(
200
,
{});
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
mockEpicSetSubscriptionRes
,
}),
);
testAction
(
actions
.
toggleEpicSubscription
,
...
...
@@ -807,6 +819,16 @@ describe('Epic Store Actions', () => {
describe
(
'
failure
'
,
()
=>
{
it
(
'
dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleFailure when request fails
'
,
done
=>
{
mock
.
onPost
(
/
(
.*
)
/
).
replyOnce
(
500
,
{});
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
epicSetSubscription
:
{
...
mockEpicSetSubscriptionRes
,
errors
:
[{
foo
:
'
bar
'
}],
},
},
}),
);
testAction
(
actions
.
toggleEpicSubscription
,
...
...
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