From 5f8d94e13e4f1288e3af974e0b7e9814d4d2973b Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sat, 29 Dec 2018 15:51:26 +0100 Subject: [PATCH 01/59] WIP - Added first report dropdown to PostCard component. --- components/PostCard.vue | 70 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/components/PostCard.vue b/components/PostCard.vue index 450e69959..d8466f2ad 100644 --- a/components/PostCard.vue +++ b/components/PostCard.vue @@ -8,6 +8,47 @@ :image="post.image" style="cursor: pointer; position: relative;" > + + + + + + @@ -55,12 +96,14 @@ + + diff --git a/layouts/default.vue b/layouts/default.vue index 6bf42691e..bcd7a46ab 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -138,17 +138,11 @@ export default { float: right; } -.avatar-menu-trigger { - user-select: none; -} .avatar-menu-popover { - display: inline-block; padding-top: 0.5rem; padding-bottom: 0.5rem; nav { - margin-left: -15px; - margin-right: -15px; padding-top: 1rem; padding-bottom: 1rem; } From 8bb4c7dbdffbc27290ffed57d6a0ccb28221e887 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sat, 29 Dec 2018 19:42:56 +0100 Subject: [PATCH 03/59] Added unique class name to body tag based on page name --- components/mixins/seo.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/mixins/seo.js b/components/mixins/seo.js index d0c232baf..de641e677 100644 --- a/components/mixins/seo.js +++ b/components/mixins/seo.js @@ -3,6 +3,9 @@ export default { return { htmlAttrs: { lang: this.$i18n.locale() + }, + bodyAttrs: { + class: `page-name-${this.$route.name}` } } } From bd8deb942aca0346a1e4934cbae4eb11a62a09d7 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sat, 29 Dec 2018 19:43:07 +0100 Subject: [PATCH 04/59] Fix styling issues --- pages/post/_slug/index.vue | 42 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue index 949263e95..8d95a4189 100644 --- a/pages/post/_slug/index.vue +++ b/pages/post/_slug/index.vue @@ -213,31 +213,33 @@ export default { + + diff --git a/styleguide/src/system/components/layout/Modal/demo.md b/styleguide/src/system/components/layout/Modal/demo.md new file mode 100644 index 000000000..68129b2f9 --- /dev/null +++ b/styleguide/src/system/components/layout/Modal/demo.md @@ -0,0 +1,65 @@ +## Basic Modal + +Basic modal usage + +You will need to add the portal-target to the end of your html body to get the modal working properly +```html + + + +``` + +``` + + +``` + +Customize button labels +``` + + +``` diff --git a/styleguide/src/system/components/layout/Modal/style.scss b/styleguide/src/system/components/layout/Modal/style.scss new file mode 100644 index 000000000..1c2ab66ec --- /dev/null +++ b/styleguide/src/system/components/layout/Modal/style.scss @@ -0,0 +1,75 @@ + +.ds-modal-wrapper { + padding: $space-base; + position: relative; +} + +.ds-modal { + position: fixed; + z-index: $z-index-modal; + left: 50%; + top: 50%; + transform: translate3d(-50%, -50%, 0); + display: flex; + flex-direction: column; + max-width: 600px; + width: calc(90vw - 40px); + max-height: 90vh; + background: white; + border-radius: $border-radius-large; + padding: 0 $space-base; + box-shadow: $box-shadow-x-large; +} +.ds-modal-close { + position: absolute; + top: $space-small; + right: $space-small; +} +.ds-modal-body { + flex: 1; + overflow-y: auto; + height: auto; + min-height: 100px; + max-height: 60vh; +} +.ds-modal-header { + padding-top: $space-base; + + .ds-modal-title { + margin-bottom: 0; + } +} +.ds-modal-backdrop { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: $z-index-modal - 1; + background: rgba(0, 0, 0, 0.7); +} +.ds-modal-footer { + display: flex; + padding: $space-base 0; + flex-shrink: 0; + justify-content: flex-end; + + & > button { + margin-left: $space-x-small; + } +} + +$easeOut: cubic-bezier(0.19, 1, 0.22, 1); + +.ds-transition-modal-appear-enter-active { + opacity: 1; + transition: all 180ms $easeOut; + transition-delay: 0; + transform: translate3d(-50%, -50%, 0) scale(1); +} +.ds-transition-modal-appear-enter, +.ds-transition-modal-appear-leave-active { + opacity: 0; + transition-delay: 0; + transform: translate3d(-50%, -50%, 0) scale(0.9); +} From cd83d35dc7c7dd22eb3e72a8d2f4c368fcc6e940 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 11 Jan 2019 15:11:17 +0100 Subject: [PATCH 11/59] Improved Modal --- .../system/components/layout/Modal/Modal.vue | 18 +++++++++++++----- .../src/system/components/layout/Modal/demo.md | 3 ++- .../system/components/layout/Modal/style.scss | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/styleguide/src/system/components/layout/Modal/Modal.vue b/styleguide/src/system/components/layout/Modal/Modal.vue index f85c3f986..5aa00cde4 100644 --- a/styleguide/src/system/components/layout/Modal/Modal.vue +++ b/styleguide/src/system/components/layout/Modal/Modal.vue @@ -15,6 +15,7 @@ @@ -94,14 +63,14 @@ diff --git a/layouts/default.vue b/layouts/default.vue index bcd7a46ab..03180b61a 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -72,6 +72,10 @@ + + + + @@ -79,11 +83,13 @@ import { mapGetters } from 'vuex' import LocaleSwitch from '~/components/LocaleSwitch' import Dropdown from '~/components/Dropdown' +import ReportModal from '~/components/ReportModal' import seo from '~/components/mixins/seo' export default { components: { Dropdown, + ReportModal, LocaleSwitch }, mixins: [seo], diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue index 8d95a4189..15d120261 100644 --- a/pages/post/_slug/index.vue +++ b/pages/post/_slug/index.vue @@ -6,6 +6,14 @@ class="post-card" > + + + @@ -112,6 +120,7 @@ diff --git a/pages/moderation/index.vue b/pages/moderation/index.vue new file mode 100644 index 000000000..62c5c4648 --- /dev/null +++ b/pages/moderation/index.vue @@ -0,0 +1,140 @@ + + + From e19de71cdbac68364caeb8a13cb999b6b57a6592 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sat, 12 Jan 2019 13:40:07 +0100 Subject: [PATCH 18/59] Improved content menu --- assets/styles/imports/_tooltip.scss | 16 ++++-- components/ContentMenu.vue | 53 ++++++++++--------- components/PostCard.vue | 2 +- layouts/default.vue | 5 -- .../src/system/tokens/border-radius.yml | 2 +- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/assets/styles/imports/_tooltip.scss b/assets/styles/imports/_tooltip.scss index 9d073c11e..3c922f8d2 100644 --- a/assets/styles/imports/_tooltip.scss +++ b/assets/styles/imports/_tooltip.scss @@ -91,24 +91,34 @@ border-radius: $border-radius-base; padding: $space-x-small $space-small; box-shadow: $box-shadow-large; + + nav { + margin-left: -$space-small; + margin-right: -$space-small; + + a { + padding-left: 12px; + } + } } .popover-arrow { border-color: $background-color-soft; } - @include arrow(8px, "popover", $background-color-soft); + @include arrow(7px, "popover", $background-color-soft); } + &[aria-hidden='true'] { visibility: hidden; opacity: 0; - transition: opacity .15s, visibility .15s; + transition: opacity .1s, visibility .1s; } &[aria-hidden='false'] { visibility: visible; opacity: 1; - transition: opacity .15s; + transition: opacity .1s; } } diff --git a/components/ContentMenu.vue b/components/ContentMenu.vue index cece9dc95..8d9ae8eee 100644 --- a/components/ContentMenu.vue +++ b/components/ContentMenu.vue @@ -1,6 +1,6 @@ - + + + {{ item.route.name }} + + + @@ -104,3 +96,14 @@ export default { } } + + diff --git a/components/PostCard.vue b/components/PostCard.vue index 6aa26673d..59e7895d4 100644 --- a/components/PostCard.vue +++ b/components/PostCard.vue @@ -115,7 +115,7 @@ export default { z-index: 1; } } -.post-menu { +.content-menu { // position: absolute; // bottom: $space-small; // right: $space-small; diff --git a/layouts/default.vue b/layouts/default.vue index 27bf5f94d..aeaf70086 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -165,14 +165,9 @@ export default { padding-bottom: 0.5rem; nav { - margin-left: -16px; margin-right: -10px; padding-top: 1rem; padding-bottom: 1rem; - - a { - padding-left: 12px; - } } } diff --git a/styleguide/src/system/tokens/border-radius.yml b/styleguide/src/system/tokens/border-radius.yml index 4bbdf785a..f299da252 100644 --- a/styleguide/src/system/tokens/border-radius.yml +++ b/styleguide/src/system/tokens/border-radius.yml @@ -9,7 +9,7 @@ props: - name: border-radius-large value: "4px" - name: border-radius-base - value: "3px" + value: "4px" - name: border-radius-rounded value: "2em" - name: border-radius-circle From 1c2745ed2dee6baee6a60933ce3a464292ab574c Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sat, 12 Jan 2019 14:09:17 +0100 Subject: [PATCH 19/59] Translated report dialog and improved popover --- assets/styles/imports/_tooltip.scss | 6 +++--- assets/styles/main.scss | 3 ++- components/ReportModal.vue | 6 +++++- locales/de.json | 9 ++++++--- locales/en.json | 9 ++++++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/assets/styles/imports/_tooltip.scss b/assets/styles/imports/_tooltip.scss index 3c922f8d2..fa6c38668 100644 --- a/assets/styles/imports/_tooltip.scss +++ b/assets/styles/imports/_tooltip.scss @@ -90,7 +90,7 @@ color: $text-color-base; border-radius: $border-radius-base; padding: $space-x-small $space-small; - box-shadow: $box-shadow-large; + box-shadow: $box-shadow-x-large; nav { margin-left: -$space-small; @@ -113,12 +113,12 @@ &[aria-hidden='true'] { visibility: hidden; opacity: 0; - transition: opacity .1s, visibility .1s; + transition: opacity 60ms; } &[aria-hidden='false'] { visibility: visible; opacity: 1; - transition: opacity .1s; + transition: opacity 60ms; } } diff --git a/assets/styles/main.scss b/assets/styles/main.scss index 1ce0c0e53..235777096 100644 --- a/assets/styles/main.scss +++ b/assets/styles/main.scss @@ -139,7 +139,7 @@ hr { } } - #overlay { +#overlay { display: block; opacity: 0; width: 100%; @@ -156,5 +156,6 @@ hr { .dropdown-open & { opacity: 1; transition-delay: 0; + transition: opacity 80ms ease-out; } } diff --git a/components/ReportModal.vue b/components/ReportModal.vue index 52b31cbd5..c79939ce5 100644 --- a/components/ReportModal.vue +++ b/components/ReportModal.vue @@ -8,7 +8,8 @@ @confirm="report" @cancel="close" > -

Are you sure that you want to report the {{ data.context }} "{{ data.name | truncate(30) }}"?

+ +

diff --git a/package.json b/package.json index 07ff10d10..f558f5adc 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "jsonwebtoken": "^8.3.0", "nuxt": "^2.0.0", "nuxt-env": "^0.0.4", - "portal-vue": "^1.5.1", "nuxt-sass-resources-loader": "^2.0.5", + "portal-vue": "^1.5.1", "v-tooltip": "^2.0.0-rc.33", "vue-count-to": "^1.0.13", "vue-izitoast": "1.1.2", diff --git a/styleguide/src/system/components/layout/Modal/Modal.vue b/styleguide/src/system/components/layout/Modal/Modal.vue index 4cb76cd49..4a273e680 100644 --- a/styleguide/src/system/components/layout/Modal/Modal.vue +++ b/styleguide/src/system/components/layout/Modal/Modal.vue @@ -1,55 +1,57 @@ + + diff --git a/pages/moderation/index.vue b/pages/moderation/index.vue index d9afc58af..40dba1504 100644 --- a/pages/moderation/index.vue +++ b/pages/moderation/index.vue @@ -74,27 +74,21 @@ - - - Empty
- NO REPORTS -
-
+ From 453ceae726a855ad4befd80807c4dfc86e8ca53e Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Thu, 17 Jan 2019 22:21:57 +0100 Subject: [PATCH 43/59] Fix scrollbehavior to top on page change --- nuxt.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nuxt.config.js b/nuxt.config.js index 19d28b04b..8e4007ae8 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -73,7 +73,10 @@ module.exports = { router: { middleware: ['authenticated'], - linkActiveClass: 'router-active-link' + linkActiveClass: 'router-active-link', + scrollBehavior: () => { + return { x: 0, y: 0 } + } }, /* From a87c9e4f4aedcee294c8b3c01e58ddffd4c199e9 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Thu, 17 Jan 2019 22:22:10 +0100 Subject: [PATCH 44/59] Added report content tests --- cypress/fixtures/users.json | 17 +++++ cypress/integration/05.ReportContent.feature | 34 +++++++++ cypress/integration/common/report.js | 73 ++++++++++++++++++++ cypress/integration/common/steps.js | 13 ++-- cypress/support/commands.js | 7 ++ cypress/support/config.js | 16 ----- 6 files changed, 138 insertions(+), 22 deletions(-) create mode 100644 cypress/fixtures/users.json create mode 100644 cypress/integration/05.ReportContent.feature create mode 100644 cypress/integration/common/report.js delete mode 100644 cypress/support/config.js diff --git a/cypress/fixtures/users.json b/cypress/fixtures/users.json new file mode 100644 index 000000000..339866774 --- /dev/null +++ b/cypress/fixtures/users.json @@ -0,0 +1,17 @@ +{ + "admin": { + "email": "admin@example.org", + "password": "1234", + "name": "Peter Lustig" + }, + "moderator": { + "email": "moderator@example.org", + "password": "1234", + "name": "Bob der Bausmeister" + }, + "user": { + "email": "user@example.org", + "password": "1234", + "name": "Jenny Rostock" + } +} diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature new file mode 100644 index 000000000..d9b9e46fe --- /dev/null +++ b/cypress/integration/05.ReportContent.feature @@ -0,0 +1,34 @@ +Feature: Report content + As a user + I would like to report content that viloates the community guidlines + So the moderators can take action on it + + As a moderator + I would like to see all reported content + So I can look into it and decide what to do + + Scenario: Report a Post from landingpage + Given I am logged in as "user" + And I am on the "landing" page + + When I click on a Post menu and select the report option + And I click on send in the confirmation dialog + Then I get a success message + + Scenario: See reported content + Given I am logged in as "moderator" + And I previously reported a post + + When I am on the "moderation" page + Then I see my reported post + + Scenario: Report while reading Post + Given I am logged in as "admin" + And I am viewing a post + + When I report the current post + And I visit the "moderation" page + Then I see my reported post + + #Scenario: Normal user can't see the moderation page + #Given I am logged in as "user" diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js new file mode 100644 index 000000000..e202bfad2 --- /dev/null +++ b/cypress/integration/common/report.js @@ -0,0 +1,73 @@ +import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' + +/* global cy */ + +let lastPostTitle + +const savePostTitle = $post => { + return $post + .first() + .find('.ds-heading') + .first() + .invoke('text') + .then(title => { + lastPostTitle = title + }) +} +const invokeReportOnElement = selector => { + cy.get(selector) + .first() + .find('.content-menu-trigger') + .first() + .click() + + return savePostTitle(cy.get(selector)).then(() => { + cy.get('.popover .ds-menu-item-link') + .contains('Report') + .click() + }) +} + +Given('I am logged in as {string}', userType => { + cy.loginAs(userType) +}) + +Given('I previously reported a post', () => { + invokeReportOnElement('.post-card') +}) + +Given('I am viewing a post', () => { + cy.visit('/') + cy.get('.post-card:nth(2)') + .click() + .wait(200) + cy.location('pathname').should('contain', '/post') +}) + +When('I report the current post', () => { + invokeReportOnElement('.post-card').then(() => { + cy.get('button') + .contains('Send') + .click() + }) +}) + +When('I click on a Post menu and select the report option', () => { + invokeReportOnElement('.post-card') +}) + +When('I click on send in the confirmation dialog', () => { + cy.get('button') + .contains('Send') + .click() +}) + +Then('I get a success message', () => { + cy.get('.iziToast-message').contains('Thanks') +}) + +Then('I see my reported post', () => { + cy.get('table').then(() => { + cy.get('tbody tr:first-child()').contains(lastPostTitle.slice(0, 20)) + }) +}) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index ee9a364f7..a7c88d74d 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -1,11 +1,9 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' import { getLangByName } from '../../support/helpers' -import find from 'lodash/find' +import users from '../../fixtures/users.json' /* global cy */ -const username = 'Peter Lustig' - const openPage = page => { if (page === 'landing') { page = '' @@ -14,7 +12,10 @@ const openPage = page => { } Given('I am logged in', () => { - cy.login('admin@example.org', 1234) + cy.loginAs('admin') +}) +Given('I am logged in as {string}', userType => { + cy.loginAs(userType) }) Given('we have a selection of tags and categories as well as posts', () => { @@ -59,7 +60,7 @@ Then('I can click on my profile picture in the top right corner', () => { }) Then('I can see my name {string} in the dropdown menu', () => { - cy.get('.avatar-menu-popover').should('contain', username) + cy.get('.avatar-menu-popover').should('contain', users.admin.name) }) Then('I see the login screen again', () => { @@ -68,7 +69,7 @@ Then('I see the login screen again', () => { Then('I am still logged in', () => { cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover').contains(username) + cy.get('.avatar-menu-popover').contains(users.admin.name) }) When('I select {string} in the language menu', name => { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 77c75c7d5..a747644de 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -15,6 +15,7 @@ /* globals Cypress cy */ import { getLangByName } from './helpers' +import users from '../fixtures/users.json' const switchLang = name => { cy.get('.locale-menu').click() @@ -54,6 +55,12 @@ Cypress.Commands.add('login', (email, password) => { .click() cy.location('pathname').should('eq', '/') // we're in! }) + +Cypress.Commands.add('loginAs', userType => { + userType = userType || 'admin' + cy.login(users[userType].email, users[userType].password) +}) + Cypress.Commands.add('logout', (email, password) => { cy.visit(`/logout`) cy.location('pathname').should('contain', '/login') // we're out diff --git a/cypress/support/config.js b/cypress/support/config.js deleted file mode 100644 index af96ad615..000000000 --- a/cypress/support/config.js +++ /dev/null @@ -1,16 +0,0 @@ -export default { - users: { - admin: { - email: 'admin@example.org', - password: 1234 - }, - moderator: { - email: 'moderator@example.org', - password: 1234 - }, - user: { - email: 'user@example.org', - password: 1234 - } - } -} From cd40879c6e32f67e0462774192f2325fc64ef616 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Thu, 17 Jan 2019 22:41:48 +0100 Subject: [PATCH 45/59] Added user report test (broken for no reason) --- cypress/integration/05.ReportContent.feature | 9 +++++++ cypress/integration/common/report.js | 28 +++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature index d9b9e46fe..2e68beb4e 100644 --- a/cypress/integration/05.ReportContent.feature +++ b/cypress/integration/05.ReportContent.feature @@ -30,5 +30,14 @@ Feature: Report content And I visit the "moderation" page Then I see my reported post + Scenario: Report user + Given I am logged in as "admin" + And I am viewing a post + + When I click on the author + And I report the author + And I visit the "moderation" page + Then I see my reported user + #Scenario: Normal user can't see the moderation page #Given I am logged in as "user" diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index e202bfad2..782c294a1 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -2,7 +2,7 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' /* global cy */ -let lastPostTitle +let lastReportTitle const savePostTitle = $post => { return $post @@ -11,7 +11,7 @@ const savePostTitle = $post => { .first() .invoke('text') .then(title => { - lastPostTitle = title + lastReportTitle = title }) } const invokeReportOnElement = selector => { @@ -56,6 +56,23 @@ When('I click on a Post menu and select the report option', () => { invokeReportOnElement('.post-card') }) +When('I click on the author', () => { + cy.get('a.author') + .first() + .click() + .wait(200) +}) + +When('I report the author', () => { + cy.get('.page-name-profile-slug').then(() => { + invokeReportOnElement('.ds-card').then(() => { + cy.get('button') + .contains('Send') + .click() + }) + }) +}) + When('I click on send in the confirmation dialog', () => { cy.get('button') .contains('Send') @@ -68,6 +85,11 @@ Then('I get a success message', () => { Then('I see my reported post', () => { cy.get('table').then(() => { - cy.get('tbody tr:first-child()').contains(lastPostTitle.slice(0, 20)) + cy.get('tbody tr:first-child()').contains(lastReportTitle.slice(0, 20)) + }) +}) +Then('I see my reported user', () => { + cy.get('table').then(() => { + cy.get('tbody tr:first-child()').contains(lastReportTitle) }) }) From 12d713d528b0ed417cc0d325326e67213a282707 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 18 Jan 2019 10:10:42 +0100 Subject: [PATCH 46/59] Fixed user report test --- cypress/integration/05.ReportContent.feature | 2 +- cypress/integration/common/report.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature index 2e68beb4e..09d5871a3 100644 --- a/cypress/integration/05.ReportContent.feature +++ b/cypress/integration/05.ReportContent.feature @@ -1,4 +1,4 @@ -Feature: Report content +Feature: Report and Moderate As a user I would like to report content that viloates the community guidlines So the moderators can take action on it diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 782c294a1..67275e61b 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -85,11 +85,15 @@ Then('I get a success message', () => { Then('I see my reported post', () => { cy.get('table').then(() => { - cy.get('tbody tr:first-child()').contains(lastReportTitle.slice(0, 20)) + cy.get('tbody tr') + .first() + .contains(lastReportTitle.trim().slice(0, 20)) }) }) Then('I see my reported user', () => { cy.get('table').then(() => { - cy.get('tbody tr:first-child()').contains(lastReportTitle) + cy.get('tbody tr') + .first() + .contains(lastReportTitle.trim()) }) }) From 9a63da733f1e736bb8b68504d3fafe380731a41d Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 18 Jan 2019 10:25:49 +0100 Subject: [PATCH 47/59] Added moderation menu item check for non moderators to be hidden --- cypress/integration/05.ReportContent.feature | 7 +++++-- cypress/integration/common/report.js | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature index 09d5871a3..29509fdcd 100644 --- a/cypress/integration/05.ReportContent.feature +++ b/cypress/integration/05.ReportContent.feature @@ -39,5 +39,8 @@ Feature: Report and Moderate And I visit the "moderation" page Then I see my reported user - #Scenario: Normal user can't see the moderation page - #Given I am logged in as "user" + Scenario: Normal user can't see the moderation page + Given I am logged in as "user" + + When I can click on my profile picture in the top right corner + Then I can't see the moderation menu item diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 67275e61b..72a45a903 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -97,3 +97,10 @@ Then('I see my reported user', () => { .contains(lastReportTitle.trim()) }) }) + +Then(`I can't see the moderation menu item`, () => { + cy.get('.avatar-menu').click() + cy.get('.avatar-menu-popover') + .find('a[href="/moderation"]') + .should('have.length', 0) +}) From e6326f772b67059e49b781384954a2e6f6dce744 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 18 Jan 2019 10:35:48 +0100 Subject: [PATCH 48/59] Secured moderation and admin pages by role --- middleware/isAdmin.js | 5 +++++ middleware/isModerator.js | 5 +++++ pages/admin.vue | 1 + pages/moderation.vue | 1 + 4 files changed, 12 insertions(+) create mode 100644 middleware/isAdmin.js create mode 100644 middleware/isModerator.js diff --git a/middleware/isAdmin.js b/middleware/isAdmin.js new file mode 100644 index 000000000..4db10bbb6 --- /dev/null +++ b/middleware/isAdmin.js @@ -0,0 +1,5 @@ +export default ({ store, error }) => { + if (!store.getters['auth/isAdmin']) { + return error({ statusCode: 403 }) + } +} diff --git a/middleware/isModerator.js b/middleware/isModerator.js new file mode 100644 index 000000000..e99793a3e --- /dev/null +++ b/middleware/isModerator.js @@ -0,0 +1,5 @@ +export default ({ store, error }) => { + if (!store.getters['auth/isModerator']) { + return error({ statusCode: 403 }) + } +} diff --git a/pages/admin.vue b/pages/admin.vue index ce2c50960..e6d0fd66b 100644 --- a/pages/admin.vue +++ b/pages/admin.vue @@ -21,6 +21,7 @@ From 272b1071d47095577bcf57c35dff4042d7fdc67b Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 18 Jan 2019 12:14:57 +0100 Subject: [PATCH 50/59] Improved content menu and empty profile page --- components/ContentMenu.vue | 9 ++++---- components/Empty.vue | 15 +++++++++++-- components/PostCard.vue | 12 ++++++----- pages/post/_slug/index.vue | 11 +++++----- pages/profile/_slug.vue | 44 ++++++++++++++++++++++++++++---------- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/components/ContentMenu.vue b/components/ContentMenu.vue index e446420da..7e4f24d9b 100644 --- a/components/ContentMenu.vue +++ b/components/ContentMenu.vue @@ -8,13 +8,14 @@ slot="default" slot-scope="{toggleMenu}" > - - +

Empty
@@ -40,7 +41,17 @@ export default { /** * Message that appears under the icon */ - message: { type: String, required: true } + message: { + type: String, + default: null + }, + /** + * Vertical spacing + */ + margin: { + type: [String, Object], + default: 'x-large' + } }, computed: { iconPath() { diff --git a/components/PostCard.vue b/components/PostCard.vue index 560eb50f0..25b410257 100644 --- a/components/PostCard.vue +++ b/components/PostCard.vue @@ -114,11 +114,13 @@ export default { .ds-card-footer { z-index: 1; } -} -.content-menu { - display: inline-block; - margin-left: $space-small; - z-index: 1; + + .content-menu { + display: inline-block; + margin-left: $space-xx-small; + margin-right: -$space-x-small; + z-index: 1; + } } .post-link { display: block; diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue index 19f697187..b321c6bd1 100644 --- a/pages/post/_slug/index.vue +++ b/pages/post/_slug/index.vue @@ -118,11 +118,10 @@
-
-

- NO COMMENTS -

-
+ @@ -132,6 +131,7 @@ import gql from 'graphql-tag' import ContentMenu from '~/components/ContentMenu' import HcAuthor from '~/components/Author.vue' import HcShoutButton from '~/components/ShoutButton.vue' +import HcEmpty from '~/components/Empty.vue' export default { transition: { @@ -141,6 +141,7 @@ export default { components: { HcAuthor, HcShoutButton, + HcEmpty, ContentMenu }, head() { diff --git a/pages/profile/_slug.vue b/pages/profile/_slug.vue index 52fee46a6..913efb429 100644 --- a/pages/profile/_slug.vue +++ b/pages/profile/_slug.vue @@ -19,7 +19,6 @@ /> - - - + + !post.deleted)) } }, watch: { @@ -395,6 +409,14 @@ export default { border: #fff 5px solid; } +.page-name-profile-slug { + .ds-flex-item:first-child .content-menu { + position: absolute; + top: $space-x-small; + right: $space-x-small; + } +} + .profile-top-navigation { position: sticky; top: 53px; From 91a9aed46a7c274d6e5ec1fa10f99edd98f27b2a Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 18 Jan 2019 14:57:43 +0100 Subject: [PATCH 51/59] Fixed content menu and modal styles --- components/ContentMenu.vue | 2 +- styleguide/src/system/components/layout/Modal/style.scss | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/ContentMenu.vue b/components/ContentMenu.vue index 7e4f24d9b..9ab85cb12 100644 --- a/components/ContentMenu.vue +++ b/components/ContentMenu.vue @@ -24,7 +24,7 @@ > Date: Fri, 18 Jan 2019 16:30:25 +0100 Subject: [PATCH 52/59] Removed polling on moderation page due to error --- pages/moderation/index.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/pages/moderation/index.vue b/pages/moderation/index.vue index 77ffc9373..995c9d560 100644 --- a/pages/moderation/index.vue +++ b/pages/moderation/index.vue @@ -106,9 +106,6 @@ export default { } } }, - mounted() { - this.$apollo.queries.Report.startPolling(10000) - }, apollo: { Report: { query, From 04663aa94a8e8239f26b47e5b7a3d7994cc32fa6 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Mon, 21 Jan 2019 08:53:17 +0100 Subject: [PATCH 53/59] Improved modal --- components/ReportModal.vue | 37 +++++++++++++++++++++++++++++++++++-- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/components/ReportModal.vue b/components/ReportModal.vue index 18e6fc9ad..1ae23fd94 100644 --- a/components/ReportModal.vue +++ b/components/ReportModal.vue @@ -8,8 +8,19 @@ @confirm="report" @cancel="close" > + + + + + +

+