Merge branch 'master' into 1923-Allow-Admin-to-CRUD-Contribution-Links

This commit is contained in:
Alexander Friedland 2022-05-31 09:39:33 +02:00 committed by GitHub
commit 5103075649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 69 additions and 335 deletions

View File

@ -4,7 +4,7 @@
"main": "index.js", "main": "index.js",
"author": "Moriz Wahl", "author": "Moriz Wahl",
"version": "1.8.3", "version": "1.8.3",
"license": "MIT", "license": "Apache License 2.0",
"private": false, "private": false,
"scripts": { "scripts": {
"start": "node run/server.js", "start": "node run/server.js",

View File

@ -13,6 +13,14 @@
{ {
"type": "dateFile", "type": "dateFile",
"filename": "../logs/backend/apollo.log", "filename": "../logs/backend/apollo.log",
"pattern": "%d{ISO8601} %p %c %m",
"keepFileExt" : true,
"fileNameSep" : "_"
},
"backend":
{
"type": "dateFile",
"filename": "../logs/backend/backend.log",
"pattern": "%d{ISO8601} %p %c %X{user} %f:%l %m", "pattern": "%d{ISO8601} %p %c %X{user} %f:%l %m",
"keepFileExt" : true, "keepFileExt" : true,
"fileNameSep" : "_" "fileNameSep" : "_"
@ -31,24 +39,52 @@
"level": "error", "level": "error",
"appender": "errorFile" "appender": "errorFile"
}, },
"out": "out":
{ {
"type": "stdout", "type": "stdout",
"layout": "layout":
{ {
"type": "pattern", "pattern": "%d{ISO8601} %p %c %X{user} %f:%l %m" "type": "pattern", "pattern": "%d{ISO8601} %p %c %X{user} %f:%l %m"
} }
},
} "apolloOut":
{
"type": "stdout",
"layout":
{
"type": "pattern", "pattern": "%d{ISO8601} %p %c %m"
}
}
}, },
"categories": "categories":
{ {
"default": "default":
{ {
"appenders": "appenders":
[ [
"out", "out",
"errors"
],
"level": "debug",
"enableCallStack": true
},
"apollo":
{
"appenders":
[
"apollo", "apollo",
"apolloOut",
"errors"
],
"level": "debug",
"enableCallStack": true
},
"backend":
{
"appenders":
[
"backend",
"out",
"errors" "errors"
], ],
"level": "debug", "level": "debug",

View File

@ -5,7 +5,7 @@
"main": "src/index.ts", "main": "src/index.ts",
"repository": "https://github.com/gradido/gradido/backend", "repository": "https://github.com/gradido/gradido/backend",
"author": "Ulf Gebhardt", "author": "Ulf Gebhardt",
"license": "MIT", "license": "Apache License 2.0",
"private": false, "private": false,
"scripts": { "scripts": {
"build": "tsc --build", "build": "tsc --build",

View File

@ -3,7 +3,7 @@ import CONFIG from './index'
describe('config/index', () => { describe('config/index', () => {
describe('decay start block', () => { describe('decay start block', () => {
it('has the correct date set', () => { it('has the correct date set', () => {
expect(CONFIG.DECAY_START_TIME).toEqual(new Date('2021-05-13 17:46:31')) expect(CONFIG.DECAY_START_TIME).toEqual(new Date('2021-05-13 17:46:31-0000'))
}) })
}) })
}) })

View File

@ -11,7 +11,7 @@ Decimal.set({
const constants = { const constants = {
DB_VERSION: '0036-unique_previous_in_transactions', DB_VERSION: '0036-unique_previous_in_transactions',
DECAY_START_TIME: new Date('2021-05-13 17:46:31'), // GMT+0 DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
LOG4JS_CONFIG: 'log4js-config.json', LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info // default log level on production should be info
LOG_LEVEL: process.env.LOG_LEVEL || 'info', LOG_LEVEL: process.env.LOG_LEVEL || 'info',

View File

@ -19,7 +19,4 @@ export default class UpdateUserInfosArgs {
@Field({ nullable: true }) @Field({ nullable: true })
passwordNew?: string passwordNew?: string
@Field({ nullable: true })
coinanimation?: boolean
} }

View File

@ -1,5 +0,0 @@
enum Setting {
COIN_ANIMATION = 'coinanimation',
}
export { Setting }

View File

@ -15,8 +15,6 @@ export class User {
this.language = user.language this.language = user.language
this.publisherId = user.publisherId this.publisherId = user.publisherId
this.isAdmin = user.isAdmin this.isAdmin = user.isAdmin
// TODO
this.coinanimation = null
this.klickTipp = null this.klickTipp = null
this.hasElopage = null this.hasElopage = null
} }
@ -61,11 +59,6 @@ export class User {
@Field(() => Date, { nullable: true }) @Field(() => Date, { nullable: true })
isAdmin: Date | null isAdmin: Date | null
// TODO this is a bit inconsistent with what we query from the database
// therefore all those fields are now nullable with default value null
@Field(() => Boolean, { nullable: true })
coinanimation: boolean | null
@Field(() => KlickTipp, { nullable: true }) @Field(() => KlickTipp, { nullable: true })
klickTipp: KlickTipp | null klickTipp: KlickTipp | null

View File

@ -344,7 +344,6 @@ describe('UserResolver', () => {
expect.objectContaining({ expect.objectContaining({
data: { data: {
login: { login: {
coinanimation: true,
email: 'bibi@bloxberg.de', email: 'bibi@bloxberg.de',
firstName: 'Bibi', firstName: 'Bibi',
hasElopage: false, hasElopage: false,
@ -479,7 +478,6 @@ describe('UserResolver', () => {
firstName: 'Bibi', firstName: 'Bibi',
lastName: 'Bloxberg', lastName: 'Bloxberg',
language: 'de', language: 'de',
coinanimation: true,
klickTipp: { klickTipp: {
newsletterState: false, newsletterState: false,
}, },

View File

@ -3,7 +3,7 @@ import { backendLogger as logger } from '@/server/logger'
import { Context, getUser } from '@/server/context' import { Context, getUser } from '@/server/context'
import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql' import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql'
import { getConnection, getCustomRepository } from '@dbTools/typeorm' import { getConnection } from '@dbTools/typeorm'
import CONFIG from '@/config' import CONFIG from '@/config'
import { User } from '@model/User' import { User } from '@model/User'
import { User as DbUser } from '@entity/User' import { User as DbUser } from '@entity/User'
@ -13,8 +13,6 @@ import CreateUserArgs from '@arg/CreateUserArgs'
import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' import UnsecureLoginArgs from '@arg/UnsecureLoginArgs'
import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs'
import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware' import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware'
import { UserSettingRepository } from '@repository/UserSettingRepository'
import { Setting } from '@enum/Setting'
import { OptInType } from '@enum/OptInType' import { OptInType } from '@enum/OptInType'
import { LoginEmailOptIn } from '@entity/LoginEmailOptIn' import { LoginEmailOptIn } from '@entity/LoginEmailOptIn'
import { sendResetPasswordEmail as sendResetPasswordEmailMailer } from '@/mailer/sendResetPasswordEmail' import { sendResetPasswordEmail as sendResetPasswordEmailMailer } from '@/mailer/sendResetPasswordEmail'
@ -228,15 +226,6 @@ export class UserResolver {
// Elopage Status & Stored PublisherId // Elopage Status & Stored PublisherId
user.hasElopage = await this.hasElopage(context) user.hasElopage = await this.hasElopage(context)
// coinAnimation
const userSettingRepository = getCustomRepository(UserSettingRepository)
const coinanimation = await userSettingRepository
.readBoolean(userEntity.id, Setting.COIN_ANIMATION)
.catch((error) => {
logger.error('error:', error)
throw new Error(error)
})
user.coinanimation = coinanimation
logger.debug(`verifyLogin... successful: ${user.firstName}.${user.lastName}, ${user.email}`) logger.debug(`verifyLogin... successful: ${user.firstName}.${user.lastName}, ${user.email}`)
return user return user
} }
@ -294,15 +283,6 @@ export class UserResolver {
DbUser.save(dbUser) DbUser.save(dbUser)
} }
// coinAnimation
const userSettingRepository = getCustomRepository(UserSettingRepository)
const coinanimation = await userSettingRepository
.readBoolean(dbUser.id, Setting.COIN_ANIMATION)
.catch((error) => {
throw new Error(error)
})
user.coinanimation = coinanimation
context.setHeaders.push({ context.setHeaders.push({
key: 'token', key: 'token',
value: encode(dbUser.pubKey), value: encode(dbUser.pubKey),
@ -598,12 +578,10 @@ export class UserResolver {
@Mutation(() => Boolean) @Mutation(() => Boolean)
async updateUserInfos( async updateUserInfos(
@Args() @Args()
{ firstName, lastName, language, password, passwordNew, coinanimation }: UpdateUserInfosArgs, { firstName, lastName, language, password, passwordNew }: UpdateUserInfosArgs,
@Ctx() context: Context, @Ctx() context: Context,
): Promise<boolean> { ): Promise<boolean> {
logger.info( logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`)
`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***, ${coinanimation})...`,
)
const userEntity = getUser(context) const userEntity = getUser(context)
if (firstName) { if (firstName) {
@ -655,15 +633,6 @@ export class UserResolver {
await queryRunner.startTransaction('READ UNCOMMITTED') await queryRunner.startTransaction('READ UNCOMMITTED')
try { try {
if (coinanimation !== null && coinanimation !== undefined) {
queryRunner.manager
.getCustomRepository(UserSettingRepository)
.setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString())
.catch((error) => {
throw new Error('error saving coinanimation: ' + error)
})
}
await queryRunner.manager.save(userEntity).catch((error) => { await queryRunner.manager.save(userEntity).catch((error) => {
throw new Error('error saving user: ' + error) throw new Error('error saving user: ' + error)
}) })

View File

@ -31,7 +31,6 @@ export const updateUserInfos = gql`
$password: String $password: String
$passwordNew: String $passwordNew: String
$locale: String $locale: String
$coinanimation: Boolean
) { ) {
updateUserInfos( updateUserInfos(
firstName: $firstName firstName: $firstName
@ -39,7 +38,6 @@ export const updateUserInfos = gql`
password: $password password: $password
passwordNew: $passwordNew passwordNew: $passwordNew
language: $locale language: $locale
coinanimation: $coinanimation
) )
} }
` `

View File

@ -8,7 +8,6 @@ export const login = gql`
firstName firstName
lastName lastName
language language
coinanimation
klickTipp { klickTipp {
newsletterState newsletterState
} }
@ -26,7 +25,6 @@ export const verifyLogin = gql`
firstName firstName
lastName lastName
language language
coinanimation
klickTipp { klickTipp {
newsletterState newsletterState
} }

View File

@ -12,7 +12,6 @@ log4js.configure(options)
const apolloLogger = log4js.getLogger('apollo') const apolloLogger = log4js.getLogger('apollo')
const backendLogger = log4js.getLogger('backend') const backendLogger = log4js.getLogger('backend')
apolloLogger.addContext('user', 'unknown')
backendLogger.addContext('user', 'unknown') backendLogger.addContext('user', 'unknown')
export { apolloLogger, backendLogger } export { apolloLogger, backendLogger }

View File

@ -32,16 +32,16 @@ const logPlugin = {
requestDidStart(requestContext: any) { requestDidStart(requestContext: any) {
const { logger } = requestContext const { logger } = requestContext
const { query, mutation, variables } = requestContext.request const { query, mutation, variables } = requestContext.request
logger.trace(`Request: logger.info(`Request:
${mutation || query}variables: ${JSON.stringify(filterVariables(variables), null, 2)}`) ${mutation || query}variables: ${JSON.stringify(filterVariables(variables), null, 2)}`)
return { return {
willSendResponse(requestContext: any) { willSendResponse(requestContext: any) {
if (requestContext.context.user) logger.trace(`User ID: ${requestContext.context.user.id}`) if (requestContext.context.user) logger.info(`User ID: ${requestContext.context.user.id}`)
if (requestContext.response.data) if (requestContext.response.data)
logger.trace(`Response-Data: logger.info(`Response-Data:
${JSON.stringify(requestContext.response.data, null, 2)}`) ${JSON.stringify(requestContext.response.data, null, 2)}`)
if (requestContext.response.errors) if (requestContext.response.errors)
logger.trace(`Response-Errors: logger.error(`Response-Errors:
${JSON.stringify(requestContext.response.errors, null, 2)}`) ${JSON.stringify(requestContext.response.errors, null, 2)}`)
return requestContext return requestContext
}, },

View File

@ -1,33 +1,22 @@
import { EntityRepository, Repository } from '@dbTools/typeorm' import { EntityRepository, Repository } from '@dbTools/typeorm'
import { UserSetting } from '@entity/UserSetting' import { UserSetting } from '@entity/UserSetting'
import { Setting } from '@enum/Setting'
import { isStringBoolean } from '@/util/validate' import { isStringBoolean } from '@/util/validate'
@EntityRepository(UserSetting) @EntityRepository(UserSetting)
export class UserSettingRepository extends Repository<UserSetting> { export class UserSettingRepository extends Repository<UserSetting> {
async setOrUpdate(userId: number, key: Setting, value: string): Promise<UserSetting> { async setOrUpdate(userId: number, value: string): Promise<UserSetting> {
switch (key) { let entity = await this.findOne({ userId: userId })
case Setting.COIN_ANIMATION:
if (!isStringBoolean(value)) {
throw new Error("coinanimation value isn't boolean")
}
break
default:
throw new Error("key isn't defined: " + key)
}
let entity = await this.findOne({ userId: userId, key: key })
if (!entity) { if (!entity) {
entity = new UserSetting() entity = new UserSetting()
entity.userId = userId entity.userId = userId
entity.key = key
} }
entity.value = value entity.value = value
return this.save(entity) return this.save(entity)
} }
async readBoolean(userId: number, key: Setting): Promise<boolean> { async readBoolean(userId: number): Promise<boolean> {
const entity = await this.findOne({ userId: userId, key: key }) const entity = await this.findOne({ userId: userId })
if (!entity || !isStringBoolean(entity.value)) { if (!entity || !isStringBoolean(entity.value)) {
return true return true
} }

View File

@ -5,7 +5,7 @@
"main": "src/index.ts", "main": "src/index.ts",
"repository": "https://github.com/gradido/gradido/database", "repository": "https://github.com/gradido/gradido/database",
"author": "Ulf Gebhardt", "author": "Ulf Gebhardt",
"license": "MIT", "license": "Apache License 2.0",
"private": false, "private": false,
"scripts": { "scripts": {
"build": "mkdir -p build/src/config/ && cp src/config/*.txt build/src/config/ && tsc --build", "build": "mkdir -p build/src/config/ && cp src/config/*.txt build/src/config/ && tsc --build",

View File

@ -0,0 +1 @@
<mxfile host="Electron" modified="2022-05-23T15:29:00.513Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/16.0.2 Chrome/96.0.4664.55 Electron/16.0.5 Safari/537.36" etag="IpEbe50ld79E_2HLyFXN" version="16.0.2" type="device"><diagram id="LWCFUfVkWozhiXBGj4Ze" name="Page-1">7VxbU9s6EP41eaTju5NHEug5D7TDlHZanhhhK45AtjKyQpL++rNy5PgiJ4Rgx4c2M8xgrVe2tN/u6vNKMLAn8eofjuazLyzEdGAZ4WpgXw0syzQNC35JyXojGXqjjSDiJFRKheCO/MZKaCjpgoQ4rSgKxqgg86owYEmCA1GRIc7Zsqo2ZbT61jmKsCa4CxDVpT9JKGZqFq5RyP/FJJqJ7YTVnRjlykqQzlDIliWRfT2wJ5wxsbmKVxNMpfFyu2z6fd5xdzswjhNxSIcoffphXUeTWCx/jtyft/OXr+GFQucF0YWa8MDyKDxvPIMXeJG8+kzZMpghLkARUA5JyOBqwjEShCVp3gHeXPRRUxbr3I4Cr7KnipiCwITLVHD2jCeMMg6ShCWgOZ4SSmuidI4CkkQgcIvWdzYHwQVM2R4vZ0TgO5DLVy3BDUHGXjCf0szcMxKGOAEZZ4skxNIaxnaEoAYj22lRc4sTODhmMRZ8DSqqg+UoaJVv26q5LBzF9pVsVnKSvBtSvhltn1zABxcKwTeg6Tqa3XEI7qyajIsZi1iC6HUhrZml0LlhmY0lVE9YiLWKTbQQrAokXhHxS3b/5KrWfenO1Uo9OWusK9aXg9tve5gLW/AA75m0rbIC4hEWe/RMuxlMjik48kt1IK1DY2uBNmGJ4ORxoYKohlsVlSYXLyHQhi8bw4ovm5buzFtZ2Zm9zpzZ0IxyUmf2D/dmsDFf/yo37ot4kM2iW9bqIAqcU0VB1vWSc7QuKcwZSURaevKtFBTeZTpuLVPW1qqavm0N9+nDxWYEhXdtp/IOh7M/Svb8QP62AbKvrOuZR0AKRG0u704pXl1KCtkuzNYxOH8yHLOM9QVIzNfgzlq3mBMwJub9+UCvLuBbfUR1D1b2jXea+ajMblcpsOm+ktir6q7KuZ3mdWcv9YI7NyR57p+BudUl8n9AwNx+18NjEmUlSZ50QXRPRcDeh6n34TjOB4DU7ZXjHENbO+Y4x3w71XD2rL7pzaHwe1avEa2tbpdhTJLelzPPqzGD3tezoWap7xwlKQqaKzDpksQUbaqSwBfyeJLWC2aEhjdozRZyzKlAwXPeGs8YJ79BHxV1TsSFihnbqGjcyZ7qmRynoHOb29esib6gVUXxBqUiHw2jFM1T8piNT3aMwWVJMmZCsLgSF20SFL+h3Ombrg6oae9BVL3tGw4ESiKYQUEVvdr7hg0OZDQ4UP11iEJ6SJDAYxkCqeZHLVDMkeZaonCtB7GGXFt3L1UQP7QKjiiJEmhSPJXdJJAkQPRSiWMShpvEvqmP32RqV04h+aYM5OyojiuiD2Nzx/ADNpzIxdaFsU6gbRZt+JHqXACNhuEjkrkPBodcYumUsJAIJNDjNlwO8r23fDnurrc3OuA+/3tXRsk3qUq4L1LMH6DTGe7W4fZ6h9vU4A5KX5IPFL4jz9h3gv3oQOw721rzjtla64ZlF0XBLUO+rxDkzj+MTOtDUON8mAdvuv1ZlC8kHGcERIVsOyywvjWzDbkyLRs1peW8Y/s465ur52X4HanY3BG1u2lXM+CdrcN6RbeyDofA9c/Id4B8AwM7LfKWXu0I5DkkHD4g0THkQq7Px+NdB6lF/DvDu4F1NeJteV3h7Wl4xzhmZ6TbRto0vb6h9jWoUQxc+RzW7YPtWD2Dbep5PGYh5kiwM23rCnVv2PfqrVfge6if/I0BPzoQ+u6yu14hB+inhMdn6tYJ5PBd3jPktl4cLyB/XJ8hbx1yt2+67uh0vZLgT7AR9jfi7vfN3R2du3P8hANxjvSOKnB9E3jvmHNknW+HmP7gDRsiXZ8f8g7dJen3iLx/BJItojbo63TfwfBsstvpD1ZX91k857WT1VV9Vx3X6fRodW7DUuK/xzApQ77XMr7qlTp4KJmn0oe6P4JWP0HkmQ0EqekI2rCzXWT9C/hHivmfvhPZApZm/S8HjIZPWqcBy86OE/qN3zfn0yCt1LK8N5/8agS/s1KWr285k2m2JkQppDWOd+J+xF/A5y4QgM0kUdntBE05tbpWZxBtzgRYfkuxuT0Hl6PTdFLTbAceaBb/MmGzjBX/eMK+/g8=</diagram></mxfile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -99,5 +99,6 @@
"not ie <= 10" "not ie <= 10"
], ],
"author": "Gradido-Akademie - https://www.gradido.net/", "author": "Gradido-Akademie - https://www.gradido.net/",
"license": "Apache License 2.0",
"description": "Gradido, the Natural Economy of Life, is a way to worldwide prosperity and peace in harmony with nature. - Gradido, die Natürliche Ökonomie des lebens, ist ein Weg zu weltweitem Wohlstand und Frieden in Harmonie mit der Natur." "description": "Gradido, the Natural Economy of Life, is a way to worldwide prosperity and peace in harmony with nature. - Gradido, die Natürliche Ökonomie des lebens, ist ein Weg zu weltweitem Wohlstand und Frieden in Harmonie mit der Natur."
} }

View File

@ -1,127 +0,0 @@
import { mount } from '@vue/test-utils'
import UserCoinAnimation from './UserCoinAnimation'
import { updateUserInfos } from '@/graphql/mutations'
import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup'
const localVue = global.localVue
const mockAPIcall = jest.fn()
const storeCommitMock = jest.fn()
describe('UserCard_CoinAnimation', () => {
let wrapper
const mocks = {
$t: jest.fn((t) => t),
$store: {
state: {
language: 'de',
coinanimation: true,
},
commit: storeCommitMock,
},
$apollo: {
mutate: mockAPIcall,
},
}
const Wrapper = () => {
return mount(UserCoinAnimation, { localVue, mocks })
}
describe('mount', () => {
beforeEach(() => {
jest.clearAllMocks()
wrapper = Wrapper()
})
it('renders the component', () => {
expect(wrapper.find('div#formusercoinanimation').exists()).toBeTruthy()
})
it('has an edit BFormCheckbox switch', () => {
expect(wrapper.find('.Test-BFormCheckbox').exists()).toBeTruthy()
})
describe('enable with success', () => {
beforeEach(async () => {
await wrapper.setData({ CoinAnimationStatus: false })
mockAPIcall.mockResolvedValue({
data: {
updateUserInfos: {
validValues: 1,
},
},
})
await wrapper.find('input').setChecked()
})
it('calls the updateUserInfos mutation', () => {
expect(mockAPIcall).toBeCalledWith({
mutation: updateUserInfos,
variables: {
coinanimation: true,
},
})
})
it('updates the store', () => {
expect(storeCommitMock).toBeCalledWith('coinanimation', true)
})
it('toasts a success message', () => {
expect(toastSuccessSpy).toBeCalledWith('settings.coinanimation.True')
})
})
describe('disable with success', () => {
beforeEach(async () => {
await wrapper.setData({ CoinAnimationStatus: true })
mockAPIcall.mockResolvedValue({
data: {
updateUserInfos: {
validValues: 1,
},
},
})
await wrapper.find('input').setChecked(false)
})
it('calls the subscribe mutation', () => {
expect(mockAPIcall).toBeCalledWith({
mutation: updateUserInfos,
variables: {
coinanimation: false,
},
})
})
it('updates the store', () => {
expect(storeCommitMock).toBeCalledWith('coinanimation', false)
})
it('toasts a success message', () => {
expect(toastSuccessSpy).toBeCalledWith('settings.coinanimation.False')
})
})
describe('disable with server error', () => {
beforeEach(() => {
mockAPIcall.mockRejectedValue({
message: 'Ouch',
})
wrapper.find('input').trigger('change')
})
it('resets the CoinAnimationStatus', () => {
expect(wrapper.vm.CoinAnimationStatus).toBeTruthy()
})
it('toasts an error message', () => {
expect(toastErrorSpy).toBeCalledWith('Ouch')
})
})
})
})

View File

@ -1,65 +0,0 @@
<template>
<b-card
id="formusercoinanimation"
class="bg-transparent gradido-custom-background gradido-no-border-radius"
>
<div>
<b-row class="mb-3">
<b-col class="mb-2 col-12">
<small>
<b>{{ $t('settings.coinanimation.coinanimation') }}</b>
</small>
</b-col>
<b-col class="col-12">
<b-form-checkbox
class="Test-BFormCheckbox"
v-model="CoinAnimationStatus"
name="check-button"
switch
@change="onSubmit"
>
{{
CoinAnimationStatus
? $t('settings.coinanimation.True')
: $t('settings.coinanimation.False')
}}
</b-form-checkbox>
</b-col>
</b-row>
</div>
</b-card>
</template>
<script>
import { updateUserInfos } from '@/graphql/mutations'
export default {
name: 'UserCoinAnimation',
data() {
return {
CoinAnimationStatus: this.$store.state.coinanimation,
}
},
methods: {
async onSubmit() {
this.$apollo
.mutate({
mutation: updateUserInfos,
variables: {
coinanimation: this.CoinAnimationStatus,
},
})
.then(() => {
this.$store.commit('coinanimation', this.CoinAnimationStatus)
this.toastSuccess(
this.CoinAnimationStatus
? this.$t('settings.coinanimation.True')
: this.$t('settings.coinanimation.False'),
)
})
.catch((error) => {
this.CoinAnimationStatus = this.$store.state.coinanimation
this.toastError(error.message)
})
},
},
}
</script>

View File

@ -31,7 +31,6 @@ export const updateUserInfos = gql`
$password: String $password: String
$passwordNew: String $passwordNew: String
$locale: String $locale: String
$coinanimation: Boolean
) { ) {
updateUserInfos( updateUserInfos(
firstName: $firstName firstName: $firstName
@ -39,7 +38,6 @@ export const updateUserInfos = gql`
password: $password password: $password
passwordNew: $passwordNew passwordNew: $passwordNew
language: $locale language: $locale
coinanimation: $coinanimation
) )
} }
` `

View File

@ -7,7 +7,6 @@ export const login = gql`
firstName firstName
lastName lastName
language language
coinanimation
klickTipp { klickTipp {
newsletterState newsletterState
} }
@ -25,7 +24,6 @@ export const verifyLogin = gql`
firstName firstName
lastName lastName
language language
coinanimation
klickTipp { klickTipp {
newsletterState newsletterState
} }

View File

@ -186,11 +186,6 @@
"send_gdd": "GDD versenden", "send_gdd": "GDD versenden",
"send_per_link": "GDD versenden per Link", "send_per_link": "GDD versenden per Link",
"settings": { "settings": {
"coinanimation": {
"coinanimation": "Münzanimation",
"False": "Münzanimation ausgeschaltet",
"True": "Münzanimation eingeschaltet"
},
"language": { "language": {
"changeLanguage": "Sprache ändern", "changeLanguage": "Sprache ändern",
"de": "Deutsch", "de": "Deutsch",

View File

@ -186,11 +186,6 @@
"send_gdd": "GDD send", "send_gdd": "GDD send",
"send_per_link": "GDD send via link", "send_per_link": "GDD send via link",
"settings": { "settings": {
"coinanimation": {
"coinanimation": "Coin animation",
"False": "Coin animation disabled",
"True": "Coin animation enabled"
},
"language": { "language": {
"changeLanguage": "Change language", "changeLanguage": "Change language",
"de": "Deutsch", "de": "Deutsch",

View File

@ -38,9 +38,5 @@ describe('Profile', () => {
it('has a user change newsletter form', () => { it('has a user change newsletter form', () => {
expect(wrapper.findComponent({ name: 'UserNewsletter' }).exists()).toBeTruthy() expect(wrapper.findComponent({ name: 'UserNewsletter' }).exists()).toBeTruthy()
}) })
it('has a user change coin animation form', () => {
expect(wrapper.findComponent({ name: 'UserCoinAnimation' }).exists()).toBeTruthy()
})
}) })
}) })

View File

@ -8,8 +8,6 @@
<user-language /> <user-language />
<hr /> <hr />
<user-newsletter /> <user-newsletter />
<hr />
<user-coin-animation />
</div> </div>
</template> </template>
<script> <script>
@ -18,7 +16,6 @@ import UserData from '@/components/UserSettings/UserData.vue'
import UserPassword from '@/components/UserSettings/UserPassword.vue' import UserPassword from '@/components/UserSettings/UserPassword.vue'
import UserLanguage from '@/components/UserSettings/UserLanguage.vue' import UserLanguage from '@/components/UserSettings/UserLanguage.vue'
import UserNewsletter from '@/components/UserSettings/UserNewsletter.vue' import UserNewsletter from '@/components/UserSettings/UserNewsletter.vue'
import UserCoinAnimation from '@/components/UserSettings/UserCoinAnimation.vue'
export default { export default {
name: 'Profile', name: 'Profile',
@ -28,7 +25,6 @@ export default {
UserPassword, UserPassword,
UserLanguage, UserLanguage,
UserNewsletter, UserNewsletter,
UserCoinAnimation,
}, },
props: { props: {
balance: { type: Number, default: 0 }, balance: { type: Number, default: 0 },

View File

@ -38,9 +38,6 @@ export const mutations = {
isAdmin: (state, isAdmin) => { isAdmin: (state, isAdmin) => {
state.isAdmin = !!isAdmin state.isAdmin = !!isAdmin
}, },
coinanimation: (state, coinanimation) => {
state.coinanimation = coinanimation
},
hasElopage: (state, hasElopage) => { hasElopage: (state, hasElopage) => {
state.hasElopage = hasElopage state.hasElopage = hasElopage
}, },
@ -53,7 +50,6 @@ export const actions = {
// commit('username', data.username) // commit('username', data.username)
commit('firstName', data.firstName) commit('firstName', data.firstName)
commit('lastName', data.lastName) commit('lastName', data.lastName)
commit('coinanimation', data.coinanimation)
commit('newsletterState', data.klickTipp.newsletterState) commit('newsletterState', data.klickTipp.newsletterState)
commit('hasElopage', data.hasElopage) commit('hasElopage', data.hasElopage)
commit('publisherId', data.publisherId) commit('publisherId', data.publisherId)
@ -65,7 +61,6 @@ export const actions = {
// commit('username', '') // commit('username', '')
commit('firstName', '') commit('firstName', '')
commit('lastName', '') commit('lastName', '')
commit('coinanimation', true)
commit('newsletterState', null) commit('newsletterState', null)
commit('hasElopage', false) commit('hasElopage', false)
commit('publisherId', null) commit('publisherId', null)
@ -91,7 +86,6 @@ try {
// username: '', // username: '',
token: null, token: null,
isAdmin: false, isAdmin: false,
coinanimation: true,
newsletterState: null, newsletterState: null,
hasElopage: false, hasElopage: false,
publisherId: null, publisherId: null,

View File

@ -20,7 +20,6 @@ const {
token, token,
firstName, firstName,
lastName, lastName,
coinanimation,
newsletterState, newsletterState,
publisherId, publisherId,
isAdmin, isAdmin,
@ -78,14 +77,6 @@ describe('Vuex store', () => {
}) })
}) })
describe('coinanimation', () => {
it('sets the state of coinanimation', () => {
const state = { coinanimation: true }
coinanimation(state, false)
expect(state.coinanimation).toEqual(false)
})
})
describe('newsletterState', () => { describe('newsletterState', () => {
it('sets the state of newsletterState', () => { it('sets the state of newsletterState', () => {
const state = { newsletterState: null } const state = { newsletterState: null }
@ -134,7 +125,6 @@ describe('Vuex store', () => {
language: 'de', language: 'de',
firstName: 'Peter', firstName: 'Peter',
lastName: 'Lustig', lastName: 'Lustig',
coinanimation: false,
klickTipp: { klickTipp: {
newsletterState: true, newsletterState: true,
}, },
@ -145,7 +135,7 @@ describe('Vuex store', () => {
it('calls nine commits', () => { it('calls nine commits', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenCalledTimes(9) expect(commit).toHaveBeenCalledTimes(8)
}) })
it('commits email', () => { it('commits email', () => {
@ -168,29 +158,24 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', 'Lustig') expect(commit).toHaveBeenNthCalledWith(4, 'lastName', 'Lustig')
}) })
it('commits coinanimation', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', false)
})
it('commits newsletterState', () => { it('commits newsletterState', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', true) expect(commit).toHaveBeenNthCalledWith(5, 'newsletterState', true)
}) })
it('commits hasElopage', () => { it('commits hasElopage', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false) expect(commit).toHaveBeenNthCalledWith(6, 'hasElopage', false)
}) })
it('commits publisherId', () => { it('commits publisherId', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', 1234) expect(commit).toHaveBeenNthCalledWith(7, 'publisherId', 1234)
}) })
it('commits isAdmin', () => { it('commits isAdmin', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', true) expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', true)
}) })
}) })
@ -200,7 +185,7 @@ describe('Vuex store', () => {
it('calls nine commits', () => { it('calls nine commits', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(9) expect(commit).toHaveBeenCalledTimes(8)
}) })
it('commits token', () => { it('commits token', () => {
@ -223,29 +208,24 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', '') expect(commit).toHaveBeenNthCalledWith(4, 'lastName', '')
}) })
it('commits coinanimation', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', true)
})
it('commits newsletterState', () => { it('commits newsletterState', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', null) expect(commit).toHaveBeenNthCalledWith(5, 'newsletterState', null)
}) })
it('commits hasElopage', () => { it('commits hasElopage', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false) expect(commit).toHaveBeenNthCalledWith(6, 'hasElopage', false)
}) })
it('commits publisherId', () => { it('commits publisherId', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', null) expect(commit).toHaveBeenNthCalledWith(7, 'publisherId', null)
}) })
it('commits isAdmin', () => { it('commits isAdmin', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', false) expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', false)
}) })
// how to get this working? // how to get this working?

View File

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"repository": "git@github.com:gradido/gradido.git", "repository": "git@github.com:gradido/gradido.git",
"author": "Ulf Gebhardt <ulf.gebhardt@webcraft-media.de>", "author": "Ulf Gebhardt <ulf.gebhardt@webcraft-media.de>",
"license": "MIT", "license": "Apache License 2.0",
"scripts": { "scripts": {
"release": "scripts/release.sh" "release": "scripts/release.sh"
}, },