Merge pull request #2101 from Human-Connection/1747-show-shouts

1747 show shouts
This commit is contained in:
Robert Schäfer 2019-11-18 17:00:43 +01:00 committed by GitHub
commit 735a31ed00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 101 additions and 1 deletions

View File

@ -127,6 +127,10 @@ module.exports = {
type: 'boolean',
default: false,
},
showShoutsPublicly: {
type: 'boolean',
default: false,
},
locale: {
type: 'string',
allow: [null],

View File

@ -177,6 +177,7 @@ export default {
'termsAndConditionsAgreedVersion',
'termsAndConditionsAgreedAt',
'allowEmbedIframes',
'showShoutsPublicly',
'locale',
],
boolean: {

View File

@ -28,6 +28,7 @@ type User {
termsAndConditionsAgreedAt: String
allowEmbedIframes: Boolean
showShoutsPublicly: Boolean
locale: String
friends: [User]! @relation(name: "FRIENDS", direction: "BOTH")
friendsCount: Int! @cypher(statement: "MATCH (this)<-[: FRIENDS]->(r: User) RETURN COUNT(DISTINCT r)")
@ -170,6 +171,8 @@ type Mutation {
termsAndConditionsAgreedVersion: String
termsAndConditionsAgreedAt: String
allowEmbedIframes: Boolean
showShoutsPublicly: Boolean
locale: String
): User

View File

@ -17,6 +17,7 @@ export default function create() {
termsAndConditionsAgreedVersion: '0.0.1',
termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z',
allowEmbedIframes: false,
showShoutsPublicly: false,
locale: 'en',
}
defaults.slug = slugify(defaults.name, { lower: true })

View File

@ -27,6 +27,7 @@ export default i18n => {
id
url
}
showShoutsPublicly
}
}
`
@ -148,6 +149,17 @@ export const allowEmbedIframesMutation = () => {
`
}
export const showShoutsPubliclyMutation = () => {
return gql`
mutation($id: ID!, $showShoutsPublicly: Boolean) {
UpdateUser(id: $id, showShoutsPublicly: $showShoutsPublicly) {
id
showShoutsPublicly
}
}
`
}
export const checkSlugAvailableQuery = gql`
query($slug: String!) {
User(slug: $slug) {

View File

@ -256,6 +256,11 @@
"passwordStrength4": "Sehr sicheres Passwort"
}
},
"privacy": {
"name": "Privatsphäre",
"make-shouts-public": "Teile von mir empfohlene Artikel öffentlich auf meinem Profil",
"success-update": "Privatsphäre-Einstellungen gespeichert"
},
"invites": {
"name": "Einladungen"
},

View File

@ -257,6 +257,11 @@
"passwordStrength4": "Very strong password"
}
},
"privacy": {
"name": "Privacy",
"make-shouts-public": "Share articles I have shouted on my public profile",
"success-update": "Privacy settings saved"
},
"invites": {
"name": "Invites"
},

View File

@ -259,6 +259,11 @@
"passwordStrength4": "Senha muito forte"
}
},
"privacy": {
"name": "Privacidade",
"make-shouts-public": "Compartilhar postagens que eu recomendei no meu perfil público",
"success-update": "Configurações de privacidade salvas"
},
"invites": {
"name": "Convites"
},

View File

@ -197,7 +197,7 @@
<li
class="Tabs__tab pointer"
:class="{ active: tabActive === 'shout' }"
v-if="myProfile"
v-if="myProfile || user.showShoutsPublicly"
>
<a @click="handleTab('shout')">
<ds-space margin="small">

View File

@ -31,6 +31,10 @@ export default {
name: this.$t('settings.security.name'),
path: `/settings/security`,
},
{
name: this.$t('settings.privacy.name'),
path: 'settings/privacy',
},
{
name: this.$t('settings.social-media.name'),
path: `/settings/my-social-media`,

View File

@ -0,0 +1,59 @@
<template>
<ds-card :header="$t('settings.privacy.name')">
<ds-space margin-bottom="small">
<input id="allow-shouts" type="checkbox" v-model="shoutsAllowed" />
<label for="allow-shouts">{{ $t('settings.privacy.make-shouts-public') }}</label>
</ds-space>
<ds-button primary @click="submit" :disabled="disabled">{{ $t('actions.save') }}</ds-button>
</ds-card>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { showShoutsPubliclyMutation } from '~/graphql/User'
export default {
data() {
return {
shoutsAllowed: false,
}
},
computed: {
...mapGetters({
currentUser: 'auth/user',
}),
disabled() {
return this.shoutsAllowed === this.currentUser.showShoutsPublicly
},
},
created() {
this.shoutsAllowed = this.currentUser.showShoutsPublicly || false
},
methods: {
...mapMutations({
setCurrentUser: 'auth/SET_USER',
}),
async submit() {
try {
await this.$apollo.mutate({
mutation: showShoutsPubliclyMutation(),
variables: {
id: this.currentUser.id,
showShoutsPublicly: this.shoutsAllowed,
},
update: (_, { data: { UpdateUser } }) => {
const { showShoutsPublicly } = UpdateUser
this.setCurrentUser({
...this.currentUser,
showShoutsPublicly,
})
this.$toast.success(this.$t('settings.privacy.success-update'))
},
})
} catch (error) {
this.$toast.error(error.message)
}
},
},
}
</script>

View File

@ -88,6 +88,7 @@ export const actions = {
contributionsCount
commentedCount
allowEmbedIframes
showShoutsPublicly
termsAndConditionsAgreedVersion
socialMedia {
id