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
34663e0e
Commit
34663e0e
authored
Oct 14, 2021
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace haml modal with vuejs modal
Trigger the modal when the relevant button is clicked
parent
5f2edc30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
169 additions
and
2 deletions
+169
-2
app/assets/javascripts/init_confirm_danger.js
app/assets/javascripts/init_confirm_danger.js
+23
-0
app/assets/javascripts/pages/projects/edit/index.js
app/assets/javascripts/pages/projects/edit/index.js
+2
-2
app/assets/javascripts/vue_shared/components/confirm_danger/confirm_danger.vue
...s/vue_shared/components/confirm_danger/confirm_danger.vue
+47
-0
app/assets/javascripts/vue_shared/components/confirm_danger/confirm_danger_modal.vue
...shared/components/confirm_danger/confirm_danger_modal.vue
+87
-0
app/assets/javascripts/vue_shared/components/confirm_danger/constants.js
...scripts/vue_shared/components/confirm_danger/constants.js
+10
-0
No files found.
app/assets/javascripts/init_confirm_danger.js
0 → 100644
View file @
34663e0e
import
Vue
from
'
vue
'
;
import
ConfirmDanger
from
'
./vue_shared/components/confirm_danger/confirm_danger.vue
'
;
export
default
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-confirm-danger
'
);
if
(
!
el
)
return
null
;
const
{
phrase
,
buttonText
,
confirmDangerMessage
}
=
el
.
dataset
;
return
new
Vue
({
el
,
render
:
(
createElement
)
=>
createElement
(
ConfirmDanger
,
{
props
:
{
phrase
,
buttonText
,
},
provide
:
{
confirmDangerMessage
,
},
}),
});
};
app/assets/javascripts/pages/projects/edit/index.js
View file @
34663e0e
import
{
PROJECT_BADGE
}
from
'
~/badges/constants
'
;
import
initConfirmDangerModal
from
'
~/confirm_danger_modal
'
;
import
init
Legacy
ConfirmDangerModal
from
'
~/confirm_danger_modal
'
;
import
dirtySubmitFactory
from
'
~/dirty_submit/dirty_submit_factory
'
;
import
initFilePickers
from
'
~/file_pickers
'
;
import
mountBadgeSettings
from
'
~/pages/shared/mount_badge_settings
'
;
...
...
@@ -13,7 +13,7 @@ import initProjectPermissionsSettings from '../shared/permissions';
import
initProjectLoadingSpinner
from
'
../shared/save_project_loader
'
;
initFilePickers
();
initConfirmDangerModal
();
init
Legacy
ConfirmDangerModal
();
initSettingsPanels
();
initProjectDeleteButton
();
mountBadgeSettings
(
PROJECT_BADGE
);
...
...
app/assets/javascripts/vue_shared/components/confirm_danger/confirm_danger.vue
0 → 100644
View file @
34663e0e
<
script
>
import
{
GlButton
,
GlModalDirective
}
from
'
@gitlab/ui
'
;
import
ConfirmDangerModal
from
'
./confirm_danger_modal.vue
'
;
export
default
{
name
:
'
ConfirmDanger
'
,
components
:
{
GlButton
,
ConfirmDangerModal
,
},
directives
:
{
GlModal
:
GlModalDirective
,
},
props
:
{
disabled
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
phrase
:
{
type
:
String
,
required
:
true
,
},
buttonText
:
{
type
:
String
,
required
:
true
,
},
},
modalId
:
'
confirm-danger-modal
'
,
};
</
script
>
<
template
>
<div>
<gl-button
v-gl-modal=
"$options.modalId"
class=
"gl-button btn btn-danger qa-transfer-button"
variant=
"danger"
:disabled=
"disabled"
>
{{
buttonText
}}
</gl-button
>
<confirm-danger-modal
:modal-id=
"$options.modalId"
:phrase=
"phrase"
@
confirm=
"$emit('confirm')"
/>
</div>
</
template
>
app/assets/javascripts/vue_shared/components/confirm_danger/confirm_danger_modal.vue
0 → 100644
View file @
34663e0e
<
script
>
import
{
GlModal
,
GlFormGroup
,
GlFormInput
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
CONFIRM_DANGER_MODAL_BUTTON
,
CONFIRM_DANGER_MODAL_TITLE
,
CONFIRM_DANGER_PHRASE_TEXT
,
CONFIRM_DANGER_WARNING
,
}
from
'
./constants
'
;
export
default
{
name
:
'
ConfirmDangerModal
'
,
components
:
{
GlModal
,
GlFormGroup
,
GlFormInput
,
GlSprintf
,
},
inject
:
{
confirmDangerMessage
:
{
default
:
''
,
},
confirmButtonText
:
{
default
:
CONFIRM_DANGER_MODAL_BUTTON
,
},
},
props
:
{
modalId
:
{
type
:
String
,
required
:
true
,
},
phrase
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
confirmationPhrase
:
''
};
},
computed
:
{
isValid
()
{
return
this
.
phrase
.
length
&&
this
.
equalString
(
this
.
confirmationPhrase
,
this
.
phrase
);
},
actionPrimary
()
{
console
.
log
(
'
this.$options.i18n
'
,
this
.
$options
.
i18n
);
return
{
text
:
this
.
$options
.
i18n
.
CONFIRM_DANGER_MODAL_BUTTON
,
attributes
:
[{
variant
:
'
danger
'
,
disabled
:
this
.
isValid
}],
};
},
},
methods
:
{
equalString
(
a
,
b
)
{
return
a
.
trim
().
toLowerCase
()
===
b
.
trim
().
toLowerCase
();
},
},
i18n
:
{
CONFIRM_DANGER_MODAL_BUTTON
,
CONFIRM_DANGER_MODAL_TITLE
,
CONFIRM_DANGER_WARNING
,
CONFIRM_DANGER_PHRASE_TEXT
,
},
};
</
script
>
<
template
>
<gl-modal
ref=
"modal"
class=
"qa-confirm-modal"
:modal-id=
"modalId"
:data-testid=
"modalId"
:title=
"$options.i18n.CONFIRM_DANGER_MODAL_TITLE"
:action-primary=
"actionPrimary"
@
primary=
"$emit('confirm')"
>
<p
class=
"text-danger js-confirm-text"
>
{{
confirmDangerMessage
}}
</p>
<p>
<span
class=
"js-warning-text"
>
{{
$options
.
i18n
.
CONFIRM_DANGER_MODAL_WARNING
}}
</span>
<gl-sprintf
:message=
"$options.i18n.CONFIRM_DANGER_PHRASE_TEXT"
>
<template
#code
>
<code
class=
"js-confirm-danger-match"
>
{{
phrase
}}
</code>
</
template
>
</gl-sprintf>
</p>
<gl-form-group
class=
"'form-control js-confirm-danger-input qa-confirm-input'"
:state=
"isValid"
>
<gl-form-input
v-model=
"confirmationPhrase"
type=
"text"
/>
</gl-form-group>
</gl-modal>
</template>
app/assets/javascripts/vue_shared/components/confirm_danger/constants.js
0 → 100644
View file @
34663e0e
import
{
__
}
from
'
~/locale
'
;
export
const
CONFIRM_DANGER_MODAL_TITLE
=
__
(
'
Confirmation required
'
);
export
const
CONFIRM_DANGER_MODAL_BUTTON
=
__
(
'
Confirm
'
);
export
const
CONFIRM_DANGER_WARNING
=
__
(
'
This action can lead to data loss. To prevent accidental actions we ask you to confirm your intention.
'
,
);
export
const
CONFIRM_DANGER_PHRASE_TEXT
=
__
(
'
Please type %{code} to proceed or close this modal to cancel.
'
,
);
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