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
1f1d3a38
Commit
1f1d3a38
authored
Mar 17, 2021
by
David O'Regan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Do not clear rotation form on validation error
parent
e51fde9e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
7 deletions
+22
-7
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue
...mponents/rotations/components/add_edit_rotation_modal.vue
+8
-4
ee/changelogs/unreleased/324688-form-clear.yml
ee/changelogs/unreleased/324688-form-clear.yml
+5
-0
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
...dule/rotations/components/add_edit_rotation_modal_spec.js
+9
-3
No files found.
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue
View file @
1f1d3a38
...
...
@@ -306,13 +306,17 @@ export default {
},
beforeShowModal
()
{
if
(
this
.
isEditMode
)
{
this
.
parseRotation
();
return
this
.
parseRotation
();
}
return
this
.
resetModal
();
},
resetModal
()
{
if
(
!
this
.
isLoading
)
{
this
.
form
=
cloneDeep
(
formEmptyState
);
this
.
validationState
=
cloneDeep
(
validiationInitialState
);
this
.
error
=
''
;
}
},
parseRotation
()
{
const
scheduleTimezone
=
this
.
schedule
.
timezone
;
...
...
ee/changelogs/unreleased/324688-form-clear.yml
0 → 100644
View file @
1f1d3a38
---
title
:
Do not clear the oncall schedule rotation form if there are validation errors
merge_request
:
56901
author
:
type
:
fixed
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
View file @
1f1d3a38
...
...
@@ -131,7 +131,6 @@ describe('AddEditRotationModal', () => {
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
const
findModal
=
()
=>
wrapper
.
findComponent
(
GlModal
);
...
...
@@ -143,16 +142,22 @@ describe('AddEditRotationModal', () => {
});
describe
(
'
Rotation create
'
,
()
=>
{
it
(
'
makes a request with `oncallRotationCreate` to create a schedule rotation
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
data
:
{
form
:
{
name
:
mockRotation
.
name
}
}
});
});
it
(
'
makes a request with `oncallRotationCreate` to create a schedule rotation and clears the form
'
,
async
()
=>
{
mutate
.
mockResolvedValueOnce
({});
findModal
().
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
expect
(
mutate
).
toHaveBeenCalledWith
({
mutation
:
expect
.
any
(
Object
),
variables
:
{
input
:
expect
.
objectContaining
({
projectPath
})
},
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
findForm
().
props
(
'
form
'
).
name
).
toBe
(
undefined
);
});
it
(
'
does not hide the rotation modal and shows error alert on fail
'
,
async
()
=>
{
it
(
'
does not hide the rotation modal and shows error alert on fail
and does not clear the form
'
,
async
()
=>
{
const
error
=
'
some error
'
;
mutate
.
mockResolvedValueOnce
({
data
:
{
oncallRotationCreate
:
{
errors
:
[
error
]
}
}
});
findModal
().
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
...
...
@@ -160,6 +165,7 @@ describe('AddEditRotationModal', () => {
expect
(
mockHideModal
).
not
.
toHaveBeenCalled
();
expect
(
findAlert
().
exists
()).
toBe
(
true
);
expect
(
findAlert
().
text
()).
toContain
(
error
);
expect
(
findForm
().
props
(
'
form
'
).
name
).
toBe
(
mockRotation
.
name
);
});
describe
(
'
Validation
'
,
()
=>
{
...
...
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