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
4e2db193
Commit
4e2db193
authored
Aug 11, 2021
by
Martin Wortschack
Committed by
Ezekiel Kigbo
Aug 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deployment rollback modal: Change form submit to POST
parent
e58a4257
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
65 deletions
+91
-65
app/assets/javascripts/environments/components/confirm_rollback_modal.vue
...cripts/environments/components/confirm_rollback_modal.vue
+31
-7
app/assets/javascripts/environments/components/rollback_modal_manager.vue
...cripts/environments/components/rollback_modal_manager.vue
+1
-6
spec/frontend/environments/confirm_rollback_modal_spec.js
spec/frontend/environments/confirm_rollback_modal_spec.js
+59
-52
No files found.
app/assets/javascripts/environments/components/confirm_rollback_modal.vue
View file @
4e2db193
...
...
@@ -6,7 +6,8 @@
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
escape
}
from
'
lodash
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
csrf
from
'
~/lib/utils/csrf
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
eventHub
from
'
../event_hub
'
;
...
...
@@ -35,6 +36,11 @@ export default {
required
:
false
,
default
:
true
,
},
retryUrl
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
...
...
@@ -66,6 +72,12 @@ export default {
return
this
.
environment
.
commitUrl
;
},
modalActionText
()
{
return
this
.
environment
.
isLastDeployment
?
s__
(
'
Environments|Re-deploy
'
)
:
s__
(
'
Environments|Rollback
'
);
},
modalText
()
{
const
linkStart
=
`<a class="commit-sha mr-0" href="
${
escape
(
this
.
commitUrl
)}
">`
;
const
commitId
=
escape
(
this
.
commitShortSha
);
...
...
@@ -90,10 +102,17 @@ export default {
);
},
modalActionText
()
{
return
this
.
environment
.
isLastDeployment
?
s__
(
'
Environments|Re-deploy
'
)
:
s__
(
'
Environments|Rollback
'
);
primaryProps
()
{
let
attributes
=
[{
variant
:
'
danger
'
}];
if
(
this
.
retryUrl
)
{
attributes
=
[...
attributes
,
{
'
data-method
'
:
'
post
'
},
{
href
:
this
.
retryUrl
}];
}
return
{
text
:
this
.
modalActionText
,
attributes
,
};
},
},
...
...
@@ -114,15 +133,20 @@ export default {
return
''
;
},
},
csrf
,
cancelProps
:
{
text
:
__
(
'
Cancel
'
),
attributes
:
[{
variant
:
'
danger
'
}],
},
};
</
script
>
<
template
>
<gl-modal
:title=
"modalTitle"
:visible=
"visible"
:action-cancel=
"$options.cancelProps"
:action-primary=
"primaryProps"
modal-id=
"confirm-rollback-modal"
:ok-title=
"modalActionText"
ok-variant=
"danger"
@
ok=
"onOk"
@
change=
"handleChange"
>
...
...
app/assets/javascripts/environments/components/rollback_modal_manager.vue
View file @
4e2db193
<
script
>
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
eventHub
from
'
../event_hub
'
;
import
ConfirmRollbackModal
from
'
./confirm_rollback_modal.vue
'
;
export
default
{
...
...
@@ -22,10 +20,6 @@ export default {
};
},
mounted
()
{
eventHub
.
$on
(
'
rollbackEnvironment
'
,
()
=>
{
redirectTo
(
this
.
retryPath
);
});
document
.
querySelectorAll
(
this
.
selector
).
forEach
((
button
)
=>
{
button
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
e
.
preventDefault
();
...
...
@@ -57,6 +51,7 @@ export default {
v-model=
"visible"
:environment=
"environment"
:has-multiple-commits=
"false"
:retry-url=
"retryPath"
/>
<div
v-else
></div>
</
template
>
spec/frontend/environments/confirm_rollback_modal_spec.js
View file @
4e2db193
...
...
@@ -23,66 +23,73 @@ describe('Confirm Rollback Modal Component', () => {
commitUrl
:
'
test/-/commit/abc0123
'
,
};
const
retryPath
=
'
test/-/jobs/123/retry
'
;
describe
.
each
`
hasMultipleCommits | environmentData
${
true
}
|
${
envWithLastDeployment
}
${
false
}
|
${
envWithoutLastDeployment
}
`
(
'
when hasMultipleCommits=$hasMultipleCommits
'
,
({
hasMultipleCommits
,
environmentData
})
=>
{
beforeEach
(()
=>
{
environment
=
environmentData
;
});
hasMultipleCommits | environmentData | retryUrl | primaryPropsAttrs
${
true
}
|
${
envWithLastDeployment
}
|
${
null
}
|
${[{
variant
:
'
danger
'
}]}
${
false
}
|
${
envWithoutLastDeployment
}
|
${
retryPath
}
|
${[{
variant
:
'
danger
'
},
{
'
data-method
'
:
'
post
'
},
{
href
:
retryPath
}]}
`
(
'
when hasMultipleCommits=$hasMultipleCommits
'
,
({
hasMultipleCommits
,
environmentData
,
retryUrl
,
primaryPropsAttrs
})
=>
{
beforeEach
(()
=>
{
environment
=
environmentData
;
});
it
(
'
should show "Rollback" when isLastDeployment is false
'
,
()
=>
{
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
{
...
environment
,
isLastDeployment
:
false
,
it
(
'
should show "Rollback" when isLastDeployment is false
'
,
()
=>
{
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
{
...
environment
,
isLastDeployment
:
false
,
},
hasMultipleCommits
,
retryUrl
,
},
hasMultipleCommits
,
},
});
const
modal
=
component
.
find
(
GlModal
);
});
const
modal
=
component
.
find
(
GlModal
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Rollback
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
ok-title
'
)).
toBe
(
'
Rollback
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Rollback
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
text
).
toBe
(
'
Rollback
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
attributes
).
toEqual
(
primaryPropsAttrs
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
it
(
'
should show "Re-deploy" when isLastDeployment is true
'
,
()
=>
{
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
{
...
environment
,
isLastDeployment
:
true
,
it
(
'
should show "Re-deploy" when isLastDeployment is true
'
,
()
=>
{
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
{
...
environment
,
isLastDeployment
:
true
,
},
hasMultipleCommits
,
},
hasMultipleCommits
,
},
});
const
modal
=
component
.
find
(
GlModal
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Re-deploy
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
text
).
toBe
(
'
Re-deploy
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
const
modal
=
component
.
find
(
GlModal
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Re-deploy
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
ok-title
'
)).
toBe
(
'
Re-deploy
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
it
(
'
should emit the "rollback" event when "ok" is clicked
'
,
()
=>
{
const
env
=
{
...
environmentData
,
isLastDeployment
:
true
};
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
env
,
hasMultipleCommits
,
},
});
const
eventHubSpy
=
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
const
modal
=
component
.
find
(
GlModal
);
modal
.
vm
.
$emit
(
'
ok
'
);
it
(
'
should emit the "rollback" event when "ok" is clicked
'
,
()
=>
{
const
env
=
{
...
environmentData
,
isLastDeployment
:
true
};
const
component
=
shallowMount
(
ConfirmRollbackModal
,
{
propsData
:
{
environment
:
env
,
hasMultipleCommits
,
},
expect
(
eventHubSpy
).
toHaveBeenCalledWith
(
'
rollbackEnvironment
'
,
env
);
});
const
eventHubSpy
=
jest
.
spyOn
(
eventHub
,
'
$emit
'
);
const
modal
=
component
.
find
(
GlModal
);
modal
.
vm
.
$emit
(
'
ok
'
);
expect
(
eventHubSpy
).
toHaveBeenCalledWith
(
'
rollbackEnvironment
'
,
env
);
});
});
},
);
});
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