mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge branch '17-Admin-Remove-user-profile' of https://github.com/Human-Connection/Human-Connection into 17-Admin-Remove-user-profile
This commit is contained in:
commit
d2e6280059
@ -12,11 +12,6 @@ type Mutation {
|
||||
unfollowUser(id: ID!): User
|
||||
}
|
||||
|
||||
enum Deletable {
|
||||
Post
|
||||
Comment
|
||||
}
|
||||
|
||||
enum ShoutTypeEnum {
|
||||
Post
|
||||
}
|
||||
|
||||
@ -185,6 +185,11 @@ type Query {
|
||||
)
|
||||
}
|
||||
|
||||
enum Deletable {
|
||||
Post
|
||||
Comment
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
UpdateUser (
|
||||
id: ID!
|
||||
|
||||
@ -156,6 +156,15 @@ export default {
|
||||
path: '/settings',
|
||||
icon: 'edit',
|
||||
})
|
||||
if (this.isAdmin === true) {
|
||||
routes.push({
|
||||
label: this.$t(`settings.deleteUserAccount.name`),
|
||||
callback: () => {
|
||||
this.$emit('delete', this.resource)
|
||||
},
|
||||
icon: 'trash',
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (this.resource.isMuted) {
|
||||
routes.push({
|
||||
@ -191,6 +200,15 @@ export default {
|
||||
icon: 'user-times',
|
||||
})
|
||||
}
|
||||
if (this.isAdmin === true) {
|
||||
routes.push({
|
||||
label: this.$t(`settings.deleteUserAccount.name`),
|
||||
callback: () => {
|
||||
this.$emit('delete', this.resource)
|
||||
},
|
||||
icon: 'trash',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
{{ $t('settings.deleteUserAccount.pleaseConfirm', { confirm: currentUser.name }) }}
|
||||
</label>
|
||||
<ds-input v-model="enableDeletionValue" />
|
||||
<p class="notice">{{ $t('settings.deleteUserAccount.accountDescription') }}</p>
|
||||
<p v-show="enableDeletionValue" class="notice">
|
||||
{{ $t('settings.deleteUserAccount.accountDescription') }}
|
||||
</p>
|
||||
<label v-if="currentUser.contributionsCount" class="checkbox">
|
||||
<input type="checkbox" v-model="deleteContributions" />
|
||||
{{
|
||||
@ -25,7 +27,7 @@
|
||||
})
|
||||
}}
|
||||
</label>
|
||||
<section v-if="deleteEnabled" class="warning">
|
||||
<section class="warning">
|
||||
<p>{{ $t('settings.deleteUserAccount.accountWarning') }}</p>
|
||||
</section>
|
||||
<base-button
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
:modalData="data.modalData"
|
||||
@close="close"
|
||||
/>
|
||||
<delete-user-modal v-if="open === 'delete'" :userdata="data.userdata" @close="close" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -38,6 +39,7 @@ import ConfirmModal from '~/components/Modal/ConfirmModal'
|
||||
import DisableModal from '~/components/Modal/DisableModal'
|
||||
import ReleaseModal from '~/components/ReleaseModal/ReleaseModal.vue'
|
||||
import ReportModal from '~/components/Modal/ReportModal'
|
||||
import DeleteUserModal from '~/components/Modal/DeleteUserModal.vue'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
@ -47,6 +49,7 @@ export default {
|
||||
ReleaseModal,
|
||||
ReportModal,
|
||||
ConfirmModal,
|
||||
DeleteUserModal,
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
|
||||
178
webapp/components/Modal/DeleteUserModal.vue
Normal file
178
webapp/components/Modal/DeleteUserModal.vue
Normal file
@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel">
|
||||
<transition name="ds-transition-fade">
|
||||
<ds-flex v-if="success" class="hc-modal-success" centered>
|
||||
<sweetalert-icon icon="success" />
|
||||
</ds-flex>
|
||||
</transition>
|
||||
<div>
|
||||
<ds-section>
|
||||
<ds-flex>
|
||||
<ds-flex-item>
|
||||
<user-teaser :user="userdata" />
|
||||
</ds-flex-item>
|
||||
<ds-flex-item>
|
||||
<ds-text size="small">
|
||||
{{ $t('modals.deleteUser.created') }}:
|
||||
<br />
|
||||
<relative-date-time :date-time="userdata.createdAt" />
|
||||
</ds-text>
|
||||
</ds-flex-item>
|
||||
<ds-flex-item>
|
||||
<ds-number
|
||||
size="small"
|
||||
:count="userdata.contributionsCount"
|
||||
:label="$t('common.post', null, userdata.contributionsCount)"
|
||||
/>
|
||||
</ds-flex-item>
|
||||
<ds-flex-item>
|
||||
<ds-number
|
||||
size="small"
|
||||
:count="userdata.commentedCount"
|
||||
:label="$t('common.comment', null, userdata.commentedCount)"
|
||||
/>
|
||||
</ds-flex-item>
|
||||
</ds-flex>
|
||||
</ds-section>
|
||||
</div>
|
||||
|
||||
<template slot="footer">
|
||||
<base-button class="cancel" @click="cancel">{{ $t('actions.cancel') }}</base-button>
|
||||
<base-button danger filled class="confirm" icon="exclamation-circle" @click="openModal">
|
||||
{{ $t('settings.deleteUserAccount.name') }}
|
||||
</base-button>
|
||||
</template>
|
||||
</ds-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import { mapMutations } from 'vuex'
|
||||
import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||
import RelativeDateTime from '~/components/RelativeDateTime'
|
||||
import UserTeaser from '~/components/UserTeaser/UserTeaser'
|
||||
|
||||
export default {
|
||||
name: 'DeleteUserModal',
|
||||
components: {
|
||||
UserTeaser,
|
||||
SweetalertIcon,
|
||||
RelativeDateTime,
|
||||
},
|
||||
props: {
|
||||
userdata: { type: Object, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: true,
|
||||
success: false,
|
||||
loading: false,
|
||||
isAdmin: this.$store.getters['auth/isAdmin'],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
title() {
|
||||
return this.$t('settings.deleteUserAccount.name')
|
||||
},
|
||||
|
||||
modalData(userdata) {
|
||||
return function (userdata) {
|
||||
return {
|
||||
name: 'confirm',
|
||||
data: {
|
||||
type: userdata.name,
|
||||
resource: userdata,
|
||||
modalData: {
|
||||
titleIdent: this.$t('settings.deleteUserAccount.accountWarningIsAdmin'),
|
||||
messageIdent: this.$t('settings.deleteUserAccount.infoAdmin'),
|
||||
messageParams: {},
|
||||
buttons: {
|
||||
confirm: {
|
||||
danger: true,
|
||||
icon: 'trash',
|
||||
textIdent: this.$t('settings.deleteUserAccount.confirmDeleting'),
|
||||
callback: () => {
|
||||
this.confirm(userdata)
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
icon: 'close',
|
||||
textIdent: this.$t('actions.cancel'),
|
||||
callback: () => {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
commitModalData: 'modal/SET_OPEN',
|
||||
}),
|
||||
openModal() {
|
||||
this.commitModalData(this.modalData(this.userdata))
|
||||
},
|
||||
cancel() {
|
||||
// TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!!
|
||||
// await this.modalData.buttons.cancel.callback()
|
||||
this.isOpen = false
|
||||
setTimeout(() => {
|
||||
this.$emit('close')
|
||||
}, 1000)
|
||||
},
|
||||
async confirm() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: gql`
|
||||
mutation($id: ID!, $resource: [Deletable]) {
|
||||
DeleteUser(id: $id, resource: $resource) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { id: this.userdata.id, resource: ['Post', 'Comment'] },
|
||||
})
|
||||
.then(({ _data }) => {
|
||||
this.success = true
|
||||
this.$toast.success(this.$t('settings.deleteUserAccount.success'))
|
||||
setTimeout(() => {
|
||||
this.isOpen = false
|
||||
setTimeout(() => {
|
||||
this.success = false
|
||||
this.$emit('close')
|
||||
this.$router.history.replace('/')
|
||||
}, 500)
|
||||
}, 1500)
|
||||
this.loading = false
|
||||
})
|
||||
.catch((err) => {
|
||||
this.$emit('close')
|
||||
this.success = false
|
||||
this.$toast.error(err.message)
|
||||
this.isOpen = false
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.ds-modal {
|
||||
max-width: 600px !important;
|
||||
}
|
||||
.hc-modal-success {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: #fff;
|
||||
opacity: 1;
|
||||
z-index: $z-index-modal;
|
||||
border-radius: $border-radius-x-large;
|
||||
}
|
||||
</style>
|
||||
@ -373,6 +373,11 @@
|
||||
"questions": "Bei Fragen oder Problemen erreichst Du uns per E-Mail an",
|
||||
"title": "Human Connection befindet sich in der Wartung"
|
||||
},
|
||||
"modals": {
|
||||
"deleteUser": {
|
||||
"created": "Erstellt"
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"name": "Moderation",
|
||||
"reports": {
|
||||
@ -632,8 +637,12 @@
|
||||
"deleteUserAccount": {
|
||||
"accountDescription": "Sei dir bewusst, dass deine Beiträge und Kommentare für unsere Community wichtig sind. Wenn du sie trotzdem löschen möchtest, musst du sie unten markieren.",
|
||||
"accountWarning": "Dein Konto, deine Beiträge oder Kommentare kannst du nach dem Löschen WEDER VERWALTEN NOCH WIEDERHERSTELLEN!",
|
||||
"accountWarningAdmin": "Das Konto, die Beiträge oder Kommentare können nach dem Löschen WEDER VERWALTEN NOCH WIEDERHERGESTELLT WERDEN!",
|
||||
"accountWarningIsAdmin": "Achtung! Du löschst jetzt ein Benutzerkonto!",
|
||||
"commentedCount": "Meine {count} Kommentare löschen",
|
||||
"confirmDeleting": "Benutzerkonto jetzt löschen",
|
||||
"contributionsCount": "Meine {count} Beiträge löschen",
|
||||
"infoAdmin": "Alle Beiträge und Kommentare des Users werden zusätzlich gelöscht!",
|
||||
"name": "Benutzerkonto löschen",
|
||||
"pleaseConfirm": "Zerstörerische Aktion! Gib „{confirm}“ ein, um zu bestätigen.",
|
||||
"success": "Konto erfolgreich gelöscht!"
|
||||
|
||||
@ -373,6 +373,11 @@
|
||||
"questions": "Any Questions or concerns, send an e-mail to",
|
||||
"title": "Human Connection is under maintenance"
|
||||
},
|
||||
"modals": {
|
||||
"deleteUser": {
|
||||
"created": "Created"
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"name": "Moderation",
|
||||
"reports": {
|
||||
@ -632,8 +637,12 @@
|
||||
"deleteUserAccount": {
|
||||
"accountDescription": "Be aware that your Posts and Comments are important to our community. If you still choose to delete them, you have to mark them below.",
|
||||
"accountWarning": "You CAN'T MANAGE and CAN'T RECOVER your Account, Posts, or Comments after deleting your account!",
|
||||
"accountWarningAdmin": "The account, contributions or comments can NOT BE ADMINISTERED OR RESTORED after deletion!",
|
||||
"accountWarningIsAdmin": "Heads up! You are about to delete a user account!",
|
||||
"commentedCount": "Delete my {count} comments",
|
||||
"confirmDeleting": "Delete user account now",
|
||||
"contributionsCount": "Delete my {count} posts",
|
||||
"infoAdmin": "All contributions and comments of the user are additionally deleted!",
|
||||
"name": "Delete user account",
|
||||
"pleaseConfirm": "Destructive action! Type “{confirm}” to confirm.",
|
||||
"success": "Account successfully deleted!"
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
@unmute="unmuteUser"
|
||||
@block="blockUser"
|
||||
@unblock="unblockUser"
|
||||
@delete="deleteUser"
|
||||
/>
|
||||
</client-only>
|
||||
<ds-space margin="small">
|
||||
@ -385,6 +386,14 @@ export default {
|
||||
this.$apollo.queries.User.refetch()
|
||||
}
|
||||
},
|
||||
async deleteUser(userdata) {
|
||||
this.$store.commit('modal/SET_OPEN', {
|
||||
name: 'delete',
|
||||
data: {
|
||||
userdata: userdata,
|
||||
},
|
||||
})
|
||||
},
|
||||
pinPost(post) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user