Skip to content

Commit

Permalink
Merge pull request #7076 from nextcloud/feature/1577/conversation-sha…
Browse files Browse the repository at this point in the history
…red-items

🗃️ Shared Items tab
  • Loading branch information
nickvergessen authored Apr 13, 2022
2 parents a0b7605 + a776228 commit a36cd1d
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 25 deletions.
1 change: 1 addition & 0 deletions css/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@include icon-black-white('text', 'filetypes', 1, true);
@include icon-black-white('promoted-view', 'spreed', 1);
@include icon-black-white('grid-view', 'spreed', 1);
@include icon-black-white('folder-multiple-image', 'spreed', 1);

.app-talk,
.talk-modal,
Expand Down
3 changes: 3 additions & 0 deletions img/folder-multiple-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ public function getObjectsSharedInRoomOverview(int $limit = 7): DataResponse {
$attachments = $this->attachmentService->getAttachmentsByType($this->room, $objectType, 0, $limit);
$messageIdsByType[$objectType] = array_map(static fn (Attachment $attachment): int => $attachment->getMessageId(), $attachments);
}
$comments = $this->chatManager->getMessagesById($this->room, array_merge(...$messageIdsByType));
$comments = $this->chatManager->getMessagesById($this->room, array_merge(...array_values($messageIdsByType)));

foreach ($comments as $comment) {
$message = $this->messageParser->createMessage($this->room, $this->participant, $comment, $this->l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
<file-preview v-bind="filePreview"
:tabindex="wrapperTabIndex"
class="file-preview"
:class="{ 'file-preview--viewer-available': isViewerAvailable, 'file-preview--upload-editor': isUploadEditor }"
:class="{ 'file-preview--viewer-available': isViewerAvailable,
'file-preview--upload-editor': isUploadEditor,
'file-preview--shared-items-grid': isSharedItemsTab && !rowLayout,
'file-preview--row-layout': rowLayout }"
@click.exact="handleClick"
@keydown.enter="handleClick">
<div v-if="!isLoading"
Expand Down Expand Up @@ -63,8 +66,8 @@
</template>
</Button>
<ProgressBar v-if="isTemporaryUpload && !isUploadEditor" :value="uploadProgress" />
<div class="name-container">
<strong v-if="shouldShowFileDetail">{{ fileDetail }}</strong>
<div v-if="shouldShowFileDetail" class="name-container">
{{ fileDetail }}
</div>
</file-preview>
</template>
Expand Down Expand Up @@ -203,6 +206,16 @@ export default {
type: Boolean,
default: false,
},
rowLayout: {
type: Boolean,
default: false,
},
isSharedItemsTab: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand All @@ -212,6 +225,9 @@ export default {
},
computed: {
shouldShowFileDetail() {
if (this.isSharedItemsTab && !this.rowLayout) {
return false
}
// display the file detail below the preview if the preview
// is not easily recognizable, when:
return (
Expand Down Expand Up @@ -473,6 +489,7 @@ export default {
.file-preview {
position: relative;
min-width: 0;
width: 100%;
/* The file preview can not be a block; otherwise it would fill the whole
width of the container and the loading icon would not be centered on the
Expand Down Expand Up @@ -522,8 +539,8 @@ export default {
}
.image-container {
display: inline-block;
position: relative;
display: flex;
height: 100%;
&.playable {
.preview {
Expand Down Expand Up @@ -554,19 +571,11 @@ export default {
}
.name-container {
/* Ellipsis with 100% width */
display: table;
table-layout: fixed;
font-weight: bold;
width: 100%;
strong {
/* As the file preview is an inline block the name is set as a block to
force it to be on its own line below the preview. */
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&:not(.file-preview--viewer-available) {
Expand All @@ -589,6 +598,29 @@ export default {
width: 100%;
}
}
&--row-layout {
display: flex;
align-items: center;
height: 36px;
border-radius: var(--border-radius);
padding: 2px 4px;
.image-container {
height: 100%;
}
.name-container {
padding: 0 4px;
}
}
&--shared-items-grid {
aspect-ratio: 1;
.preview {
width: 100%;
}
}
}
.remove-file {
Expand Down
26 changes: 19 additions & 7 deletions src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
:title="title"
:title-tooltip="title"
:starred="isFavorited"
:active="activeTab"
:title-editable="canModerate && isRenamingConversation"
:class="'active-tab-' + activeTab"
@update:active="handleUpdateActive"
Expand Down Expand Up @@ -55,18 +56,15 @@
:can-search="canSearchParticipants"
:can-add="canAddParticipants" />
</AppSidebarTab>
<AppSidebarTab id="details-tab"
<AppSidebarTab v-if="!getUserId || showSIPSettings"
id="details-tab"
:order="3"
:name="t('spreed', 'Details')"
icon="icon-details">
<SetGuestUsername v-if="!getUserId" />
<SipSettings v-if="showSIPSettings"
:meeting-id="conversation.token"
:attendee-pin="conversation.attendeePin" />
<CollectionList v-if="getUserId && conversation.token"
:id="conversation.token"
type="room"
:name="conversation.displayName" />
<div v-if="!getUserId" id="app-settings">
<div id="app-settings-header">
<Button type="tertiary" @click="showSettings">
Expand All @@ -80,15 +78,23 @@
</div>
</div>
</AppSidebarTab>
<AppSidebarTab v-if="getUserId"
id="shared-items"
ref="sharedItemsTab"
:order="4"
icon="icon-folder-multiple-image"
:name="t('spreed', 'Shared items')">
<SharedItemsTab :active="activeTab === 'shared-items'" />
</AppSidebarTab>
</AppSidebar>
</template>

<script>
import { emit } from '@nextcloud/event-bus'
import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar'
import AppSidebarTab from '@nextcloud/vue/dist/Components/AppSidebarTab'
import SharedItemsTab from './SharedItems/SharedItemsTab'
import ChatView from '../ChatView'
import { CollectionList } from 'nextcloud-vue-collections'
import BrowserStorage from '../../services/BrowserStorage'
import { CONVERSATION, WEBINAR, PARTICIPANT } from '../../constants'
import ParticipantsTab from './Participants/ParticipantsTab'
Expand All @@ -104,8 +110,8 @@ export default {
components: {
AppSidebar,
AppSidebarTab,
SharedItemsTab,
ChatView,
CollectionList,
ParticipantsTab,
SetGuestUsername,
SipSettings,
Expand Down Expand Up @@ -226,6 +232,12 @@ export default {
if (!this.isRenamingConversation) {
this.conversationName = this.conversation.displayName
}
if (this.isOneToOne) {
this.activeTab = 'shared-items'
} else {
this.activeTab = 'participants'
}
},
token() {
Expand Down
169 changes: 169 additions & 0 deletions src/components/RightSidebar/SharedItems/SharedItems.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<!--
- @copyright Copyright (c) 2022 Marco Ambrosini <[email protected]>
-
- @author Marco Ambrosini <[email protected]>
-
- @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>
<div class="shared-items">
<AppNavigationCaption :title="title" />
<div class="files" :class="{'files__list' : isList}">
<template v-for="file in filesToDisplay">
<FilePreview :key="file.id"
:small-preview="isList"
:row-layout="isList"
:is-shared-items-tab="true"
v-bind="file.messageParameters.file" />
</template>
</div>
<Button v-if="hasMore"
type="tertiary"
class="shared-items__more"
:wide="true"
@click="handleCaptionClick">
<template #icon>
<DotsHorizontal :size="20"
decorative
title="" />
</template>
{{ buttonTitle }}
</Button>
</div>
</template>

<script>
import Button from '@nextcloud/vue/dist/Components/Button'
import FilePreview from '../../MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue'
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
import AppNavigationCaption from '@nextcloud/vue/dist/Components/AppNavigationCaption'
import { showMessage } from '@nextcloud/dialogs'
export default {
name: 'SharedItems',
components: {
Button,
FilePreview,
DotsHorizontal,
AppNavigationCaption,
},
props: {
type: {
type: String,
required: true,
},
items: {
type: Object,
required: true,
},
},
computed: {
filesToDisplay() {
return Object.values(this.items).reverse().slice(0, 6)
},
title() {
switch (this.type) {
case 'media':
return t('spreed', 'Media')
case 'file':
return t('spreed', 'Files')
case 'deck-card':
return t('spreed', 'Deck cards')
case 'voice':
return t('spreed', 'Voice messages')
case 'location':
return t('spreed', 'Locations')
case 'audio':
return t('spreed', 'Audio')
case 'other':
return t('spreed', 'Other')
default:
return ''
}
},
buttonTitle() {
switch (this.type) {
case 'media':
return t('spreed', 'Show all media')
case 'file':
return t('spreed', 'Show all files')
case 'deck-card':
return t('spreed', 'Show all deck cards')
case 'voice':
return t('spreed', 'Show all voice messages')
case 'location':
return t('spreed', 'Show all locations')
case 'audio':
return t('spreed', 'Show all audio')
case 'other':
return t('spreed', 'Show all other')
default:
return ''
}
},
isList() {
switch (this.type) {
case 'media':
return false
case 'locations':
return false
default:
return true
}
},
hasMore() {
return Object.values(this.items).length > 6
},
},
methods: {
handleCaptionClick() {
showMessage('Screenshot feature only. Implementation of the real feature will come soon! 😎')
console.debug('Show more')
},
},
}
</script>

<style lang="scss" scoped>
.files {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 4px;
&__list {
display: flex;
flex-direction: column;
}
}
.shared-items {
margin-bottom: 16px;
&__more {
margin-top: 8px;
}
}
</style>
Loading

0 comments on commit a36cd1d

Please sign in to comment.