Support room version 12 and the "creator power level"
This commit is contained in:
parent
f804e0377b
commit
c36deef7e2
13 changed files with 351 additions and 113 deletions
|
|
@ -53,6 +53,9 @@
|
|||
<v-btn variant="text" size="x-large" block v-if="activeMember.userId != $matrix.currentUserId && !isAdminComp && canMakeAdminComp" class="start-private-chat clickable d-block text-none justify-start" @click="makeAdmin">
|
||||
<v-icon start>$vuetify.icons.make_admin</v-icon> {{ $t("menu.user_make_admin") }}
|
||||
</v-btn>
|
||||
<v-btn variant="text" size="x-large" block v-if="activeMember.userId != $matrix.currentUserId && isAdminComp && canRevokeAdminComp" class="start-private-chat clickable d-block text-none justify-start" @click="revokeAdmin">
|
||||
<v-icon start>$vuetify.icons.make_admin</v-icon> {{ $t("menu.user_revoke_admin") }}
|
||||
</v-btn>
|
||||
<v-btn variant="text" size="x-large" block v-if="activeMember.userId != $matrix.currentUserId && !isModeratorComp && !isAdminComp && canMakeModeratorComp" class="start-private-chat clickable d-block text-none justify-start" @click="makeModerator">
|
||||
<v-icon start>$vuetify.icons.make_moderator</v-icon> {{ $t("menu.user_make_moderator") }}
|
||||
</v-btn>
|
||||
|
|
@ -65,6 +68,7 @@
|
|||
</v-dialog>
|
||||
|
||||
<ConfirmationDialog :message="$t('room_info.confirm_make_admin')" v-model="showConfirmMakeAdmin" v-on:ok="doMakeAdmin" />
|
||||
<ConfirmationDialog :message="$t('room_info.confirm_revoke_admin')" v-model="showConfirmRevokeAdmin" v-on:ok="doRevokeAdmin" />
|
||||
<ConfirmationDialog :message="$t('room_info.confirm_make_moderator')" v-model="showConfirmMakeModerator" v-on:ok="doMakeModerator" />
|
||||
<ConfirmationDialog :message="$t('room_info.confirm_revoke_moderator')" v-model="showConfirmRevokeModerator" v-on:ok="doRevokeModerator" />
|
||||
<ConfirmationDialog :message="$t('room_info.confirm_ban')" v-model="showConfirmBan" v-on:ok="doBanUser" />
|
||||
|
|
@ -76,6 +80,7 @@ import AuthedImage from "./AuthedImage.vue";
|
|||
import util from "../plugins/utils";
|
||||
import RoomDialogBase from "./RoomDialogBase.vue";
|
||||
import ConfirmationDialog from "./ConfirmationDialog.vue";
|
||||
import { consoleError } from "vuetify/lib/util/console.mjs";
|
||||
|
||||
export default {
|
||||
name: "UserProfileDialog",
|
||||
|
|
@ -96,12 +101,16 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
showConfirmMakeAdmin: false,
|
||||
showConfirmRevokeAdmin: false,
|
||||
showConfirmMakeModerator: false,
|
||||
showConfirmRevokeModerator: false,
|
||||
showConfirmBan: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
canRevokeAdminComp () {
|
||||
return this.canRevokeAdmin(this.activeMember)
|
||||
},
|
||||
canRevokeModeratorComp () {
|
||||
return this.canRevokeModerator(this.activeMember)
|
||||
},
|
||||
|
|
@ -198,6 +207,19 @@ export default {
|
|||
}
|
||||
return false;
|
||||
},
|
||||
/**
|
||||
* Return true if WE can "unmake" the member an administraor (= we are creator of the room)
|
||||
* @param member
|
||||
*/
|
||||
canRevokeAdmin(member) {
|
||||
if (this.room) {
|
||||
// TODO - not supposed to parse room versions as int.
|
||||
const roomVersion = parseInt(this.room.getVersion()?.split(".").reverse()[0] ?? "0");
|
||||
const myUserId = this.$matrix.currentUserId;
|
||||
return roomVersion > 11 && this.room.getCreator() === myUserId;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if WE can make the member a moderator
|
||||
|
|
@ -235,6 +257,19 @@ export default {
|
|||
this.showDialog = false;
|
||||
}
|
||||
},
|
||||
revokeAdmin() {
|
||||
if (this.room && this.activeMember) {
|
||||
this.showConfirmRevokeAdmin = true;
|
||||
this.showDialog = false;
|
||||
}
|
||||
},
|
||||
doRevokeAdmin() {
|
||||
if (this.room && this.activeMember) {
|
||||
this.$matrix.revokeAdmin(this.room.roomId, this.activeMember.userId)
|
||||
this.showDialog = false;
|
||||
}
|
||||
},
|
||||
|
||||
makeModerator() {
|
||||
if (this.room && this.activeMember) {
|
||||
this.showConfirmMakeModerator = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue