Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ConversationSettingsDialog.vue « ConversationSettings « components « src - github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5963658ac9c32318991b81f0428922d12d7c8b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!--
  - @copyright Copyright (c) 2020 Vincent Petry <vincent@nextcloud.com>
  -
  - @author Vincent Petry <vincent@nextcloud.com>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - 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>
	<AppSettingsDialog role="dialog"
		:aria-label="t('spreed', 'Conversation settings')"
		:open.sync="showSettings"
		:show-navigation="true"
		:container="container">
		<!-- description -->
		<AppSettingsSection v-if="showDescription"
			id="description"
			:title="t('spreed', 'Description')">
			<Description :editable="canFullModerate"
				:description="description"
				:editing="isEditingDescription"
				:loading="isDescriptionLoading"
				:placeholder="t('spreed', 'Enter a description for this conversation')"
				@submit-description="handleUpdateDescription"
				@update:editing="handleEditDescription" />
		</AppSettingsSection>

		<!-- Notifications settings -->
		<AppSettingsSection id="notifications"
			:title="t('spreed', 'Notifications')">
			<NotificationsSettings :conversation="conversation" />
		</AppSettingsSection>

		<!-- Devices preview sceren -->
		<AppSettingsSection id="device-checker"
			:title="t('spreed', 'Device check')">
			<CheckboxRadioSwitch :checked.sync="showDeviceChecker">
				{{ t('spreed', 'Always show the device preview screen before joining a call in this conversation.') }}
			</CheckboxRadioSwitch>
		</AppSettingsSection>

		<!-- Guest access -->
		<AppSettingsSection v-if="canFullModerate"
			id="guests"
			:title="t('spreed', 'Guests access')">
			<LinkShareSettings ref="linkShareSettings" />
		</AppSettingsSection>

		<!-- TODO sepatate these 2 settings and rename the settings sections
		all the settings in this component are conversation settings. Proposal:
		move lock conversation in destructive actions and create a separate
		section for listablesettings -->
		<AppSettingsSection v-if="canFullModerate"
			id="conversation-settings"
			:title="t('spreed', 'Conversation settings')">
			<ListableSettings :token="token" />
			<LockingSettings :token="token" />
		</AppSettingsSection>

		<!-- Conversation permissions -->
		<AppSettingsSection v-if="canFullModerate"
			id="permissions"
			:title="t('spreed', 'Participants permissions')">
			<ConversationPermissionsSettings :token="token" />
		</AppSettingsSection>

		<!-- Meeting settings -->
		<AppSettingsSection v-if="canFullModerate"
			id="meeting"
			:title="t('spreed', 'Meeting settings')">
			<LobbySettings :token="token" />
			<SipSettings v-if="canUserEnableSIP" />
		</AppSettingsSection>
		<AppSettingsSection v-if="canFullModerate && matterbridgeEnabled"
			:title="t('spreed', 'Matterbridge')">
			<MatterbridgeSettings />
		</AppSettingsSection>

		<!-- Destructive actions -->
		<AppSettingsSection v-if="canLeaveConversation || canDeleteConversation"
			id="dangerzone"
			:title="t('spreed', 'Danger zone')">
			<DangerZone :conversation="conversation"
				:can-leave-conversation="canLeaveConversation"
				:can-delete-conversation="canDeleteConversation" />
		</AppSettingsSection>
	</AppSettingsDialog>
</template>

<script>
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { PARTICIPANT, CONVERSATION } from '../../constants.js'
import AppSettingsDialog from '@nextcloud/vue/dist/Components/AppSettingsDialog'
import AppSettingsSection from '@nextcloud/vue/dist/Components/AppSettingsSection'
import LinkShareSettings from './LinkShareSettings.vue'
import ListableSettings from './ListableSettings.vue'
import LockingSettings from './LockingSettings.vue'
import LobbySettings from './LobbySettings.vue'
import SipSettings from './SipSettings.vue'
import MatterbridgeSettings from './Matterbridge/MatterbridgeSettings.vue'
import { loadState } from '@nextcloud/initial-state'
import DangerZone from './DangerZone.vue'
import NotificationsSettings from './NotificationsSettings.vue'
import { showError } from '@nextcloud/dialogs'
import Description from '../Description/Description.vue'
import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch'
import BrowserStorage from '../../services/BrowserStorage.js'
import ConversationPermissionsSettings from './ConversationPermissionsSettings.vue'

export default {
	name: 'ConversationSettingsDialog',

	components: {
		AppSettingsDialog,
		AppSettingsSection,
		LinkShareSettings,
		LobbySettings,
		ListableSettings,
		LockingSettings,
		SipSettings,
		MatterbridgeSettings,
		DangerZone,
		NotificationsSettings,
		Description,
		CheckboxRadioSwitch,
		ConversationPermissionsSettings,
	},

	data() {
		return {
			showSettings: false,
			matterbridgeEnabled: loadState('spreed', 'enable_matterbridge'),
			isEditingDescription: false,
			isDescriptionLoading: false,
			showDeviceChecker: false,
		}
	},

	computed: {
		container() {
			return this.$store.getters.getMainContainerSelector()
		},

		canUserEnableSIP() {
			return this.conversation.canEnableSIP
		},

		token() {
			return this.$store.getters.getConversationSettingsToken()
				|| this.$store.getters.getToken()
		},

		conversation() {
			return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation
		},

		participantType() {
			return this.conversation.participantType
		},

		canFullModerate() {
			return (this.participantType === PARTICIPANT.TYPE.OWNER
				|| this.participantType === PARTICIPANT.TYPE.MODERATOR)
				&& this.conversation.type !== CONVERSATION.TYPE.ONE_TO_ONE
		},

		canDeleteConversation() {
			return this.conversation.canDeleteConversation
		},

		canLeaveConversation() {
			return this.conversation.canLeaveConversation
		},

		description() {
			return this.conversation.description
		},

		showDescription() {
			if (this.canFullModerate) {
				return this.conversation.type !== CONVERSATION.TYPE.ONE_TO_ONE
			} else {
				return this.description !== ''
			}
		},
	},

	watch: {
		showDeviceChecker(newValue) {
			const browserValue = newValue ? 'true' : 'false'
			BrowserStorage.setItem('showDeviceChecker' + this.token, browserValue)
		},
	},

	mounted() {
		subscribe('show-conversation-settings', this.handleShowSettings)
		subscribe('hide-conversation-settings', this.handleHideSettings)

		/**
		 * Get the deviceChecker value from the browserstorage.
		 */
		this.showDeviceChecker = BrowserStorage.getItem('showDeviceChecker' + this.token) === null
			|| BrowserStorage.getItem('showDeviceChecker' + this.token) === 'true'
	},

	methods: {
		handleShowSettings({ token }) {
			this.$store.dispatch('updateConversationSettingsToken', token)
			this.showSettings = true
			this.$nextTick(() => {
				this.$refs.linkShareSettings.focus()
			})
		},

		handleHideSettings() {
			this.showSettings = false
			this.$store.dispatch('updateConversationSettingsToken', '')
		},

		beforeDestroy() {
			unsubscribe('show-conversation-settings', this.handleShowSettings)
			unsubscribe('hide-conversation-settings', this.handleHideSettings)
		},

		async handleUpdateDescription(description) {
			this.isDescriptionLoading = true
			try {
				await this.$store.dispatch('setConversationDescription', {
					token: this.token,
					description,
				})
				this.isEditingDescription = false
			} catch (error) {
				console.error('Error while setting conversation description', error)
				showError(t('spreed', 'Error while updating conversation description'))
			}
			this.isDescriptionLoading = false
		},

		handleEditDescription(payload) {
			this.isEditingDescription = payload
		},
	},
}
</script>

<style lang="scss" scoped>
::v-deep button.icon {
	height: 32px;
	width: 32px;
	display: inline-block;
	margin-left: 5px;
	vertical-align: middle;
}

::v-deep .modal-container {
	display: flex !important;
}

::v-deep .app-settings-section__hint {
	color: var(--color-text-lighter);
	padding: 8px 0;
}

::v-deep .app-settings-subsection {
	margin-top: 25px;

	&:first-child {
		margin-top: 0;
	}
}
</style>