diff --git a/backend/src/apis/humhub/HumHubClient.ts b/backend/src/apis/humhub/HumHubClient.ts index a78a0915e..dbada6ac3 100644 --- a/backend/src/apis/humhub/HumHubClient.ts +++ b/backend/src/apis/humhub/HumHubClient.ts @@ -125,6 +125,7 @@ export class HumHubClient { * @param user for saving on humhub instance */ public async createUser(user: PostUser): Promise { + logger.info('create new humhub user', user) const options = await this.createRequestOptions() try { const response = await this.restClient.create('/api/v1/user', user, options) @@ -147,6 +148,7 @@ export class HumHubClient { * @returns updated user object on success */ public async updateUser(user: PostUser, humhubUserId: number): Promise { + logger.info('update humhub user', user) const options = await this.createRequestOptions() const response = await this.restClient.update( `/api/v1/user/${humhubUserId}`, @@ -162,6 +164,7 @@ export class HumHubClient { } public async deleteUser(humhubUserId: number): Promise { + logger.info('delete humhub user', { userId: humhubUserId }) const options = await this.createRequestOptions() const response = await this.restClient.del(`/api/v1/user/${humhubUserId}`, options) if (response.statusCode === 400) { diff --git a/backend/src/graphql/resolver/util/syncHumhub.test.ts b/backend/src/graphql/resolver/util/syncHumhub.test.ts index a5a8a87e4..c25eb52a8 100644 --- a/backend/src/graphql/resolver/util/syncHumhub.test.ts +++ b/backend/src/graphql/resolver/util/syncHumhub.test.ts @@ -3,7 +3,6 @@ import { UserContact } from '@entity/UserContact' import { HumHubClient } from '@/apis/humhub/HumHubClient' import { GetUser } from '@/apis/humhub/model/GetUser' -import { ExecutedHumhubAction } from '@/apis/humhub/syncUser' import { UpdateUserInfosArgs } from '@/graphql/arg/UpdateUserInfosArgs' import { PublishNameType } from '@/graphql/enum/PublishNameType' import { backendLogger as logger } from '@/server/logger' @@ -28,9 +27,6 @@ describe('syncHumhub', () => { jest.spyOn(HumHubClient, 'getInstance') }) - afterEach(() => { - // humhubClientMockbAfterEach() - }) afterAll(() => { jest.resetAllMocks() }) @@ -39,7 +35,7 @@ describe('syncHumhub', () => { await syncHumhub(mockUpdateUserInfosArg, new User()) expect(HumHubClient.getInstance).not.toBeCalled() // language logging from some other place - expect(logger.debug).toBeCalledTimes(4) + expect(logger.debug).toBeCalledTimes(5) expect(logger.info).toBeCalledTimes(0) }) @@ -47,11 +43,11 @@ describe('syncHumhub', () => { mockUpdateUserInfosArg.firstName = 'New' // Relevant changes mockUser.firstName = 'New' await syncHumhub(mockUpdateUserInfosArg, mockUser) - expect(logger.debug).toHaveBeenCalledTimes(7) // Four language logging calls, two debug calls in function, one for not syncing + expect(logger.debug).toHaveBeenCalledTimes(8) // Four language logging calls, two debug calls in function, one for not syncing expect(logger.info).toHaveBeenLastCalledWith('finished sync user with humhub', { localId: mockUser.id, externId: mockHumHubUser.id, - result: ExecutedHumhubAction.UPDATE, + result: 'UPDATE', }) }) diff --git a/backend/src/graphql/resolver/util/syncHumhub.ts b/backend/src/graphql/resolver/util/syncHumhub.ts index 1ed1af7ab..7a964331c 100644 --- a/backend/src/graphql/resolver/util/syncHumhub.ts +++ b/backend/src/graphql/resolver/util/syncHumhub.ts @@ -2,7 +2,7 @@ import { User } from '@entity/User' import { HumHubClient } from '@/apis/humhub/HumHubClient' import { GetUser } from '@/apis/humhub/model/GetUser' -import { syncUser } from '@/apis/humhub/syncUser' +import { ExecutedHumhubAction, syncUser } from '@/apis/humhub/syncUser' import { UpdateUserInfosArgs } from '@/graphql/arg/UpdateUserInfosArgs' import { backendLogger as logger } from '@/server/logger' @@ -12,13 +12,14 @@ export async function syncHumhub( ): Promise { // check for humhub relevant changes if ( - !updateUserInfosArg.alias && - !updateUserInfosArg.firstName && - !updateUserInfosArg.lastName && - !updateUserInfosArg.humhubAllowed && - !updateUserInfosArg.humhubPublishName && - !updateUserInfosArg.language + updateUserInfosArg.alias === undefined && + updateUserInfosArg.firstName === undefined && + updateUserInfosArg.lastName === undefined && + updateUserInfosArg.humhubAllowed === undefined && + updateUserInfosArg.humhubPublishName === undefined && + updateUserInfosArg.language === undefined ) { + logger.debug('no relevant changes') return } logger.debug('changed user-settings relevant for humhub-user update...') @@ -37,6 +38,9 @@ export async function syncHumhub( logger.info('finished sync user with humhub', { localId: user.id, externId: humhubUser?.id, - result, + // for preventing this warning https://github.com/eslint-community/eslint-plugin-security/blob/main/docs/rules/detect-object-injection.md + // and possible danger coming with it + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + result: ExecutedHumhubAction[result as ExecutedHumhubAction], }) } diff --git a/frontend/src/components/UserSettings/UserNamingFormat.vue b/frontend/src/components/UserSettings/UserNamingFormat.vue index 2879e37e0..e5c5740ab 100644 --- a/frontend/src/components/UserSettings/UserNamingFormat.vue +++ b/frontend/src/components/UserSettings/UserNamingFormat.vue @@ -58,7 +58,10 @@ export default { }, computed: { selectedOptionLabel() { - return this.dropdownOptions.find((option) => option.value === this.selectedOption).label + const selected = this.dropdownOptions.find((option) => option.value === this.selectedOption) + .label + return selected || this.$t('settings.publish-name.alias-or-initials') + // return this.dropdownOptions.find((option) => option.value === this.selectedOption).label }, }, methods: { diff --git a/frontend/src/components/UserSettings/UserSettingsSwitch.vue b/frontend/src/components/UserSettings/UserSettingsSwitch.vue index 53d0f6df8..dfa4e5260 100644 --- a/frontend/src/components/UserSettings/UserSettingsSwitch.vue +++ b/frontend/src/components/UserSettings/UserSettingsSwitch.vue @@ -4,6 +4,7 @@ test="BFormCheckbox" v-model="value" name="check-button" + :disabled="disabled" switch @change="onChange" > @@ -19,6 +20,7 @@ export default { attrName: { type: String }, enabledText: { type: String }, disabledText: { type: String }, + disabled: { type: Boolean, default: false }, }, data() { return { @@ -27,6 +29,7 @@ export default { }, methods: { async onChange() { + if (this.isDisabled) return const variables = [] variables[this.attrName] = this.value this.$apollo diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index ed55a0990..5a13e9572 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -8,7 +8,7 @@ "GDD": "GDD", "GDT": "GDT", "GMS": { - "title": "Geo Matching System GMS", + "title": "Geo Matching System GMS (in Entwicklung)", "desc": "Finde Mitglieder aller Communities auf einer Landkarte." }, "Humhub": { @@ -316,8 +316,8 @@ "label": "Positionsbestimmung", "button": "Klick mich!" }, - "location-format": "Positionstyp", - "naming-format": "Namensformat im GMS", + "location-format": "Position auf Karte anzeigen:", + "naming-format": "Namen anzeigen:", "publish-location": { "exact": "Genaue Position", "approximate": "Ungefähre Position", @@ -326,19 +326,17 @@ }, "publish-name": { "updated": "Namensformat für GMS aktualisiert" - }, - "switch": "Erlaubnis Daten nach GMS zu exportieren." + } }, "hideAmountGDD": "Dein GDD Betrag ist versteckt.", "hideAmountGDT": "Dein GDT Betrag ist versteckt.", "humhub": { "disabled": "Daten werden nicht in die Gradido Community exportiert", "enabled": "Daten werden in die Gradido Community exportiert", - "naming-format": "Namensformat in der Gradido Community", + "naming-format": "Namen anzeigen:", "publish-name": { "updated": "Namensformat für die Gradido Community aktualisiert." - }, - "switch": "Erlaubnis Daten in die Gradido Community zu exportieren." + } }, "info": "Transaktionen können nun per Benutzername oder E-Mail-Adresse getätigt werden.", "language": { @@ -378,7 +376,7 @@ "subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen." }, "publish-name": { - "alias-or-initials": "Benutzername oder Initialen (Default)", + "alias-or-initials": "Benutzername oder Initialen", "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", "first": "Vorname", "first-tooltip": "Nur der Vornamen", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 9bd79448a..c9e8ce824 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -8,7 +8,7 @@ "GDD": "GDD", "GDT": "GDT", "GMS": { - "title": "Geo Matching System GMS", + "title": "Geo Matching System GMS (in develop)", "desc": "Find members of all communities on a map." }, "Humhub": { @@ -316,8 +316,8 @@ "label": "pinpoint location", "button": "click me!" }, - "location-format": "location type", - "naming-format": "Format of name in GMS", + "location-format": "Show position on map:", + "naming-format": "Show Name:", "publish-location": { "exact": "exact position", "approximate": "approximate position", @@ -326,19 +326,17 @@ }, "publish-name": { "updated": "format of name for GMS updated" - }, - "switch": "Allow data export to GMS" + } }, "hideAmountGDD": "Your GDD amount is hidden.", "hideAmountGDT": "Your GDT amount is hidden.", "humhub": { "disabled": "Data not exported into the Gradido Community", "enabled": "Data exported into the Gradido Community", - "naming-format": "Format of name in the Gradido Community", + "naming-format": "Show Name:", "publish-name": { "updated": "Format of name for the Gradido Community updated." - }, - "switch": "Allow data export into the Gradido Community." + } }, "info": "Transactions can now be made by username or email address.", "language": { diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index 14a1df920..7cd6e96f2 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -82,26 +82,52 @@
{{ $t('settings.allow-community-services') }}
-
-
{{ $t('GMS.title') }}
-
{{ $t('GMS.desc') }}
- +
+ - {{ $t('settings.GMS.switch') }} -
- {{ gmsAllowed ? $t('settings.GMS.enabled') : $t('settings.GMS.disabled') }} -
+
{{ $t('Humhub.title') }}
+
+ + + +
+
{{ $t('Humhub.desc') }}
+ + + {{ $t('settings.humhub.naming-format') }} + + + + + +
+
+ + +
{{ $t('GMS.title') }}
+
{{ $t('GMS.desc') }}
@@ -133,41 +159,6 @@
-
-
{{ $t('Humhub.title') }}
-
{{ $t('Humhub.desc') }}
- - - {{ $t('settings.humhub.switch') }} -
- {{ - humhubAllowed ? $t('settings.humhub.enabled') : $t('settings.humhub.disabled') - }} -
-
- - - -
- - - {{ $t('settings.humhub.naming-format') }} - - - - - -
@@ -292,7 +283,7 @@ export default {