Don't allow uploads if the conversation is read-only

Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
This commit is contained in:
Marco Ambrosini 2020-03-05 09:12:37 +01:00
Родитель 3c62a1c7e7
Коммит ee9b1b862a
2 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -31,7 +31,10 @@
<div class="drop-hint">
<div
class="drop-hint__icon"
:class="{'icon-upload' : !isGuest, 'icon-user' : isGuest}" />
:class="{
'icon-upload' : !isGuest && !isReadOnly,
'icon-user' : isGuest,
'icon-error' : isReadOnly}" />
<h2
class="drop-hint__text">
{{ dropHintText }}
@ -53,6 +56,7 @@
import MessagesList from './MessagesList/MessagesList'
import NewMessageForm from './NewMessageForm/NewMessageForm'
import { processFiles } from '../utils/fileUpload'
import { CONVERSATION } from '../constants'
export default {
@ -83,18 +87,28 @@ export default {
dropHintText() {
if (this.isGuest) {
return t('spreed', 'You need to be logged in to upload files')
} else if (this.isReadOnly) {
return t('spreed', 'This conversation is read only')
} else {
return t('spreed', 'Drop your files to upload')
}
},
isReadOnly() {
if (this.$store.getters.conversation(this.token)) {
return this.$store.getters.conversation(this.token).readOnly === CONVERSATION.STATE.READ_ONLY
} else {
return undefined
}
},
},
methods: {
handleDropFiles(event) {
// Restore non dragover state
this.isDraggingOver = false
// Stop the executin if the user is a guest
if (this.isGuest) {
if (this.isGuest || this.isReadOnly) {
return
}
// Get the files from the event

Просмотреть файл

@ -45,6 +45,13 @@ const state = {
const getters = {
conversations: state => state.conversations,
conversationsList: state => Object.values(state.conversations),
/**
* Get a conversation providing it's token
* @param {object} state state object
* @returns {function} The callback function
* @returns {object} The conversation object
*/
conversation: state => token => state.conversations[token],
}
const mutations = {