From 38100b2df7cfae7bfcacb504841f57cd4fad2c7d Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Thu, 8 Aug 2019 11:04:41 +0200 Subject: [PATCH 01/47] add masonry grid --- webapp/components/PostCard/index.vue | 34 +++++++++++++++++++++++++--- webapp/pages/index.vue | 28 ++++++++++++++++++----- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/webapp/components/PostCard/index.vue b/webapp/components/PostCard/index.vue index 3fee24176..a7bdbe68b 100644 --- a/webapp/components/PostCard/index.vue +++ b/webapp/components/PostCard/index.vue @@ -1,5 +1,5 @@ - + diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 683e5eb65..868b01836 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -1,10 +1,10 @@ diff --git a/webapp/graphql/PostCommentsQuery.js b/webapp/graphql/PostCommentsQuery.js deleted file mode 100644 index 08c8ea4ea..000000000 --- a/webapp/graphql/PostCommentsQuery.js +++ /dev/null @@ -1,39 +0,0 @@ -import gql from 'graphql-tag' - -export default i18n => { - const lang = i18n.locale().toUpperCase() - return gql(` - query Post($slug: String!) { - Post(slug: $slug) { - comments(orderBy: createdAt_asc) { - id - contentExcerpt - content - createdAt - disabled - deleted - author { - id - slug - name - avatar - disabled - deleted - shoutedCount - contributionsCount - commentsCount - followedByCount - followedByCurrentUser - location { - name: name${lang} - } - badges { - id - icon - } - } - } - } - } - `) -} diff --git a/webapp/graphql/PostQuery.js b/webapp/graphql/PostQuery.js index 9d54a5d2b..88c32b120 100644 --- a/webapp/graphql/PostQuery.js +++ b/webapp/graphql/PostQuery.js @@ -37,9 +37,10 @@ export default i18n => { name } commentsCount - comments(orderBy: createdAt_desc) { + comments(orderBy: createdAt_asc) { id contentExcerpt + content createdAt disabled deleted diff --git a/webapp/graphql/UserProfile/User.js b/webapp/graphql/User.js similarity index 98% rename from webapp/graphql/UserProfile/User.js rename to webapp/graphql/User.js index 9febce142..9de986a8a 100644 --- a/webapp/graphql/UserProfile/User.js +++ b/webapp/graphql/User.js @@ -2,7 +2,7 @@ import gql from 'graphql-tag' export default i18n => { const lang = i18n.locale().toUpperCase() - return gql(` + return gql` query User($id: ID!) { User(id: $id) { id @@ -73,5 +73,5 @@ export default i18n => { } } } - `) + ` } diff --git a/webapp/graphql/UserProfile/Post.js b/webapp/graphql/UserProfile/Post.js deleted file mode 100644 index c33572a9e..000000000 --- a/webapp/graphql/UserProfile/Post.js +++ /dev/null @@ -1,38 +0,0 @@ -import gql from 'graphql-tag' - -export default i18n => { - const lang = i18n.locale().toUpperCase() - return gql(` - query Post($filter: _PostFilter, $first: Int, $offset: Int) { - Post(filter: $filter, first: $first, offset: $offset, orderBy: createdAt_desc) { - id - slug - title - contentExcerpt - shoutedCount - commentsCount - deleted - image - createdAt - disabled - deleted - categories { - id - name - icon - } - author { - id - slug - avatar - name - disabled - deleted - location { - name: name${lang} - } - } - } - } - `) -} diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index 6a39c7d81..6125ec51d 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -84,7 +84,7 @@ import HcShoutButton from '~/components/ShoutButton.vue' import HcCommentForm from '~/components/comments/CommentForm' import HcCommentList from '~/components/comments/CommentList' import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers' -import PostQuery from '~/graphql/PostQuery.js' +import PostQuery from '~/graphql/PostQuery' import HcEmotions from '~/components/Emotions/Emotions' export default { @@ -122,29 +122,6 @@ export default { this.title = this.post.title }, }, - async asyncData(context) { - const { - params, - error, - app: { apolloProvider, $i18n }, - } = context - const client = apolloProvider.defaultClient - const query = PostQuery($i18n) - const variables = { slug: params.slug } - const { - data: { Post }, - } = await client.query({ query, variables }) - if (Post.length <= 0) { - // TODO: custom 404 error page with translations - const message = 'This post could not be found' - return error({ statusCode: 404, message }) - } - const [post] = Post - return { - post, - title: post.title, - } - }, mounted() { setTimeout(() => { // NOTE: quick fix for jumping flexbox implementation @@ -175,6 +152,19 @@ export default { } }, }, + apollo: { + Post: { + query() { + return PostQuery(this.$i18n) + }, + variables() { + return { + slug: this.$route.params.slug, + } + }, + fetchPolicy: 'cache-and-network', + }, + }, } @@ -187,7 +177,6 @@ export default { } .post-card { - // max-width: 800px; margin: auto; .comments { diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 540e6bdc8..2d4090aab 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -254,8 +254,9 @@ import HcEmpty from '~/components/Empty.vue' import ContentMenu from '~/components/ContentMenu' import HcUpload from '~/components/Upload' import HcAvatar from '~/components/Avatar/Avatar.vue' -import PostQuery from '~/graphql/UserProfile/Post.js' -import UserQuery from '~/graphql/UserProfile/User.js' +import { filterPosts } from '~/graphql/PostQuery' +// import PostQuery from '~/graphql/UserProfile/Post.js' +import UserQuery from '~/graphql/User' import { Block, Unblock } from '~/graphql/settings/BlockedUsers.js' const tabToFilterMapping = ({ tab, id }) => { @@ -401,7 +402,7 @@ export default { apollo: { Post: { query() { - return PostQuery(this.$i18n) + return filterPosts(this.$i18n) }, variables() { return { From dbaa8e687fe6995dfe6d069a52c89991a86d36ee Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Fri, 16 Aug 2019 13:28:55 +0200 Subject: [PATCH 07/47] Fix vue warnings, fix tests, refactor - was throwing an error when trying to update commentsCount because of new implementation by @roschaefer which uses countResolver, but there was no related for commentsCount, it was r... also commentsCount is no longer needed anywhere in the code base, it is commentedCount now --- backend/src/schema/resolvers/users.js | 1 - backend/src/schema/types/type/Post.gql | 5 -- backend/src/schema/types/type/User.gql | 2 - webapp/components/Comment.vue | 2 +- .../CommentForm.spec.js} | 2 +- .../index.vue => CommentForm/CommentForm.vue} | 2 +- .../CommentList/CommentList.spec.js | 73 ++++++++----------- .../index.vue => CommentList/CommentList.vue} | 2 +- .../components/DeleteData/DeleteData.spec.js | 2 +- webapp/components/DeleteData/DeleteData.vue | 6 +- .../EditCommentForm/EditCommentForm.vue | 0 webapp/components/PostCard/PostCard.story.js | 4 +- webapp/components/PostCard/index.vue | 4 +- webapp/components/SearchInput.spec.js | 2 +- webapp/components/SearchInput.vue | 2 +- webapp/components/User/index.vue | 4 +- webapp/graphql/CommentMutations.js | 32 ++++++-- webapp/graphql/CommentQuery.js | 2 +- webapp/graphql/PostQuery.js | 8 +- webapp/graphql/User.js | 5 +- webapp/locales/de.json | 2 +- webapp/locales/en.json | 2 +- webapp/locales/pl.json | 2 +- webapp/pages/index.vue | 2 +- webapp/pages/post/_id/_slug/index.vue | 4 +- webapp/pages/post/_id/_slug/more-info.vue | 4 +- webapp/store/auth.js | 2 +- webapp/store/posts.js | 3 +- webapp/store/search.js | 2 +- 29 files changed, 91 insertions(+), 92 deletions(-) rename webapp/components/{comments/CommentForm/spec.js => CommentForm/CommentForm.spec.js} (98%) rename webapp/components/{comments/CommentForm/index.vue => CommentForm/CommentForm.vue} (97%) rename webapp/components/{comments => }/CommentList/CommentList.spec.js (68%) rename webapp/components/{comments/CommentList/index.vue => CommentList/CommentList.vue} (96%) rename webapp/components/{comments => }/EditCommentForm/EditCommentForm.vue (100%) diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index 74561c5fe..4710942b6 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -151,7 +151,6 @@ export default { friendsCount: '<-[:FRIENDS]->(related:User)', followingCount: '-[:FOLLOWS]->(related:User)', followedByCount: '<-[:FOLLOWS]-(related:User)', - commentsCount: '-[:WROTE]->(r:Comment)', commentedCount: '-[:WROTE]->(:Comment)-[:COMMENTS]->(related:Post)', shoutedCount: '-[:SHOUTED]->(related:Post)', badgesCount: '<-[:REWARDED]-(related:Badge)', diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 519af14ae..cbbcddfc9 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -29,11 +29,6 @@ type Post { categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") comments: [Comment]! @relation(name: "COMMENTS", direction: "IN") - commentsCount: Int! - @cypher( - statement: "MATCH (this)<-[:COMMENTS]-(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)" - ) - shoutedBy: [User]! @relation(name: "SHOUTED", direction: "IN") shoutedCount: Int! @cypher( diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index e3e8f8450..46e699410 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -64,7 +64,6 @@ type User { ) comments: [Comment]! @relation(name: "WROTE", direction: "OUT") - commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") commentedCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment)-[:COMMENTS]->(p:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true AND NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))") shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") @@ -143,7 +142,6 @@ type Query { followedByCount: Int followedByCurrentUser: Boolean contributionsCount: Int - commentsCount: Int commentedCount: Int shoutedCount: Int badgesCount: Int diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 9096fb6e8..c53d0a231 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -67,7 +67,7 @@ import { mapGetters, mapMutations } from 'vuex' import HcUser from '~/components/User' import ContentMenu from '~/components/ContentMenu' import ContentViewer from '~/components/Editor/ContentViewer' -import HcEditCommentForm from '~/components/comments/EditCommentForm/EditCommentForm' +import HcEditCommentForm from '~/components/EditCommentForm/EditCommentForm' export default { data: function() { diff --git a/webapp/components/comments/CommentForm/spec.js b/webapp/components/CommentForm/CommentForm.spec.js similarity index 98% rename from webapp/components/comments/CommentForm/spec.js rename to webapp/components/CommentForm/CommentForm.spec.js index 2d212c91d..5e7c952af 100644 --- a/webapp/components/comments/CommentForm/spec.js +++ b/webapp/components/CommentForm/CommentForm.spec.js @@ -1,5 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' -import CommentForm from './index.vue' +import CommentForm from './CommentForm' import Styleguide from '@human-connection/styleguide' import Vuex from 'vuex' import MutationObserver from 'mutation-observer' diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/CommentForm/CommentForm.vue similarity index 97% rename from webapp/components/comments/CommentForm/index.vue rename to webapp/components/CommentForm/CommentForm.vue index a04b4f068..795727578 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/CommentForm/CommentForm.vue @@ -69,7 +69,7 @@ export default { this.disabled = true this.$apollo .mutate({ - mutation: CommentMutations().CreateComment, + mutation: CommentMutations(this.$i18n).CreateComment, variables: { postId: this.post.id, content: this.form.content, diff --git a/webapp/components/comments/CommentList/CommentList.spec.js b/webapp/components/CommentList/CommentList.spec.js similarity index 68% rename from webapp/components/comments/CommentList/CommentList.spec.js rename to webapp/components/CommentList/CommentList.spec.js index 023974284..e1090475a 100644 --- a/webapp/components/comments/CommentList/CommentList.spec.js +++ b/webapp/components/CommentList/CommentList.spec.js @@ -1,5 +1,5 @@ import { config, mount, createLocalVue } from '@vue/test-utils' -import CommentList from '.' +import CommentList from './CommentList' import Empty from '~/components/Empty' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' @@ -21,63 +21,52 @@ describe('CommentList.vue', () => { let store let wrapper let propsData - let data - - propsData = { - post: { - id: 1, - }, - } - store = new Vuex.Store({ - getters: { - 'auth/user': () => { - return {} - }, - }, - }) - mocks = { - $t: jest.fn(), - $filters: { - truncate: a => a, - }, - $apollo: { - queries: { - Post: { - refetch: jest.fn(), - }, - }, - }, - } - data = () => { - return { - comments: [], - } - } describe('shallowMount', () => { + beforeEach(() => { + propsData = { + post: { + id: 1, + comments: [{ id: 'comment134', contentExcerpt: 'this is a comment' }], + }, + } + store = new Vuex.Store({ + getters: { + 'auth/user': () => { + return {} + }, + }, + }) + mocks = { + $t: jest.fn(), + $filters: { + truncate: a => a, + }, + $apollo: { + queries: { + Post: { + refetch: jest.fn(), + }, + }, + }, + } + }) + const Wrapper = () => { return mount(CommentList, { store, mocks, localVue, propsData, - data, }) } beforeEach(() => { wrapper = Wrapper() - wrapper.setData({ - comments: [ - { - id: 'c1', - contentExcerpt: 'this is a comment', - }, - ], - }) }) it('displays a message icon when there are no comments to display', () => { + propsData.post.comments = [] expect(Wrapper().findAll(Empty)).toHaveLength(1) }) diff --git a/webapp/components/comments/CommentList/index.vue b/webapp/components/CommentList/CommentList.vue similarity index 96% rename from webapp/components/comments/CommentList/index.vue rename to webapp/components/CommentList/CommentList.vue index 7e30e2452..2ae670bf4 100644 --- a/webapp/components/comments/CommentList/index.vue +++ b/webapp/components/CommentList/CommentList.vue @@ -4,7 +4,7 @@ { } getters = { 'auth/user': () => { - return { id: 'u343', name: deleteAccountName, contributionsCount: 2, commentsCount: 3 } + return { id: 'u343', name: deleteAccountName, contributionsCount: 2, commentedCount: 3 } }, } actions = { 'auth/logout': jest.fn() } diff --git a/webapp/components/DeleteData/DeleteData.vue b/webapp/components/DeleteData/DeleteData.vue index 293e65221..f6e6d47f0 100644 --- a/webapp/components/DeleteData/DeleteData.vue +++ b/webapp/components/DeleteData/DeleteData.vue @@ -30,12 +30,12 @@ }} -   - + - {{ post.commentsCount }} + {{ post.commentedCount }} { name: 'Trick', slug: 'trick', }, - commentsCount: 0, + commentedCount: 0, createdAt: '2019-03-13T11:00:20.835Z', id: 'p10', label: 'Eos aut illo omnis quis eaque et iure aut.', diff --git a/webapp/components/SearchInput.vue b/webapp/components/SearchInput.vue index 098b30610..c93e65d61 100644 --- a/webapp/components/SearchInput.vue +++ b/webapp/components/SearchInput.vue @@ -46,7 +46,7 @@ - {{ option.commentsCount }} + {{ option.commentedCount }} diff --git a/webapp/components/User/index.vue b/webapp/components/User/index.vue index 7841fe596..b4e8fae66 100644 --- a/webapp/components/User/index.vue +++ b/webapp/components/User/index.vue @@ -64,8 +64,8 @@ diff --git a/webapp/graphql/CommentMutations.js b/webapp/graphql/CommentMutations.js index 6b0f653fc..bf4fc33ea 100644 --- a/webapp/graphql/CommentMutations.js +++ b/webapp/graphql/CommentMutations.js @@ -1,6 +1,6 @@ import gql from 'graphql-tag' -export default () => { +export default i18n => { return { CreateComment: gql` mutation($postId: ID!, $content: String!) { @@ -8,15 +8,26 @@ export default () => { id contentExcerpt content + createdAt + disabled + deleted author { id slug name avatar + disabled + deleted + shoutedCount + contributionsCount + commentedCount + followedByCount + followedByCurrentUser + badges { + id + icon + } } - createdAt - deleted - disabled } } `, @@ -24,8 +35,19 @@ export default () => { mutation($content: String!, $id: ID!) { UpdateComment(content: $content, id: $id) { id - content contentExcerpt + content + createdAt + disabled + deleted + author { + id + slug + name + avatar + disabled + deleted + } } } `, diff --git a/webapp/graphql/CommentQuery.js b/webapp/graphql/CommentQuery.js index 4d82165f0..c2daaa943 100644 --- a/webapp/graphql/CommentQuery.js +++ b/webapp/graphql/CommentQuery.js @@ -17,7 +17,7 @@ export default app => { deleted shoutedCount contributionsCount - commentsCount + commentedCount followedByCount followedByCurrentUser location { diff --git a/webapp/graphql/PostQuery.js b/webapp/graphql/PostQuery.js index 88c32b120..124342dc2 100644 --- a/webapp/graphql/PostQuery.js +++ b/webapp/graphql/PostQuery.js @@ -22,7 +22,7 @@ export default i18n => { deleted shoutedCount contributionsCount - commentsCount + commentedCount followedByCount followedByCurrentUser location { @@ -36,7 +36,6 @@ export default i18n => { tags { name } - commentsCount comments(orderBy: createdAt_asc) { id contentExcerpt @@ -53,7 +52,7 @@ export default i18n => { deleted shoutedCount contributionsCount - commentsCount + commentedCount followedByCount followedByCurrentUser location { @@ -100,7 +99,7 @@ export const filterPosts = i18n => { deleted contributionsCount shoutedCount - commentsCount + commentedCount followedByCount followedByCurrentUser location { @@ -111,7 +110,6 @@ export const filterPosts = i18n => { icon } } - commentsCount categories { id name diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js index 9de986a8a..7771481a6 100644 --- a/webapp/graphql/User.js +++ b/webapp/graphql/User.js @@ -35,7 +35,7 @@ export default i18n => { followedByCount followedByCurrentUser contributionsCount - commentsCount + commentedCount badges { id icon @@ -57,7 +57,7 @@ export default i18n => { followedByCount followedByCurrentUser contributionsCount - commentsCount + commentedCount badges { id icon @@ -66,7 +66,6 @@ export default i18n => { name: name${lang} } } - contributionsCount socialMedia { id url diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 33c8e37c5..14980a112 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -171,7 +171,7 @@ "deleteUserAccount": { "name": "Daten löschen", "contributionsCount": "Meine {count} Beiträge löschen", - "commentsCount": "Meine {count} Kommentare löschen", + "commentedCount": "Meine {count} Kommentare löschen", "accountDescription": "Sei dir bewusst, dass deine Beiträge und Kommentare für unsere Community wichtig sind. Wenn du sie trotzdem löschen möchtest, musst du sie unten markieren.", "accountWarning": "Dein Konto, deine Beiträge oder Kommentare kannst du nach dem Löschen WEDER VERWALTEN NOCH WIEDERHERSTELLEN!", "success": "Konto erfolgreich gelöscht!", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 664cbaff2..59323fd5a 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -171,7 +171,7 @@ "deleteUserAccount": { "name": "Delete data", "contributionsCount": "Delete my {count} posts", - "commentsCount": "Delete my {count} comments", + "commentedCount": "Delete my {count} comments", "accountDescription": "Be aware that your Post and Comments are important to our community. If you still choose to delete them, you have to mark them below.", "accountWarning": "You CAN'T MANAGE and CAN'T RECOVER your Account, Posts, or Comments after deleting your account!", "success": "Account successfully deleted!", diff --git a/webapp/locales/pl.json b/webapp/locales/pl.json index 3f6746adf..ed5f049ab 100644 --- a/webapp/locales/pl.json +++ b/webapp/locales/pl.json @@ -121,7 +121,7 @@ "deleteUserAccount": { "name": "UsuÅ„ dane", "contributionsCount": "UsuÅ„ {count} moich postów", - "commentsCount": "UsuÅ„ {count} moich komentarzy", + "commentedCount": "UsuÅ„ {count} moich komentarzy", "accountDescription": "Be aware that your Post and Comments are important to our community. If you still choose to delete them, you have to mark them below.", "accountWarning": "Po usuniÄ™cie Twojego konta, nie możesz ZARZÄ„DZAĆ ani ODZYSKAĆ danych, wpisów oraz komentarzy!", "success": "Konto zostaÅ‚o usuniÄ™te", diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 7566ce791..e8d68a561 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -96,7 +96,7 @@ export default { label: this.$t('sorting.commented'), value: 'Commented', icons: 'comment', - order: 'commentsCount_desc', + order: 'commentedCount_desc', }, ], } diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index 6125ec51d..29fec1821 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -81,8 +81,8 @@ import HcTag from '~/components/Tag' import ContentMenu from '~/components/ContentMenu' import HcUser from '~/components/User' import HcShoutButton from '~/components/ShoutButton.vue' -import HcCommentForm from '~/components/comments/CommentForm' -import HcCommentList from '~/components/comments/CommentList' +import HcCommentForm from '~/components/CommentForm/CommentForm' +import HcCommentList from '~/components/CommentList/CommentList' import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers' import PostQuery from '~/graphql/PostQuery' import HcEmotions from '~/components/Emotions/Emotions' diff --git a/webapp/pages/post/_id/_slug/more-info.vue b/webapp/pages/post/_id/_slug/more-info.vue index ef442b7d6..ab711e101 100644 --- a/webapp/pages/post/_id/_slug/more-info.vue +++ b/webapp/pages/post/_id/_slug/more-info.vue @@ -91,7 +91,7 @@ export default { slug contentExcerpt shoutedCount - commentsCount + commentedCount categories { id name @@ -105,7 +105,7 @@ export default { contributionsCount followedByCount followedByCurrentUser - commentsCount + commentedCount location { name: name${this.$i18n.locale().toUpperCase()} } diff --git a/webapp/store/auth.js b/webapp/store/auth.js index 6185a38cf..f756fc2c9 100644 --- a/webapp/store/auth.js +++ b/webapp/store/auth.js @@ -80,7 +80,7 @@ export const actions = { about locationName contributionsCount - commentsCount + commentedCount socialMedia { id url diff --git a/webapp/store/posts.js b/webapp/store/posts.js index 17e764537..2d9e3ffdc 100644 --- a/webapp/store/posts.js +++ b/webapp/store/posts.js @@ -88,7 +88,7 @@ export const actions = { deleted contributionsCount shoutedCount - commentsCount + commentedCount followedByCount followedByCurrentUser location { @@ -99,7 +99,6 @@ export const actions = { icon } } - commentsCount categories { id name diff --git a/webapp/store/search.js b/webapp/store/search.js index c5ed9523a..bae9bc249 100644 --- a/webapp/store/search.js +++ b/webapp/store/search.js @@ -53,7 +53,7 @@ export const actions = { label: title value: title, shoutedCount - commentsCount + commentedCount createdAt author { id From fdc0d808f69a36f2fbfd8086fe26153ae0db6d57 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Fri, 16 Aug 2019 14:18:18 +0200 Subject: [PATCH 08/47] Fix search query --- webapp/graphql/settings/BlockedUsers.js | 36 ++++++++++++++----------- webapp/pages/profile/_id/_slug.vue | 3 +-- webapp/store/search.js | 7 +++-- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/webapp/graphql/settings/BlockedUsers.js b/webapp/graphql/settings/BlockedUsers.js index e47355b18..8f882f8ad 100644 --- a/webapp/graphql/settings/BlockedUsers.js +++ b/webapp/graphql/settings/BlockedUsers.js @@ -1,7 +1,7 @@ import gql from 'graphql-tag' export const BlockedUsers = () => { - return gql(` + return gql` { blockedUsers { id @@ -13,27 +13,31 @@ export const BlockedUsers = () => { deleted } } - `) + ` } export const Block = () => { - return gql(`mutation($id:ID!) { - block(id: $id) { - id - name - isBlocked - followedByCurrentUser + return gql` + mutation($id: ID!) { + block(id: $id) { + id + name + isBlocked + followedByCurrentUser + } } - }`) + ` } export const Unblock = () => { - return gql(`mutation($id:ID!) { - unblock(id: $id) { - id - name - isBlocked - followedByCurrentUser + return gql` + mutation($id: ID!) { + unblock(id: $id) { + id + name + isBlocked + followedByCurrentUser + } } - }`) + ` } diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 2d4090aab..6e4baba4d 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -255,9 +255,8 @@ import ContentMenu from '~/components/ContentMenu' import HcUpload from '~/components/Upload' import HcAvatar from '~/components/Avatar/Avatar.vue' import { filterPosts } from '~/graphql/PostQuery' -// import PostQuery from '~/graphql/UserProfile/Post.js' import UserQuery from '~/graphql/User' -import { Block, Unblock } from '~/graphql/settings/BlockedUsers.js' +import { Block, Unblock } from '~/graphql/settings/BlockedUsers' const tabToFilterMapping = ({ tab, id }) => { return { diff --git a/webapp/store/search.js b/webapp/store/search.js index bae9bc249..0d0172a98 100644 --- a/webapp/store/search.js +++ b/webapp/store/search.js @@ -45,15 +45,14 @@ export const actions = { commit('SET_QUICK_PENDING', true) await this.app.apolloProvider.defaultClient .query({ - query: gql(` + query: gql` query findPosts($query: String!) { findPosts(query: $query, limit: 10) { id slug label: title - value: title, + value: title shoutedCount - commentedCount createdAt author { id @@ -62,7 +61,7 @@ export const actions = { } } } - `), + `, variables: { query: value.replace(/\s/g, '~ ') + '~', }, From b27a01438ed4255091c2f6badf2de4fa143cfeca Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 16 Aug 2019 16:53:38 +0200 Subject: [PATCH 09/47] Damn you're right @mattwr18 You are right with this statement: https://github.com/Human-Connection/Human-Connection/pull/1280#discussion_r314675882 --- cypress/integration/common/steps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index e1eab98c1..cc5d0551a 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -260,7 +260,7 @@ Then("the first post on the landing page has the title:", title => { Then( "the page {string} returns a 404 error with a message:", (route, message) => { - // TODO: how can we check HTTP codes with cypress? + cy.request({ url: route, failOnStatusCode: false }).its('status').should('eq', 404) cy.visit(route, { failOnStatusCode: false }); cy.get(".error").should("contain", message); } From aa52587f83db66eb875149361ab67ba4581d234f Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 16 Aug 2019 17:05:16 +0200 Subject: [PATCH 10/47] Get rid of property warnings If we always choose `0` as the default value for `endVal` in case it is not given (maybe apollo assigns null when the request is in flight) then just make `0` the default. --- webapp/components/CountTo.vue | 2 +- webapp/components/User/index.vue | 10 +++++----- webapp/pages/admin/index.vue | 18 +++++++++--------- webapp/pages/profile/_id/_slug.vue | 8 ++------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/webapp/components/CountTo.vue b/webapp/components/CountTo.vue index 65ad84b56..3210944c8 100644 --- a/webapp/components/CountTo.vue +++ b/webapp/components/CountTo.vue @@ -20,7 +20,7 @@ export default { }, props: { startVal: { type: Number, default: 0 }, - endVal: { type: Number, required: true }, + endVal: { type: Number, default: 0 }, duration: { type: Number, default: 3000 }, autoplay: { type: Boolean, default: true }, separator: { type: String, default: '.' }, diff --git a/webapp/components/User/index.vue b/webapp/components/User/index.vue index 7841fe596..bf3556b29 100644 --- a/webapp/components/User/index.vue +++ b/webapp/components/User/index.vue @@ -50,7 +50,11 @@ - + @@ -121,10 +125,6 @@ export default { itsMe() { return this.user.slug === this.$store.getters['auth/user'].slug }, - fanCount() { - let count = Number(this.user.followedByCount) || 0 - return count - }, userLink() { const { id, slug } = this.user if (!(id && slug)) return '' diff --git a/webapp/pages/admin/index.vue b/webapp/pages/admin/index.vue index 39dd4800e..ca8ce4df7 100644 --- a/webapp/pages/admin/index.vue +++ b/webapp/pages/admin/index.vue @@ -7,7 +7,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -30,7 +30,7 @@ uppercase > - + @@ -44,7 +44,7 @@ uppercase > - + @@ -58,7 +58,7 @@ uppercase > - + @@ -72,7 +72,7 @@ uppercase > - + @@ -81,7 +81,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 540e6bdc8..03d1aa859 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -43,14 +43,14 @@ - + - + @@ -309,10 +309,6 @@ export default { myProfile() { return this.$route.params.id === this.$store.getters['auth/user'].id }, - followedByCount() { - let count = Number(this.user.followedByCount) || 0 - return count - }, user() { return this.User ? this.User[0] : {} }, From 76be960c0394051e508a280f10747754ed97db40 Mon Sep 17 00:00:00 2001 From: Alina Beck Date: Sun, 18 Aug 2019 18:25:14 +0100 Subject: [PATCH 11/47] move grid calculations to masonry grid components --- webapp/components/MasonryGrid/MasonryGrid.vue | 42 +++++++++++++++++++ .../MasonryGrid/MasonryGridItem.vue | 28 +++++++++++++ webapp/pages/index.vue | 22 ++++++---- 3 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 webapp/components/MasonryGrid/MasonryGrid.vue create mode 100644 webapp/components/MasonryGrid/MasonryGridItem.vue diff --git a/webapp/components/MasonryGrid/MasonryGrid.vue b/webapp/components/MasonryGrid/MasonryGrid.vue new file mode 100644 index 000000000..b852173b1 --- /dev/null +++ b/webapp/components/MasonryGrid/MasonryGrid.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/webapp/components/MasonryGrid/MasonryGridItem.vue b/webapp/components/MasonryGrid/MasonryGridItem.vue new file mode 100644 index 000000000..8a923fb22 --- /dev/null +++ b/webapp/components/MasonryGrid/MasonryGridItem.vue @@ -0,0 +1,28 @@ + + + diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index bf01c0182..9d4304199 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -1,6 +1,6 @@