type check for status prop
This commit is contained in:
parent
2630f17cd5
commit
466801f4db
1 changed files with 134 additions and 121 deletions
|
|
@ -4,130 +4,143 @@ import PageList from 'src/components/page_list/page_list.vue'
|
||||||
import AdminStatusCard from 'src/components/settings_modal/admin_tabs/admin_status_card.vue'
|
import AdminStatusCard from 'src/components/settings_modal/admin_tabs/admin_status_card.vue'
|
||||||
|
|
||||||
const AdminCard = {
|
const AdminCard = {
|
||||||
props: ['userDetails'],
|
props: {
|
||||||
data () {
|
userDetails: {
|
||||||
return {
|
type: Object,
|
||||||
progress: false,
|
required: true,
|
||||||
topLevelExpanded: false,
|
validator (u) {
|
||||||
jsonExpanded: false,
|
return (
|
||||||
timelineExpanded: false,
|
typeof(u.id) === 'string' &&
|
||||||
justApproved: false,
|
typeof(u._original) === 'object' &&
|
||||||
justConfirmed: false,
|
typeof(u._original.is_approved) === 'boolean' &&
|
||||||
justDeleted: false,
|
typeof(u._original.is_confirmed) === 'boolean'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
computed: {
|
},
|
||||||
isLoaded () {
|
data () {
|
||||||
return typeof(this.user) !== 'undefined'
|
return {
|
||||||
},
|
progress: false,
|
||||||
user () {
|
topLevelExpanded: false,
|
||||||
return this.$store.getters.findUser(this.userDetails.id)
|
jsonExpanded: false,
|
||||||
},
|
timelineExpanded: false,
|
||||||
relationship () {
|
justApproved: false,
|
||||||
return this.$store.getters.relationship(this.userDetails.id)
|
justConfirmed: false,
|
||||||
},
|
justDeleted: false,
|
||||||
isLocal () {
|
}
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
},
|
||||||
if (typeof(u) !== 'undefined') {
|
computed: {
|
||||||
return u.is_local === true
|
isLoaded () {
|
||||||
}
|
return typeof(this.user) !== 'undefined'
|
||||||
return false
|
},
|
||||||
},
|
user () {
|
||||||
isAdmin () {
|
return this.$store.getters.findUser(this.userDetails.id)
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
},
|
||||||
if (typeof(u) !== 'undefined') {
|
relationship () {
|
||||||
return u.rights.admin === true
|
return this.$store.getters.relationship(this.userDetails.id)
|
||||||
}
|
},
|
||||||
return false
|
isLocal () {
|
||||||
},
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
isModerator () {
|
if (typeof(u) !== 'undefined') {
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
return u.is_local === true
|
||||||
if (typeof(u) !== 'undefined') {
|
|
||||||
return u.rights.moderator === true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
isActivated () {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
if (typeof(u) !== 'undefined') {
|
|
||||||
return u.deactivated === false
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
isConfirmed () {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
return (u._original.pleroma.is_confirmed === true) || (this.justConfirmed === true)
|
|
||||||
},
|
|
||||||
isApproved () {
|
|
||||||
return (this.userDetails._original.is_approved === true) || (this.justApproved === true)
|
|
||||||
}
|
}
|
||||||
},
|
return false
|
||||||
components: {
|
},
|
||||||
BasicUserCard,
|
isAdmin () {
|
||||||
Checkbox,
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
PageList,
|
if (typeof(u) !== 'undefined') {
|
||||||
AdminStatusCard,
|
return u.rights.admin === true
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
toggleAdmin (v) {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
if (v === true) {
|
|
||||||
this.$store.dispatch('adminAddUserToAdminGroup', u)
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch('adminRemoveUserFromAdminGroup', u)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleModerator (v) {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
if (v === true) {
|
|
||||||
this.$store.dispatch('adminAddUserToModeratorGroup', u)
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch('adminRemoveUserFromModeratorGroup', u)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
toggleActivation (v) {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
if (v === true) {
|
|
||||||
this.$store.dispatch('adminActivateUser', u)
|
|
||||||
} else {
|
|
||||||
this.$store.dispatch('adminDeactivateUser', u)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirmUser () {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
this.$store.dispatch('adminConfirmUser', u)
|
|
||||||
this.just_confirmed = true
|
|
||||||
},
|
|
||||||
resendConfirmationEmail () {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
this.$store.dispatch('adminResendConfirmationEmail', u)
|
|
||||||
},
|
|
||||||
toggleApproval () {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
this.$store.dispatch('adminApproveUser', u)
|
|
||||||
},
|
|
||||||
forceUpdateUser () {
|
|
||||||
this.$store.dispatch('fetchUser', this.userDetails.id)
|
|
||||||
},
|
|
||||||
deleteSelection () {
|
|
||||||
const l = this.$refs.timelineList
|
|
||||||
const s = l.getSelected()
|
|
||||||
s.forEach(p => this.$store.dispatch('deleteStatus', p))
|
|
||||||
l.reset()
|
|
||||||
},
|
|
||||||
deleteUser () {
|
|
||||||
if (!this.justDeleted) {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
this.$store.dispatch('adminDeleteUser', u)
|
|
||||||
this.justDeleted = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchStatuses (store, opts) {
|
|
||||||
const u = this.$store.getters.findUser(this.userDetails.id)
|
|
||||||
const res = store.dispatch('adminListStatuses', { user: u, opts: { pageSize: opts.pageSize, godmode: true, withReblogs: true}})
|
|
||||||
return Promise.resolve(res.then(r => r.activities))
|
|
||||||
}
|
}
|
||||||
}
|
return false
|
||||||
|
},
|
||||||
|
isModerator () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
if (typeof(u) !== 'undefined') {
|
||||||
|
return u.rights.moderator === true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
isActivated () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
if (typeof(u) !== 'undefined') {
|
||||||
|
return u.deactivated === false
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
isConfirmed () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
return (u._original.is_confirmed === true) || (this.justConfirmed === true)
|
||||||
|
},
|
||||||
|
isApproved () {
|
||||||
|
return (this.userDetails._original.is_approved === true) || (this.justApproved === true)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
BasicUserCard,
|
||||||
|
Checkbox,
|
||||||
|
PageList,
|
||||||
|
AdminStatusCard,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleAdmin (v) {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
if (v === true) {
|
||||||
|
this.$store.dispatch('adminAddUserToAdminGroup', u)
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('adminRemoveUserFromAdminGroup', u)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleModerator (v) {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
if (v === true) {
|
||||||
|
this.$store.dispatch('adminAddUserToModeratorGroup', u)
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('adminRemoveUserFromModeratorGroup', u)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleActivation (v) {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
if (v === true) {
|
||||||
|
this.$store.dispatch('adminActivateUser', u)
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('adminDeactivateUser', u)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmUser () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
this.$store.dispatch('adminConfirmUser', u)
|
||||||
|
this.just_confirmed = true
|
||||||
|
},
|
||||||
|
resendConfirmationEmail () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
this.$store.dispatch('adminResendConfirmationEmail', u)
|
||||||
|
},
|
||||||
|
toggleApproval () {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
this.$store.dispatch('adminApproveUser', u)
|
||||||
|
},
|
||||||
|
forceUpdateUser () {
|
||||||
|
this.$store.dispatch('fetchUser', this.userDetails.id)
|
||||||
|
},
|
||||||
|
deleteSelection () {
|
||||||
|
const l = this.$refs.timelineList
|
||||||
|
const s = l.getSelected()
|
||||||
|
s.forEach(p => this.$store.dispatch('deleteStatus', p))
|
||||||
|
l.reset()
|
||||||
|
},
|
||||||
|
deleteUser () {
|
||||||
|
if (!this.justDeleted) {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
this.$store.dispatch('adminDeleteUser', u)
|
||||||
|
this.justDeleted = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fetchStatuses (store, opts) {
|
||||||
|
const u = this.$store.getters.findUser(this.userDetails.id)
|
||||||
|
const res = store.dispatch('adminListStatuses', { user: u, opts: { pageSize: opts.pageSize, godmode: true, withReblogs: true}})
|
||||||
|
return Promise.resolve(res.then(r => r.activities))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AdminCard
|
export default AdminCard
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue