From c4fae48b1d9f094fc4c4f75c702fd1e91c5ae4c4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 8 Feb 2023 09:44:21 +0100 Subject: [PATCH 01/12] toast by automatically logged out --- frontend/src/components/SessionLogoutTimeout.vue | 2 ++ frontend/src/mixins/toaster.js | 11 ++++++++++- frontend/src/pages/Login.vue | 6 ++++++ frontend/src/store/store.js | 5 +++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index 1ebff752a..7a7cdfc5e 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -67,6 +67,7 @@ export default { } if (this.tokenExpiresInSeconds === 0) { this.$timer.stop('tokenExpires') + this.$store.commit('automaticallyLoggedOut', true) this.$emit('logout') } }, @@ -84,6 +85,7 @@ export default { }) .catch(() => { this.$timer.stop('tokenExpires') + this.$store.commit('automaticallyLoggedOut', true) this.$emit('logout') }) }, diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 175ffeec0..109bf0d9a 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -4,24 +4,33 @@ export const toasters = { this.toast(message, { title: this.$t('success'), variant: 'success', + autoHideDelay: 5000, }) }, toastError(message) { this.toast(message, { title: this.$t('error.error'), variant: 'danger', + autoHideDelay: 5000, }) }, toastInfo(message) { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', + autoHideDelay: 5000, + }) + }, + toastInfoNoHide(message) { + this.toast(message, { + title: this.$t('navigation.info'), + variant: 'warning', + noAutoHide: true, }) }, toast(message, options) { if (message.replace) message = message.replace(/^GraphQL error: /, '') this.$root.$bvToast.toast(message, { - autoHideDelay: 5000, appendToast: true, solid: true, toaster: 'b-toaster-top-right', diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index bd07af3ef..5e2597c45 100755 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -123,5 +123,11 @@ export default { return !this.showPageMessage }, }, + mounted() { + if (this.$store.state.automaticallyLoggedOut) { + this.toastInfoNoHide('Du wurdest automatisch abgemeldet') + this.$store.commit('automaticallyLoggedOut', false) + } + }, } diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 1cd874c06..8f87cf468 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -53,6 +53,9 @@ export const mutations = { hideAmountGDT: (state, hideAmountGDT) => { state.hideAmountGDT = !!hideAmountGDT }, + automaticallyLoggedOut: (state, automaticallyLoggedOut) => { + state.automaticallyLoggedOut = !!automaticallyLoggedOut + }, } export const actions = { @@ -68,6 +71,7 @@ export const actions = { commit('isAdmin', data.isAdmin) commit('hideAmountGDD', data.hideAmountGDD) commit('hideAmountGDT', data.hideAmountGDT) + commit('automaticallyLoggedOut', false) }, logout: ({ commit, state }) => { commit('token', null) @@ -108,6 +112,7 @@ try { publisherId: null, hideAmountGDD: null, hideAmountGDT: null, + automaticallyLoggedOut: false, }, getters: {}, // Syncronous mutation of the state From af47bf847ba1d008e9675faf81cab0770c637e79 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 16:19:21 +0100 Subject: [PATCH 02/12] remove store way --- frontend/src/components/SessionLogoutTimeout.vue | 4 ++-- frontend/src/pages/Login.vue | 6 ------ frontend/src/store/store.js | 5 ----- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index 7a7cdfc5e..a41da851e 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -67,7 +67,7 @@ export default { } if (this.tokenExpiresInSeconds === 0) { this.$timer.stop('tokenExpires') - this.$store.commit('automaticallyLoggedOut', true) + this.toastInfoNoHide('Du wurdest automatisch abgemeldet') this.$emit('logout') } }, @@ -85,7 +85,7 @@ export default { }) .catch(() => { this.$timer.stop('tokenExpires') - this.$store.commit('automaticallyLoggedOut', true) + this.toastInfoNoHide('Du wurdest automatisch abgemeldet') this.$emit('logout') }) }, diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue index 5e2597c45..bd07af3ef 100755 --- a/frontend/src/pages/Login.vue +++ b/frontend/src/pages/Login.vue @@ -123,11 +123,5 @@ export default { return !this.showPageMessage }, }, - mounted() { - if (this.$store.state.automaticallyLoggedOut) { - this.toastInfoNoHide('Du wurdest automatisch abgemeldet') - this.$store.commit('automaticallyLoggedOut', false) - } - }, } diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 8f87cf468..1cd874c06 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -53,9 +53,6 @@ export const mutations = { hideAmountGDT: (state, hideAmountGDT) => { state.hideAmountGDT = !!hideAmountGDT }, - automaticallyLoggedOut: (state, automaticallyLoggedOut) => { - state.automaticallyLoggedOut = !!automaticallyLoggedOut - }, } export const actions = { @@ -71,7 +68,6 @@ export const actions = { commit('isAdmin', data.isAdmin) commit('hideAmountGDD', data.hideAmountGDD) commit('hideAmountGDT', data.hideAmountGDT) - commit('automaticallyLoggedOut', false) }, logout: ({ commit, state }) => { commit('token', null) @@ -112,7 +108,6 @@ try { publisherId: null, hideAmountGDD: null, hideAmountGDT: null, - automaticallyLoggedOut: false, }, getters: {}, // Syncronous mutation of the state From 12e7b9cce3fb2cf791d4778f7239fd1b7ce68da0 Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Thu, 9 Feb 2023 16:38:11 +0100 Subject: [PATCH 03/12] Update frontend/src/mixins/toaster.js Co-authored-by: Moriz Wahl --- frontend/src/mixins/toaster.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 109bf0d9a..3d180dd61 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -21,7 +21,7 @@ export const toasters = { autoHideDelay: 5000, }) }, - toastInfoNoHide(message) { + toastInfoNoHide(message, { noAutoHide: true }) { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', From c7e3425f29663eba5f073a9eab3f1a3bef88d3ac Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Thu, 9 Feb 2023 16:38:31 +0100 Subject: [PATCH 04/12] Update frontend/src/mixins/toaster.js Co-authored-by: Moriz Wahl --- frontend/src/mixins/toaster.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 3d180dd61..c5c0f0204 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -25,7 +25,6 @@ export const toasters = { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', - noAutoHide: true, }) }, toast(message, options) { From f12da2c7ade8f49aac5a84fe55d0d09e042c8edd Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Thu, 9 Feb 2023 16:38:44 +0100 Subject: [PATCH 05/12] Update frontend/src/mixins/toaster.js Co-authored-by: Moriz Wahl --- frontend/src/mixins/toaster.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index c5c0f0204..8a2b2f812 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -18,7 +18,6 @@ export const toasters = { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', - autoHideDelay: 5000, }) }, toastInfoNoHide(message, { noAutoHide: true }) { From 77c72b00d97dc216f0b9acc7586e819efa113b7e Mon Sep 17 00:00:00 2001 From: Alexander Friedland Date: Thu, 9 Feb 2023 16:38:54 +0100 Subject: [PATCH 06/12] Update frontend/src/mixins/toaster.js Co-authored-by: Moriz Wahl --- frontend/src/mixins/toaster.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 8a2b2f812..d2b4ad6fb 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -4,7 +4,6 @@ export const toasters = { this.toast(message, { title: this.$t('success'), variant: 'success', - autoHideDelay: 5000, }) }, toastError(message) { From b7740e5351caa7364f14edeecdf2dbfaa2626add Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 16:49:19 +0100 Subject: [PATCH 07/12] remove code --- frontend/src/mixins/toaster.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index d2b4ad6fb..109bf0d9a 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -4,6 +4,7 @@ export const toasters = { this.toast(message, { title: this.$t('success'), variant: 'success', + autoHideDelay: 5000, }) }, toastError(message) { @@ -17,12 +18,14 @@ export const toasters = { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', + autoHideDelay: 5000, }) }, - toastInfoNoHide(message, { noAutoHide: true }) { + toastInfoNoHide(message) { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', + noAutoHide: true, }) }, toast(message, options) { From 72e0e90e2ef6ecf6351f8d3b76e87d342ab9fdcb Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 16:53:44 +0100 Subject: [PATCH 08/12] remove code 2 --- frontend/src/mixins/toaster.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 109bf0d9a..6ed73b697 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -4,21 +4,18 @@ export const toasters = { this.toast(message, { title: this.$t('success'), variant: 'success', - autoHideDelay: 5000, }) }, toastError(message) { this.toast(message, { title: this.$t('error.error'), variant: 'danger', - autoHideDelay: 5000, }) }, toastInfo(message) { this.toast(message, { title: this.$t('navigation.info'), variant: 'warning', - autoHideDelay: 5000, }) }, toastInfoNoHide(message) { @@ -32,6 +29,7 @@ export const toasters = { if (message.replace) message = message.replace(/^GraphQL error: /, '') this.$root.$bvToast.toast(message, { appendToast: true, + autoHideDelay: 5000, solid: true, toaster: 'b-toaster-top-right', headerClass: 'gdd-toaster-title', From bacac0c93da361da16cccc248cda02270328d6c7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 17:02:01 +0100 Subject: [PATCH 09/12] add locales --- frontend/src/components/SessionLogoutTimeout.vue | 4 ++-- frontend/src/locales/de.json | 3 ++- frontend/src/locales/en.json | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue index a41da851e..7a11d1d83 100644 --- a/frontend/src/components/SessionLogoutTimeout.vue +++ b/frontend/src/components/SessionLogoutTimeout.vue @@ -67,7 +67,7 @@ export default { } if (this.tokenExpiresInSeconds === 0) { this.$timer.stop('tokenExpires') - this.toastInfoNoHide('Du wurdest automatisch abgemeldet') + this.toastInfoNoHide(this.$t('session.automaticallyLoggedOut')) this.$emit('logout') } }, @@ -85,7 +85,7 @@ export default { }) .catch(() => { this.$timer.stop('tokenExpires') - this.toastInfoNoHide('Du wurdest automatisch abgemeldet') + this.toastInfoNoHide(this.$t('session.automaticallyLoggedOut')) this.$emit('logout') }) }, diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index eff4237ca..4563db397 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -275,7 +275,8 @@ "extend": "Angemeldet bleiben", "lightText": "Wenn du länger als 10 Minuten keine Aktion getätigt hast, wirst du aus Sicherheitsgründen abgemeldet.", "logoutIn": "Abmelden in ", - "warningText": "Bist du noch da?" + "warningText": "Bist du noch da?", + "automaticallyLoggedOut":"Du wurdest automatisch abgemeldet" }, "settings": { "hideAmountGDD": "Dein GDD Betrag ist versteckt.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 068282891..50a8e45a1 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -275,7 +275,8 @@ "extend": "Stay logged in", "lightText": "If you have not performed any action for more than 10 minutes, you will be logged out for security reasons.", "logoutIn": "Log out in ", - "warningText": "Are you still there?" + "warningText": "Are you still there?", + "automaticallyLoggedOut":"You have been automatically logged out." }, "settings": { "hideAmountGDD": "Your GDD amount is hidden.", From 3c93b5a5b49b11070e0b7e75975e23268c4fe6a4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 17:03:23 +0100 Subject: [PATCH 10/12] fix lint --- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 4563db397..04d49ed82 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -276,7 +276,7 @@ "lightText": "Wenn du länger als 10 Minuten keine Aktion getätigt hast, wirst du aus Sicherheitsgründen abgemeldet.", "logoutIn": "Abmelden in ", "warningText": "Bist du noch da?", - "automaticallyLoggedOut":"Du wurdest automatisch abgemeldet" + "automaticallyLoggedOut": "Du wurdest automatisch abgemeldet" }, "settings": { "hideAmountGDD": "Dein GDD Betrag ist versteckt.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 50a8e45a1..360325c8f 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -276,7 +276,7 @@ "lightText": "If you have not performed any action for more than 10 minutes, you will be logged out for security reasons.", "logoutIn": "Log out in ", "warningText": "Are you still there?", - "automaticallyLoggedOut":"You have been automatically logged out." + "automaticallyLoggedOut": "You have been automatically logged out." }, "settings": { "hideAmountGDD": "Your GDD amount is hidden.", From 1c8a9efc503a04bfccd2e6cea37355e323ffebe8 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Feb 2023 17:03:41 +0100 Subject: [PATCH 11/12] fix locales --- frontend/src/locales/de.json | 4 ++-- frontend/src/locales/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 04d49ed82..016698abc 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -272,11 +272,11 @@ "send_gdd": "GDD versenden", "send_per_link": "GDD versenden per Link", "session": { + "automaticallyLoggedOut": "Du wurdest automatisch abgemeldet", "extend": "Angemeldet bleiben", "lightText": "Wenn du länger als 10 Minuten keine Aktion getätigt hast, wirst du aus Sicherheitsgründen abgemeldet.", "logoutIn": "Abmelden in ", - "warningText": "Bist du noch da?", - "automaticallyLoggedOut": "Du wurdest automatisch abgemeldet" + "warningText": "Bist du noch da?" }, "settings": { "hideAmountGDD": "Dein GDD Betrag ist versteckt.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 360325c8f..d95187b41 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -272,11 +272,11 @@ "send_gdd": "Send GDD", "send_per_link": "Send GDD via Link", "session": { + "automaticallyLoggedOut": "You have been automatically logged out.", "extend": "Stay logged in", "lightText": "If you have not performed any action for more than 10 minutes, you will be logged out for security reasons.", "logoutIn": "Log out in ", - "warningText": "Are you still there?", - "automaticallyLoggedOut": "You have been automatically logged out." + "warningText": "Are you still there?" }, "settings": { "hideAmountGDD": "Your GDD amount is hidden.", From 218ad21e4f65afc02c05915db05a7448d2a8460c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 9 Feb 2023 17:29:17 +0100 Subject: [PATCH 12/12] raise coverage eliminate warnings --- .../Contributions/ContributionList.spec.js | 10 ++++++++++ frontend/src/pages/Community.spec.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/frontend/src/components/Contributions/ContributionList.spec.js b/frontend/src/components/Contributions/ContributionList.spec.js index a1dfc934d..de875cf74 100644 --- a/frontend/src/components/Contributions/ContributionList.spec.js +++ b/frontend/src/components/Contributions/ContributionList.spec.js @@ -116,5 +116,15 @@ describe('ContributionList', () => { expect(wrapper.emitted('delete-contribution')).toEqual([[{ id: 2 }]]) }) }) + + describe('update status', () => { + beforeEach(() => { + wrapper.findComponent({ name: 'ContributionListItem' }).vm.$emit('update-state', { id: 2 }) + }) + + it('emits update status', () => { + expect(wrapper.emitted('update-state')).toEqual([[{ id: 2 }]]) + }) + }) }) }) diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index ecfc01716..b4d1677df 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -70,6 +70,8 @@ describe('Community', () => { lastName: 'Bloxberg', state: 'IN_PROGRESS', messagesCount: 0, + deniedAt: null, + deniedBy: null, }, { id: 1550, @@ -84,6 +86,8 @@ describe('Community', () => { lastName: 'Bloxberg', state: 'CONFIRMED', messagesCount: 0, + deniedAt: null, + deniedBy: null, }, ], contributionCount: 1, @@ -112,6 +116,10 @@ describe('Community', () => { confirmedAt: null, firstName: 'Bibi', lastName: 'Bloxberg', + deniedAt: null, + deniedBy: null, + messagesCount: 0, + state: 'IN_PROGRESS', }, { id: 1550, @@ -124,7 +132,10 @@ describe('Community', () => { firstName: 'Bibi', contributionDate: '2022-06-15T08:47:06.000Z', lastName: 'Bloxberg', + deniedAt: null, + deniedBy: null, messagesCount: 0, + state: 'IN_PROGRESS', }, { id: 1556, @@ -137,6 +148,10 @@ describe('Community', () => { confirmedAt: null, firstName: 'Bob', lastName: 'der Baumeister', + deniedAt: null, + deniedBy: null, + messagesCount: 0, + state: 'IN_PROGRESS', }, ], contributionCount: 3,