From bb86be723b300bd0cb2faade5e5d71eb48a382c5 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 2 Feb 2022 16:30:31 +0100 Subject: [PATCH 01/71] refactor: Mixin for Creation Labels --- admin/src/components/UserTable.vue | 1 + admin/src/mixins/creationMonths.js | 8 +++++++- admin/src/pages/Creation.vue | 13 ++----------- admin/src/pages/UserSearch.vue | 19 +++---------------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 4d14a35cb..b37aa5c9d 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -195,6 +195,7 @@ export default { creation: { type: Array, required: false, + default: () => [null, null, null], }, }, components: { diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js index a2bbdcd1a..c26dc5b02 100644 --- a/admin/src/mixins/creationMonths.js +++ b/admin/src/mixins/creationMonths.js @@ -1,6 +1,9 @@ export const creationMonths = { props: { - creation: [1000, 1000, 1000], + creation: { + type: Array, + default: () => [1000, 1000, 1000], + }, }, computed: { creationDates() { @@ -31,5 +34,8 @@ export const creationMonths = { } }) }, + creationLabel() { + return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') + }, }, } diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 0e2cb541e..472bcb446 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -55,9 +55,11 @@ import CreationFormular from '../components/CreationFormular.vue' import UserTable from '../components/UserTable.vue' import { searchUsers } from '../graphql/searchUsers' +import { creationMonths } from '../mixins/creationMonths' export default { name: 'Creation', + mixins: [creationMonths], components: { CreationFormular, UserTable, @@ -69,7 +71,6 @@ export default { itemsMassCreation: this.$store.state.userSelectedInMassCreation, radioSelectedMass: '', criteria: '', - creation: [null, null, null], rows: 0, currentPage: 1, perPage: 25, @@ -163,16 +164,6 @@ export default { { key: 'bookmark', label: this.$t('remove') }, ] }, - creationLabel() { - const now = new Date(this.now) - const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) - const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) - return [ - this.$d(beforeLastMonth, 'monthShort'), - this.$d(lastMonth, 'monthShort'), - this.$d(now, 'monthShort'), - ].join(' | ') - }, }, watch: { currentPage() { diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index b7c19d03a..7b07241ec 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -35,9 +35,11 @@ + diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 8fe34c026..9b26b63b6 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -12,7 +12,7 @@ > - + diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 446ffa338..28e1a7774 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -16,7 +16,7 @@ :placeholder="$t('user_search')" > - + From 36e016cc62b4878cab695b95393a8eadca0e37d7 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 4 Feb 2022 09:11:31 +0100 Subject: [PATCH 45/71] change test text --- admin/src/pages/UserSearch.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/pages/UserSearch.spec.js b/admin/src/pages/UserSearch.spec.js index a999e05e8..dc4b9dede 100644 --- a/admin/src/pages/UserSearch.spec.js +++ b/admin/src/pages/UserSearch.spec.js @@ -120,7 +120,7 @@ describe('UserSearch', () => { }) describe('reset the search field', () => { - it('is value remove', async () => { + it('calls the API with empty criteria', async () => { jest.clearAllMocks() await wrapper.find('.test-click-clear-criteria').trigger('click') expect(apolloQueryMock).toBeCalledWith( From 70d8b586b629bc5d27363557469b37c4a8e8b6d3 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 4 Feb 2022 10:29:17 +0100 Subject: [PATCH 46/71] add rmove button for all selected user in mass creation, remove overlay request by remove from only selected user for mass creation --- admin/src/components/UserTable.vue | 12 +----------- admin/src/pages/Creation.vue | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 0fa72f573..e518ac6d1 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -133,7 +133,7 @@ variant="danger" v-show="type === 'UserListMassCreation' || type === 'PageCreationConfirm'" size="md" - @click="overlayShow('remove', row.item)" + @click="bookmarkRemove(row.item)" class="mr-2" > @@ -242,13 +242,6 @@ export default { this.overlayBookmarkType = bookmarkType this.overlayItem = item - if (bookmarkType === 'remove') { - this.overlayText.header = this.$t('overlay.remove.title') - this.overlayText.text1 = this.$t('overlay.remove.text') - this.overlayText.text2 = this.$t('overlay.remove.question') - this.overlayText.button_ok = this.$t('overlay.remove.yes') - this.overlayText.button_cancel = this.$t('overlay.remove.no') - } if (bookmarkType === 'confirm') { this.overlayText.header = this.$t('overlay.confirm.title') this.overlayText.text1 = this.$t('overlay.confirm.text') @@ -258,9 +251,6 @@ export default { } }, overlayOK(bookmarkType, item) { - if (bookmarkType === 'remove') { - this.bookmarkRemove(item) - } if (bookmarkType === 'confirm') { this.$emit('confirm-creation', item) } diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 6da762a15..9f1c4ef5d 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -25,14 +25,21 @@ > - +
+
+ + + alle Nutzer entfernen + +
+ +
{{ $t('multiple_creation_text') }}
From ffc96c91308fc523fc3b168c2d8ce652605f2ba2 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 4 Feb 2022 11:25:21 +0100 Subject: [PATCH 47/71] remove overlay from tests creation.spec.js --- admin/src/pages/Creation.spec.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index e06e43607..6dbc10901 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -174,25 +174,14 @@ describe('Creation', () => { .trigger('click') }) - it('opens a dialog', () => { - expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeTruthy() - }) - describe('cancel remove item', () => { - beforeEach(async () => { - await wrapper.findAll('#overlay').at(1).findAll('button').at(0).trigger('click') - }) - - it('closes the dialog', () => { - expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeFalsy() - }) it('has one item in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(1) + expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2) }) it('has one item in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(1) + expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) }) }) From df8ce64680713de007e6fbd9770e78a19745b377 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 4 Feb 2022 11:30:28 +0100 Subject: [PATCH 48/71] add lokalize button text --- admin/src/locales/de.json | 1 + admin/src/locales/en.json | 1 + admin/src/pages/Creation.vue | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 7585ee122..05e82bdd9 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -54,6 +54,7 @@ } }, "remove": "Entfernen", + "remove_all":"alle Nutzer entfernen", "transaction": "Transaktion", "transactionlist": { "amount": "Betrag", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 2680a1c00..4c25ca149 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -54,6 +54,7 @@ } }, "remove": "Remove", + "remove_all":"Remove all users", "transaction": "Transaction", "transactionlist": { "amount": "Amount", diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 9f1c4ef5d..28ef8d344 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -29,7 +29,8 @@
- alle Nutzer entfernen + + {{ $t('remove_all') }}
Date: Fri, 4 Feb 2022 11:31:17 +0100 Subject: [PATCH 49/71] yarn lint, yarn locales --- admin/src/locales/de.json | 2 +- admin/src/locales/en.json | 2 +- admin/src/pages/Creation.spec.js | 1 - admin/src/pages/Creation.vue | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 05e82bdd9..327cfd302 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -54,7 +54,7 @@ } }, "remove": "Entfernen", - "remove_all":"alle Nutzer entfernen", + "remove_all": "alle Nutzer entfernen", "transaction": "Transaktion", "transactionlist": { "amount": "Betrag", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 4c25ca149..3f12f10a8 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -54,7 +54,7 @@ } }, "remove": "Remove", - "remove_all":"Remove all users", + "remove_all": "Remove all users", "transaction": "Transaction", "transactionlist": { "amount": "Amount", diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index 6dbc10901..eced66544 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -175,7 +175,6 @@ describe('Creation', () => { }) describe('cancel remove item', () => { - it('has one item in left table', () => { expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2) }) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 28ef8d344..13e3783da 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -29,8 +29,8 @@
- - {{ $t('remove_all') }} + + {{ $t('remove_all') }}
Date: Fri, 4 Feb 2022 13:41:24 +0100 Subject: [PATCH 50/71] removed todo no longer applying --- database/migrations/0017-combine_user_tables.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/database/migrations/0017-combine_user_tables.ts b/database/migrations/0017-combine_user_tables.ts index d4a0f7c0c..023c85fb9 100644 --- a/database/migrations/0017-combine_user_tables.ts +++ b/database/migrations/0017-combine_user_tables.ts @@ -14,7 +14,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn('ALTER TABLE `state_users` DROP INDEX `public_key`;') // Allow NULL on the `state_users` pubkey like it is allowed on `login_users` - // TODO remove the random key shenanigans await queryFn('ALTER TABLE `state_users` MODIFY COLUMN `public_key` binary(32) DEFAULT NULL;') // instead use a unique constraint for the email like on `login_users` From 1025ba433648fcc553950e3c3e0320fbd9de9924 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 4 Feb 2022 13:47:57 +0100 Subject: [PATCH 51/71] removed loginUserId --- database/src/seeds/users/bibi-bloxberg.ts | 1 - database/src/seeds/users/bob-baumeister.ts | 1 - database/src/seeds/users/garrick-ollivander.ts | 1 - database/src/seeds/users/peter-lustig.ts | 1 - database/src/seeds/users/raeuber-hotzenplotz.ts | 1 - 5 files changed, 5 deletions(-) diff --git a/database/src/seeds/users/bibi-bloxberg.ts b/database/src/seeds/users/bibi-bloxberg.ts index 86fae0300..221349cb7 100644 --- a/database/src/seeds/users/bibi-bloxberg.ts +++ b/database/src/seeds/users/bibi-bloxberg.ts @@ -1,5 +1,4 @@ export const bibiBloxberg = { - loginUserId: 1, email: 'bibi@bloxberg.de', firstName: 'Bibi', lastName: 'Bloxberg', diff --git a/database/src/seeds/users/bob-baumeister.ts b/database/src/seeds/users/bob-baumeister.ts index a42993a1d..013636079 100644 --- a/database/src/seeds/users/bob-baumeister.ts +++ b/database/src/seeds/users/bob-baumeister.ts @@ -1,5 +1,4 @@ export const bobBaumeister = { - loginUserId: 2, email: 'bob@baumeister.de', firstName: 'Bob', lastName: 'der Baumeister', diff --git a/database/src/seeds/users/garrick-ollivander.ts b/database/src/seeds/users/garrick-ollivander.ts index d84cd02db..1c7bbb9fc 100644 --- a/database/src/seeds/users/garrick-ollivander.ts +++ b/database/src/seeds/users/garrick-ollivander.ts @@ -1,5 +1,4 @@ export const garrickOllivander = { - loginUserId: 3, email: 'garrick@ollivander.com', firstName: 'Garrick', lastName: 'Ollivander', diff --git a/database/src/seeds/users/peter-lustig.ts b/database/src/seeds/users/peter-lustig.ts index 96b44cda4..c96b28a65 100644 --- a/database/src/seeds/users/peter-lustig.ts +++ b/database/src/seeds/users/peter-lustig.ts @@ -1,5 +1,4 @@ export const peterLustig = { - loginUserId: 4, email: 'peter@lustig.de', firstName: 'Peter', lastName: 'Lustig', diff --git a/database/src/seeds/users/raeuber-hotzenplotz.ts b/database/src/seeds/users/raeuber-hotzenplotz.ts index 0df964167..c1f31b490 100644 --- a/database/src/seeds/users/raeuber-hotzenplotz.ts +++ b/database/src/seeds/users/raeuber-hotzenplotz.ts @@ -1,5 +1,4 @@ export const raeuberHotzenplotz = { - loginUserId: 5, email: 'raeuber@hotzenplotz.de', firstName: 'Räuber', lastName: 'Hotzenplotz', From 72af3ebdbc499c74ac0ba913f364c466e5222a18 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 4 Feb 2022 13:53:28 +0100 Subject: [PATCH 52/71] checked an removed todos where possible --- database/migrations/0017-combine_user_tables.ts | 3 --- .../0018-combine_login_user_backups_and_user_table.ts | 1 - 2 files changed, 4 deletions(-) diff --git a/database/migrations/0017-combine_user_tables.ts b/database/migrations/0017-combine_user_tables.ts index 023c85fb9..04be53615 100644 --- a/database/migrations/0017-combine_user_tables.ts +++ b/database/migrations/0017-combine_user_tables.ts @@ -10,7 +10,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn('ALTER TABLE `state_users` DROP COLUMN `group_id`;') // Remove the unique constraint from the pubkey - // TODO - check for code impact await queryFn('ALTER TABLE `state_users` DROP INDEX `public_key`;') // Allow NULL on the `state_users` pubkey like it is allowed on `login_users` @@ -21,11 +20,9 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis await queryFn( 'ALTER TABLE `state_users` MODIFY COLUMN `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL;', ) - // TODO - check for code impact await queryFn('ALTER TABLE `state_users` ADD CONSTRAINT `email` UNIQUE KEY (`email`);') // Create `login_user_id` column - to store the login_users.id field to not break references. - // TODO - what happens when we create a new user - how do we generate the login_user_id? await queryFn( 'ALTER TABLE `state_users` ADD COLUMN `login_user_id` int(10) unsigned DEFAULT NULL AFTER `id`;', ) diff --git a/database/migrations/0018-combine_login_user_backups_and_user_table.ts b/database/migrations/0018-combine_login_user_backups_and_user_table.ts index 9cc1853dd..2141017bd 100644 --- a/database/migrations/0018-combine_login_user_backups_and_user_table.ts +++ b/database/migrations/0018-combine_login_user_backups_and_user_table.ts @@ -7,7 +7,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { // We only keep the passphrase, the mnemonic type is a constant, // since every passphrase was converted to mnemonic type 2 - // TODO there is now default NULL instead of NOT NULL - check code impact await queryFn( 'ALTER TABLE `state_users` ADD COLUMN `passphrase` text DEFAULT NULL AFTER `publisher_id`;', ) From 317067ab96d622750aeeea29b2f3943ab1e27e97 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 4 Feb 2022 14:41:24 +0100 Subject: [PATCH 53/71] improve test --- admin/src/pages/Creation.spec.js | 79 +++++++++----------------------- admin/src/pages/Creation.vue | 6 +-- 2 files changed, 25 insertions(+), 60 deletions(-) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index eced66544..85ad81031 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -154,43 +154,16 @@ describe('Creation', () => { }, ]) }) - }) - describe('remove item', () => { - beforeEach(async () => { - await wrapper - .findAll('table') - .at(0) - .findAll('tbody > tr') - .at(1) - .find('button') - .trigger('click') - await wrapper - .findAll('table') - .at(1) - .findAll('tbody > tr') - .at(0) - .find('button') - .trigger('click') - }) - - describe('cancel remove item', () => { - it('has one item in left table', () => { - expect(wrapper.findAll('table').at(0).findAll('tbody > tr')).toHaveLength(2) - }) - - it('has one item in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) - }) - }) - - describe('confirm remove item', () => { + describe('remove item', () => { beforeEach(async () => { - await wrapper.findAll('#overlay').at(1).findAll('button').at(1).trigger('click') - }) - - it('closes the dialog', () => { - expect(wrapper.findAll('#overlay').at(1).isVisible()).toBeFalsy() + await wrapper + .findAll('table') + .at(1) + .findAll('tbody > tr') + .at(0) + .find('button') + .trigger('click') }) it('has two items in left table', () => { @@ -211,32 +184,24 @@ describe('Creation', () => { expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) }) }) - }) - // this can only happen after API call in CreationForm - describe('remove all bookmarks', () => { - beforeEach(async () => { - await wrapper - .findAll('table') - .at(0) - .findAll('tbody > tr') - .at(1) - .find('button') - .trigger('click') - jest.clearAllMocks() - wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark') - }) + describe('remove all bookmarks', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.find('button.btn-light').trigger('click') + }) - it('has no items in right table', () => { - expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) - }) + it('has no items in right table', () => { + expect(wrapper.findAll('table').at(1).findAll('tbody > tr')).toHaveLength(0) + }) - it('commits empty array to userSelectedInMassCreation', () => { - expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) - }) + it('commits empty array to userSelectedInMassCreation', () => { + expect(storeCommitMock).toBeCalledWith('setUserSelectedInMassCreation', []) + }) - it('calls searchUsers', () => { - expect(apolloQueryMock).toBeCalled() + it('calls searchUsers', () => { + expect(apolloQueryMock).toBeCalled() + }) }) }) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 13e3783da..7810a611f 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -27,7 +27,7 @@
- + {{ $t('remove_all') }} @@ -49,7 +49,7 @@ type="massCreation" :creation="creation" :items="itemsMassCreation" - @remove-all-bookmark="removeAllBookmark" + @remove-all-bookmark="removeAllBookmarks" /> @@ -131,7 +131,7 @@ export default { ) this.$store.commit('setUserSelectedInMassCreation', this.itemsMassCreation) }, - removeAllBookmark() { + removeAllBookmarks() { this.itemsMassCreation = [] this.$store.commit('setUserSelectedInMassCreation', []) this.getUsers() From b50a552fadfa6a6702920a19bd4a9538b91180b2 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 4 Feb 2022 15:14:43 +0100 Subject: [PATCH 54/71] disable form if balance <= 0, and show danger info text --- .../Pages/SendOverview/GddSend/TransactionForm.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Pages/SendOverview/GddSend/TransactionForm.vue b/frontend/src/views/Pages/SendOverview/GddSend/TransactionForm.vue index 364f54ac7..87dca8424 100644 --- a/frontend/src/views/Pages/SendOverview/GddSend/TransactionForm.vue +++ b/frontend/src/views/Pages/SendOverview/GddSend/TransactionForm.vue @@ -41,6 +41,7 @@ placeholder="E-Mail" style="font-size: large" class="pl-3" + :disabled="isBalanceDisabled" > @@ -76,6 +77,7 @@ :placeholder="$n(0.01)" style="font-size: large" class="pl-3" + :disabled="isBalanceDisabled" > @@ -105,6 +107,7 @@ v-model="form.memo" class="pl-3" style="font-size: large" + :disabled="isBalanceDisabled" > @@ -114,7 +117,8 @@

- +
Du hast keine GDD zum versenden.
+ {{ $t('form.reset') }} @@ -126,6 +130,7 @@ +
@@ -192,6 +197,11 @@ export default { this.form.email = this.form.email.trim() }, }, + computed: { + isBalanceDisabled(){ + return this.balance <= 0 ? 'disabled' : false + } + } }