-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '17-Admin-Remove-user-profile' of https://github.com/Hum…
…an-Connection/Human-Connection into 17-Admin-Remove-user-profile
- Loading branch information
Showing
9 changed files
with
235 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,11 @@ type Query { | |
) | ||
} | ||
|
||
enum Deletable { | ||
Post | ||
Comment | ||
} | ||
|
||
type Mutation { | ||
UpdateUser ( | ||
id: ID! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters