-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ConversationSettings): allow moderators to enable consent per co…
…nversation (V2) Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
- Loading branch information
Showing
5 changed files
with
192 additions
and
2 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
152 changes: 152 additions & 0 deletions
152
src/components/ConversationSettings/RecordingConsentSettings.vue
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,152 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2023 Maksim Sukharev <antreesy.web@gmail.com> | ||
- | ||
- @author Maksim Sukharev <antreesy.web@gmail.com> | ||
- | ||
- @license AGPL-3.0-or-later | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<template> | ||
<div class="app-settings-subsection"> | ||
<h4 class="app-settings-section__subtitle"> | ||
{{ t('spreed', 'Recording Consent') }} | ||
</h4> | ||
|
||
<template v-if="canFullModerate && !isGlobalConsent"> | ||
<label for="recording-consent_input" class="recording-consent__label"> | ||
{{ t('spreed', 'Require recording consent before joining call in this conversation') }} | ||
</label> | ||
<NcSelect v-model="recordingConsentSelected" | ||
input-id="recording-consent_input" | ||
class="recording-consent__select" | ||
name="recording-consent" | ||
:options="recordingConsentOptions" | ||
:clearable="false" | ||
:placeholder="t('spreed', 'Recording consent')" | ||
label="label" | ||
no-wrap | ||
:disabled="isSelectDisabled" | ||
@input="setRecordingConsent" /> | ||
</template> | ||
<p v-else-if="isGlobalConsent"> | ||
{{ t('spreed', 'Recording consent is required for all calls') }} | ||
</p> | ||
<p v-else> | ||
{{ summaryLabel }} | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { showError } from '@nextcloud/dialogs' | ||
|
||
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' | ||
|
||
import { CALL } from '../../constants.js' | ||
import { getCapabilities } from '@nextcloud/capabilities' | ||
|
||
const recordingConsent = getCapabilities()?.spreed?.config?.call?.['recording-consent'] | ||
const recordingConsentOptions = [ | ||
{ id: CALL.RECORDING_CONSENT.OFF, label: t('spreed', 'Off') }, | ||
{ id: CALL.RECORDING_CONSENT.REQUIRED, label: t('spreed', 'Enabled') }, | ||
] | ||
|
||
export default { | ||
name: 'RecordingConsentSettings', | ||
|
||
components: { | ||
NcSelect, | ||
}, | ||
|
||
props: { | ||
token: { | ||
type: String, | ||
default: null, | ||
}, | ||
|
||
canFullModerate: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
|
||
setup() { | ||
return { | ||
recordingConsentOptions | ||
} | ||
}, | ||
|
||
data() { | ||
return { | ||
loading: false, | ||
recordingConsentSelected: recordingConsentOptions[0], | ||
} | ||
}, | ||
|
||
computed: { | ||
conversation() { | ||
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation | ||
}, | ||
|
||
isGlobalConsent() { | ||
return recordingConsent === CALL.RECORDING_CONSENT.REQUIRED | ||
}, | ||
|
||
isSelectDisabled() { | ||
return this.isGlobalConsent || this.loading || this.conversation.hasCall | ||
}, | ||
|
||
summaryLabel() { | ||
return this.recordingConsentSelected.id === CALL.RECORDING_CONSENT.REQUIRED | ||
? t('spreed', 'Recording consent is required for calls in this conversation') | ||
: t('spreed', 'Recording consent is not required for calls in this conversation') | ||
}, | ||
}, | ||
|
||
mounted() { | ||
this.recordingConsentSelected = recordingConsentOptions.find(option => option.id === this.conversation.recordingConsent) | ||
}, | ||
|
||
methods: { | ||
async setRecordingConsent(option) { | ||
this.loading = true | ||
try { | ||
await this.$store.dispatch('setRecordingConsent', { | ||
token: this.token, | ||
state: option.id, | ||
}) | ||
} catch (error) { | ||
showError(t('spreed', 'Error occurred while updating recording consent')) | ||
console.error(error) | ||
} | ||
this.loading = false | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.recording-consent { | ||
&__select { | ||
width: 300px; | ||
} | ||
|
||
&__label { | ||
display: block; | ||
padding: 4px 0; | ||
} | ||
} | ||
</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