diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FilesSidebarCallViewApp.vue | 56 | ||||
-rw-r--r-- | src/mainFilesSidebar.js | 11 | ||||
-rw-r--r-- | src/mainFilesSidebarLoader.js | 2 | ||||
-rw-r--r-- | src/views/FilesSidebarCallView.js | 54 |
4 files changed, 121 insertions, 2 deletions
diff --git a/src/FilesSidebarCallViewApp.vue b/src/FilesSidebarCallViewApp.vue new file mode 100644 index 000000000..f172245b9 --- /dev/null +++ b/src/FilesSidebarCallViewApp.vue @@ -0,0 +1,56 @@ +<!-- + - @copyright Copyright (c) 2019, Daniel Calviño Sánchez <danxuliu@gmail.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> + <p v-show="isInCall"> + Call in progress + </p> +</template> + +<script> +import { PARTICIPANT } from './constants' + +export default { + + name: 'FilesSidebarCallViewApp', + + computed: { + token() { + return this.$store.getters.getToken() + }, + + isInCall() { + const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier()) + if (participantIndex === -1) { + return false + } + + const participant = this.$store.getters.getParticipant(this.token, participantIndex) + + return participant.inCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED + }, + }, + + methods: { + setFileInfo(fileInfo) { + }, + }, +} +</script> diff --git a/src/mainFilesSidebar.js b/src/mainFilesSidebar.js index 6ac645fd9..b2e94d141 100644 --- a/src/mainFilesSidebar.js +++ b/src/mainFilesSidebar.js @@ -23,7 +23,8 @@ */ import Vue from 'vue' -import App from './FilesSidebarTabApp' +import FilesSidebarCallViewApp from './FilesSidebarCallViewApp' +import FilesSidebarTabApp from './FilesSidebarTabApp' // Store import Vuex from 'vuex' @@ -56,9 +57,14 @@ Vue.prototype.OCA = OCA Vue.use(Vuex) Vue.use(vuescroll, { debounce: 600 }) +const newCallView = () => new Vue({ + store, + render: h => h(FilesSidebarCallViewApp), +}) + const newTab = () => new Vue({ store, - render: h => h(App), + render: h => h(FilesSidebarTabApp), }) if (!window.OCA.Talk) { @@ -66,6 +72,7 @@ if (!window.OCA.Talk) { } Object.assign(window.OCA.Talk, { fileInfo: null, + newCallView, newTab, store: store, }) diff --git a/src/mainFilesSidebarLoader.js b/src/mainFilesSidebarLoader.js index d5500fa63..d2ab43e6c 100644 --- a/src/mainFilesSidebarLoader.js +++ b/src/mainFilesSidebarLoader.js @@ -20,6 +20,7 @@ * */ +import FilesSidebarCallView from './views/FilesSidebarCallView' import FilesSidebarTab from './views/FilesSidebarTab' import { leaveConversation } from './services/participantsService' @@ -43,6 +44,7 @@ const isEnabled = function(fileInfo) { window.addEventListener('DOMContentLoaded', () => { if (OCA.Files && OCA.Files.Sidebar) { + OCA.Files.Sidebar.registerSecondaryView(new FilesSidebarCallView()) OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab('talk-chat', FilesSidebarTab, isEnabled)) } }) diff --git a/src/views/FilesSidebarCallView.js b/src/views/FilesSidebarCallView.js new file mode 100644 index 000000000..31c0eb08a --- /dev/null +++ b/src/views/FilesSidebarCallView.js @@ -0,0 +1,54 @@ +/** + * + * @copyright Copyright (c) 2019, Daniel Calviño Sánchez <danxuliu@gmail.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/>. + * + */ + +/** + * Helper class to wrap a Vue instance with a FilesSidebarCallViewApp component + * to be used as a secondary view in the Files sidebar. + * + * Although Vue instances/components can be added as tabs to the Files sidebar + * currently only legacy views can be added as secondary views to the Files + * sidebar. Those legacy views are expected to provide a root element, $el, with + * a "replaceAll" method that replaces the given element with the $el element, + * and a "setFileInfo" method that is called when the sidebar is opened or the + * current file changes. + */ +export default class FilesSidebarCallView { + + constructor() { + this.callViewInstance = OCA.Talk.newCallView() + + this.$el = document.createElement('div') + + this.callViewInstance.$mount(this.$el) + this.$el = this.callViewInstance.$el + + this.$el.replaceAll = function(target) { + target.replaceWith(this.$el) + }.bind(this) + } + + setFileInfo(fileInfo) { + // The FilesSidebarCallViewApp is the first (and only) child of the Vue + // instance. + this.callViewInstance.$children[0].setFileInfo(fileInfo) + } + +} |