From dc0b3065ed30c8f7957a67ad700ef2652221d056 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 Sep 2023 12:25:29 +0200 Subject: [PATCH 1/7] remove sharedItems.js mixin Signed-off-by: Maksim Sukharev --- .../SharedItemsBrowser.vue | 15 +++-- .../SharedItems/SharedItemsTab.vue | 55 ++++++----------- .../SharedItems/sharedItemsConstants.js | 39 ++++++++++++ src/mixins/sharedItems.js | 59 ------------------- 4 files changed, 68 insertions(+), 100 deletions(-) rename src/components/RightSidebar/SharedItems/{SharedItemsBrowser => }/SharedItemsBrowser.vue (93%) create mode 100644 src/components/RightSidebar/SharedItems/sharedItemsConstants.js delete mode 100644 src/mixins/sharedItems.js diff --git a/src/components/RightSidebar/SharedItems/SharedItemsBrowser/SharedItemsBrowser.vue b/src/components/RightSidebar/SharedItems/SharedItemsBrowser.vue similarity index 93% rename from src/components/RightSidebar/SharedItems/SharedItemsBrowser/SharedItemsBrowser.vue rename to src/components/RightSidebar/SharedItems/SharedItemsBrowser.vue index bbdaa7faad..774bc3a342 100644 --- a/src/components/RightSidebar/SharedItems/SharedItemsBrowser/SharedItemsBrowser.vue +++ b/src/components/RightSidebar/SharedItems/SharedItemsBrowser.vue @@ -29,7 +29,7 @@ :class="{'active' : activeTab === type}" type="tertiary" @click="handleTabClick(type)"> - {{ getTitle(type) }} + {{ sharedItemTitle[type] || sharedItemTitle.default }} @@ -47,9 +47,9 @@ import debounce from 'debounce' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import NcModal from '@nextcloud/vue/dist/Components/NcModal.js' -import SharedItems from '../SharedItems.vue' +import SharedItems from './SharedItems.vue' -import sharedItems from '../../../../mixins/sharedItems.js' +import { sharedItemsOrder, sharedItemTitle } from './sharedItemsConstants.js' export default { name: 'SharedItemsBrowser', @@ -60,8 +60,6 @@ export default { SharedItems, }, - mixins: [sharedItems], - props: { sharedItems: { type: Object, @@ -76,6 +74,13 @@ export default { emits: ['update:active-tab'], + setup() { + return { + sharedItemTitle, + sharedItemsOrder, + } + }, + data() { return { firstItemsLoaded: {}, diff --git a/src/components/RightSidebar/SharedItems/SharedItemsTab.vue b/src/components/RightSidebar/SharedItems/SharedItemsTab.vue index 1221863cec..660c8bbeec 100644 --- a/src/components/RightSidebar/SharedItems/SharedItemsTab.vue +++ b/src/components/RightSidebar/SharedItems/SharedItemsTab.vue @@ -23,7 +23,7 @@
@@ -78,10 +78,14 @@ import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' import NcRelatedResourcesPanel from '@nextcloud/vue/dist/Components/NcRelatedResourcesPanel.js' import SharedItems from './SharedItems.vue' -import SharedItemsBrowser from './SharedItemsBrowser/SharedItemsBrowser.vue' +import SharedItemsBrowser from './SharedItemsBrowser.vue' -import { SHARED_ITEM } from '../../../constants.js' -import sharedItems from '../../../mixins/sharedItems.js' +import { + sharedItemButtonTitle, + sharedItemsOrder, + sharedItemsWithPreviewLimit, + sharedItemTitle, +} from './sharedItemsConstants.js' export default { @@ -99,8 +103,6 @@ export default { FolderMultipleImage, }, - mixins: [sharedItems], - props: { active: { @@ -109,6 +111,15 @@ export default { }, }, + setup() { + return { + sharedItemButtonTitle, + sharedItemTitle, + sharedItemsOrder, + sharedItemsWithPreviewLimit, + } + }, + data() { return { showSharedItemsBrowser: false, @@ -167,35 +178,7 @@ export default { }, limit(type) { - if (type === SHARED_ITEM.TYPES.DECK_CARD || type === SHARED_ITEM.TYPES.LOCATION || type === SHARED_ITEM.TYPES.POLL) { - return 2 - } else { - return 6 - } - }, - - getButtonTitle(type) { - switch (type) { - case SHARED_ITEM.TYPES.MEDIA: - return t('spreed', 'Show all media') - case SHARED_ITEM.TYPES.FILE: - return t('spreed', 'Show all files') - case SHARED_ITEM.TYPES.POLL: - return t('spreed', 'Show all polls') - case SHARED_ITEM.TYPES.DECK_CARD: - return t('spreed', 'Show all deck cards') - case SHARED_ITEM.TYPES.VOICE: - return t('spreed', 'Show all voice messages') - case SHARED_ITEM.TYPES.LOCATION: - return t('spreed', 'Show all locations') - case SHARED_ITEM.TYPES.AUDIO: - return t('spreed', 'Show all audio') - case SHARED_ITEM.TYPES.RECORDING: - return t('spreed', 'Show all call recordings') - case SHARED_ITEM.TYPES.OTHER: - default: - return t('spreed', 'Show all other') - } + return this.sharedItemsWithPreviewLimit.includes(type) ? 2 : 6 }, }, } diff --git a/src/components/RightSidebar/SharedItems/sharedItemsConstants.js b/src/components/RightSidebar/SharedItems/sharedItemsConstants.js new file mode 100644 index 0000000000..c2dce06dbe --- /dev/null +++ b/src/components/RightSidebar/SharedItems/sharedItemsConstants.js @@ -0,0 +1,39 @@ +import { SHARED_ITEM } from '../../../constants.js' + +export const sharedItemsOrder = [SHARED_ITEM.TYPES.MEDIA, + SHARED_ITEM.TYPES.FILE, + SHARED_ITEM.TYPES.RECORDING, + SHARED_ITEM.TYPES.POLL, + SHARED_ITEM.TYPES.VOICE, + SHARED_ITEM.TYPES.AUDIO, + SHARED_ITEM.TYPES.LOCATION, + SHARED_ITEM.TYPES.DECK_CARD, + SHARED_ITEM.TYPES.OTHER] + +export const sharedItemsWithPreviewLimit = [SHARED_ITEM.TYPES.DECK_CARD, SHARED_ITEM.TYPES.LOCATION, SHARED_ITEM.TYPES.POLL] + +export const sharedItemTitle = { + [SHARED_ITEM.TYPES.MEDIA]: t('spreed', 'Media'), + [SHARED_ITEM.TYPES.FILE]: t('spreed', 'Files'), + [SHARED_ITEM.TYPES.POLL]: t('spreed', 'Polls'), + [SHARED_ITEM.TYPES.DECK_CARD]: t('spreed', 'Deck cards'), + [SHARED_ITEM.TYPES.VOICE]: t('spreed', 'Voice messages'), + [SHARED_ITEM.TYPES.LOCATION]: t('spreed', 'Locations'), + [SHARED_ITEM.TYPES.RECORDING]: t('spreed', 'Call recordings'), + [SHARED_ITEM.TYPES.AUDIO]: t('spreed', 'Audio'), + [SHARED_ITEM.TYPES.OTHER]: t('spreed', 'Other'), + default: t('spreed', 'Other'), +} + +export const sharedItemButtonTitle = { + [SHARED_ITEM.TYPES.MEDIA]: t('spreed', 'Show all media'), + [SHARED_ITEM.TYPES.FILE]: t('spreed', 'Show all files'), + [SHARED_ITEM.TYPES.POLL]: t('spreed', 'Show all polls'), + [SHARED_ITEM.TYPES.DECK_CARD]: t('spreed', 'Show all deck cards'), + [SHARED_ITEM.TYPES.VOICE]: t('spreed', 'Show all voice messages'), + [SHARED_ITEM.TYPES.LOCATION]: t('spreed', 'Show all locations'), + [SHARED_ITEM.TYPES.RECORDING]: t('spreed', 'Show all call recordings'), + [SHARED_ITEM.TYPES.AUDIO]: t('spreed', 'Show all audio'), + [SHARED_ITEM.TYPES.OTHER]: t('spreed', 'Show all other'), + default: t('spreed', 'Show all other'), +} diff --git a/src/mixins/sharedItems.js b/src/mixins/sharedItems.js deleted file mode 100644 index 0cd037b5cf..0000000000 --- a/src/mixins/sharedItems.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @copyright Copyright (c) 2022 Marco Ambrosini - * - * @author Marco Ambrosini - * - * @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 . - * - */ - -import { SHARED_ITEM } from '../constants.js' - -const sharedItems = { - computed: { - // Defines the order of the sections - sharedItemsOrder() { - return [SHARED_ITEM.TYPES.MEDIA, SHARED_ITEM.TYPES.FILE, SHARED_ITEM.TYPES.RECORDING, SHARED_ITEM.TYPES.POLL, SHARED_ITEM.TYPES.VOICE, SHARED_ITEM.TYPES.AUDIO, SHARED_ITEM.TYPES.LOCATION, SHARED_ITEM.TYPES.DECK_CARD, SHARED_ITEM.TYPES.OTHER] - }, - }, - - methods: { - getTitle(type) { - switch (type) { - case SHARED_ITEM.TYPES.MEDIA: - return t('spreed', 'Media') - case SHARED_ITEM.TYPES.FILE: - return t('spreed', 'Files') - case SHARED_ITEM.TYPES.POLL: - return t('spreed', 'Polls') - case SHARED_ITEM.TYPES.DECK_CARD: - return t('spreed', 'Deck cards') - case SHARED_ITEM.TYPES.VOICE: - return t('spreed', 'Voice messages') - case SHARED_ITEM.TYPES.LOCATION: - return t('spreed', 'Locations') - case SHARED_ITEM.TYPES.RECORDING: - return t('spreed', 'Call recordings') - case SHARED_ITEM.TYPES.AUDIO: - return t('spreed', 'Audio') - default: - return t('spreed', 'Other') - } - }, - }, -} - -export default sharedItems From a6b8b0790281e37ca88fcc07f3207ed6c9f440e6 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Tue, 19 Sep 2023 12:47:34 +0200 Subject: [PATCH 2/7] refactor SharedItems.vue component Signed-off-by: Maksim Sukharev --- .../Message/MessagePart/DeckCard.vue | 1 + .../RightSidebar/SharedItems/SharedItems.vue | 121 +++++++++--------- .../SharedItems/SharedItemsBrowser.vue | 10 +- .../SharedItems/SharedItemsTab.vue | 3 + 4 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/DeckCard.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/DeckCard.vue index 2d889f0064..ac0c81bc2b 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/DeckCard.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/DeckCard.vue @@ -141,6 +141,7 @@ export default { .wide { max-width: 400px; + width: 100%; margin: 4px auto; } diff --git a/src/components/RightSidebar/SharedItems/SharedItems.vue b/src/components/RightSidebar/SharedItems/SharedItems.vue index 23e752a722..9e62462584 100644 --- a/src/components/RightSidebar/SharedItems/SharedItems.vue +++ b/src/components/RightSidebar/SharedItems/SharedItems.vue @@ -20,47 +20,40 @@ -->
+
- - - @license GNU AGPL version 3 or any later version + - @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 @@ -21,6 +21,7 @@