mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Migrate PRs from archived repos to monorepo
Co-authored-by: Joseph Ngugi <jngugi88@gmail.com>
This commit is contained in:
parent
3a768a66d5
commit
aca3562e22
@ -57,6 +57,7 @@ const permissions = shield({
|
|||||||
UpdateBadge: isAdmin,
|
UpdateBadge: isAdmin,
|
||||||
DeleteBadge: isAdmin,
|
DeleteBadge: isAdmin,
|
||||||
AddUserBadges: isAdmin,
|
AddUserBadges: isAdmin,
|
||||||
|
addSocialMedia: isAuthenticated,
|
||||||
// AddBadgeRewarded: isAdmin,
|
// AddBadgeRewarded: isAdmin,
|
||||||
// RemoveBadgeRewarded: isAdmin,
|
// RemoveBadgeRewarded: isAdmin,
|
||||||
reward: isAdmin,
|
reward: isAdmin,
|
||||||
|
|||||||
@ -100,6 +100,25 @@ export default {
|
|||||||
|
|
||||||
return encode(currentUser)
|
return encode(currentUser)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
addSocialMedia: async (_, { url }, { driver, user }) => {
|
||||||
|
const session = driver.session()
|
||||||
|
|
||||||
|
const { email } = user
|
||||||
|
const result = await session.run(
|
||||||
|
`MATCH (user:User {email: $userEmail})
|
||||||
|
SET user.socialMedia = [$url]
|
||||||
|
RETURN user {.socialMedia}`,
|
||||||
|
{
|
||||||
|
userEmail: email,
|
||||||
|
url
|
||||||
|
}
|
||||||
|
)
|
||||||
|
session.close()
|
||||||
|
const [currentUser] = result.records.map(record => {
|
||||||
|
return record.get('user')
|
||||||
|
})
|
||||||
|
return !!currentUser.socialMedia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ type Mutation {
|
|||||||
disable(id: ID!): ID
|
disable(id: ID!): ID
|
||||||
enable(id: ID!): ID
|
enable(id: ID!): ID
|
||||||
reward(fromBadgeId: ID!, toUserId: ID!): ID
|
reward(fromBadgeId: ID!, toUserId: ID!): ID
|
||||||
|
addSocialMedia(url: String!): Boolean!
|
||||||
unreward(fromBadgeId: ID!, toUserId: ID!): ID
|
unreward(fromBadgeId: ID!, toUserId: ID!): ID
|
||||||
"Shout the given Type and ID"
|
"Shout the given Type and ID"
|
||||||
shout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """
|
shout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """
|
||||||
@ -120,6 +121,7 @@ type User {
|
|||||||
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
||||||
locationName: String
|
locationName: String
|
||||||
about: String
|
about: String
|
||||||
|
socialMedia: [String]
|
||||||
|
|
||||||
createdAt: String
|
createdAt: String
|
||||||
updatedAt: String
|
updatedAt: String
|
||||||
|
|||||||
14
cypress/integration/SocialMedia.feature
Normal file
14
cypress/integration/SocialMedia.feature
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Feature: List Social Media Accounts
|
||||||
|
As a User
|
||||||
|
I'd like to enter my social media
|
||||||
|
So I can show them to other users to get in contact
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given I have a user account
|
||||||
|
And I am logged in
|
||||||
|
And I am on the "settings" page
|
||||||
|
|
||||||
|
Scenario: Adding Social Media
|
||||||
|
Given I click on the "My social media" link
|
||||||
|
Then I should be on the "/settings/my-social-media" page
|
||||||
|
And I should be able to add a social media link
|
||||||
@ -61,3 +61,30 @@ Then(
|
|||||||
'I can see my new name {string} when I click on my profile picture in the top right',
|
'I can see my new name {string} when I click on my profile picture in the top right',
|
||||||
name => matchNameInUserMenu(name)
|
name => matchNameInUserMenu(name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
When('I click on the {string} link', link => {
|
||||||
|
cy.get('a')
|
||||||
|
.contains(link)
|
||||||
|
.click()
|
||||||
|
})
|
||||||
|
|
||||||
|
Then('I should be on the {string} page', page => {
|
||||||
|
cy.location()
|
||||||
|
.should(loc => {
|
||||||
|
expect(loc.pathname).to.eq(page)
|
||||||
|
})
|
||||||
|
.get('h3')
|
||||||
|
.should('contain', 'My social media')
|
||||||
|
})
|
||||||
|
|
||||||
|
Then('I should be able to add a social media link', () => {
|
||||||
|
cy.get("input[name='social-media']")
|
||||||
|
.type('https://freeradical.zone/@mattwr18')
|
||||||
|
.get('button')
|
||||||
|
.contains('Add social media')
|
||||||
|
.click()
|
||||||
|
.get('.iziToast-message')
|
||||||
|
.should('contain', 'Updated user')
|
||||||
|
.get('a')
|
||||||
|
.contains("src='https://freeradical.zone/@mattwr18'")
|
||||||
|
})
|
||||||
|
|||||||
@ -47,6 +47,11 @@
|
|||||||
},
|
},
|
||||||
"languages": {
|
"languages": {
|
||||||
"name": "Languages"
|
"name": "Languages"
|
||||||
|
},
|
||||||
|
"social-media": {
|
||||||
|
"name": "My social media",
|
||||||
|
"submit": "Add social media",
|
||||||
|
"success": "Updated user"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
|
|||||||
@ -54,6 +54,10 @@ export default {
|
|||||||
{
|
{
|
||||||
name: this.$t('settings.languages.name'),
|
name: this.$t('settings.languages.name'),
|
||||||
path: `/settings/languages`
|
path: `/settings/languages`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: this.$t('settings.social-media.name'),
|
||||||
|
path: `/settings/my-social-media`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
75
webapp/pages/settings/my-social-media.vue
Normal file
75
webapp/pages/settings/my-social-media.vue
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<template>
|
||||||
|
<ds-card :header="$t('settings.social-media.name')">
|
||||||
|
<div>
|
||||||
|
<ds-input
|
||||||
|
v-model="value"
|
||||||
|
placeholder="Add social media url"
|
||||||
|
name="social-media"
|
||||||
|
:schema="{type: 'url'}"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<ds-space margin-top="base">
|
||||||
|
<div>
|
||||||
|
<ds-button
|
||||||
|
primary
|
||||||
|
@click="handleAddSocialMedia"
|
||||||
|
>
|
||||||
|
{{ $t('settings.social-media.submit') }}
|
||||||
|
</ds-button>
|
||||||
|
</div>
|
||||||
|
</ds-space>
|
||||||
|
<ds-space
|
||||||
|
v-if="currentUser.socialMedia && currentUser.socialMedia.length"
|
||||||
|
margin-top="base"
|
||||||
|
margin="x-small"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<img
|
||||||
|
:src="currentUser.socialMedia[0] + '/favicon.ico'"
|
||||||
|
alt=""
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</ds-space>
|
||||||
|
</ds-card>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import gql from 'graphql-tag'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
socialMedia: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
currentUser: 'auth/user'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleAddSocialMedia() {
|
||||||
|
this.$apollo
|
||||||
|
.mutate({
|
||||||
|
mutation: gql`
|
||||||
|
mutation($url: String!) {
|
||||||
|
addSocialMedia(url: $url)
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
variables: {
|
||||||
|
url: this.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() =>
|
||||||
|
this.$toast.success(this.$t('settings.social-media.success'))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -83,6 +83,7 @@ export const actions = {
|
|||||||
role
|
role
|
||||||
about
|
about
|
||||||
locationName
|
locationName
|
||||||
|
socialMedia
|
||||||
}
|
}
|
||||||
}`)
|
}`)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user