diff options
author | Vincent Petry <vincent@nextcloud.com> | 2020-10-08 16:59:55 +0300 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2020-10-13 17:54:29 +0300 |
commit | bd78555cc31e653171ec68a1f87eafe2304d7bba (patch) | |
tree | 0274c3349a606ac3f41407d09f62e4d1d9965104 /src | |
parent | acaf9aac3fec3b9e99c2a1e685127470501ee74d (diff) |
Add checkbox for locking conversation
Added logic for setting a conversation to read-only.
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/TopBar/TopBar.vue | 20 | ||||
-rw-r--r-- | src/services/conversationsService.js | 17 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 13 |
3 files changed, 50 insertions, 0 deletions
diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 7efdae757..14499f8a3 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -119,6 +119,12 @@ </ActionInput> <ActionSeparator /> <ActionCheckbox + :checked="isReadOnly" + :disabled="readOnlyStateLoading" + @change="toggleReadOnly"> + {{ t('spreed', 'Lock conversation') }} + </ActionCheckbox> + <ActionCheckbox :checked="hasLobbyEnabled" @change="toggleLobby"> {{ t('spreed', 'Enable lobby') }} @@ -204,6 +210,7 @@ export default { // Switch for the password-editing operation isEditingPassword: false, lobbyTimerLoading: false, + readOnlyStateLoading: false, } }, @@ -317,6 +324,9 @@ export default { hasLobbyEnabled() { return this.conversation.lobbyState === WEBINAR.LOBBY.NON_MODERATORS }, + isReadOnly() { + return this.conversation.readOnly === CONVERSATION.STATE.READ_ONLY + }, isPasswordProtected() { return this.conversation.hasPassword }, @@ -457,6 +467,16 @@ export default { this.lobbyTimerLoading = false }, + + async toggleReadOnly() { + this.readOnlyStateLoading = true + await this.$store.dispatch('setReadOnlyState', { + token: this.token, + readOnly: this.isReadOnly ? CONVERSATION.STATE.READ_WRITE : CONVERSATION.STATE.READ_ONLY, + }) + this.readOnlyStateLoading = false + }, + async handlePasswordDisable() { // disable the password protection for the current conversation if (this.conversation.hasPassword) { diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js index fcb827aab..0aa97ed73 100644 --- a/src/services/conversationsService.js +++ b/src/services/conversationsService.js @@ -297,6 +297,22 @@ const changeLobbyState = async function(token, newState, timestamp) { } } +/** + * Change the read-only state + * @param {string} token The token of the conversation to be modified + * @param {int} readOnly The new read-only state to set + */ +const changeReadOnlyState = async function(token, readOnly) { + try { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v2', 2) + `room/${token}/read-only`, { + state: readOnly, + }) + return response + } catch (error) { + console.debug('Error while updating read-only state: ', error) + } +} + export { fetchConversations, fetchConversation, @@ -312,6 +328,7 @@ export { makePublic, makePrivate, changeLobbyState, + changeReadOnlyState, setConversationPassword, setConversationName, } diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index fa7f4a4bd..886d13bcf 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -24,6 +24,7 @@ import { makePublic, makePrivate, changeLobbyState, + changeReadOnlyState, addToFavorites, removeFromFavorites, setConversationName, @@ -206,6 +207,18 @@ const actions = { commit('addConversation', conversation) }, + async setReadOnlyState({ commit, getters }, { token, readOnly }) { + const conversation = Object.assign({}, getters.conversations[token]) + if (!conversation) { + return + } + + await changeReadOnlyState(token, readOnly) + conversation.readOnly = readOnly + + commit('addConversation', conversation) + }, + async setLobbyTimer({ commit, getters }, { token, timestamp }) { const conversation = Object.assign({}, getters.conversations[token]) if (!conversation) { |