2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2018-12-13 13:39:08 +05:30
|
|
|
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
|
|
|
|
import { __, s__, sprintf } from '~/locale';
|
|
|
|
import csrf from '~/lib/utils/csrf';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
DeprecatedModal,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
actionUrl: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
confirmWithPassword: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
enteredPassword: '',
|
|
|
|
enteredUsername: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
csrfToken() {
|
|
|
|
return csrf.token;
|
|
|
|
},
|
|
|
|
inputLabel() {
|
|
|
|
let confirmationValue;
|
|
|
|
if (this.confirmWithPassword) {
|
|
|
|
confirmationValue = __('password');
|
|
|
|
} else {
|
|
|
|
confirmationValue = __('username');
|
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
confirmationValue = `<code>${confirmationValue}</code>`;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
return sprintf(
|
|
|
|
s__('Profiles|Type your %{confirmationValue} to confirm:'),
|
|
|
|
{ confirmationValue },
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
text() {
|
|
|
|
return sprintf(
|
|
|
|
s__(`Profiles|
|
2018-03-17 18:26:18 +05:30
|
|
|
You are about to permanently delete %{yourAccount}, and all of the issues, merge requests, and groups linked to your account.
|
|
|
|
Once you confirm %{deleteAccount}, it cannot be undone or recovered.`),
|
2018-12-13 13:39:08 +05:30
|
|
|
{
|
|
|
|
yourAccount: `<strong>${s__('Profiles|your account')}</strong>`,
|
|
|
|
deleteAccount: `<strong>${s__('Profiles|Delete Account')}</strong>`,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
canSubmit() {
|
|
|
|
if (this.confirmWithPassword) {
|
|
|
|
return this.enteredPassword !== '';
|
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
return this.enteredUsername === this.username;
|
|
|
|
},
|
|
|
|
onSubmit() {
|
|
|
|
this.$refs.form.submit();
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-05-09 12:01:36 +05:30
|
|
|
<deprecated-modal
|
2018-03-17 18:26:18 +05:30
|
|
|
id="delete-account-modal"
|
|
|
|
:title="s__('Profiles|Delete your account?')"
|
|
|
|
:text="text"
|
|
|
|
:primary-button-label="s__('Profiles|Delete account')"
|
2018-11-08 19:23:39 +05:30
|
|
|
:submit-disabled="!canSubmit()"
|
|
|
|
kind="danger"
|
2019-01-03 12:48:30 +05:30
|
|
|
@submit="onSubmit">
|
|
|
|
|
|
|
|
<template
|
|
|
|
slot="body"
|
|
|
|
slot-scope="props">
|
2018-03-17 18:26:18 +05:30
|
|
|
<p v-html="props.text"></p>
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
<form
|
|
|
|
ref="form"
|
|
|
|
:action="actionUrl"
|
|
|
|
method="post">
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
<input
|
|
|
|
type="hidden"
|
|
|
|
name="_method"
|
|
|
|
value="delete"
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
:value="csrfToken"
|
|
|
|
type="hidden"
|
|
|
|
name="authenticity_token"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<p
|
|
|
|
id="input-label"
|
|
|
|
v-html="inputLabel"
|
|
|
|
>
|
|
|
|
</p>
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
<input
|
|
|
|
v-if="confirmWithPassword"
|
2018-11-08 19:23:39 +05:30
|
|
|
v-model="enteredPassword"
|
2018-03-17 18:26:18 +05:30
|
|
|
name="password"
|
|
|
|
class="form-control"
|
|
|
|
type="password"
|
|
|
|
aria-labelledby="input-label"
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
v-else
|
2018-11-08 19:23:39 +05:30
|
|
|
v-model="enteredUsername"
|
2018-03-17 18:26:18 +05:30
|
|
|
name="username"
|
|
|
|
class="form-control"
|
|
|
|
type="text"
|
|
|
|
aria-labelledby="input-label"
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
</template>
|
2019-01-03 12:48:30 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
</deprecated-modal>
|
2018-03-17 18:26:18 +05:30
|
|
|
</template>
|