diff --git a/CHANGELOG.md b/CHANGELOG.md index 580e9e333..cd785773b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,67 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v0.1.10](https://github.com/Human-Connection/Human-Connection/compare/v0.1.9...v0.1.10) + +> 13 November 2019 + +- Update contribution guidelines [`#2127`](https://github.com/Human-Connection/Human-Connection/pull/2127) +- fix: return `null` for missig translations [`#2218`](https://github.com/Human-Connection/Human-Connection/pull/2218) +- Add donation status and button [`#2194`](https://github.com/Human-Connection/Human-Connection/pull/2194) +- Added Empty Definitions For Missing Getters And Mutations [`#2197`](https://github.com/Human-Connection/Human-Connection/pull/2197) +- build(deps): bump @sentry/node from 5.7.1 to 5.8.0 in /backend [`#2209`](https://github.com/Human-Connection/Human-Connection/pull/2209) +- build(deps-dev): bump eslint-plugin-jest from 23.0.2 to 23.0.3 in /backend [`#2206`](https://github.com/Human-Connection/Human-Connection/pull/2206) +- build(deps-dev): bump vue-svg-loader from 0.14.0 to 0.15.0 in /webapp [`#2204`](https://github.com/Human-Connection/Human-Connection/pull/2204) +- build(deps-dev): bump async-validator from 3.2.1 to 3.2.2 in /webapp [`#2203`](https://github.com/Human-Connection/Human-Connection/pull/2203) +- Update deployment names in deploy script [`#2216`](https://github.com/Human-Connection/Human-Connection/pull/2216) +- Fix: Delete Block Button in MainPage PostCards [`#2193`](https://github.com/Human-Connection/Human-Connection/pull/2193) +- Update doctl to use default context [`#2199`](https://github.com/Human-Connection/Human-Connection/pull/2199) +- console.error in Hashtag.spec.js #2161 [`#2201`](https://github.com/Human-Connection/Human-Connection/pull/2201) +- build(deps-dev): bump @storybook/addon-actions from 5.2.5 to 5.2.6 in /webapp [`#2186`](https://github.com/Human-Connection/Human-Connection/pull/2186) +- build(deps-dev): bump style-resources-loader from 1.2.1 to 1.3.2 in /webapp [`#2188`](https://github.com/Human-Connection/Human-Connection/pull/2188) +- build(deps-dev): bump @storybook/vue from 5.2.5 to 5.2.6 in /webapp [`#2183`](https://github.com/Human-Connection/Human-Connection/pull/2183) +- build(deps-dev): bump @storybook/addon-a11y from 5.2.5 to 5.2.6 in /webapp [`#2176`](https://github.com/Human-Connection/Human-Connection/pull/2176) +- build(deps-dev): bump cypress from 3.6.0 to 3.6.1 [`#2173`](https://github.com/Human-Connection/Human-Connection/pull/2173) +- build(deps): bump date-fns from 2.6.0 to 2.7.0 in /webapp [`#2164`](https://github.com/Human-Connection/Human-Connection/pull/2164) +- Update docs for deploying new server, env variables [`#2191`](https://github.com/Human-Connection/Human-Connection/pull/2191) +- Remove unintended comma [`#2192`](https://github.com/Human-Connection/Human-Connection/pull/2192) +- added Russian to locales [`#2111`](https://github.com/Human-Connection/Human-Connection/pull/2111) +- Add notifications page with All Notifications [`#1975`](https://github.com/Human-Connection/Human-Connection/pull/1975) +- 1931 - after successful login the saved language of the user is set [`#2073`](https://github.com/Human-Connection/Human-Connection/pull/2073) +- build(deps-dev): bump cypress-file-upload from 3.4.0 to 3.5.0 [`#2167`](https://github.com/Human-Connection/Human-Connection/pull/2167) +- build(deps): bump date-fns from 2.6.0 to 2.7.0 in /backend [`#2166`](https://github.com/Human-Connection/Human-Connection/pull/2166) +- build(deps-dev): bump date-fns from 2.6.0 to 2.7.0 [`#2165`](https://github.com/Human-Connection/Human-Connection/pull/2165) +- build(deps-dev): bump eslint-plugin-vue from 5.2.3 to 6.0.0 in /webapp [`#2156`](https://github.com/Human-Connection/Human-Connection/pull/2156) +- build(deps): bump merge-graphql-schemas from 1.7.2 to 1.7.3 in /backend [`#2155`](https://github.com/Human-Connection/Human-Connection/pull/2155) +- build(deps-dev): bump @babel/core from 7.6.4 to 7.7.2 in /backend [`#2154`](https://github.com/Human-Connection/Human-Connection/pull/2154) +- Add missing portuguese translation [`#1909`](https://github.com/Human-Connection/Human-Connection/pull/1909) +- Migrate design tokens [`#2159`](https://github.com/Human-Connection/Human-Connection/pull/2159) +- build(deps-dev): bump @babel/core from 7.7.0 to 7.7.2 in /webapp [`#2158`](https://github.com/Human-Connection/Human-Connection/pull/2158) +- build(deps-dev): bump vue-svg-loader from 0.12.0 to 0.14.0 in /webapp [`#2157`](https://github.com/Human-Connection/Human-Connection/pull/2157) +- Remove graphql-requests [`#2151`](https://github.com/Human-Connection/Human-Connection/pull/2151) +- close all open sessions [`#2148`](https://github.com/Human-Connection/Human-Connection/pull/2148) +- Implement refresh posts, fix duplicate posts bug [`#2126`](https://github.com/Human-Connection/Human-Connection/pull/2126) +- Fix: Email is Case-Sensitive [`#2118`](https://github.com/Human-Connection/Human-Connection/pull/2118) +- build(deps-dev): bump @babel/preset-env from 7.6.3 to 7.7.1 in /backend [`#2135`](https://github.com/Human-Connection/Human-Connection/pull/2135) +- build(deps): bump graphql-shield from 7.0.1 to 7.0.2 in /backend [`#2136`](https://github.com/Human-Connection/Human-Connection/pull/2136) +- build(deps-dev): bump @babel/node from 7.6.3 to 7.7.0 in /backend [`#2134`](https://github.com/Human-Connection/Human-Connection/pull/2134) +- build(deps-dev): bump @babel/core from 7.6.4 to 7.7.0 in /webapp [`#2132`](https://github.com/Human-Connection/Human-Connection/pull/2132) +- build(deps-dev): bump @babel/preset-env from 7.6.3 to 7.7.1 in /webapp [`#2133`](https://github.com/Human-Connection/Human-Connection/pull/2133) +- build(deps-dev): bump @babel/register from 7.6.2 to 7.7.0 in /backend [`#2131`](https://github.com/Human-Connection/Human-Connection/pull/2131) +- build(deps): bump graphql-middleware from 4.0.1 to 4.0.2 in /backend [`#2130`](https://github.com/Human-Connection/Human-Connection/pull/2130) +- build(deps-dev): bump @babel/cli from 7.6.4 to 7.7.0 in /backend [`#2129`](https://github.com/Human-Connection/Human-Connection/pull/2129) +- 1851 tags clickable [`#2091`](https://github.com/Human-Connection/Human-Connection/pull/2091) +- build(deps): bump graphql-shield from 7.0.0 to 7.0.1 in /backend [`#2123`](https://github.com/Human-Connection/Human-Connection/pull/2123) +- build(deps): bump merge-graphql-schemas from 1.7.0 to 1.7.2 in /backend [`#2121`](https://github.com/Human-Connection/Human-Connection/pull/2121) +- build(deps-dev): bump vue-loader from 15.7.1 to 15.7.2 in /webapp [`#2122`](https://github.com/Human-Connection/Human-Connection/pull/2122) +- build(deps-dev): bump async-validator from 3.2.0 to 3.2.1 in /webapp [`#2120`](https://github.com/Human-Connection/Human-Connection/pull/2120) +- 🍰 Add migration plan and frontend code guidelines to our docs [`#2075`](https://github.com/Human-Connection/Human-Connection/pull/2075) +- Update feature template [`#2116`](https://github.com/Human-Connection/Human-Connection/pull/2116) +- Update to version 0.1.9 [`#2114`](https://github.com/Human-Connection/Human-Connection/pull/2114) +- add current file [`26c0d4d`](https://github.com/Human-Connection/Human-Connection/commit/26c0d4d83e4418a2378e05b66b6b47461f82735f) +- Finish portuguese translations [`15c671c`](https://github.com/Human-Connection/Human-Connection/commit/15c671c4a8aae86317896ca30601389504bce9e1) +- add design token addon to storybook [`fc387f6`](https://github.com/Human-Connection/Human-Connection/commit/fc387f63e2cd4aef0964c81a13b892bdba952e12) + #### [v0.1.9](https://github.com/Human-Connection/Human-Connection/compare/v0.1.8...v0.1.9) > 4 November 2019 @@ -67,7 +128,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix #1993 [`#1993`](https://github.com/Human-Connection/Human-Connection/issues/1993) - first implementation [`aeae72f`](https://github.com/Human-Connection/Human-Connection/commit/aeae72f6918861aa2a4c64d0b32c847d9e857e93) - build(deps-dev): bump eslint-plugin-jest in /backend [`6c1bd53`](https://github.com/Human-Connection/Human-Connection/commit/6c1bd535ac482eb0a05d21e227a476800717a19e) -- Add auto changelog [`6f4517b`](https://github.com/Human-Connection/Human-Connection/commit/6f4517b0e9d832abab271471cedeea0aa00f4d43) +- add migration plan to webapp readme [`8816f7b`](https://github.com/Human-Connection/Human-Connection/commit/8816f7be2a9662bc1333e37b306dee6b964fc2e0) #### [v0.1.8](https://github.com/Human-Connection/Human-Connection/compare/0.1.7...v0.1.8) @@ -196,8 +257,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Implement public registration [`#1814`](https://github.com/Human-Connection/Human-Connection/pull/1814) - Refactor embed settings page [`#1861`](https://github.com/Human-Connection/Human-Connection/pull/1861) - fixed lint errors [`f73ff99`](https://github.com/Human-Connection/Human-Connection/commit/f73ff995e18240192904693416a866fc7a8ddb7a) +- Start adding missing portuguese translation [`33eb000`](https://github.com/Human-Connection/Human-Connection/commit/33eb000ee33e5aa513083450f0a00abd7240efb0) - refactor: restructure translations and components [`bb5d581`](https://github.com/Human-Connection/Human-Connection/commit/bb5d581906b5e6e723966c3dc687c7f309356841) -- Refactored backend database to a single `REPORTED` relation [`82228c6`](https://github.com/Human-Connection/Human-Connection/commit/82228c6c99c4b33ab20ddfbc13cce6ac6f95792c) #### [0.1.4](https://github.com/Human-Connection/Human-Connection/compare/0.1.3...0.1.4) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1475df0de..e0926678b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,79 +1,101 @@ # CONTRIBUTING -Thanks so much for thinking of contributing to the Human Connection project, we really appreciate it! :-\) +Thank you so much for thinking of contributing to the Human Connection project! It's awesome you're here, we really appreciate it. :-\) ## Getting Set Up -Instructions for how to install all the necessary software can be found in our [documentation](https://docs.human-connection.org/human-connection/). +Instructions for how to install all the necessary software and some code guidelines can be found in our [documentation](https://docs.human-connection.org/human-connection/). -We recommend that new folks should ideally work together with an existing developer. Please join our [discord](https://discord.gg/6ub73U3) instance to chat with developers or just ask them in tickets in [Zenhub](https://app.zenhub.com/workspaces/human-connection-nitro-5c0154ecc699f60fc92cf11f/boards?repos=152252353): +To get you started we recommend that you join forces with a regular contributor. Please join [our discord instance](https://human-connection.org/discord) to chat with developers or just get in touch directly on an issue on either [Github](https://github.com/Human-Connection/Human-Connection/issues) or [Zenhub](https://app.zenhub.com/workspaces/human-connection-nitro-5c0154ecc699f60fc92cf11f/boards?repos=152252353): ![](https://dl.dropbox.com/s/vbmcihkduy9dhko/Screenshot%202019-01-03%2015.50.11.png?dl=0) -Here are some general notes on our development flow: +We also have regular pair programming sessions that you are very welcome to join! We feel this is often the best way to get to know both the project and the team. Most developers are also available for spontaneous sessions if the times listed below don't work for you – just ping us on discord. -## Development +## Development Flow -* Currently operating in two week sprints -* We are using ZenHub to coordinate - * estimating time per issue is the crucial feature of [Zenhub](https://app.zenhub.com/workspaces/human-connection-nitro-5c0154ecc699f60fc92cf11f) that Github does not have - * "up-for-grabs" links to [Github project](https://github.com/Human-Connection/Human-Connection/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) - * ordering on ZenHub not necessarily reflected on github projects -* AgileVentures run open pairing sessions at 10:30am UTC each week on Tuesdays and Thursdays -* Core team - * all the people who are hired by HC non-profit corporation - * you can Meet-the-team [every two weeks in German](https://human-connection.org/veranstaltungen/) and [every month in English](https://human-connection.org/en/events/). - * 9 people - * 2 core developers \(Robert [@roschaefer](https://github.com/roschaefer) and Greg [@appinteractive](https://github.com/appinteractive)\) - * 3 marketeers Jasi, Dennis and Sensi - * Hardy doing business development - * Martin head of IT and previously data protection officer - * Victor doing accounting and controlling - * Nicolas is the community manager \(reviews content in the network\) reflects community opinion back to the core team -* when can folks pair with Robert - * 10am UTC until 5pm UTC every working day +We operate in two week sprints that are planned, estimated and prioritised on [Zenhub](https://app.zenhub.com/workspaces/human-connection-nitro-5c0154ecc699f60fc92cf11f). All issues are also linked to and synced with [Github](https://github.com/Human-Connection/Human-Connection/issues). Look for the `good first issue` label if you're not sure where to start! + +We try to discuss all questions directly related to a feature or bug in the respective issue, in order to preserve it for the future and for other developers. We use discord for real-time communication. + +This is how we solve bugs and implement features, step by step: +1. We find an issue we want to work on, usually during the sprint planning but as an open source contributor this can happen at any time. +2. We communicate with the team to see if the issue is still available. (When you comment on an issue but don't get an answer there within 1-2 days try to mention @Human-Connection/hc-dev-team to make sure we check in.) +3. We make sure we understand the issue in detail – what problem is it solving and how should it be implemented? +4. We assign ourselves to the issue and move it to `In Progress` on [Zenhub](https://app.zenhub.com/workspaces/human-connection-nitro-5c0154ecc699f60fc92cf11f). +5. We start working on it in a `new branch` and open a `pull request` prefixed with `[WIP]` (work in progress) to which we regularly push our changes. +6. When questions come up we clarify them with the team (directly in the issue on Github). +7. When we are happy with our work and our PR is passing all tests we remove the `[WIP]` from the PR description and ask for reviews (if you're not sure who to ask there is @Human-Connection/hc-dev-team which pings all core developers). +8. We then incorporate the suggestions from the reviews into our work and once it has been approved it can be merged into master! + +Every pull request needs to: +* fix an issue (if there is something you want to work on but there is no issue for it, create one first and discuss it with the team) +* include tests for the code that is added or changed +* pass all tests (linter, backend, frontend, end-to-end) +* be approved by at least 1 developer who is not the owner of the PR (when more than 10 files were changed it needs 2 approvals) + +## The Team + +There are many volunteers all around the world helping us build this network and without their contributions we wouldn't be where we are today. Big thank you to all of you! + +You can see the core team behind Human Connection [on our website](https://human-connection.org/en/the-team/). On Github you will mostly run into our developers: +* Robert (@roschaefer) +* Matt (@mattwr18) +* Wolle (@Tirokk) +* Alex (@ogerly) +* Alina (@alina-beck) +* Martin (@datenbrei), our head of IT +* and sometimes Dennis (@DennisHack), the founder of Human Connection + +## Meetings and Pair Programming Sessions + +Times below refer to **German Time** – that's CET (GMT+1) in winter and CEST (GMT+2) in summer – because most Human Connection core team members are living in Germany. + +Daily standup +* every Monday–Friday 11:30 +* in the discord `Conference Room` +* all contributors welcome! +* everybody shares what they are working on and asks for help if they are blocked + +Regular pair programming sessions +* every Monday, Wednesday and Thursday 15:00 +* the link will be posted in the [discord chat](https://discord.gg/6ub73U3) and on the [Agile Ventures website](https://www.agileventures.org/events?utf8=%E2%9C%93&project_id=220&commit=Filter+by+Project) +* all contributors welcome! +* we team up and work on an issue together (often using Visual Studio live sharing sessions) + +Open-Source Community Meeting +* every Thursday 13:00 +* the link will be posted in the [discord chat](https://discord.gg/6ub73U3) and on the [Agile Ventures website](https://www.agileventures.org/events?utf8=%E2%9C%93&project_id=220&commit=Filter+by+Project) +* all contributors welcome! + +Meet the team +* every Monday 21:00 (at the moment only in German) +* details here https://human-connection.org/veranstaltungen/ +* via this [zoom link](https://zoom.us/j/936943532) +* all contributors and users of the network welcome! +* users of the network chat with the Human Connection team and discuss current questions and issues + +Sprint planning +* bi-weekly on Tuesday 13:00 +* via this [zoom link](https://zoom.us/j/7743582385) +* all contributors welcome (recommended for those who want to work on an issue in this sprint) +* we select and prioritise the issues we will work on in the following two weeks + +Sprint retrospective +* bi-weekly on Monday 13:00 +* via this [zoom link](https://zoom.us/j/7743582385) +* all contributors welcome (most interesting for those who participated in the sprint) +* we review the past sprint and talk about what went well and what we could improve ## Philosophy We practise [collective code ownership](http://www.extremeprogramming.org/rules/collective.html) rather than strong code ownership, which means that: - -* anyone can start working on anyone elses code -* we avoid blocking because someone else isn't working on something -* however it's sometimes good to leave something in order to create successful education experience +* developers can make contributions to other people's PRs (after checking in with them) +* we avoid blocking because someone else isn't working, so we sometimes take over PRs from other developers * everyone should always push their code to branches so others can see it -Everyone feel free to request merges or answers to issues from the project managers +We believe in open source contributions as a learning experience – everyone is welcome to join our team of volunteers and to contribute to the project, no matter their background or level of experience. -But what do we do when waiting for merge into master \(wanting to keep PRs small\) --> Robert recommends creating a pull request for each step +We use pair programming sessions as a tool for knowledge sharing. We can learn a lot from each other and only by sharing what we know and overcoming challenges together can we grow as a team and truly own this project collectively. -* programming is also about thinking about other people - empathy for your co-workers - * but what about when you are waiting for merge? - * solutions - * 1\) put 2nd PR into branch that the first PR is hitting - but requires update after merging - * 2\) prefer to leave existing PR until it can be reviewed, and instead go and work on some other part of the codebase that is not impacted by the first PR - -### Code Review -* Github setting in place - at least one review is required to merge - - in principle anyone (who is not the PR owner) can review - - but often it will be the core developers (Robert, Wolfgang, Matt, Alina, Alex) - - once there is a review, and presuming no requested changes, PR opener can merge - -* CI/tests - - the CI needs to pass - - linting (yarn lint --fix) - - tests (unit, feature) (backend, frontend) - - codecoverage - -## Notes - -question: when you want to pick a task - \(find out priority\) - is it in discord? is it in AV slack? --> Robert says you can always ask in discord - group channels are the best - -Robert shares: [Zenhub board](https://app.zenhub.com/workspaces/nitro-embed-5c0154ecc699f60fc92cf11f/boards?repos=112590397,152252353,152252578,157710732,163305928) Robert says the order of tickets are preserved in ZenHub and reflect their priority \(most important at the top\) and so check out the current milestones - -Matt - question about who can work on [ticket 100](https://app.zenhub.com/workspaces/nitro-embed-5c0154ecc699f60fc92cf11f/issues/human-connection/human-connection/100) --> Robert - in rare occasions it might be exclusive to someone with admin permissions Robert: notes greg just pushed this today: [https://github.com/Human-Connection/Nitro-Deployment](https://github.com/Human-Connection/Nitro-Deployment) - -Matt makes point that new stories will have to be taken off the "New Issues" and Robert says that's fine, if you don't like the first one, then you can take the next one. Volunteeers have no commitment except their own self development and their awesomeness by contributing to free and open-source software projects. - -Robert notes that everyone is invited to join the kickoff meetings - -Robert - difference between "important" \(creates a lot of value\) and "beginner friendly" \(easy to implement\) +As a volunteeer you have no commitment except your own self development and your awesomeness by contributing to this free and open-source software project. Cheers to you! diff --git a/VERSION b/VERSION index 1a030947e..9767cc98e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.9 +0.1.10 diff --git a/backend/package.json b/backend/package.json index 710d98ead..699dc9972 100644 --- a/backend/package.json +++ b/backend/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@hapi/joi": "^16.1.7", - "@sentry/node": "^5.7.1", + "@sentry/node": "^5.8.0", "apollo-cache-inmemory": "~1.6.3", "apollo-client": "~2.6.4", "apollo-link-context": "~1.0.19", @@ -115,7 +115,7 @@ "eslint-config-prettier": "~6.5.0", "eslint-config-standard": "~14.1.0", "eslint-plugin-import": "~2.18.2", - "eslint-plugin-jest": "~23.0.2", + "eslint-plugin-jest": "~23.0.3", "eslint-plugin-node": "~10.0.0", "eslint-plugin-prettier": "~3.1.1", "eslint-plugin-promise": "~4.2.1", diff --git a/backend/src/middleware/permissionsMiddleware.js b/backend/src/middleware/permissionsMiddleware.js index ea09e6a80..b6f0ecadb 100644 --- a/backend/src/middleware/permissionsMiddleware.js +++ b/backend/src/middleware/permissionsMiddleware.js @@ -135,6 +135,7 @@ const permissions = shield( blockedUsers: isAuthenticated, notifications: isAuthenticated, profilePagePosts: or(onlyEnabledContent, isModerator), + Donations: isAuthenticated, }, Mutation: { '*': deny, @@ -176,6 +177,7 @@ const permissions = shield( VerifyEmailAddress: isAuthenticated, pinPost: isAdmin, unpinPost: isAdmin, + UpdateDonations: isAdmin, }, User: { email: or(isMyOwn, isAdmin), diff --git a/backend/src/models/Donations.js b/backend/src/models/Donations.js new file mode 100644 index 000000000..45e06e1d4 --- /dev/null +++ b/backend/src/models/Donations.js @@ -0,0 +1,14 @@ +import uuid from 'uuid/v4' + +module.exports = { + id: { type: 'string', primary: true, default: uuid }, + goal: { type: 'number' }, + progress: { type: 'number' }, + createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() }, + updatedAt: { + type: 'string', + isoDate: true, + required: true, + default: () => new Date().toISOString(), + }, +} diff --git a/backend/src/models/index.js b/backend/src/models/index.js index 08362b69f..bd89ddc51 100644 --- a/backend/src/models/index.js +++ b/backend/src/models/index.js @@ -12,4 +12,5 @@ export default { Category: require('./Category.js'), Tag: require('./Tag.js'), Location: require('./Location.js'), + Donations: require('./Donations.js'), } diff --git a/backend/src/schema/index.js b/backend/src/schema/index.js index be00a1435..5fefe26f7 100644 --- a/backend/src/schema/index.js +++ b/backend/src/schema/index.js @@ -25,6 +25,7 @@ export default applyScalars( 'NOTIFIED', 'REPORTED', 'DECIDED', + 'Donations', ], // add 'User' here as soon as possible }, @@ -46,6 +47,7 @@ export default applyScalars( 'NOTIFIED', 'REPORTED', 'DECIDED', + 'Donations', ], // add 'User' here as soon as possible }, diff --git a/backend/src/schema/resolvers/donations.js b/backend/src/schema/resolvers/donations.js new file mode 100644 index 000000000..88149077d --- /dev/null +++ b/backend/src/schema/resolvers/donations.js @@ -0,0 +1,32 @@ +export default { + Mutation: { + UpdateDonations: async (_parent, params, context, _resolveInfo) => { + const { driver } = context + const session = driver.session() + let donations + const writeTxResultPromise = session.writeTransaction(async txc => { + const updateDonationsTransactionResponse = await txc.run( + ` + MATCH (donations:Donations) + WITH donations LIMIT 1 + SET donations += $params + SET donations.updatedAt = toString(datetime()) + RETURN donations + `, + { params }, + ) + return updateDonationsTransactionResponse.records.map( + record => record.get('donations').properties, + ) + }) + try { + const txResult = await writeTxResultPromise + if (!txResult[0]) return null + donations = txResult[0] + } finally { + session.close() + } + return donations + }, + }, +} diff --git a/backend/src/schema/resolvers/donations.spec.js b/backend/src/schema/resolvers/donations.spec.js new file mode 100644 index 000000000..327688d3a --- /dev/null +++ b/backend/src/schema/resolvers/donations.spec.js @@ -0,0 +1,174 @@ +import { createTestClient } from 'apollo-server-testing' +import Factory from '../../seed/factories' +import { gql } from '../../jest/helpers' +import { neode as getNeode, getDriver } from '../../bootstrap/neo4j' +import createServer from '../../server' + +let mutate, query, authenticatedUser, variables +const factory = Factory() +const instance = getNeode() +const driver = getDriver() + +const updateDonationsMutation = gql` + mutation($goal: Int, $progress: Int) { + UpdateDonations(goal: $goal, progress: $progress) { + id + goal + progress + createdAt + updatedAt + } + } +` +const donationsQuery = gql` + query { + Donations { + id + goal + progress + } + } +` + +describe('donations', () => { + let currentUser, newlyCreatedDonations + beforeAll(async () => { + await factory.cleanDatabase() + authenticatedUser = undefined + const { server } = createServer({ + context: () => { + return { + driver, + neode: instance, + user: authenticatedUser, + } + }, + }) + mutate = createTestClient(server).mutate + query = createTestClient(server).query + }) + + beforeEach(async () => { + variables = {} + newlyCreatedDonations = await factory.create('Donations') + }) + + afterEach(async () => { + await factory.cleanDatabase() + }) + + describe('query for donations', () => { + describe('unauthenticated', () => { + it('throws authorization error', async () => { + authenticatedUser = undefined + await expect(query({ query: donationsQuery, variables })).resolves.toMatchObject({ + errors: [{ message: 'Not Authorised!' }], + }) + }) + + describe('authenticated', () => { + beforeEach(async () => { + currentUser = await factory.create('User', { + id: 'normal-user', + role: 'user', + }) + authenticatedUser = await currentUser.toJson() + }) + + it('returns the current Donations info', async () => { + await expect(query({ query: donationsQuery, variables })).resolves.toMatchObject({ + data: { Donations: [{ goal: 15000, progress: 0 }] }, + }) + }) + }) + }) + }) + + describe('update donations', () => { + beforeEach(() => { + variables = { goal: 20000, progress: 3000 } + }) + + describe('unauthenticated', () => { + it('throws authorization error', async () => { + authenticatedUser = undefined + await expect( + mutate({ mutation: updateDonationsMutation, variables }), + ).resolves.toMatchObject({ + errors: [{ message: 'Not Authorised!' }], + }) + }) + + describe('authenticated', () => { + describe('as a normal user', () => { + beforeEach(async () => { + currentUser = await factory.create('User', { + id: 'normal-user', + role: 'user', + }) + authenticatedUser = await currentUser.toJson() + }) + + it('throws authorization error', async () => { + await expect( + mutate({ mutation: updateDonationsMutation, variables }), + ).resolves.toMatchObject({ + data: { UpdateDonations: null }, + errors: [{ message: 'Not Authorised!' }], + }) + }) + }) + + describe('as a moderator', () => { + beforeEach(async () => { + currentUser = await factory.create('User', { + id: 'moderator', + role: 'moderator', + }) + authenticatedUser = await currentUser.toJson() + }) + + it('throws authorization error', async () => { + await expect( + mutate({ mutation: updateDonationsMutation, variables }), + ).resolves.toMatchObject({ + data: { UpdateDonations: null }, + errors: [{ message: 'Not Authorised!' }], + }) + }) + }) + + describe('as an admin', () => { + beforeEach(async () => { + currentUser = await factory.create('User', { + id: 'admin', + role: 'admin', + }) + authenticatedUser = await currentUser.toJson() + }) + + it('updates Donations info', async () => { + await expect( + mutate({ mutation: updateDonationsMutation, variables }), + ).resolves.toMatchObject({ + data: { UpdateDonations: { goal: 20000, progress: 3000 } }, + errors: undefined, + }) + }) + + it('updates the updatedAt attribute', async () => { + newlyCreatedDonations = await newlyCreatedDonations.toJson() + const { + data: { UpdateDonations }, + } = await mutate({ mutation: updateDonationsMutation, variables }) + expect(newlyCreatedDonations.updatedAt).toBeTruthy() + expect(Date.parse(newlyCreatedDonations.updatedAt)).toEqual(expect.any(Number)) + expect(UpdateDonations.updatedAt).toBeTruthy() + expect(Date.parse(UpdateDonations.updatedAt)).toEqual(expect.any(Number)) + expect(newlyCreatedDonations.updatedAt).not.toEqual(UpdateDonations.updatedAt) + }) + }) + }) + }) + }) +}) diff --git a/backend/src/schema/resolvers/locations.js b/backend/src/schema/resolvers/locations.js new file mode 100644 index 000000000..be72001f7 --- /dev/null +++ b/backend/src/schema/resolvers/locations.js @@ -0,0 +1,19 @@ +import Resolver from './helpers/Resolver' + +export default { + Location: { + ...Resolver('Location', { + undefinedToNull: [ + 'nameEN', + 'nameDE', + 'nameFR', + 'nameNL', + 'nameIT', + 'nameES', + 'namePT', + 'namePL', + 'nameRU', + ], + }), + }, +} diff --git a/backend/src/schema/resolvers/locations.spec.js b/backend/src/schema/resolvers/locations.spec.js new file mode 100644 index 000000000..aed2419e0 --- /dev/null +++ b/backend/src/schema/resolvers/locations.spec.js @@ -0,0 +1,85 @@ +import Factory from '../../seed/factories' +import { gql } from '../../jest/helpers' +import { neode as getNeode, getDriver } from '../../bootstrap/neo4j' +import createServer from '../../server' +import { createTestClient } from 'apollo-server-testing' + +const factory = Factory() + +let mutate, authenticatedUser + +const driver = getDriver() +const neode = getNeode() + +beforeAll(() => { + const { server } = createServer({ + context: () => { + return { + driver, + neode, + user: authenticatedUser, + } + }, + }) + mutate = createTestClient(server).mutate +}) + +afterEach(async () => { + await factory.cleanDatabase() +}) + +describe('resolvers', () => { + describe('Location', () => { + describe('custom mutation, not handled by neo4j-graphql-js', () => { + let variables + const updateUserMutation = gql` + mutation($id: ID!, $name: String) { + UpdateUser(id: $id, name: $name) { + name + location { + name: nameRU + nameEN + } + } + } + ` + + beforeEach(async () => { + variables = { + id: 'u47', + name: 'John Doughnut', + } + const Paris = await factory.create('Location', { + id: 'region.9397217726497330', + name: 'Paris', + type: 'region', + lat: 2.35183, + lng: 48.85658, + nameEN: 'Paris', + }) + + const user = await factory.create('User', { + id: 'u47', + name: 'John Doe', + }) + await user.relateTo(Paris, 'isIn') + authenticatedUser = await user.toJson() + }) + + it('returns `null` if location translation is not available', async () => { + await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject({ + data: { + UpdateUser: { + name: 'John Doughnut', + location: { + name: null, + nameEN: 'Paris', + }, + }, + }, + errors: undefined, + }) + }) + }) + }) +}) diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index 82f6fcfb5..619a21aa2 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -177,6 +177,7 @@ export default { 'termsAndConditionsAgreedVersion', 'termsAndConditionsAgreedAt', 'allowEmbedIframes', + 'locale', ], boolean: { followedByCurrentUser: diff --git a/backend/src/schema/types/type/Donations.gql b/backend/src/schema/types/type/Donations.gql new file mode 100644 index 000000000..39cfe9b71 --- /dev/null +++ b/backend/src/schema/types/type/Donations.gql @@ -0,0 +1,15 @@ +type Donations { + id: ID! + goal: Int! + progress: Int! + createdAt: String + updatedAt: String +} + +type Query { + Donations: [Donations] +} + +type Mutation { + UpdateDonations(goal: Int, progress: Int): Donations +} \ No newline at end of file diff --git a/backend/src/seed/factories/donations.js b/backend/src/seed/factories/donations.js new file mode 100644 index 000000000..e22cdb6d7 --- /dev/null +++ b/backend/src/seed/factories/donations.js @@ -0,0 +1,18 @@ +import uuid from 'uuid/v4' + +export default function create() { + return { + factory: async ({ args, neodeInstance }) => { + const defaults = { + id: uuid(), + goal: 15000, + progress: 0, + } + args = { + ...defaults, + ...args, + } + return neodeInstance.create('Donations', args) + }, + } +} diff --git a/backend/src/seed/factories/index.js b/backend/src/seed/factories/index.js index 2c96c8698..5054155fc 100644 --- a/backend/src/seed/factories/index.js +++ b/backend/src/seed/factories/index.js @@ -8,6 +8,7 @@ import createTag from './tags.js' import createSocialMedia from './socialMedia.js' import createLocation from './locations.js' import createEmailAddress from './emailAddresses.js' +import createDonations from './donations.js' import createUnverifiedEmailAddresss from './unverifiedEmailAddresses.js' const factories = { @@ -21,6 +22,7 @@ const factories = { Location: createLocation, EmailAddress: createEmailAddress, UnverifiedEmailAddress: createUnverifiedEmailAddresss, + Donations: createDonations, } export const cleanDatabase = async (options = {}) => { diff --git a/backend/src/seed/seed-db.js b/backend/src/seed/seed-db.js index a7a784bba..7d3b54eaf 100644 --- a/backend/src/seed/seed-db.js +++ b/backend/src/seed/seed-db.js @@ -992,6 +992,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] }), ) + await factory.create('Donations') /* eslint-disable-next-line no-console */ console.log('Seeded Data...') process.exit(0) diff --git a/backend/yarn.lock b/backend/yarn.lock index fbd07377f..7dc7c6503 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1154,44 +1154,44 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= -"@sentry/core@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.7.1.tgz#3eb2b7662cac68245931ee939ec809bf7a639d0e" - integrity sha512-AOn3k3uVWh2VyajcHbV9Ta4ieDIeLckfo7UMLM+CTk2kt7C89SayDGayJMSsIrsZlL4qxBoLB9QY4W2FgAGJrg== +"@sentry/core@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.8.0.tgz#bbfd2f4711491951a8e3a0e8fa8b172fdf7bff6f" + integrity sha512-aAh2KLidIXJVGrxmHSVq2eVKbu7tZiYn5ylW6yzJXFetS5z4MA+JYaSBaG2inVYDEEqqMIkb17TyWxxziUDieg== dependencies: - "@sentry/hub" "5.7.1" - "@sentry/minimal" "5.7.1" + "@sentry/hub" "5.8.0" + "@sentry/minimal" "5.8.0" "@sentry/types" "5.7.1" - "@sentry/utils" "5.7.1" + "@sentry/utils" "5.8.0" tslib "^1.9.3" -"@sentry/hub@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.7.1.tgz#a52acd9fead7f3779d96e9965c6978aecc8b9cad" - integrity sha512-evGh323WR073WSBCg/RkhlUmCQyzU0xzBzCZPscvcoy5hd4SsLE6t9Zin+WACHB9JFsRQIDwNDn+D+pj3yKsig== +"@sentry/hub@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.8.0.tgz#56aaeb7324cb66d90db838011cb0127f5558007f" + integrity sha512-VdApn1ZCNwH1wwQwoO6pu53PM/qgHG+DQege0hbByluImpLBhAj9w50nXnF/8KzV4UoMIVbzCb6jXzMRmqqp9A== dependencies: "@sentry/types" "5.7.1" - "@sentry/utils" "5.7.1" + "@sentry/utils" "5.8.0" tslib "^1.9.3" -"@sentry/minimal@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.7.1.tgz#56afc537737586929e25349765e37a367958c1e1" - integrity sha512-nS/Dg+jWAZtcxQW8wKbkkw4dYvF6uyY/vDiz/jFCaux0LX0uhgXAC9gMOJmgJ/tYBLJ64l0ca5LzpZa7BMJQ0g== +"@sentry/minimal@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.8.0.tgz#b7ad5113504ab67f1ef2b0f465b7ba608e6b8dc5" + integrity sha512-MIlFOgd+JvAUrBBmq7vr9ovRH1HvckhnwzHdoUPpKRBN+rQgTyZy1o6+kA2fASCbrRqFCP+Zk7EHMACKg8DpIw== dependencies: - "@sentry/hub" "5.7.1" + "@sentry/hub" "5.8.0" "@sentry/types" "5.7.1" tslib "^1.9.3" -"@sentry/node@^5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.7.1.tgz#94e2fbac94f6cc061be3bc14b22813536c59698d" - integrity sha512-hVM10asFStrOhYZzMqFM7V1lrHkr1ydc2n/SFG0ZmIQxfTjCVElyXV/BJASIdqadM1fFIvvtD/EfgkTcZmub1g== +"@sentry/node@^5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.8.0.tgz#68ec032b0e7fb840cc8ccc1b39c09ac6febc1046" + integrity sha512-hIzt1BysyQJez8ChgWpFkLcGq3t/HaLMqzrXF5vu+Uuekl5OfwsvzZ+8Dlv78rI4CvlL9a2EuI/94iqUNwhOSQ== dependencies: - "@sentry/core" "5.7.1" - "@sentry/hub" "5.7.1" + "@sentry/core" "5.8.0" + "@sentry/hub" "5.8.0" "@sentry/types" "5.7.1" - "@sentry/utils" "5.7.1" + "@sentry/utils" "5.8.0" cookie "^0.3.1" https-proxy-agent "^3.0.0" lru_map "^0.3.3" @@ -1202,10 +1202,10 @@ resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.7.1.tgz#4c4c1d4d891b6b8c2c3c7b367d306a8b1350f090" integrity sha512-tbUnTYlSliXvnou5D4C8Zr+7/wJrHLbpYX1YkLXuIJRU0NSi81bHMroAuHWILcQKWhVjaV/HZzr7Y/hhWtbXVQ== -"@sentry/utils@5.7.1": - version "5.7.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.7.1.tgz#cf37ad55f78e317665cd8680f202d307fa77f1d0" - integrity sha512-nhirUKj/qFLsR1i9kJ5BRvNyzdx/E2vorIsukuDrbo8e3iZ11JMgCOVrmC8Eq9YkHBqgwX4UnrPumjFyvGMZ2Q== +"@sentry/utils@5.8.0": + version "5.8.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.8.0.tgz#34683088159b9935f973b6e6cad1a1cc26bbddac" + integrity sha512-KDxUvBSYi0/dHMdunbxAxD3389pcQioLtcO6CI6zt/nJXeVFolix66cRraeQvqupdLhvOk/el649W4fCPayTHw== dependencies: "@sentry/types" "5.7.1" tslib "^1.9.3" @@ -3342,10 +3342,10 @@ eslint-plugin-import@~2.18.2: read-pkg-up "^2.0.0" resolve "^1.11.0" -eslint-plugin-jest@~23.0.2: - version "23.0.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-23.0.2.tgz#54a59bfe77245186afe13711a297067aefefff0a" - integrity sha512-fkxcvOJm0hC/jbJqYJjtuC9mvpTJqXd0Nixx7joVQvJoBQuXk/ws3+MtRYzD/4TcKSgvr21uuSLdwSxKJKC2cg== +eslint-plugin-jest@~23.0.3: + version "23.0.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-23.0.3.tgz#d3f157f7791f97713372c13259ba1dfc436eb4c1" + integrity sha512-9cNxr66zeOyz1S9AkQL4/ouilR6QHpYj8vKOQZ60fu9hAt5PJWS4KqWqfr1aqN5NFEZSPjFOla2Azn+KTWiGwg== dependencies: "@typescript-eslint/experimental-utils" "^2.5.0" diff --git a/deployment/digital-ocean/dashboard/README.md b/deployment/digital-ocean/dashboard/README.md index 3ae6378bf..5f66afe0b 100644 --- a/deployment/digital-ocean/dashboard/README.md +++ b/deployment/digital-ocean/dashboard/README.md @@ -5,7 +5,7 @@ The kubernetes dashboard is optional but very helpful for debugging. If you want ```bash # in folder deployment/digital-ocean/ $ kubectl apply -f dashboard/ -$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml +$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml ``` ### Login to your dashboard @@ -18,7 +18,7 @@ $ kubectl proxy Visit: -[http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/](http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/) +[http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/](http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/) You should see a login screen. diff --git a/deployment/digital-ocean/https/README.md b/deployment/digital-ocean/https/README.md index d100ba8dd..855a7facf 100644 --- a/deployment/digital-ocean/https/README.md +++ b/deployment/digital-ocean/https/README.md @@ -1,15 +1,16 @@ # Setup Ingress and HTTPS Follow [this quick start guide](https://docs.cert-manager.io/en/latest/tutorials/acme/quick-start/index.html) and install certmanager via helm and tiller: +[This resource was also helpful](https://docs.cert-manager.io/en/latest/getting-started/install/kubernetes.html#installing-with-helm) -```text +```bash $ kubectl create serviceaccount tiller --namespace=kube-system $ kubectl create clusterrolebinding tiller-admin --serviceaccount=kube-system:tiller --clusterrole=cluster-admin $ helm init --service-account=tiller +$ helm repo add jetstack https://charts.jetstack.io $ helm repo update -$ helm install stable/nginx-ingress -$ kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.6/deploy/manifests/00-crds.yaml -$ helm install --name cert-manager --namespace cert-manager stable/cert-manager +$ kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.11/deploy/manifests/00-crds.yaml +$ helm install --name cert-manager --namespace cert-manager --version v0.11.0 jetstack/cert-manager ``` ## Create Letsencrypt Issuers and Ingress Services diff --git a/deployment/digital-ocean/https/templates/ingress.template.yaml b/deployment/digital-ocean/https/templates/ingress.template.yaml index a1af35bc7..d55c4d834 100644 --- a/deployment/digital-ocean/https/templates/ingress.template.yaml +++ b/deployment/digital-ocean/https/templates/ingress.template.yaml @@ -12,20 +12,20 @@ spec: tls: - hosts: # - nitro-mailserver.human-connection.org - - nitro-staging.human-connection.org + - develop.human-connection.org secretName: tls rules: - - host: nitro-staging.human-connection.org + - host: develop.human-connection.org http: paths: - path: / backend: - serviceName: nitro-web + serviceName: web servicePort: 3000 - # - host: nitro-mailserver.human-connection.org - # http: - # paths: - # - path: / - # backend: - # serviceName: mailserver - # servicePort: 80 + - host: mailserver.human-connection.org + http: + paths: + - path: / + backend: + serviceName: mailserver + servicePort: 80 diff --git a/deployment/human-connection/deployment-backend.yaml b/deployment/human-connection/deployment-backend.yaml index 51f0eb43c..0f75127e5 100644 --- a/deployment/human-connection/deployment-backend.yaml +++ b/deployment/human-connection/deployment-backend.yaml @@ -1,47 +1,60 @@ ---- - apiVersion: extensions/v1beta1 - kind: Deployment - metadata: - name: nitro-backend - namespace: human-connection - spec: - replicas: 1 - minReadySeconds: 15 - progressDeadlineSeconds: 60 - strategy: - rollingUpdate: - maxSurge: 0 - maxUnavailable: "100%" - selector: - matchLabels: +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + human-connection.org/commit: COMMIT + human-connection.org/selector: deployment-human-connection-backend + name: backend + namespace: human-connection +spec: + minReadySeconds: 15 + progressDeadlineSeconds: 60 + replicas: 1 + revisionHistoryLimit: 2147483647 + selector: + matchLabels: + human-connection.org/selector: deployment-human-connection-backend + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: 100% + type: RollingUpdate + template: + metadata: + annotations: + backup.velero.io/backup-volumes: uploads + creationTimestamp: null + labels: + human-connection.org/commit: COMMIT human-connection.org/selector: deployment-human-connection-backend - template: - metadata: - annotations: - backup.velero.io/backup-volumes: uploads - labels: - human-connection.org/commit: COMMIT - human-connection.org/selector: deployment-human-connection-backend - name: "nitro-backend" - spec: - containers: - - name: nitro-backend - image: humanconnection/nitro-backend:latest - imagePullPolicy: Always - ports: - - containerPort: 4000 - envFrom: - - configMapRef: - name: configmap - - secretRef: - name: human-connection - volumeMounts: - - mountPath: /nitro-backend/public/uploads - name: uploads - volumes: - - name: uploads - persistentVolumeClaim: - claimName: uploads-claim - restartPolicy: Always - terminationGracePeriodSeconds: 30 - status: {} + name: backend + spec: + containers: + - envFrom: + - configMapRef: + name: configmap + - secretRef: + name: human-connection + image: humanconnection/nitro-backend:latest + imagePullPolicy: Always + name: nitro-backend + ports: + - containerPort: 4000 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /nitro-backend/public/uploads + name: uploads + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - name: uploads + persistentVolumeClaim: + claimName: uploads-claim +status: {} diff --git a/deployment/human-connection/deployment-neo4j.yaml b/deployment/human-connection/deployment-neo4j.yaml index 3b381ce7b..5ff67b1a6 100644 --- a/deployment/human-connection/deployment-neo4j.yaml +++ b/deployment/human-connection/deployment-neo4j.yaml @@ -1,47 +1,61 @@ ---- - apiVersion: extensions/v1beta1 - kind: Deployment - metadata: - name: nitro-neo4j - namespace: human-connection - spec: - replicas: 1 - strategy: - rollingUpdate: - maxSurge: 0 - maxUnavailable: "100%" - selector: - matchLabels: +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + human-connection.org/selector: deployment-human-connection-neo4j + name: neo4j + namespace: human-connection +spec: + progressDeadlineSeconds: 2147483647 + replicas: 1 + revisionHistoryLimit: 2147483647 + selector: + matchLabels: + human-connection.org/selector: deployment-human-connection-neo4j + strategy: + rollingUpdate: + maxSurge: 0 + maxUnavailable: 100% + type: RollingUpdate + template: + metadata: + annotations: + backup.velero.io/backup-volumes: neo4j-data + creationTimestamp: null + labels: human-connection.org/selector: deployment-human-connection-neo4j - template: - metadata: - annotations: - backup.velero.io/backup-volumes: neo4j-data - labels: - human-connection.org/selector: deployment-human-connection-neo4j - name: nitro-neo4j - spec: - containers: - - name: nitro-neo4j - image: humanconnection/neo4j:latest - imagePullPolicy: Always - resources: - requests: - memory: "2G" - limits: - memory: "8G" - envFrom: - - configMapRef: - name: configmap - ports: - - containerPort: 7687 - - containerPort: 7474 - volumeMounts: - - mountPath: /data/ - name: neo4j-data - volumes: - - name: neo4j-data - persistentVolumeClaim: - claimName: neo4j-data-claim - restartPolicy: Always - terminationGracePeriodSeconds: 30 + name: neo4j + spec: + containers: + - envFrom: + - configMapRef: + name: configmap + image: humanconnection/neo4j:latest + imagePullPolicy: Always + name: neo4j + ports: + - containerPort: 7687 + protocol: TCP + - containerPort: 7474 + protocol: TCP + resources: + limits: + memory: 2G + requests: + memory: 1G + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /data/ + name: neo4j-data + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + volumes: + - name: neo4j-data + persistentVolumeClaim: + claimName: neo4j-data-claim +status: {} diff --git a/deployment/human-connection/deployment-web.yaml b/deployment/human-connection/deployment-web.yaml index 885762e0a..db9c22a1f 100644 --- a/deployment/human-connection/deployment-web.yaml +++ b/deployment/human-connection/deployment-web.yaml @@ -1,37 +1,54 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - name: nitro-web + creationTimestamp: null + labels: + human-connection.org/commit: COMMIT + human-connection.org/selector: deployment-human-connection-web + name: web namespace: human-connection spec: - replicas: 2 minReadySeconds: 15 progressDeadlineSeconds: 60 + replicas: 2 + revisionHistoryLimit: 2147483647 selector: matchLabels: human-connection.org/selector: deployment-human-connection-web + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate template: metadata: + creationTimestamp: null labels: human-connection.org/commit: COMMIT human-connection.org/selector: deployment-human-connection-web - name: nitro-web + name: web spec: containers: - - name: web + - env: + - name: HOST + value: 0.0.0.0 envFrom: - configMapRef: name: configmap - secretRef: name: human-connection - env: - - name: HOST - value: 0.0.0.0 image: humanconnection/nitro-web:latest + imagePullPolicy: Always + name: web ports: - containerPort: 3000 + protocol: TCP resources: {} - imagePullPolicy: Always + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} terminationGracePeriodSeconds: 30 status: {} diff --git a/deployment/human-connection/mailserver/deployment-mailserver.yaml b/deployment/human-connection/mailserver/deployment-mailserver.yaml index d97a66bc9..7037c54da 100644 --- a/deployment/human-connection/mailserver/deployment-mailserver.yaml +++ b/deployment/human-connection/mailserver/deployment-mailserver.yaml @@ -1,34 +1,51 @@ ---- - apiVersion: extensions/v1beta1 - kind: Deployment - metadata: - name: mailserver - namespace: human-connection - spec: - replicas: 1 - minReadySeconds: 15 - progressDeadlineSeconds: 60 - selector: - matchLabels: +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + human-connection.org/selector: deployment-human-connection-mailserver + name: mailserver + namespace: human-connection +spec: + minReadySeconds: 15 + progressDeadlineSeconds: 60 + replicas: 1 + revisionHistoryLimit: 2147483647 + selector: + matchLabels: + human-connection.org/selector: deployment-human-connection-mailserver + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + creationTimestamp: null + labels: human-connection.org/selector: deployment-human-connection-mailserver - template: - metadata: - labels: - human-connection.org/selector: deployment-human-connection-mailserver - name: "mailserver" - spec: - containers: - - name: mailserver - image: djfarrelly/maildev - imagePullPolicy: Always - ports: - - containerPort: 80 - - containerPort: 25 - envFrom: - - configMapRef: - name: configmap - - secretRef: - name: human-connection - restartPolicy: Always - terminationGracePeriodSeconds: 30 - status: {} + name: mailserver + spec: + containers: + - envFrom: + - configMapRef: + name: configmap + - secretRef: + name: human-connection + image: djfarrelly/maildev + imagePullPolicy: Always + name: mailserver + ports: + - containerPort: 80 + protocol: TCP + - containerPort: 25 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 +status: {} diff --git a/deployment/human-connection/service-backend.yaml b/deployment/human-connection/service-backend.yaml index 52e4621b2..b36172ea7 100644 --- a/deployment/human-connection/service-backend.yaml +++ b/deployment/human-connection/service-backend.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: nitro-backend + name: backend namespace: human-connection labels: human-connection.org/selector: deployment-human-connection-backend diff --git a/deployment/human-connection/service-neo4j.yaml b/deployment/human-connection/service-neo4j.yaml index ebe7c5208..e5633884b 100644 --- a/deployment/human-connection/service-neo4j.yaml +++ b/deployment/human-connection/service-neo4j.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: nitro-neo4j + name: neo4j namespace: human-connection labels: human-connection.org/selector: deployment-human-connection-neo4j diff --git a/deployment/human-connection/service-web.yaml b/deployment/human-connection/service-web.yaml index 548b874c2..ec39442d5 100644 --- a/deployment/human-connection/service-web.yaml +++ b/deployment/human-connection/service-web.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: nitro-web + name: web namespace: human-connection labels: human-connection.org/selector: deployment-human-connection-web diff --git a/package.json b/package.json index cb5c764ab..38509a631 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nitro-cypress", - "version": "0.1.9", + "version": "0.1.10", "description": "Fullstack tests with cypress for Human Connection", "author": "Human Connection gGmbh", "license": "MIT", @@ -24,7 +24,7 @@ "bcryptjs": "^2.4.3", "codecov": "^3.6.1", "cross-env": "^6.0.3", - "cypress": "^3.6.0", + "cypress": "^3.6.1", "cypress-cucumber-preprocessor": "^1.16.2", "cypress-file-upload": "^3.5.0", "cypress-plugin-retries": "^1.4.0", diff --git a/scripts/deploy.sh b/scripts/deploy.sh index cfde8008d..146d342c9 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash sed -i "s//${TRAVIS_COMMIT}/g" $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml sed -i "s//${TRAVIS_COMMIT}/g" $TRAVIS_BUILD_DIR/scripts/patches/patch-configmap.yaml -kubectl --namespace=human-connection patch configmap configmap -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-configmap.yaml)" -kubectl --namespace=human-connection patch deployment nitro-backend -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)" -kubectl --namespace=human-connection patch deployment nitro-web -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)" +kubectl --namespace=human-connection patch configmap configmap -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-configmap.yaml)" +kubectl --namespace=human-connection patch deployment backend -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)" +kubectl --namespace=human-connection patch deployment web -p "$(cat $TRAVIS_BUILD_DIR/scripts/patches/patch-deployment.yaml)" diff --git a/scripts/setup_kubernetes.sh b/scripts/setup_kubernetes.sh index 2596a3e51..ea39312f6 100755 --- a/scripts/setup_kubernetes.sh +++ b/scripts/setup_kubernetes.sh @@ -13,6 +13,6 @@ tar xf doctl-1.14.0-linux-amd64.tar.gz chmod +x ./doctl sudo mv ./doctl /usr/local/bin/doctl -doctl auth init --access-token $DOCTL_ACCESS_TOKEN +doctl auth init --access-token $DIGITALOCEAN_ACCESS_TOKEN mkdir -p ~/.kube/ -doctl kubernetes cluster kubeconfig show nitro-staging > ~/.kube/config +doctl k8s cluster kubeconfig show develop > ~/.kube/config diff --git a/webapp/components/DonationInfo/DonationInfo.spec.js b/webapp/components/DonationInfo/DonationInfo.spec.js new file mode 100644 index 000000000..ca719c19a --- /dev/null +++ b/webapp/components/DonationInfo/DonationInfo.spec.js @@ -0,0 +1,80 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import Styleguide from '@human-connection/styleguide' +import DonationInfo from './DonationInfo.vue' + +const localVue = createLocalVue() +localVue.use(Styleguide) + +const mockDate = new Date(2019, 11, 6) +global.Date = jest.fn(() => mockDate) + +describe('DonationInfo.vue', () => { + let mocks, wrapper + + beforeEach(() => { + mocks = { + $t: jest.fn(string => string), + $i18n: { + locale: () => 'de', + }, + } + }) + + const Wrapper = () => mount(DonationInfo, { mocks, localVue }) + + it('includes a link to the Human Connection donations website', () => { + expect( + Wrapper() + .find('a') + .attributes('href'), + ).toBe('https://human-connection.org/spenden/') + }) + + it('displays a call to action button', () => { + expect( + Wrapper() + .find('.ds-button') + .text(), + ).toBe('donations.donate-now') + }) + + it('creates a title from the current month and a translation string', () => { + mocks.$t = jest.fn(() => 'Spenden für') + expect(Wrapper().vm.title).toBe('Spenden für Dezember') + }) + + describe('mount with data', () => { + beforeEach(() => { + wrapper = Wrapper() + wrapper.setData({ goal: 50000, progress: 10000 }) + }) + + describe('given german locale', () => { + it('creates a label from the given amounts and a translation string', () => { + expect(mocks.$t).toBeCalledWith( + 'donations.amount-of-total', + expect.objectContaining({ + amount: '10.000', + total: '50.000', + }), + ) + }) + }) + + describe('given english locale', () => { + beforeEach(() => { + mocks.$i18n.locale = () => 'en' + }) + + it('creates a label from the given amounts and a translation string', () => { + expect(mocks.$t).toBeCalledWith( + 'donations.amount-of-total', + expect.objectContaining({ + amount: '10,000', + total: '50,000', + }), + ) + }) + }) + }) +}) diff --git a/webapp/components/DonationInfo/DonationInfo.vue b/webapp/components/DonationInfo/DonationInfo.vue new file mode 100644 index 000000000..10f42e880 --- /dev/null +++ b/webapp/components/DonationInfo/DonationInfo.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/webapp/components/Hashtag/Hashtag.spec.js b/webapp/components/Hashtag/Hashtag.spec.js index cfb7d7e3f..cfd1a7c2a 100644 --- a/webapp/components/Hashtag/Hashtag.spec.js +++ b/webapp/components/Hashtag/Hashtag.spec.js @@ -1,10 +1,12 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils' +import { config, shallowMount, createLocalVue } from '@vue/test-utils' import Styleguide from '@human-connection/styleguide' import Hashtag from './Hashtag' const localVue = createLocalVue() localVue.use(Styleguide) +config.stubs['nuxt-link'] = '' + describe('Hashtag', () => { let id diff --git a/webapp/components/ProgressBar/ProgressBar.spec.js b/webapp/components/ProgressBar/ProgressBar.spec.js new file mode 100644 index 000000000..6fb6f1666 --- /dev/null +++ b/webapp/components/ProgressBar/ProgressBar.spec.js @@ -0,0 +1,65 @@ +import { mount } from '@vue/test-utils' +import ProgressBar from './ProgressBar' + +describe('ProgessBar.vue', () => { + let propsData + + beforeEach(() => { + propsData = { + goal: 50000, + progress: 10000, + } + }) + + const Wrapper = () => mount(ProgressBar, { propsData }) + + describe('given only goal and progress', () => { + it('renders no title', () => { + expect( + Wrapper() + .find('.progress-bar__title') + .exists(), + ).toBe(false) + }) + + it('renders no label', () => { + expect( + Wrapper() + .find('.progress-bar__label') + .exists(), + ).toBe(false) + }) + + it('calculates the progress bar width as a percentage of the goal', () => { + expect(Wrapper().vm.progressBarWidth).toBe('width: 20%;') + }) + }) + + describe('given a title', () => { + beforeEach(() => { + propsData.title = 'This is progress' + }) + + it('renders the title', () => { + expect( + Wrapper() + .find('.progress-bar__title') + .text(), + ).toBe('This is progress') + }) + }) + + describe('given a label', () => { + beforeEach(() => { + propsData.label = 'Going well' + }) + + it('renders the label', () => { + expect( + Wrapper() + .find('.progress-bar__label') + .text(), + ).toBe('Going well') + }) + }) +}) diff --git a/webapp/components/ProgressBar/ProgressBar.vue b/webapp/components/ProgressBar/ProgressBar.vue new file mode 100644 index 000000000..9fd799b39 --- /dev/null +++ b/webapp/components/ProgressBar/ProgressBar.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/webapp/components/User/User.vue b/webapp/components/User/User.vue index 4b92ee890..f1508cc4e 100644 --- a/webapp/components/User/User.vue +++ b/webapp/components/User/User.vue @@ -79,7 +79,7 @@ - + - - - - - diff --git a/webapp/graphql/Donations.js b/webapp/graphql/Donations.js new file mode 100644 index 000000000..cc2a6a783 --- /dev/null +++ b/webapp/graphql/Donations.js @@ -0,0 +1,24 @@ +import gql from 'graphql-tag' + +export const DonationsQuery = () => gql` + query { + Donations { + id + goal + progress + } + } +` + +export const UpdateDonations = () => { + return gql` + mutation($goal: Int, $progress: Int) { + UpdateDonations(goal: $goal, progress: $progress) { + id + goal + progress + updatedAt + } + } + ` +} diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 7f2fe9816..2867f5495 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -62,6 +62,11 @@ } } }, + "donations": { + "donations-for": "Spenden für", + "donate-now": "Jetzt spenden", + "amount-of-total": "{amount} von {total} € erreicht" + }, "maintenance": { "title": "Human Connection befindet sich in der Wartung", "explanation": "Zurzeit führen wir einige geplante Wartungsarbeiten durch, bitte versuch es später erneut.", @@ -375,6 +380,12 @@ "name": "Benutzer einladen", "title": "Leute einladen", "description": "Einladungen sind ein wunderbarer Weg, deine Freund in deinem Netzwerk zu haben …" + }, + "donations": { + "name": "Spendeninfo", + "goal": "Monatlich benötigte Spenden", + "progress": "Bereits gesammelte Spenden", + "successfulUpdate": "Spenden-Info erfolgreich aktualisiert!" } }, "post": { diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 57e578fe1..d1b56cdc0 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -63,6 +63,11 @@ } } }, + "donations": { + "donations-for": "Donations for", + "donate-now": "Donate now", + "amount-of-total": "{amount} of {total} € collected" + }, "maintenance": { "title": "Human Connection is under maintenance", "explanation": "At the moment we are doing some scheduled maintenance, please try again later.", @@ -376,6 +381,12 @@ "name": "Invite users", "title": "Invite people", "description": "Invitations are a wonderful way to have your friends in your network …" + }, + "donations": { + "name": "Donations info", + "goal": "Monthly donations needed", + "progress": "Donations collected so far", + "successfulUpdate": "Donations info updated successfully!" } }, "post": { diff --git a/webapp/locales/pt.json b/webapp/locales/pt.json index ba3209b5f..76560aba9 100644 --- a/webapp/locales/pt.json +++ b/webapp/locales/pt.json @@ -380,6 +380,12 @@ "name": "Convidar usuários", "title": "Convidar pessoas", "description": "Convites são uma maneira maravilhosa de ter seus amigos em sua rede …" + }, + "donations": { + "name": "Informações sobre Doações", + "goal": "Doações mensais necessárias", + "progress": "Doações arrecadadas até o momento", + "successfulUpdate": "Informações sobre doações atualizadas com sucesso!" } }, "post": { @@ -690,7 +696,7 @@ "terms-of-service": { "title": "Termos do Serviço", "description": "As seguintes condições de utilização constituem a base para a utilização da nossa rede. Ao registar-se, deve aceitar os termos de utilização e informaremos mais tarde sobre quaisquer alterações que possam ocorrer. A Human Connection Network é operada na Alemanha e, portanto, está sujeita à lei alemã. O local de jurisdição é Kirchheim / Teck. Para mais detalhes, veja a nossa impressão: https://human-connection.org/imprint " - }, + }, "use-and-license" : { "title": "Uso e Licença", "description": "Se qualquer conteúdo que você publicar para nós for protegido por direitos de propriedade intelectual, você nos concede uma licença não exclusiva, transferível, sublicenciável e mundial para usar tal conteúdo para postar em nossa rede. Esta licença expira quando você exclui seu conteúdo ou toda a sua conta. Lembre-se de que outros podem compartilhar seu conteúdo e nós não podemos excluí-lo." @@ -718,6 +724,6 @@ "addition" : { "title": "Além disso, realizamos regularmente eventos onde você também pode compartilhar suas impressões e fazer perguntas. Você pode encontrar uma visão geral atual aqui:", "description": " https://human-connection.org/events/ " - } + } } } diff --git a/webapp/package.json b/webapp/package.json index 613e9f9d0..a75d80095 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -65,7 +65,7 @@ "cookie-universal-nuxt": "~2.0.18", "cropperjs": "^1.5.5", "cross-env": "~6.0.3", - "date-fns": "2.6.0", + "date-fns": "2.7.0", "express": "~4.17.1", "graphql": "~14.5.8", "jsonwebtoken": "~8.5.1", @@ -95,15 +95,15 @@ "@babel/core": "~7.7.2", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/preset-env": "~7.7.1", - "@storybook/addon-a11y": "^5.2.5", - "@storybook/addon-actions": "^5.2.5", + "@storybook/addon-a11y": "^5.2.6", + "@storybook/addon-actions": "^5.2.6", "@storybook/addon-notes": "^5.2.5", - "@storybook/vue": "~5.2.5", + "@storybook/vue": "~5.2.6", "@vue/cli-shared-utils": "~4.0.5", "@vue/eslint-config-prettier": "~5.0.0", "@vue/server-test-utils": "~1.0.0-beta.29", "@vue/test-utils": "~1.0.0-beta.29", - "async-validator": "^3.2.1", + "async-validator": "^3.2.2", "babel-core": "~7.0.0-bridge.0", "babel-eslint": "~10.0.3", "babel-jest": "~24.9.0", @@ -134,10 +134,10 @@ "storybook-design-token": "^0.4.1", "storybook-vue-router": "^1.0.7", "style-loader": "~0.23.1", - "style-resources-loader": "~1.2.1", + "style-resources-loader": "~1.3.2", "vue-jest": "~3.0.5", "vue-loader": "~15.7.2", - "vue-svg-loader": "~0.14.0", + "vue-svg-loader": "~0.15.0", "vue-template-compiler": "^2.6.10" } } diff --git a/webapp/pages/admin.vue b/webapp/pages/admin.vue index 7852673b0..8f2b989d6 100644 --- a/webapp/pages/admin.vue +++ b/webapp/pages/admin.vue @@ -55,6 +55,10 @@ export default { name: this.$t('admin.invites.name'), path: `/admin/invite`, }, + { + name: this.$t('admin.donations.name'), + path: '/admin/donations', + }, // TODO implement /* { name: this.$t('admin.settings.name'), diff --git a/webapp/pages/admin/donations.vue b/webapp/pages/admin/donations.vue new file mode 100644 index 000000000..7f0205be5 --- /dev/null +++ b/webapp/pages/admin/donations.vue @@ -0,0 +1,63 @@ + + + diff --git a/webapp/pages/index.spec.js b/webapp/pages/index.spec.js index 0433957bb..0cee06b38 100644 --- a/webapp/pages/index.spec.js +++ b/webapp/pages/index.spec.js @@ -29,6 +29,7 @@ describe('PostIndex', () => { beforeEach(() => { mutations = { 'posts/SELECT_ORDER': jest.fn(), + 'posts/SET_CURRENT_POSTS': jest.fn(), } store = new Vuex.Store({ getters: { @@ -53,6 +54,7 @@ describe('PostIndex', () => { 'auth/user': () => { return { id: 'u23' } }, + 'posts/currentPosts': () => [], }, mutations, }) @@ -62,6 +64,9 @@ describe('PostIndex', () => { truncate: a => a, removeLinks: jest.fn(), }, + $i18n: { + locale: () => 'de', + }, // If you are mocking router, than don't use VueRouter with localVue: https://vue-test-utils.vuejs.org/guides/using-with-vue-router.html $router: { history: { diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index f15634ccc..caf5d54f6 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -4,7 +4,8 @@ - + +