Merge branch 'master' into fix-possible-sql-error

This commit is contained in:
Moriz Wahl 2022-02-23 16:22:31 +01:00 committed by GitHub
commit 0bc96b35ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 203 additions and 48 deletions

View File

@ -11,7 +11,7 @@
"serve": "vue-cli-service serve --open",
"dev": "yarn run serve",
"build": "vue-cli-service build",
"lint": "eslint --ext .js,.vue .",
"lint": "eslint --max-warnings=0 --ext .js,.vue .",
"test": "TZ=UTC jest --coverage",
"locales": "scripts/missing-keys.sh && scripts/sort.sh"
},

View File

@ -0,0 +1,31 @@
import { mount } from '@vue/test-utils'
import Overlay from './Overlay.vue'
const localVue = global.localVue
const propsData = {
item: {},
}
const mocks = {
$t: jest.fn((t) => t),
$d: jest.fn((d) => String(d)),
}
describe('Overlay', () => {
let wrapper
const Wrapper = () => {
return mount(Overlay, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
it('has a DIV element with the class.component-overlay', () => {
expect(wrapper.find('.component-overlay').exists()).toBeTruthy()
})
})
})

View File

@ -0,0 +1,67 @@
<template>
<div class="component-overlay">
<b-jumbotron class="bg-light p-4">
<template #header>{{ $t('overlay.confirm.title') }}</template>
<template #lead>
<b-row class="mt-4">
<b-col class="col-3">{{ $t('transactionlist.amount') }}</b-col>
<b-col class="h3">
<b>{{ item.amount }} GDD</b>
</b-col>
</b-row>
<b-row>
<b-col class="col-3">{{ $t('creation_for_month') }}</b-col>
<b-col class="h3">
{{ $d(new Date(item.date), 'month') }} {{ $d(new Date(item.date), 'year') }}
</b-col>
</b-row>
<b-row>
<b-col class="col-3">{{ $t('transactionlist.memo') }}</b-col>
<b-col>{{ item.memo }}</b-col>
</b-row>
<b-row class="mt-3">
<b-col class="col-3">{{ $t('name') }}</b-col>
<b-col>{{ item.firstName }} {{ item.lastName }}</b-col>
</b-row>
<b-row>
<b-col class="col-3">{{ $t('e_mail') }}</b-col>
<b-col>{{ item.email }}</b-col>
</b-row>
</template>
<hr class="my-4" />
<p>{{ $t('overlay.confirm.text') }}</p>
<p>
{{ $t('overlay.confirm.question') }}
</p>
<b-container>
<b-row>
<b-col>
<b-button size="md" variant="danger" class="m-3" @click="$emit('overlay-cancel')">
{{ $t('overlay.confirm.cancel') }}
</b-button>
</b-col>
<b-col class="text-right">
<b-button
size="md"
variant="success"
class="m-3 text-right"
@click="$emit('confirm-creation', item)"
>
{{ $t('overlay.confirm.yes') }}
</b-button>
</b-col>
</b-row>
</b-container>
</b-jumbotron>
</div>
</template>
<script>
export default {
name: 'overlay',
props: {
item: { type: Object, required: true },
},
}
</script>

View File

@ -20,6 +20,7 @@
"toasted_update": "`Offene Schöpfung {value} GDD) für {email} wurde geändert und liegt zur Bestätigung bereit",
"update_creation": "Schöpfung aktualisieren"
},
"creation_for_month": "Schöpfung für Monat",
"date": "Datum",
"delete": "Löschen",
"details": "Details",
@ -31,6 +32,7 @@
"lastname": "Nachname",
"moderator": "Moderator",
"multiple_creation_text": "Bitte wähle ein oder mehrere Mitglieder aus für die du Schöpfen möchtest.",
"name": "Name",
"navbar": {
"logout": "Abmelden",
"multi_creation": "Mehrfachschöpfung",
@ -44,7 +46,7 @@
"open_creations": "Offene Schöpfungen",
"overlay": {
"confirm": {
"no": "Nein, nicht speichern.",
"cancel": "Abbrechen",
"question": "Willst du diese vorgespeicherte Schöpfung wirklich vollziehen und endgültig speichern?",
"text": "Nach dem Speichern ist der Datensatz nicht mehr änderbar und kann auch nicht mehr gelöscht werden. Bitte überprüfe genau, dass alles stimmt.",
"title": "Schöpfung bestätigen!",

View File

@ -20,6 +20,7 @@
"toasted_update": "Open creation {value} GDD) for {email} has been changed and is ready for confirmation.",
"update_creation": "Creation update"
},
"creation_for_month": "Creation for month",
"date": "Date",
"delete": "Delete",
"details": "Details",
@ -31,6 +32,7 @@
"lastname": "Lastname",
"moderator": "Moderator",
"multiple_creation_text": "Please select one or more members for which you would like to perform creations.",
"name": "Name",
"navbar": {
"logout": "Logout",
"multi_creation": "Multiple creation",
@ -44,7 +46,7 @@
"open_creations": "Open creations",
"overlay": {
"confirm": {
"no": "No, do not save.",
"cancel": "Cancel",
"question": "Do you really want to carry out and finally save this pre-stored creation?",
"text": "After saving, the record can no longer be changed or deleted. Please check carefully that everything is correct.",
"title": "Confirm creation!",

View File

@ -132,8 +132,8 @@ describe('CreationConfirm', () => {
await wrapper.find('#overlay').findAll('button').at(0).trigger('click')
})
it('closes the overlay', () => {
expect(wrapper.find('#overlay').isVisible()).toBeFalsy()
it('closes the overlay', async () => {
expect(wrapper.find('#overlay').exists()).toBeFalsy()
})
it('still has 2 items in the table', () => {

View File

@ -1,18 +1,7 @@
<template>
<div class="creation-confirm">
<div v-show="overlay" id="overlay" class="">
<b-jumbotron class="bg-light p-4">
<template #header>{{ $t('overlay.confirm.title') }}</template>
<template #lead>{{ $t('overlay.confirm.text') }}</template>
<hr class="my-4" />
<p>{{ $t('overlay.confirm.question') }}</p>
<b-button size="md" variant="danger" class="m-3" @click="overlay = false">
{{ $t('overlay.confirm.no') }}
</b-button>
<b-button size="md" variant="success" class="m-3 text-right" @click="confirmCreation">
{{ $t('overlay.confirm.yes') }}
</b-button>
</b-jumbotron>
<div v-if="overlay" id="overlay" @dblclick="overlay = false">
<overlay :item="item" @overlay-cancel="overlay = false" @confirm-creation="confirmCreation" />
</div>
<open-creations-table
class="mt-4"
@ -24,6 +13,7 @@
</div>
</template>
<script>
import Overlay from '../components/Overlay.vue'
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
import { getPendingCreations } from '../graphql/getPendingCreations'
import { deletePendingCreation } from '../graphql/deletePendingCreation'
@ -33,12 +23,13 @@ export default {
name: 'CreationConfirm',
components: {
OpenCreationsTable,
Overlay,
},
data() {
return {
pendingCreations: [],
overlay: false,
item: [],
item: {},
}
},
methods: {

View File

@ -12,7 +12,7 @@
"clean": "tsc --build --clean",
"start": "node build/src/index.js",
"dev": "nodemon -w src --ext ts --exec ts-node src/index.ts",
"lint": "eslint . --ext .js,.ts",
"lint": "eslint --max-warnings=0 --ext .js,.ts .",
"test": "TZ=UTC NODE_ENV=development jest --runInBand --coverage --forceExit --detectOpenHandles"
},
"dependencies": {

View File

@ -53,6 +53,7 @@ async function calculateAndAddDecayTransactions(
transactionIndiced[transaction.id] = transaction
involvedUserIds.push(transaction.userId)
if (transaction.transactionTypeId === TransactionTypeId.SEND) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
involvedUserIds.push(transaction.sendReceiverUserId!) // TODO ensure not null properly
}
})

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* FIRST MIGRATION
*
* This migration is special since it takes into account that
@ -12,6 +9,9 @@
* databases.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// write upgrade logic as parameter of queryFn
await queryFn(`

View File

@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO ADD USER SETTINGS
*
* This migration adds the table `user_setting` in order to store all sorts of user configuration data
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`
CREATE TABLE IF NOT EXISTS \`user_setting\` (

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO CREATE THE LOGIN_SERVER TABLES
*
* This migration creates the `login_server` tables in the `community_server` database (`gradido_community`).
@ -8,6 +5,9 @@
* `0004-login_server_data` which will fill the tables with the existing data
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`
CREATE TABLE IF NOT EXISTS \`login_app_access_tokens\` (

View File

@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* MIGRATION TO COPY LOGIN_SERVER DATA
*
* This migration copies all existing data from the `login_server` database (`gradido_login`)
@ -12,6 +9,9 @@
* NOTE: This migration does not delete the data when downgrading!
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
const LOGIN_SERVER_DB = 'gradido_login'
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
@ -62,6 +62,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
`)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// TODO NO EMPTY FUNCTION
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// EMPTY FUNCTION
}

View File

@ -3,6 +3,9 @@
* This migration adds the table `login_pending_tasks_admin` to store pending creations
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`
CREATE TABLE IF NOT EXISTS \`login_pending_tasks_admin\` (

View File

@ -5,6 +5,9 @@
* to also explicitly define it in the table
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Explicitly change the charset and collate to the one used to then change it
await queryFn('ALTER TABLE `login_users` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;')

View File

@ -6,10 +6,13 @@
* and dead entries
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn('DELETE FROM `login_pending_tasks`;')
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot undelete things
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot undelete things
}

View File

@ -6,6 +6,9 @@
* login_users.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Fill in missing emails from login_users
await queryFn(
@ -18,6 +21,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
await queryFn(`DELETE FROM state_users WHERE email = ''`)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot undelete things
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot undelete things
}

View File

@ -5,6 +5,9 @@
* account is set as not yet activated
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Generate a random private key where the required data is present (pubkey + password + passphrase).
// Furthermore the email needs to be confirmed
@ -23,6 +26,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot undelete things
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot undelete things
}

View File

@ -4,6 +4,9 @@
* Copy missing data from login_users to state_users.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Copy data with intact private key
await queryFn(
@ -40,6 +43,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot undelete things
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot undelete things
}

View File

@ -5,6 +5,9 @@
* delete the right one of the duplicate keys
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Delete data with no reference in login_users table
await queryFn(`DELETE FROM login_user_backups WHERE user_id NOT IN (SELECT id FROM login_users)`)
@ -13,6 +16,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
await queryFn(`DELETE FROM login_user_backups WHERE id IN (21, 103, 313, 325, 726, 750, 1098)`)
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot undelete things
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot undelete things
}

View File

@ -4,6 +4,10 @@
* we need to detect which word list was used and transform it accordingly.
* This also removes the trailing space
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import fs from 'fs'
import path from 'path'
@ -62,6 +66,6 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis
})
}
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
return [] // cannot transform things back
export async function downgrade(/* queryFn: (query: string, values?: any[]) => Promise<Array<any>> */) {
// cannot transform things back
}

View File

@ -5,6 +5,9 @@
* The migration reduces the amount of tables to 28
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`DROP TABLE \`login_app_access_tokens\`;`)
await queryFn(`DROP TABLE \`pending_transactions\`;`)

View File

@ -5,6 +5,9 @@
* The migration reduces the amount of tables to 16
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`DROP TABLE \`address_types\`;`)
await queryFn(`DROP TABLE \`admin_errors\`;`)

View File

@ -7,6 +7,9 @@
* the new table to properly describe what it does
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// drop duplicate table, it was unused
await queryFn('DROP TABLE `login_pending_tasks`;')

View File

@ -4,6 +4,9 @@
* combines its data with transaction_signatures.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Drop column `state_group_id` since it only contains "0" as value, no variation.
// Furthermore it was not present in our model itself (meaning that newly created )

View File

@ -4,6 +4,9 @@
* the `state_users` table, where the later is the target.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Drop column `group_id` since it contains uniform data which is not the same as the uniform data
// on login_users. Since we do not need this data anyway, we sjust throw it away.

View File

@ -4,6 +4,9 @@
* the `state_users` table, where the later is the target.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// We only keep the passphrase, the mnemonic type is a constant,
// since every passphrase was converted to mnemonic type 2

View File

@ -5,6 +5,9 @@
* The table affected is `login_email_opt_in`
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Delete email opt in codes which can not be linked to an user
await queryFn(`

View File

@ -4,6 +4,9 @@
* and removes columns with no meaningful value
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// rename `state_users` table to `users`
await queryFn('RENAME TABLE `state_users` TO `users`;')

View File

@ -4,6 +4,9 @@
* `publisher_id`, `order_id`. `product_id`.
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(
'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `affiliate_program_id` int(11) DEFAULT NULL;',

View File

@ -4,6 +4,9 @@
* we can delete it from the database
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Remove transactions with type 9 (start decay block). This should affect exactly 1 row
await queryFn(`DELETE FROM transactions WHERE transaction_type_id = 9;`)

View File

@ -4,6 +4,9 @@
* a date as it is standard for soft delete fields
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Create new `deletedAt` column
await queryFn(

View File

@ -3,6 +3,9 @@
* Combine all transaction tables into one table with all data
*/
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
// Create new `user_id` column (former `state_user_id`), with a temporary default of null
await queryFn(

View File

@ -16,7 +16,7 @@
"dev_up": "ts-node src/index.ts up",
"dev_down": "ts-node src/index.ts down",
"dev_reset": "ts-node src/index.ts reset",
"lint": "eslint . --ext .js,.ts",
"lint": "eslint --max-warnings=0 --ext .js,.ts .",
"seed:config": "ts-node ./node_modules/typeorm-seeding/dist/cli.js config",
"seed": "ts-node src/index.ts seed"
},

View File

@ -7,7 +7,7 @@
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"analyse-bundle": "yarn build && webpack-bundle-analyzer dist/webpack.stats.json",
"lint": "eslint --ext .js,.vue .",
"lint": "eslint --max-warnings=0 --ext .js,.vue .",
"dev": "yarn run serve",
"i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'",
"test": "jest --coverage",