Merge branch 'master' into disable-cypress-retries

This commit is contained in:
mahula 2023-07-11 16:56:40 +02:00 committed by GitHub
commit 7add9f4a4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 88 additions and 89 deletions

View File

@ -23,7 +23,7 @@ jobs:
prepare:
name: Prepare
if: needs.files-changed.outputs.webapp
if: needs.files-changed.outputs.webapp == 'true'
needs: files-changed
runs-on: ubuntu-latest
steps:
@ -37,7 +37,7 @@ jobs:
build_test_webapp:
name: Docker Build Test - Webapp
if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp
if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true'
needs: [files-changed, prepare]
runs-on: ubuntu-latest
steps:
@ -57,7 +57,7 @@ jobs:
lint_webapp:
name: Lint Webapp
if: needs.files-changed.outputs.webapp
if: needs.files-changed.outputs.webapp == 'true'
needs: files-changed
runs-on: ubuntu-latest
steps:
@ -69,7 +69,7 @@ jobs:
unit_test_webapp:
name: Unit Tests - Webapp
if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp
if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp == 'true'
needs: [files-changed, build_test_webapp]
runs-on: ubuntu-latest
permissions:

View File

@ -92,6 +92,21 @@ describe('Room', () => {
})
})
describe('user id is self', () => {
it('throws error', async () => {
await expect(
mutate({
mutation: createRoomMutation(),
variables: {
userId: 'chatting-user',
},
}),
).resolves.toMatchObject({
errors: [{ message: 'Cannot create a room with self' }],
})
})
})
describe('user id exists', () => {
it('returns the id of the room', async () => {
const result = await mutate({

View File

@ -32,6 +32,9 @@ export default {
const {
user: { id: currentUserId },
} = context
if (userId === currentUserId) {
throw new Error('Cannot create a room with self')
}
const session = context.driver.session()
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
const createRoomCypher = `

View File

@ -2,6 +2,10 @@
When you overtake this deploy and rebrand repo to your network you have to recognize the following changes and doings:
## Version >= 2.7.0 with 'ocelotDockerVersionTag' 2.7.0-470
- You have to rename all `.js` files to `.ts` in `branding/constants`
## Version >= 2.4.0 with 'ocelotDockerVersionTag' 2.4.0-298
- You have to set `SHOW_CONTENT_FILTER_HEADER_MENU` and `SHOW_CONTENT_FILTER_MASONRY_GRID` in `branding/constants/filter.js` originally in main code file `webapp/constants/filter.js` to your preferred value.

View File

@ -3,7 +3,7 @@
<client-only>
<vue-advanced-chat
:theme="theme"
:current-user-id="currentUserId"
:current-user-id="currentUser.id"
:room-id="null"
:template-actions="JSON.stringify(templatesText)"
:menu-actions="JSON.stringify(menuActions)"
@ -28,7 +28,8 @@
<script>
import { roomQuery, createRoom } from '~/graphql/Rooms'
import { messageQuery } from '~/graphql/Messages'
import { messageQuery, createMessageMutation } from '~/graphql/Messages'
import { mapGetters } from 'vuex'
export default {
name: 'Chat',
@ -43,7 +44,6 @@ export default {
},
data() {
return {
currentUserId: '1234',
menuActions: [
/* {
name: 'inviteUser',
@ -131,87 +131,51 @@ export default {
})
}
},
computed: {
...mapGetters({
currentUser: 'auth/user',
}),
},
methods: {
fetchMessages({ room, options = {} }) {
// console.log(room, options)
this.messagesLoaded = false
setTimeout(async () => {
if (options.reset) {
// console.log('reset messages')
this.messages = [] // this.addMessages(true)
} else {
try {
const {
data: { Message },
} = await this.$apollo.query({
query: messageQuery(),
variables: {
roomId: room.id,
},
})
// console.log('Messages', Message)
this.messages = Message
} catch (error) {
// console.log('Error', error)
this.messages = [] // this.addMessages(true)
this.$toast.error(error.message)
}
try {
const {
data: { Message },
} = await this.$apollo.query({
query: messageQuery(),
variables: {
roomId: room.id,
},
fetchPolicy: 'no-cache',
})
this.messages = Message
} catch (error) {
this.messages = []
this.$toast.error(error.message)
}
this.messagesLoaded = true
})
},
/* addMessages(reset) {
const messages = []
for (let i = 0; i < 30; i++) {
messages.push({
_id: reset ? i : this.messages.length + i,
content: `${reset ? '' : 'paginated'} message ${i + 1}`,
senderId: '4321',
username: 'John Doe',
date: '13 November',
timestamp: '10:20',
})
}
messages.push({
_id: '31',
content: `Hallo Welt`,
senderId: '1234',
username: 'John Doe',
date: '13 November',
timestamp: '10:20',
})
return messages
}, */
sendMessage(message) {
this.messages = [
...this.messages,
{
_id: this.messages.length,
content: message.content,
senderId: this.currentUserId,
timestamp: new Date().toString().substring(16, 21),
date: new Date().toDateString(),
},
]
refetchMessage(roomId) {
this.fetchMessages({ room: this.rooms.find((r) => r.roomId === roomId) })
},
addNewMessage() {
setTimeout(() => {
this.messages = [
...this.messages,
{
_id: this.messages.length,
content: 'NEW MESSAGE',
senderId: '1234',
timestamp: new Date().toString().substring(16, 21),
date: new Date().toDateString(),
async sendMessage(message) {
try {
await this.$apollo.mutate({
mutation: createMessageMutation(),
variables: {
roomId: message.roomId,
content: message.content,
},
]
}, 2000)
})
} catch (error) {
this.$toast.error(error.message)
}
this.refetchMessage(message.roomId)
},
},
apollo: {
@ -220,7 +184,6 @@ export default {
return roomQuery()
},
update({ Room }) {
// console.log('Rooms', Room)
if (!Room) {
this.rooms = []
return
@ -240,14 +203,12 @@ export default {
}).filter((r) =>
this.singleRoom ? r.users.filter((u) => u.id === this.singleRoomId).length > 0 : true,
)
// console.log(this.rooms)
},
error(error) {
this.rooms = []
this.$toast.error(error.message)
},
fetchPolicy: 'cache-and-network',
fetchPolicy: 'no-cache',
},
},
}

View File

@ -4,7 +4,9 @@ export const messageQuery = () => {
return gql`
query ($roomId: ID!) {
Message(roomId: $roomId) {
_id
id
senderId
content
author {
id
@ -13,3 +15,14 @@ export const messageQuery = () => {
}
`
}
export const createMessageMutation = () => {
return gql`
mutation ($roomId: ID!, $content: String!) {
CreateMessage(roomId: $roomId, content: $content) {
id
content
}
}
`
}

View File

@ -37,7 +37,7 @@ describe('default.vue', () => {
getters: {
'auth/isLoggedIn': () => true,
'chat/showChat': () => {
return { showChat: false, roomID: 'u0' }
return { showChat: false, roomID: null }
},
},
})

View File

@ -16,7 +16,7 @@
<div v-if="$store.getters['chat/showChat'].showChat" class="chat-modul">
<ds-text align="right" class="close">
RoomID: {{ $store.getters['chat/showChat'].roomID }}
<ds-button @click="$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: 'u0' })">
<ds-button @click="$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: null })">
x
</ds-button>
</ds-text>
@ -41,6 +41,9 @@ export default {
ChatModule,
},
mixins: [seo, mobile()],
beforeCreate() {
this.$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: null })
},
}
</script>

View File

@ -580,7 +580,7 @@
"moreInfo": "Was ist {APPLICATION_NAME}?",
"moreInfoHint": "zur Präsentationsseite",
"no-account": "Du hast noch kein Nutzerkonto?",
"no-cookie": "Es kann kein Cookie angelegt werden. Du must Cookies akzeptieren.",
"no-cookie": "Es kann kein Cookie angelegt werden. Du musst Cookies akzeptieren.",
"password": "Dein Passwort",
"register": "Nutzerkonto erstellen",
"success": "Du bist eingeloggt!"
@ -759,9 +759,9 @@
"viewEvent": {
"eventEnd": "Ende",
"eventIsOnline": "Online",
"eventLocationName": "Stadt",
"eventLocationName": "Stadt - z.B. Musterstraße 1, 12345 Musterstadt",
"eventStart": "Beginn",
"eventVenue": "Veranstaltungsort",
"eventVenue": "Veranstaltungsort - z.B. Hinterhof, 1. OG, ...",
"title": "Veranstaltung"
},
"viewPost": {

View File

@ -759,9 +759,9 @@
"viewEvent": {
"eventEnd": "End",
"eventIsOnline": "Online",
"eventLocationName": "City",
"eventLocationName": "City - e.g. Example street 1, 12345 City",
"eventStart": "Start",
"eventVenue": "Venue",
"eventVenue": "Venue - e.g. Backyard, 1st Floor, ...",
"title": "Event"
},
"viewPost": {

View File

@ -1,14 +1,14 @@
export const state = () => {
return {
showChat: false,
roomID: 'u0',
roomID: null,
}
}
export const mutations = {
SET_OPEN_CHAT(state, ctx) {
state.showChat = ctx.showChat || false
state.roomID = ctx.roomID || 'u0'
state.roomID = ctx.roomID || null
},
}