diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-05-08 18:01:25 +0200 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-06-14 10:27:25 +0200 |
commit | d9f80e4dc5a4ba8647a3b2d2a7b19854153f8b2d (patch) | |
tree | e04c34ad63f62b8ddf08b0b12507136f686111b6 /src | |
parent | 477a6d1a6a8885a0998c196ed93c5df78e1b68d2 (diff) |
feat(capabilities): apply manager for static capabilities (unchanged with conversation switch)
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/AdminSettings/RecordingServers.vue | 4 | ||||
-rw-r--r-- | src/components/ConversationIcon.vue | 5 | ||||
-rw-r--r-- | src/components/ConversationSettings/BasicInfo.vue | 4 | ||||
-rw-r--r-- | src/components/LeftSidebar/LeftSidebar.vue | 12 | ||||
-rw-r--r-- | src/components/MediaSettings/VideoBackgroundEditor.vue | 15 | ||||
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js | 23 | ||||
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue | 1 | ||||
-rw-r--r-- | src/components/NewConversationDialog/NewConversationSetupPage.vue | 5 | ||||
-rw-r--r-- | src/components/SettingsDialog/SettingsDialog.vue | 4 | ||||
-rw-r--r-- | src/services/conversationsService.js | 8 | ||||
-rw-r--r-- | src/utils/webrtc/index.js | 4 | ||||
-rw-r--r-- | src/views/AdminSettings.vue | 6 | ||||
-rw-r--r-- | src/views/FlowPostToConversation.vue | 4 |
13 files changed, 40 insertions, 55 deletions
diff --git a/src/components/AdminSettings/RecordingServers.vue b/src/components/AdminSettings/RecordingServers.vue index dae1f7be8..db8602a17 100644 --- a/src/components/AdminSettings/RecordingServers.vue +++ b/src/components/AdminSettings/RecordingServers.vue @@ -76,7 +76,6 @@ import debounce from 'debounce' import Plus from 'vue-material-design-icons/Plus.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showSuccess } from '@nextcloud/dialogs' import { formatFileSize } from '@nextcloud/files' import { loadState } from '@nextcloud/initial-state' @@ -90,8 +89,9 @@ import RecordingServer from '../../components/AdminSettings/RecordingServer.vue' import TransitionWrapper from '../UIShared/TransitionWrapper.vue' import { CALL } from '../../constants.js' +import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' -const recordingConsentCapability = getCapabilities()?.spreed?.features?.includes('recording-consent') +const recordingConsentCapability = hasTalkFeature('local', 'recording-consent') const recordingConsentOptions = [ { value: CALL.RECORDING_CONSENT.OFF, label: t('spreed', 'Disabled for all calls') }, { value: CALL.RECORDING_CONSENT.REQUIRED, label: t('spreed', 'Enabled for all calls') }, diff --git a/src/components/ConversationIcon.vue b/src/components/ConversationIcon.vue index 04f1ed209..548aec703 100644 --- a/src/components/ConversationIcon.vue +++ b/src/components/ConversationIcon.vue @@ -58,15 +58,14 @@ import Star from 'vue-material-design-icons/Star.vue' import VideoIcon from 'vue-material-design-icons/Video.vue' import WebIcon from 'vue-material-design-icons/Web.vue' -import { getCapabilities } from '@nextcloud/capabilities' - import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js' import { AVATAR, CONVERSATION } from '../constants.js' import { getConversationAvatarOcsUrl } from '../services/avatarService.ts' +import { hasTalkFeature } from '../services/CapabilitiesManager.ts' import { isDarkTheme } from '../utils/isDarkTheme.js' -const supportsAvatar = getCapabilities()?.spreed?.features?.includes('avatar') +const supportsAvatar = hasTalkFeature('local', 'avatar') export default { name: 'ConversationIcon', diff --git a/src/components/ConversationSettings/BasicInfo.vue b/src/components/ConversationSettings/BasicInfo.vue index a212aa712..993619e53 100644 --- a/src/components/ConversationSettings/BasicInfo.vue +++ b/src/components/ConversationSettings/BasicInfo.vue @@ -46,15 +46,15 @@ <script> import { Fragment } from 'vue-frag' -import { getCapabilities } from '@nextcloud/capabilities' import { showError } from '@nextcloud/dialogs' import ConversationAvatarEditor from './ConversationAvatarEditor.vue' import EditableTextField from '../UIShared/EditableTextField.vue' import { CONVERSATION } from '../../constants.js' +import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' -const supportsAvatar = getCapabilities()?.spreed?.features?.includes('avatar') +const supportsAvatar = hasTalkFeature('local', 'avatar') export default { name: 'BasicInfo', diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue index 7222b40bb..2331bbd33 100644 --- a/src/components/LeftSidebar/LeftSidebar.vue +++ b/src/components/LeftSidebar/LeftSidebar.vue @@ -307,7 +307,6 @@ import Note from 'vue-material-design-icons/NoteEditOutline.vue' import Phone from 'vue-material-design-icons/Phone.vue' import Plus from 'vue-material-design-icons/Plus.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showError } from '@nextcloud/dialogs' import { emit } from '@nextcloud/event-bus' import { loadState } from '@nextcloud/initial-state' @@ -338,6 +337,7 @@ import TransitionWrapper from '../UIShared/TransitionWrapper.vue' import { useArrowNavigation } from '../../composables/useArrowNavigation.js' import { ATTENDEE, CONVERSATION } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' +import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManager.ts' import { createPrivateConversation, fetchNoteToSelfConversation, @@ -353,11 +353,11 @@ import { hasUnreadMentions, filterFunction } from '../../utils/conversation.js' import { requestTabLeadership } from '../../utils/requestTabLeadership.js' const isFederationEnabled = loadState('spreed', 'federation_enabled') -const canModerateSipDialOut = getCapabilities()?.spreed?.features?.includes('sip-support-dialout') - && getCapabilities()?.spreed?.config.call['sip-enabled'] - && getCapabilities()?.spreed?.config.call['sip-dialout-enabled'] - && getCapabilities()?.spreed?.config.call['can-enable-sip'] -const canNoteToSelf = getCapabilities()?.spreed?.features?.includes('note-to-self') +const canModerateSipDialOut = hasTalkFeature('local', 'sip-support-dialout') + && getTalkConfig('local', 'call', 'sip-enabled') + && getTalkConfig('local', 'call', 'sip-dialout-enabled') + && getTalkConfig('local', 'call', 'can-enable-sip') +const canNoteToSelf = hasTalkFeature('local', 'note-to-self') export default { name: 'LeftSidebar', diff --git a/src/components/MediaSettings/VideoBackgroundEditor.vue b/src/components/MediaSettings/VideoBackgroundEditor.vue index 5c58b53ae..ef6d8af82 100644 --- a/src/components/MediaSettings/VideoBackgroundEditor.vue +++ b/src/components/MediaSettings/VideoBackgroundEditor.vue @@ -78,18 +78,16 @@ import CheckBold from 'vue-material-design-icons/CheckBold.vue' import Folder from 'vue-material-design-icons/Folder.vue' import Upload from 'vue-material-design-icons/Upload.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showError } from '@nextcloud/dialogs' import { FilePickerVue } from '@nextcloud/dialogs/filepicker.js' import { imagePath, generateUrl } from '@nextcloud/router' import { VIRTUAL_BACKGROUND } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { getDavClient } from '../../services/DavClient.js' import { findUniquePath } from '../../utils/fileUpload.js' -const canUploadBackgrounds = getCapabilities()?.spreed?.config?.call?.['can-upload-background'] -const predefinedBackgrounds = getCapabilities()?.spreed?.config?.call?.['predefined-backgrounds'] const predefinedBackgroundLabels = { '1_office': t('spreed', 'Select virtual office background'), '2_home': t('spreed', 'Select virtual home background'), @@ -124,15 +122,14 @@ export default { setup() { return { - canUploadBackgrounds, - predefinedBackgrounds, + canUploadBackgrounds: getTalkConfig('local', 'call', 'can-upload-background'), + predefinedBackgrounds: getTalkConfig('local', 'call', 'predefined-backgrounds'), } }, data() { return { selectedBackground: undefined, - getCapabilities, showFilePicker: false, } }, @@ -145,15 +142,11 @@ export default { }, predefinedBackgroundsURLs() { - return predefinedBackgrounds.map(fileName => { + return this.predefinedBackgrounds.map(fileName => { return imagePath('spreed', 'backgrounds/' + fileName) }) }, - hasBackgroundsCapability() { - return !!predefinedBackgrounds - }, - relativeBackgroundsFolderPath() { return this.$store.getters.getAttachmentFolder() + '/Backgrounds' }, diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js index acd341a6a..5ce908605 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js @@ -9,7 +9,6 @@ import Vuex from 'vuex' import PlayCircleOutline from 'vue-material-design-icons/PlayCircleOutline.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { imagePath, generateRemoteUrl } from '@nextcloud/router' import { getUploader } from '@nextcloud/upload' @@ -20,7 +19,15 @@ import FilePreview from './FilePreview.vue' import storeConfig from '../../../../../store/storeConfig.js' jest.mock('@nextcloud/capabilities', () => ({ - getCapabilities: jest.fn(), + getCapabilities: jest.fn(() => ({ + spreed: { + config: { + previews: { + 'max-gif-size': 1024, + }, + }, + } + })), })) describe('FilePreview.vue', () => { @@ -252,18 +259,6 @@ describe('FilePreview.vue', () => { propsData.mimetype = 'image/gif' propsData.name = 'test %20.gif' propsData.path = 'path/to/test %20.gif' - - getCapabilities.mockImplementation(() => { - return { - spreed: { - config: { - previews: { - 'max-gif-size': 1024, - }, - }, - }, - } - }) }) test('directly renders small GIF files', async () => { propsData.size = '128' diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue index fc5dfb5c9..d32671774 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue @@ -119,7 +119,6 @@ import CheckAllIcon from 'vue-material-design-icons/CheckAll.vue' import ContentCopyIcon from 'vue-material-design-icons/ContentCopy.vue' import ReloadIcon from 'vue-material-design-icons/Reload.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showError, showSuccess } from '@nextcloud/dialogs' import moment from '@nextcloud/moment' diff --git a/src/components/NewConversationDialog/NewConversationSetupPage.vue b/src/components/NewConversationDialog/NewConversationSetupPage.vue index d71ad2253..0798cbee5 100644 --- a/src/components/NewConversationDialog/NewConversationSetupPage.vue +++ b/src/components/NewConversationDialog/NewConversationSetupPage.vue @@ -60,8 +60,6 @@ </template> <script> -import { getCapabilities } from '@nextcloud/capabilities' - import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js' import NcTextArea from '@nextcloud/vue/dist/Components/NcTextArea.js' @@ -71,8 +69,9 @@ import ConversationAvatarEditor from '../ConversationSettings/ConversationAvatar import ListableSettings from '../ConversationSettings/ListableSettings.vue' import { CONVERSATION } from '../../constants.js' +import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' -const supportsAvatar = getCapabilities()?.spreed?.features?.includes('avatar') +const supportsAvatar = hasTalkFeature('local', 'avatar') export default { diff --git a/src/components/SettingsDialog/SettingsDialog.vue b/src/components/SettingsDialog/SettingsDialog.vue index 8e80c46b6..4e9f1a9ca 100644 --- a/src/components/SettingsDialog/SettingsDialog.vue +++ b/src/components/SettingsDialog/SettingsDialog.vue @@ -163,7 +163,6 @@ </template> <script> -import { getCapabilities } from '@nextcloud/capabilities' import { showError, showSuccess } from '@nextcloud/dialogs' import { FilePickerVue } from '@nextcloud/dialogs/filepicker.js' import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' @@ -178,9 +177,10 @@ import MediaDevicesPreview from './MediaDevicesPreview.vue' import { PRIVACY } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useSettingsStore } from '../../stores/settings.js' -const supportTypingStatus = getCapabilities()?.spreed?.config?.chat?.['typing-privacy'] !== undefined +const supportTypingStatus = getTalkConfig('local', 'chat', 'typing-privacy') !== undefined export default { name: 'SettingsDialog', diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js index e56a12acf..c2fc37cf0 100644 --- a/src/services/conversationsService.js +++ b/src/services/conversationsService.js @@ -4,14 +4,14 @@ */ import axios from '@nextcloud/axios' -import { getCapabilities } from '@nextcloud/capabilities' import { generateOcsUrl } from '@nextcloud/router' +import { getTalkConfig, hasTalkFeature } from './CapabilitiesManager.ts' import { ATTENDEE, CONVERSATION, SHARE } from '../constants.js' -const canInviteToFederation = getCapabilities()?.spreed?.features?.includes('federation-v1') - && getCapabilities()?.spreed?.config?.federation?.enabled - && getCapabilities()?.spreed?.config?.federation?.['outgoing-enabled'] +const canInviteToFederation = hasTalkFeature('local', 'federation-v1') + && getTalkConfig('local', 'federation', 'enabled') + && getTalkConfig('local', 'federation', 'outgoing-enabled') /** * Fetches the conversations from the server. diff --git a/src/utils/webrtc/index.js b/src/utils/webrtc/index.js index 579fea6db..ec66d7238 100644 --- a/src/utils/webrtc/index.js +++ b/src/utils/webrtc/index.js @@ -4,7 +4,6 @@ */ import Axios from '@nextcloud/axios' -import { getCapabilities } from '@nextcloud/capabilities' import CallAnalyzer from './analyzers/CallAnalyzer.js' import CallParticipantsAudioPlayer from './CallParticipantsAudioPlayer.js' @@ -19,6 +18,7 @@ import SpeakingStatusHandler from './SpeakingStatusHandler.js' import initWebRtc from './webrtc.js' import { PARTICIPANT, PRIVACY, VIRTUAL_BACKGROUND } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { fetchSignalingSettings } from '../../services/signalingService.js' import store from '../../store/index.js' import { isSafari } from '../browserCheck.js' @@ -38,7 +38,7 @@ let speakingStatusHandler = null // This does not really belongs here, as it is unrelated to WebRTC, but it is // included here for the time being until signaling and WebRTC are split. -const enableTypingIndicators = getCapabilities()?.spreed?.config?.chat?.['typing-privacy'] === PRIVACY.PUBLIC +const enableTypingIndicators = getTalkConfig('local', 'chat', 'typing-privacy') === PRIVACY.PUBLIC const signalingTypingHandler = enableTypingIndicators ? new SignalingTypingHandler(store) : null let cancelFetchSignalingSettings = null diff --git a/src/views/AdminSettings.vue b/src/views/AdminSettings.vue index 0e9a1cbfa..7717e807c 100644 --- a/src/views/AdminSettings.vue +++ b/src/views/AdminSettings.vue @@ -21,8 +21,6 @@ </template> <script> -import { getCapabilities } from '@nextcloud/capabilities' - import AllowedGroups from '../components/AdminSettings/AllowedGroups.vue' import BotsSettings from '../components/AdminSettings/BotsSettings.vue' import Federation from '../components/AdminSettings/Federation.vue' @@ -36,7 +34,9 @@ import StunServers from '../components/AdminSettings/StunServers.vue' import TurnServers from '../components/AdminSettings/TurnServers.vue' import WebServerSetupChecks from '../components/AdminSettings/WebServerSetupChecks.vue' -const supportFederation = getCapabilities()?.spreed?.features?.includes('federation-v1') +import { hasTalkFeature } from '../services/CapabilitiesManager.ts' + +const supportFederation = hasTalkFeature('local', 'federation-v1') export default { name: 'AdminSettings', diff --git a/src/views/FlowPostToConversation.vue b/src/views/FlowPostToConversation.vue index 57fc002d0..271f2514a 100644 --- a/src/views/FlowPostToConversation.vue +++ b/src/views/FlowPostToConversation.vue @@ -21,14 +21,14 @@ <script> import axios from '@nextcloud/axios' -import { getCapabilities } from '@nextcloud/capabilities' import { generateOcsUrl } from '@nextcloud/router' import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' import { FLOW, CONVERSATION, PARTICIPANT } from '../constants.js' +import { hasTalkFeature } from '../services/CapabilitiesManager.ts' -const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1') +const supportFederationV1 = hasTalkFeature('local', 'federation-v1') export default { name: 'FlowPostToConversation', |