Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ import { parseSpecialSymbols } from '../../utils/textParse.ts'
const disableKeyboardShortcuts = OCP.Accessibility.disableKeyboardShortcuts()
const supportTypingStatus = getCapabilities()?.spreed?.config?.chat?.['typing-privacy'] !== undefined
const canEditMessage = getCapabilities()?.spreed?.features?.includes('edit-messages')
const attachmentsAllowed = getCapabilities()?.spreed?.config?.attachments?.allowed
const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1')

export default {
name: 'NewMessage',
Expand Down Expand Up @@ -407,17 +409,18 @@ export default {

canShareFiles() {
return !this.currentUserIsGuest
&& (!supportFederationV1 || !this.conversation.remoteServer)
},

canUploadFiles() {
return getCapabilities()?.spreed?.config?.attachments?.allowed
return attachmentsAllowed && this.canShareFiles
&& this.$store.getters.getAttachmentFolderFreeSpace() !== 0
&& this.canShareFiles
},

canCreatePoll() {
return !this.isOneToOne && !this.noChatPermission
&& this.conversation.type !== CONVERSATION.TYPE.NOTE_TO_SELF
&& (!supportFederationV1 || !this.conversation.remoteServer)
},

currentConversationIsJoined() {
Expand Down
16 changes: 14 additions & 2 deletions src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
:main-conversation="mainConversation"
:is-active="activeTab === 'breakout-rooms'" />
</NcAppSidebarTab>
<NcAppSidebarTab v-if="!getUserId || showSIPSettings"
<NcAppSidebarTab v-if="showDetailsTab"
id="details-tab"
:order="4"
:name="t('spreed', 'Details')">
Expand All @@ -87,7 +87,7 @@
</div>
</div>
</NcAppSidebarTab>
<NcAppSidebarTab v-if="getUserId"
<NcAppSidebarTab v-if="showSharedItemsTab"
id="shared-items"
ref="sharedItemsTab"
:order="5"
Expand All @@ -108,6 +108,7 @@ import FolderMultipleImage from 'vue-material-design-icons/FolderMultipleImage.v
import InformationOutline from 'vue-material-design-icons/InformationOutline.vue'
import Message from 'vue-material-design-icons/Message.vue'

import { getCapabilities } from '@nextcloud/capabilities'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'

import NcAppSidebar from '@nextcloud/vue/dist/Components/NcAppSidebar.js'
Expand All @@ -125,6 +126,8 @@ import SetGuestUsername from '../SetGuestUsername.vue'
import { CONVERSATION, WEBINAR, PARTICIPANT } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'

const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1')

export default {
name: 'RightSidebar',
components: {
Expand Down Expand Up @@ -266,13 +269,22 @@ export default {

showBreakoutRoomsTab() {
return this.getUserId && !this.isOneToOne
&& (!supportFederationV1 || !this.conversation.remoteServer)
&& (this.breakoutRoomsConfigured || this.conversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE || this.conversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM)
},

showParticipantsTab() {
return (this.getUserId || this.isModeratorOrUser) && !this.isOneToOne && !this.isNoteToSelf
},

showSharedItemsTab() {
return this.getUserId && (!supportFederationV1 || !this.conversation.remoteServer)
},

showDetailsTab() {
return !this.getUserId || this.showSIPSettings
},

isNoteToSelf() {
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
},
Expand Down
4 changes: 4 additions & 0 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import VideoBoxOff from 'vue-material-design-icons/VideoBoxOff.vue'
import VideoOff from 'vue-material-design-icons/VideoOff.vue'
import VideoOutlineIcon from 'vue-material-design-icons/VideoOutline.vue'

import { getCapabilities } from '@nextcloud/capabilities'
import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
Expand All @@ -119,6 +120,8 @@ import { useSettingsStore } from '../../stores/settings.js'
import { useTalkHashStore } from '../../stores/talkHash.js'
import { blockCalls, unsupportedWarning } from '../../utils/browserCheck.js'

const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1')

export default {
name: 'CallButton',

Expand Down Expand Up @@ -298,6 +301,7 @@ export default {
return this.callEnabled
&& this.conversation.type !== CONVERSATION.TYPE.NOTE_TO_SELF
&& this.conversation.readOnly === CONVERSATION.STATE.READ_WRITE
&& (!supportFederationV1 || !this.conversation.remoteServer)
&& !this.isInCall
},

Expand Down
8 changes: 6 additions & 2 deletions src/services/conversationsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
*/

import axios from '@nextcloud/axios'
import { loadState } from '@nextcloud/initial-state'
import { getCapabilities } from '@nextcloud/capabilities'
import { generateOcsUrl } from '@nextcloud/router'

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']

/**
* Fetches the conversations from the server.
*
Expand Down Expand Up @@ -88,7 +92,7 @@ const searchPossibleConversations = async function({ searchText, token, onlyUser
!onlyUsers ? SHARE.TYPE.GROUP : null,
!onlyUsers ? SHARE.TYPE.CIRCLE : null,
(!onlyUsers && token !== 'new') ? SHARE.TYPE.EMAIL : null,
(!onlyUsers && token !== 'new' && loadState('spreed', 'federation_enabled')) ? SHARE.TYPE.REMOTE : null,
(!onlyUsers && token !== 'new' && canInviteToFederation) ? SHARE.TYPE.REMOTE : null,
].filter(type => type !== null)

return axios.get(generateOcsUrl('core/autocomplete/get'), {
Expand Down
29 changes: 9 additions & 20 deletions src/services/conversationsService.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from '@nextcloud/axios'
import { loadState } from '@nextcloud/initial-state'
import { generateOcsUrl } from '@nextcloud/router'

import { searchPossibleConversations } from './conversationsService.js'
Expand All @@ -9,22 +8,16 @@ jest.mock('@nextcloud/axios', () => ({
get: jest.fn(),
}))

describe('conversationsService', () => {
let loadStateSettings

beforeEach(() => {
loadStateSettings = {
federation_enabled: false,
}

loadState.mockImplementation((app, key) => {
if (app === 'spreed') {
return loadStateSettings[key]
}
return null
})
})
jest.mock('@nextcloud/capabilities', () => ({
getCapabilities: jest.fn(() => ({
spreed: {
features: ['federation-v1'],
config: { federation: { enabled: true, 'outgoing-enabled': true } },
},
}))
}))

describe('conversationsService', () => {
afterEach(() => {
// cleaning up the mess left behind the previous test
jest.clearAllMocks()
Expand Down Expand Up @@ -71,10 +64,6 @@ describe('conversationsService', () => {
})

test('searchPossibleConversations with other share types', () => {
loadStateSettings = {
federation_enabled: true,
}

testSearchPossibleConversations(
'conversation-token',
false,
Expand Down