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
Show 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 @@
...
@@ -6,7 +6,8 @@
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
escape
}
from
'
lodash
'
;
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
'
;
import
eventHub
from
'
../event_hub
'
;
...
@@ -35,6 +36,11 @@ export default {
...
@@ -35,6 +36,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
true
,
default
:
true
,
},
},
retryUrl
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
},
},
computed
:
{
computed
:
{
...
@@ -66,6 +72,12 @@ export default {
...
@@ -66,6 +72,12 @@ export default {
return
this
.
environment
.
commitUrl
;
return
this
.
environment
.
commitUrl
;
},
},
modalActionText
()
{
return
this
.
environment
.
isLastDeployment
?
s__
(
'
Environments|Re-deploy
'
)
:
s__
(
'
Environments|Rollback
'
);
},
modalText
()
{
modalText
()
{
const
linkStart
=
`<a class="commit-sha mr-0" href="
${
escape
(
this
.
commitUrl
)}
">`
;
const
linkStart
=
`<a class="commit-sha mr-0" href="
${
escape
(
this
.
commitUrl
)}
">`
;
const
commitId
=
escape
(
this
.
commitShortSha
);
const
commitId
=
escape
(
this
.
commitShortSha
);
...
@@ -90,10 +102,17 @@ export default {
...
@@ -90,10 +102,17 @@ export default {
);
);
},
},
modalActionText
()
{
primaryProps
()
{
return
this
.
environment
.
isLastDeployment
let
attributes
=
[{
variant
:
'
danger
'
}];
?
s__
(
'
Environments|Re-deploy
'
)
:
s__
(
'
Environments|Rollback
'
);
if
(
this
.
retryUrl
)
{
attributes
=
[...
attributes
,
{
'
data-method
'
:
'
post
'
},
{
href
:
this
.
retryUrl
}];
}
return
{
text
:
this
.
modalActionText
,
attributes
,
};
},
},
},
},
...
@@ -114,15 +133,20 @@ export default {
...
@@ -114,15 +133,20 @@ export default {
return
''
;
return
''
;
},
},
},
},
csrf
,
cancelProps
:
{
text
:
__
(
'
Cancel
'
),
attributes
:
[{
variant
:
'
danger
'
}],
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<gl-modal
<gl-modal
:title=
"modalTitle"
:title=
"modalTitle"
:visible=
"visible"
:visible=
"visible"
:action-cancel=
"$options.cancelProps"
:action-primary=
"primaryProps"
modal-id=
"confirm-rollback-modal"
modal-id=
"confirm-rollback-modal"
:ok-title=
"modalActionText"
ok-variant=
"danger"
@
ok=
"onOk"
@
ok=
"onOk"
@
change=
"handleChange"
@
change=
"handleChange"
>
>
...
...
app/assets/javascripts/environments/components/rollback_modal_manager.vue
View file @
4e2db193
<
script
>
<
script
>
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
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
'
;
import
ConfirmRollbackModal
from
'
./confirm_rollback_modal.vue
'
;
export
default
{
export
default
{
...
@@ -22,10 +20,6 @@ export default {
...
@@ -22,10 +20,6 @@ export default {
};
};
},
},
mounted
()
{
mounted
()
{
eventHub
.
$on
(
'
rollbackEnvironment
'
,
()
=>
{
redirectTo
(
this
.
retryPath
);
});
document
.
querySelectorAll
(
this
.
selector
).
forEach
((
button
)
=>
{
document
.
querySelectorAll
(
this
.
selector
).
forEach
((
button
)
=>
{
button
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
button
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
...
@@ -57,6 +51,7 @@ export default {
...
@@ -57,6 +51,7 @@ export default {
v-model=
"visible"
v-model=
"visible"
:environment=
"environment"
:environment=
"environment"
:has-multiple-commits=
"false"
:has-multiple-commits=
"false"
:retry-url=
"retryPath"
/>
/>
<div
v-else
></div>
<div
v-else
></div>
</
template
>
</
template
>
spec/frontend/environments/confirm_rollback_modal_spec.js
View file @
4e2db193
...
@@ -23,11 +23,15 @@ describe('Confirm Rollback Modal Component', () => {
...
@@ -23,11 +23,15 @@ describe('Confirm Rollback Modal Component', () => {
commitUrl
:
'
test/-/commit/abc0123
'
,
commitUrl
:
'
test/-/commit/abc0123
'
,
};
};
const
retryPath
=
'
test/-/jobs/123/retry
'
;
describe
.
each
`
describe
.
each
`
hasMultipleCommits | environmentData
hasMultipleCommits | environmentData | retryUrl | primaryPropsAttrs
${
true
}
|
${
envWithLastDeployment
}
${
true
}
|
${
envWithLastDeployment
}
|
${
null
}
|
${[{
variant
:
'
danger
'
}]}
${
false
}
|
${
envWithoutLastDeployment
}
${
false
}
|
${
envWithoutLastDeployment
}
|
${
retryPath
}
|
${[{
variant
:
'
danger
'
},
{
'
data-method
'
:
'
post
'
},
{
href
:
retryPath
}]}
`
(
'
when hasMultipleCommits=$hasMultipleCommits
'
,
({
hasMultipleCommits
,
environmentData
})
=>
{
`
(
'
when hasMultipleCommits=$hasMultipleCommits
'
,
({
hasMultipleCommits
,
environmentData
,
retryUrl
,
primaryPropsAttrs
})
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
environment
=
environmentData
;
environment
=
environmentData
;
});
});
...
@@ -40,13 +44,15 @@ describe('Confirm Rollback Modal Component', () => {
...
@@ -40,13 +44,15 @@ describe('Confirm Rollback Modal Component', () => {
isLastDeployment
:
false
,
isLastDeployment
:
false
,
},
},
hasMultipleCommits
,
hasMultipleCommits
,
retryUrl
,
},
},
});
});
const
modal
=
component
.
find
(
GlModal
);
const
modal
=
component
.
find
(
GlModal
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Rollback
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Rollback
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
ok-title
'
)).
toBe
(
'
Rollback
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
text
).
toBe
(
'
Rollback
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
attributes
).
toEqual
(
primaryPropsAttrs
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
});
...
@@ -65,7 +71,7 @@ describe('Confirm Rollback Modal Component', () => {
...
@@ -65,7 +71,7 @@ describe('Confirm Rollback Modal Component', () => {
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Re-deploy
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
Re-deploy
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
title
'
)).
toContain
(
'
test
'
);
expect
(
modal
.
attributes
(
'
ok-title
'
)
).
toBe
(
'
Re-deploy
'
);
expect
(
modal
.
props
(
'
actionPrimary
'
).
text
).
toBe
(
'
Re-deploy
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
commit abc0123
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
expect
(
modal
.
text
()).
toContain
(
'
Are you sure you want to continue?
'
);
});
});
...
@@ -84,5 +90,6 @@ describe('Confirm Rollback Modal Component', () => {
...
@@ -84,5 +90,6 @@ describe('Confirm Rollback Modal Component', () => {
expect
(
eventHubSpy
).
toHaveBeenCalledWith
(
'
rollbackEnvironment
'
,
env
);
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