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
fe03366a
Commit
fe03366a
authored
Jan 06, 2020
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GraphQL for epic date updates
Use GraphQL mutation `updateEpic` to update epic startDate and dueDate.
parent
a5b6245d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
59 deletions
+58
-59
ee/app/assets/javascripts/epic/queries/updateEpic.mutation.graphql
...sets/javascripts/epic/queries/updateEpic.mutation.graphql
+6
-0
ee/app/assets/javascripts/epic/store/actions.js
ee/app/assets/javascripts/epic/store/actions.js
+25
-11
ee/app/assets/javascripts/epic/utils/epic_utils.js
ee/app/assets/javascripts/epic/utils/epic_utils.js
+4
-0
ee/spec/javascripts/epic/store/actions_spec.js
ee/spec/javascripts/epic/store/actions_spec.js
+23
-48
No files found.
ee/app/assets/javascripts/epic/queries/updateEpic.mutation.graphql
0 → 100644
View file @
fe03366a
mutation
updateEpic
(
$updateEpicInput
:
UpdateEpicInput
!)
{
updateEpic
(
input
:
$updateEpicInput
)
{
clientMutationId
errors
}
}
ee/app/assets/javascripts/epic/store/actions.js
View file @
fe03366a
...
...
@@ -7,6 +7,8 @@ import { visitUrl } from '~/lib/utils/url_utility';
import
epicUtils
from
'
../utils/epic_utils
'
;
import
{
statusType
,
statusEvent
,
dateTypes
}
from
'
../constants
'
;
import
updateEpic
from
'
../queries/updateEpic.mutation.graphql
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
const
setEpicMeta
=
({
commit
},
meta
)
=>
commit
(
types
.
SET_EPIC_META
,
meta
);
...
...
@@ -125,23 +127,35 @@ export const requestEpicDateSaveFailure = ({ commit }, data) => {
);
};
export
const
saveDate
=
({
state
,
dispatch
},
{
dateType
,
dateTypeIsFixed
,
newDate
})
=>
{
const
requestBody
=
{
[
dateType
===
dateTypes
.
start
?
'
start_date_is_fixed
'
:
'
due_date_is_fixed
'
]:
dateTypeIsFixed
,
const
updateEpicInput
=
{
iid
:
`
${
state
.
epicId
}
`
,
groupPath
:
state
.
groupPath
,
[
dateType
===
dateTypes
.
start
?
'
startDateIsFixed
'
:
'
dueDateIsFixed
'
]:
dateTypeIsFixed
,
};
if
(
dateTypeIsFixed
)
{
requestBody
[
dateType
===
dateTypes
.
start
?
'
start_date_fixed
'
:
'
due_date_f
ixed
'
]
=
newDate
;
updateEpicInput
[
dateType
===
dateTypes
.
start
?
'
startDateFixed
'
:
'
dueDateF
ixed
'
]
=
newDate
;
}
dispatch
(
'
requestEpicDateSave
'
,
{
dateType
});
axios
.
put
(
state
.
endpoint
,
requestBody
)
.
then
(()
=>
{
epicUtils
.
gqClient
.
mutate
({
mutation
:
updateEpic
,
variables
:
{
updateEpicInput
,
},
})
.
then
(({
data
})
=>
{
if
(
!
data
?.
updateEpic
?.
errors
.
length
)
{
dispatch
(
'
requestEpicDateSaveSuccess
'
,
{
dateType
,
dateTypeIsFixed
,
newDate
,
});
}
else
{
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
throw
new
Error
(
'
An error occurred while saving the date
'
);
}
})
.
catch
(()
=>
{
dispatch
(
'
requestEpicDateSaveFailure
'
,
{
...
...
ee/app/assets/javascripts/epic/utils/epic_utils.js
View file @
fe03366a
...
...
@@ -3,11 +3,14 @@ import Cookies from 'js-cookie';
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
createGqClient
from
'
~/lib/graphql
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
dateInWords
,
parsePikadayDate
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
dateTypes
}
from
'
../constants
'
;
const
gqClient
=
createGqClient
();
const
triggerDocumentEvent
=
(
eventName
,
eventParam
)
=>
{
$
(
document
).
trigger
(
eventName
,
eventParam
);
};
...
...
@@ -90,6 +93,7 @@ const getDateFromMilestonesTooltip = ({
// be default export of dependency as per
// https://gitlab.com/help/development/testing_guide/frontend_testing.md#stubbing-and-mocking
const
epicUtils
=
{
gqClient
,
triggerDocumentEvent
,
bindDocumentEvent
,
toggleContainerClass
,
...
...
ee/spec/javascripts/epic/store/actions_spec.js
View file @
fe03366a
...
...
@@ -605,6 +605,14 @@ describe('Epic Store Actions', () => {
describe
(
'
saveDate
'
,
()
=>
{
let
mock
;
const
mockUpdateEpicMutationRes
=
{
updateEpic
:
{
clientMutationId
:
null
,
errors
:
[],
__typename
:
'
UpdateEpicPayload
'
,
},
};
const
data
=
{
dateType
:
dateTypes
.
start
,
dateTypeIsFixed
:
true
,
...
...
@@ -621,6 +629,11 @@ describe('Epic Store Actions', () => {
it
(
'
dispatches requestEpicDateSave and requestEpicDateSaveSuccess when request is successful
'
,
done
=>
{
mock
.
onPut
(
/
(
.*
)
/
).
replyOnce
(
200
,
{});
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
mockUpdateEpicMutationRes
,
}),
);
testAction
(
actions
.
saveDate
,
...
...
@@ -643,6 +656,16 @@ describe('Epic Store Actions', () => {
it
(
'
dispatches requestEpicDateSave and requestEpicDateSaveFailure when request fails
'
,
done
=>
{
mock
.
onPut
(
/
(
.*
)
/
).
replyOnce
(
500
,
{});
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
updateEpic
:
{
...
mockUpdateEpicMutationRes
,
errors
:
[{
foo
:
'
bar
'
}],
},
},
}),
);
testAction
(
actions
.
saveDate
,
...
...
@@ -662,54 +685,6 @@ describe('Epic Store Actions', () => {
done
,
);
});
it
(
'
calls `axios.put` with request body containing start date related payload when called with `dateType` as `start`
'
,
()
=>
{
spyOn
(
axios
,
'
put
'
).
and
.
callFake
(()
=>
new
Promise
(()
=>
{}));
actions
.
saveDate
(
{
state
:
{
endpoint
:
'
/foo/bar
'
},
dispatch
:
()
=>
{},
},
{
dateType
:
dateTypes
.
start
,
newDate
:
'
2018-1-1
'
,
dateTypeIsFixed
:
true
,
},
);
expect
(
axios
.
put
).
toHaveBeenCalledWith
(
'
/foo/bar
'
,
jasmine
.
objectContaining
({
start_date_is_fixed
:
true
,
start_date_fixed
:
'
2018-1-1
'
,
}),
);
});
it
(
'
calls `axios.put` with request body containing due date related payload when called with `dateType` as `due`
'
,
()
=>
{
spyOn
(
axios
,
'
put
'
).
and
.
callFake
(()
=>
new
Promise
(()
=>
{}));
actions
.
saveDate
(
{
state
:
{
endpoint
:
'
/foo/bar
'
},
dispatch
:
()
=>
{},
},
{
dateType
:
dateTypes
.
due
,
newDate
:
'
2018-1-1
'
,
dateTypeIsFixed
:
true
,
},
);
expect
(
axios
.
put
).
toHaveBeenCalledWith
(
'
/foo/bar
'
,
jasmine
.
objectContaining
({
due_date_is_fixed
:
true
,
due_date_fixed
:
'
2018-1-1
'
,
}),
);
});
});
describe
(
'
requestEpicSubscriptionToggle
'
,
()
=>
{
...
...
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