Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(OpenConversationsList): expose description #12243

Merged
merged 3 commits into from
May 4, 2024
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
1 change: 1 addition & 0 deletions lib/Service/RoomFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function formatRoomV4(
return array_merge($roomData, [
'name' => $room->getName(),
'displayName' => $room->getDisplayName($isListingBreakoutRooms || $isSIPBridgeRequest || $this->userId === null ? '' : $this->userId, $isListingBreakoutRooms || $isSIPBridgeRequest),
'description' => $room->getListable() !== Room::LISTABLE_NONE ? $room->getDescription() : '',
'objectType' => $room->getObjectType(),
'objectId' => $room->getObjectId(),
'readOnly' => $room->getReadOnly(),
Expand Down
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,10 @@ export default {
body .modal-wrapper * {
box-sizing: border-box;
}

.modal-wrapper h2 {
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
margin-top: 0;
}
</style>

<style lang="scss" scoped>
Expand Down
4 changes: 0 additions & 4 deletions src/components/BreakoutRoomsEditor/BreakoutRoomsEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ export default {
justify-content: flex-start;
align-items: flex-start;

h2 {
margin-top: 0;
}

&__number-input{
display: block;
margin-bottom: calc(var(--default-grid-baseline)*4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('Conversation.vue', () => {

test('displays nothing when there is no last chat message', () => {
item.lastMessage = {}
testConversationLabel(item, '')
testConversationLabel(item, 'No messages')
})

describe('author name', () => {
Expand Down Expand Up @@ -191,10 +191,11 @@ describe('Conversation.vue', () => {
testConversationLabel(item, 'Guest: hello')
})

test('displays last message for search results', () => {
test('displays description for search results', () => {
// search results have no actor id
item.actorId = null
testConversationLabel(item, 'Alice: hello', true)
item.description = 'This is a description'
testConversationLabel(item, 'This is a description', true)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</template>

<script>
import { inject, toRefs } from 'vue'
import { inject, toRefs, ref } from 'vue'

import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'

Expand All @@ -39,10 +39,6 @@ export default {
},

props: {
exposeMessages: {
type: Boolean,
default: false,
},
item: {
type: Object,
default() {
Expand All @@ -66,9 +62,10 @@ export default {
emits: ['click'],

setup(props) {
const { item, exposeMessages } = toRefs(props)
const { item } = toRefs(props)
const selectedRoom = inject('selectedRoom', null)
const { counterType, conversationInformation } = useConversationInfo({ item, exposeMessages })
const exposeDescriptionRef = inject('exposeDescription', ref(false))
const { counterType, conversationInformation } = useConversationInfo({ item, exposeDescriptionRef })

return {
selectedRoom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:item-size="CONVERSATION_ITEM_SIZE"
key-field="token">
<template #default="{ item }">
<ConversationSearchResult :item="item" :expose-messages="exposeMessages" @click="onClick" />
<ConversationSearchResult :item="item" @click="onClick" />
</template>
<template #after>
<LoadingPlaceholder v-if="loading" type="conversations" />
Expand Down Expand Up @@ -42,10 +42,7 @@ export default {
type: Array,
required: true,
},
exposeMessages: {
type: Boolean,
default: false,
},

loading: {
type: Boolean,
default: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</template>

<script>
import { provide, ref } from 'vue'

import RoomSelector from '../../RoomSelector.vue'

Expand All @@ -25,6 +26,10 @@ export default {
RoomSelector,
},

setup() {
provide('exposeDescription', ref(true))
},

data() {
return {
modal: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,6 @@ export default {
&__editor {
height: 100%;
padding: 20px;

h2 {
margin-top: 0;
}
}
}

Expand Down
21 changes: 14 additions & 7 deletions src/composables/useConversationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ import { ATTENDEE, CONVERSATION } from '../constants.js'
* @param {object} payload function payload
* @param {import('vue').Ref} payload.item conversation item
* @param {import('vue').Ref} [payload.isSearchResult] whether conversation item appears as search result
* @param {import('vue').Ref} [payload.exposeMessages] whether to show messages in conversation item
* @param {import('vue').Ref} [payload.exposeMessagesRef] whether to show messages in conversation item
* @param {import('vue').Ref} [payload.exposeDescriptionRef] whether to show description in conversation item
*/
export function useConversationInfo({
item,
isSearchResult = ref(null),
exposeMessages = ref(null),
exposeMessagesRef = ref(null),
exposeDescriptionRef = ref(null),
}) {
const exposeMessages = exposeMessagesRef.value !== null ? exposeMessagesRef.value : !isSearchResult.value
const exposeDescription = exposeDescriptionRef.value !== null ? exposeDescriptionRef.value : isSearchResult.value

const counterType = computed(() => {
if (exposeMessages.value === false) {
if (!exposeMessages) {
return ''
} else if (item.value.unreadMentionDirect || (item.value.unreadMessages !== 0
&& [CONVERSATION.TYPE.ONE_TO_ONE, CONVERSATION.TYPE.ONE_TO_ONE_FORMER].includes(item.value.type)
Expand All @@ -43,7 +48,7 @@ export function useConversationInfo({
* e.g. no avatars on mentions.
*/
const simpleLastChatMessage = computed(() => {
if (exposeMessages.value === false || !hasLastMessage.value) {
if (!exposeMessages || !hasLastMessage.value) {
return ''
}

Expand All @@ -62,7 +67,7 @@ export function useConversationInfo({
* @return {string} Part of the name until the first space
*/
const shortLastChatMessageAuthor = computed(() => {
if (exposeMessages.value === false || !hasLastMessage.value || item.value.lastMessage.systemMessage.length) {
if (!exposeMessages || !hasLastMessage.value || item.value.lastMessage.systemMessage.length) {
return ''
}

Expand All @@ -81,8 +86,10 @@ export function useConversationInfo({
return t('spreed', 'Joining conversation …')
}

if (exposeMessages.value === false || !hasLastMessage.value) {
return ''
if (!exposeMessages) {
return exposeDescription ? item.value?.description : ''
} else if (!hasLastMessage.value) {
return t('spreed', 'No messages')
}

if (shortLastChatMessageAuthor.value === '') {
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/features/conversation-2/find-listed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ Feature: conversation/find-listed
And user "creator" creates room "public-room" (v4)
| roomType | 3 |
| roomName | public-room |
And user "creator" sets description for room "group-room" to "the group-room description" with 200 (v4)
And user "creator" sets description for room "public-room" to "the public-room description" with 200 (v4)
When user "creator" allows listing room "group-room" for "users" with 200 (v4)
And user "creator" allows listing room "public-room" for "users" with 200 (v4)
Then user "regular-user" can find listed rooms (v4)
| name | listable |
| group-room | 1 |
| public-room | 1 |
| name | listable | description |
| group-room | 1 | the group-room description |
| public-room | 1 | the public-room description |
And user "user-guest@example.com" cannot find any listed rooms (v4)

Scenario: All users can find all-listed rooms
Expand Down
Loading