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
18dcb756
Commit
18dcb756
authored
Oct 06, 2020
by
Amelia Bauerly
Committed by
Jose Ivan Vargas
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate DeprecatedModal to GitLab UI Modal
parent
d50d8d25
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
53 deletions
+45
-53
app/assets/javascripts/pages/milestones/shared/components/delete_milestone_modal.vue
...s/milestones/shared/components/delete_milestone_modal.vue
+17
-14
app/assets/javascripts/pages/milestones/shared/delete_milestone_modal_init.js
...ts/pages/milestones/shared/delete_milestone_modal_init.js
+20
-34
app/views/projects/milestones/index.html.haml
app/views/projects/milestones/index.html.haml
+1
-1
app/views/shared/milestones/_delete_button.html.haml
app/views/shared/milestones/_delete_button.html.haml
+2
-4
changelogs/unreleased/Migrate-deprecated-delete-milestone-modal-ab.yml
...released/Migrate-deprecated-delete-milestone-modal-ab.yml
+5
-0
No files found.
app/assets/javascripts/pages/milestones/shared/components/delete_milestone_modal.vue
View file @
18dcb756
<
script
>
import
{
GlSafeHtmlDirective
as
SafeHtml
}
from
'
@gitlab/ui
'
;
import
{
GlSafeHtmlDirective
as
SafeHtml
,
GlModal
}
from
'
@gitlab/ui
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
deprecatedCreateFlash
as
Flash
}
from
'
~/flash
'
;
import
DeprecatedModal
from
'
~/vue_shared/components/deprecated_modal.vue
'
;
import
{
n__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
__
,
n__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
eventHub
from
'
../event_hub
'
;
export
default
{
components
:
{
Deprecated
Modal
,
Gl
Modal
,
},
directives
:
{
SafeHtml
,
...
...
@@ -115,20 +114,24 @@ Once deleted, it cannot be undone or recovered.`),
});
},
},
primaryProps
:
{
text
:
s__
(
'
Milestones|Delete milestone
'
),
attributes
:
[{
variant
:
'
danger
'
},
{
category
:
'
primary
'
}],
},
cancelProps
:
{
text
:
__
(
'
Cancel
'
),
},
};
</
script
>
<
template
>
<
deprecated
-modal
id=
"delete-milestone-modal"
<
gl
-modal
modal-
id=
"delete-milestone-modal"
:title=
"title"
:text=
"text"
:primary-button-label=
"s__('Milestones|Delete milestone')"
kind=
"danger"
@
submit=
"onSubmit"
:action-primary=
"$options.primaryProps"
:action-cancel=
"$options.cancelProps"
@
primary=
"onSubmit"
>
<template
#body
="
props
"
>
<p
v-safe-html=
"props.text"
></p>
</
template
>
</deprecated-modal>
<p
v-safe-html=
"text"
></p>
</gl-modal>
</
template
>
app/assets/javascripts/pages/milestones/shared/delete_milestone_modal_init.js
View file @
18dcb756
import
Vue
from
'
vue
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
d
eleteMilestoneModal
from
'
./components/delete_milestone_modal.vue
'
;
import
D
eleteMilestoneModal
from
'
./components/delete_milestone_modal.vue
'
;
import
eventHub
from
'
./event_hub
'
;
export
default
()
=>
{
...
...
@@ -18,6 +18,8 @@ export default () => {
button
.
querySelector
(
'
.js-loading-icon
'
).
classList
.
add
(
'
hidden
'
);
};
const
deleteMilestoneButtons
=
document
.
querySelectorAll
(
'
.js-delete-milestone-button
'
);
const
onRequestStarted
=
milestoneUrl
=>
{
const
button
=
document
.
querySelector
(
`.js-delete-milestone-button[data-milestone-url="
${
milestoneUrl
}
"]`
,
...
...
@@ -27,35 +29,8 @@ export default () => {
eventHub
.
$once
(
'
deleteMilestoneModal.requestFinished
'
,
onRequestFinished
);
};
const
onDeleteButtonClick
=
event
=>
{
const
button
=
event
.
currentTarget
;
const
modalProps
=
{
milestoneId
:
parseInt
(
button
.
dataset
.
milestoneId
,
10
),
milestoneTitle
:
button
.
dataset
.
milestoneTitle
,
milestoneUrl
:
button
.
dataset
.
milestoneUrl
,
issueCount
:
parseInt
(
button
.
dataset
.
milestoneIssueCount
,
10
),
mergeRequestCount
:
parseInt
(
button
.
dataset
.
milestoneMergeRequestCount
,
10
),
};
eventHub
.
$once
(
'
deleteMilestoneModal.requestStarted
'
,
onRequestStarted
);
eventHub
.
$emit
(
'
deleteMilestoneModal.props
'
,
modalProps
);
};
const
deleteMilestoneButtons
=
document
.
querySelectorAll
(
'
.js-delete-milestone-button
'
);
deleteMilestoneButtons
.
forEach
(
button
=>
{
button
.
addEventListener
(
'
click
'
,
onDeleteButtonClick
);
});
eventHub
.
$once
(
'
deleteMilestoneModal.mounted
'
,
()
=>
{
deleteMilestoneButtons
.
forEach
(
button
=>
{
button
.
removeAttribute
(
'
disabled
'
);
});
});
return
new
Vue
({
el
:
'
#delete-milestone-modal
'
,
components
:
{
deleteMilestoneModal
,
},
el
:
'
#js-delete-milestone-modal
'
,
data
()
{
return
{
modalProps
:
{
...
...
@@ -69,10 +44,21 @@ export default () => {
},
mounted
()
{
eventHub
.
$on
(
'
deleteMilestoneModal.props
'
,
this
.
setModalProps
);
eventHub
.
$emit
(
'
deleteMilestoneModal.mounted
'
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
deleteMilestoneModal.props
'
,
this
.
setModalProps
);
deleteMilestoneButtons
.
forEach
(
button
=>
{
button
.
removeAttribute
(
'
disabled
'
);
button
.
addEventListener
(
'
click
'
,
()
=>
{
this
.
$root
.
$emit
(
'
bv::show::modal
'
,
'
delete-milestone-modal
'
);
eventHub
.
$once
(
'
deleteMilestoneModal.requestStarted
'
,
onRequestStarted
);
this
.
setModalProps
({
milestoneId
:
parseInt
(
button
.
dataset
.
milestoneId
,
10
),
milestoneTitle
:
button
.
dataset
.
milestoneTitle
,
milestoneUrl
:
button
.
dataset
.
milestoneUrl
,
issueCount
:
parseInt
(
button
.
dataset
.
milestoneIssueCount
,
10
),
mergeRequestCount
:
parseInt
(
button
.
dataset
.
milestoneMergeRequestCount
,
10
),
});
});
});
},
methods
:
{
setModalProps
(
modalProps
)
{
...
...
@@ -80,7 +66,7 @@ export default () => {
},
},
render
(
createElement
)
{
return
createElement
(
d
eleteMilestoneModal
,
{
return
createElement
(
D
eleteMilestoneModal
,
{
props
:
this
.
modalProps
,
});
},
...
...
app/views/projects/milestones/index.html.haml
View file @
18dcb756
...
...
@@ -12,7 +12,7 @@
=
_
(
'New milestone'
)
.milestones
#delete-milestone-modal
#
js-
delete-milestone-modal
#promote-milestone-modal
%ul
.content-list
...
...
app/views/shared/milestones/_delete_button.html.haml
View file @
18dcb756
-
milestone_url
=
@milestone
.
project_milestone?
?
project_milestone_path
(
@project
,
@milestone
)
:
group_milestone_path
(
@group
,
@milestone
)
%button
.js-delete-milestone-button.btn.btn-grouped.btn-danger
{
data:
{
toggle:
'modal'
,
target:
'#delete-milestone-modal'
,
milestone_id:
@milestone
.
id
,
%button
.js-delete-milestone-button.btn.btn-grouped.btn-danger
{
data:
{
milestone_id:
@milestone
.
id
,
milestone_title:
markdown_field
(
@milestone
,
:title
),
milestone_url:
milestone_url
,
milestone_issue_count:
@milestone
.
issues
.
count
,
...
...
@@ -11,4 +9,4 @@
=
_
(
'Delete'
)
.spinner.js-loading-icon.hidden
#delete-milestone-modal
#
js-
delete-milestone-modal
changelogs/unreleased/Migrate-deprecated-delete-milestone-modal-ab.yml
0 → 100644
View file @
18dcb756
---
title
:
Migrate DeprecatedModal to GitLab UI Modal
merge_request
:
42113
author
:
type
:
changed
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