Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.3 #911

Merged
merged 30 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e4cb80c
Add overflow: hidden to prevent leaky image
charlottedibb Feb 14, 2020
f161224
Remove unneeded border-radius
charlottedibb Feb 14, 2020
05d6d76
Update README.md
chrismclarke Feb 18, 2020
8036a8c
remove additional profile creation method
chrismclarke Feb 24, 2020
aacbe53
add user revision backup function
chrismclarke Feb 24, 2020
36e35ac
add template firestore rules
chrismclarke Feb 25, 2020
3077342
Merge pull request #885 from charcharmasonjar/798-how-to
chrismclarke Feb 25, 2020
426ed60
bump version
chrismclarke Feb 25, 2020
92731d8
remove deprecated analytics code
chrismclarke Feb 25, 2020
cd00d7d
refactor user revision backend function
chrismclarke Feb 25, 2020
6cc8973
refactor user backup
chrismclarke Feb 25, 2020
b94351b
add backend email integration
chrismclarke Feb 25, 2020
ae796c1
CreatedBy in How-to is now link to creator profile
ginnie7 Feb 29, 2020
d3b424e
adapting the test
ginnie7 Mar 1, 2020
30794fa
Add 'HowTo' publication date
tudi2d Mar 2, 2020
a86c9cb
remove header height in academy container
BenGamma Mar 6, 2020
412ca3a
Merge pull request #907 from ONEARMY/904_multiple_scroll_bar
BenGamma Mar 6, 2020
640bc9b
Merge pull request #889 from ONEARMY/fix/profile-wipe
BenGamma Mar 6, 2020
5e9d8c6
Add last edit date to HowTo Description
tudi2d Mar 8, 2020
fd7ae17
Add test for "Last edit:" in HowTo Description
tudi2d Mar 8, 2020
96c56a1
replaced &nbsp with a space and removed unnecessary check in tests
ginnie7 Mar 8, 2020
619713c
underline link & keep same font color
BenGamma Mar 10, 2020
d12862e
Merge pull request #908 from ONEARMY/895-link-username-to-profile
BenGamma Mar 10, 2020
ce51aa0
fix conflicts with master
BenGamma Mar 10, 2020
b223455
display edit date only if different from creation date & change color
BenGamma Mar 10, 2020
08c225b
Merge pull request #909 from ONEARMY/894-add-publication-date
BenGamma Mar 10, 2020
f5ca691
comment feedback button for survey banner
BenGamma Mar 11, 2020
ec48c31
update tests
BenGamma Mar 11, 2020
b950bfe
Merge pull request #910 from ONEARMY/benj/add-survey-banner
BenGamma Mar 11, 2020
14df77e
Merge pull request #893 from ONEARMY/feat/email-automation
BenGamma Mar 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Society and the environment are kind of screwed 💩 in many ways. We think free
## 🤝   Contributions

Contributions, issues and feature requests are very welcome.
Please make sure to read the [Contributing Guide](/CONTRIBUTING.md) before making a pull request.
Please make sure to read the [Contributing Guide](/CONTRIBUTING.md) before making a pull request.

It also covers lots of handy additional information such as setting up a local server, or finding [good first issues](https://github.com/ONEARMY/community-platform/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%22++label%3A%22Help+wanted%22+) to work on

## 🌟   Core Team

Expand Down
22 changes: 11 additions & 11 deletions cypress/integration/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,41 @@ describe('[Common]', () => {

it('[Page Navigation]', () => {
cy.visit('/how-to')
cy.step('Feedback button opens the survey in a new tab')
cy.get('a[data-cy=feedback][target=_blank]')
.should('have.attr', 'href')
.and(
'eq',
'https://docs.google.com/forms/d/e/1FAIpQLSd3nevXb6iewap1lkFPWQxyerLsndcRkocv4QXIL3iLIyzazA/viewform?usp=pp_url&entry.1856170488=',
)
// cy.step('Feedback button opens the survey in a new tab')
// cy.get('a[data-cy=feedback][target=_blank]')
// .should('have.attr', 'href')
// .and(
// 'eq',
// 'https://docs.google.com/forms/d/e/1FAIpQLSd3nevXb6iewap1lkFPWQxyerLsndcRkocv4QXIL3iLIyzazA/viewform?usp=pp_url&entry.1856170488=',
// )

cy.step('Go to Events page')
cy.get('[data-cy=page-link]')
.contains('Events')
.click()
cy.url().should('include', '/events')
cy.get('[data-cy=feedback] > button').should('be.visible')
// cy.get('[data-cy=feedback] > button').should('be.visible')

cy.step('Go to Map page')
cy.get('[data-cy=page-link]')
.contains('Map')
.click()
cy.url().should('include', '/map')
cy.get('[data-cy=feedback] > button').should('be.visible')
// cy.get('[data-cy=feedback] > button').should('be.visible')

cy.step('Go to Academy page')
cy.get('[data-cy=page-link]')
.contains('Academy')
.click()
cy.url().should('include', '/academy')
cy.get('[data-cy=feedback] > button').should('be.visible')
// cy.get('[data-cy=feedback] > button').should('be.visible')

cy.step('Go to How-to page')
cy.get('[data-cy=page-link]')
.contains('How-to')
.click()
cy.url().should('include', '/how-to')
cy.get('[data-cy=feedback] > button').should('be.visible')
// cy.get('[data-cy=feedback] > button').should('be.visible')
})

describe('[User Menu]', () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/howto/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('[How To]', () => {
cy.step('How-to has basic info')
cy.get('[data-cy=how-to-basis]').then($summary => {
expect($summary).to.contain('By howto_creator', 'Author')
expect($summary).to.contain('Last edit:', 'Edit')
expect($summary).to.contain('Make an interlocking brick', 'Title')
expect($summary).to.contain(
'show you how to make a brick using the injection machine',
Expand Down
31 changes: 31 additions & 0 deletions firestore.rules.WiP
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// WiP - CC - 2020-02-24
// As part of future security update will make better use of firestore rules, as stubbed out below

service cloud.firestore {
// rules will apply to all docs in database
match /databases/{database}/documents {
// Function to check whether request user has specific permission set in user database
function hasUserRole(username,role){
// TODO - look up a profile to see if the user has specific role (e.g. admin)
// NOTE - this is not currently possible as the username is not sent with a request
// but could be made possible by setting the firebase auth name to the username
// and ensuring all users had a userRoles property
// NOTE 2 - possible code below but would need testing (https://firebase.google.com/docs/reference/rules/rules.List)
// return role in get(/databases/$(database)/documents/v3_users/$(username)).data.userRoles
return true
}
// Function to check if request to modify a document is by the auth owner
function isSameUser(username){
return get(/databases/$(database)/documents/v3_users/$(username)).data._authID==request.auth.uid
}
match /v3_users/{username} {
allow read, write: if hasUserRole('admin')
allow read,write
}
// users can read/write their own user docs
match /v3_users/{username} {
allow read, write: if isSameUser(username)
}
}
}

54 changes: 0 additions & 54 deletions functions/src/Analytics/analytics.ts

This file was deleted.

16 changes: 0 additions & 16 deletions functions/src/Analytics/comments.ts

This file was deleted.

29 changes: 29 additions & 0 deletions functions/src/Integrations/firebase-email.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as functions from 'firebase-functions'
import { IDBEndpoint } from '../models'
import { db } from '..//Firebase/firestoreDB'

const USER_ENDPOINT: IDBEndpoint = 'v3_users'

/**
* Example function to show how an automated email can be triggered
* In this case it is being used temporarily to help debug
* https://github.com/ONEARMY/community-platform/issues/883
*/
export const notifyEmailDemo = functions.firestore
.document(`${USER_ENDPOINT}/precious-plastic`)
.onWrite(async (change, context) => {
return db.collection('mail').add({
to: 'chris.m.clarke@live.co.uk',
message: {
subject: 'PP Profile Edited',
html: `
<p>Just thought you should know that an edit has been made to your profile</p>
<h2>Before</h2>
<code>${JSON.stringify(change.before.data())}</code>
<h2>After</h2>
<code>${JSON.stringify(change.after.data())}</code>
<p>To see a clear breakdown of differences you could copy-paste each section into http://www.jsondiff.com</p>
`,
},
})
})
22 changes: 22 additions & 0 deletions functions/src/Integrations/firebase-userBackup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as functions from 'firebase-functions'
import { DBDoc, IDBEndpoint } from '../models'
const USERS_ENDPOINT: IDBEndpoint = 'v3_users'

/**
* Automatically create user revision on update
* Nests revision as subcollection of original document,
* labeled by previous _modified timestamp
*/
export const FirebaseUserBackup = functions.firestore
.document(`${USERS_ENDPOINT}/{username}`)
.onUpdate((change, context) => {
const { before, after } = change
const rev = before.data() as DBDoc
if (rev && rev._modified) {
return before.ref
.collection('revisions')
.doc(rev._modified)
.set(rev)
}
return null
})
4 changes: 4 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { weeklyTasks, dailyTasks } from './exports/tasks'
import { DH_Exports } from './DaveHakkensNL'
import * as IntegrationsSlack from './Integrations/firebase-slack'
import * as IntegrationsDiscord from './Integrations/firebase-discord'
import { FirebaseUserBackup } from './Integrations/firebase-userBackup'
import * as IntegrationsEmail from './Integrations/firebase-email'

// the following endpoints are exposed for use by various triggers
// see individual files for more informaiton
Expand All @@ -18,3 +20,5 @@ exports.notifyNewEvent = IntegrationsSlack.notifyNewEvent
exports.notifyPinAccepted = IntegrationsDiscord.notifyPinAccepted
exports.notifyHowToAccepted = IntegrationsDiscord.notifyHowToAccepted
exports.notifyEventAccepted = IntegrationsDiscord.notifyEventAccepted
exports.firebaseUserBackup = FirebaseUserBackup
exports.emailNotificationDemo = IntegrationsEmail.notifyEmailDemo
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "precious-plastic-community-plateform",
"version": "1.0.1",
"name": "precious-plastic-community-platform",
"version": "1.0.3",
"private": true,
"scripts": {
"start": "node scripts/start.js",
Expand Down
57 changes: 36 additions & 21 deletions src/pages/Howto/Content/Howto/HowtoDescription/HowtoDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import TagDisplay from 'src/components/Tags/TagDisplay/TagDisplay'
import differenceInDays from 'date-fns/difference_in_days'
import { format } from 'date-fns'
import { IHowtoDB } from 'src/models/howto.models'
import Heading from 'src/components/Heading'
import Text from 'src/components/Text'
Expand Down Expand Up @@ -29,15 +29,17 @@ export default class HowtoDescription extends React.PureComponent<IProps, any> {
super(props)
}

public durationSincePosted(postDate: Date) {
const daysSince: number = differenceInDays(new Date(), new Date(postDate))
switch (daysSince) {
case 0:
return 'today'
case 1:
return `${daysSince} day ago`
default:
return `${daysSince} days ago`
private dateCreatedByText(howto: IHowtoDB): string {
return format(new Date(howto._created), 'DD-MM-YYYY')
}

private dateLastEditText(howto: IHowtoDB): string {
const lastModifiedDate = format(new Date(howto._modified), 'DD-MM-YYYY')
const creationDate = format(new Date(howto._created), 'DD-MM-YYYY')
if (lastModifiedDate !== creationDate) {
return 'Last edit: ' + format(new Date(howto._modified), 'DD-MM-YYYY')
} else {
return ''
}
}

Expand Down Expand Up @@ -95,17 +97,26 @@ export default class HowtoDescription extends React.PureComponent<IProps, any> {
))}
</Flex>
<Text auxiliary mt={3} mb={2}>
By {howto._createdBy}
&nbsp;|&nbsp;
<Text inline color={'grey'}>
{this.durationSincePosted(new Date(howto._created))}
By{' '}
<Link
sx={{
textDecoration: 'underline',
color: 'inherit',
}}
to={'/u/' + howto._createdBy}
>
{howto._createdBy}
</Link>{' '}
<Text inline> {this.dateCreatedByText(howto)}</Text>
<Text auxiliary sx={{ color: '#b7b5b5 !important' }} mt={1} mb={2}>
{this.dateLastEditText(howto)}
</Text>
<Heading medium mt={2} mb={1}>
{howto.title}
</Heading>
<Text preLine paragraph>
{howto.description}
</Text>
</Text>
<Heading medium mt={2} mb={1}>
{howto.title}
</Heading>
<Text preLine paragraph>
{howto.description}
</Text>

<Flex mt={4} mb={2}>
Expand Down Expand Up @@ -143,7 +154,11 @@ export default class HowtoDescription extends React.PureComponent<IProps, any> {
sx={{ position: 'relative' }}
>
<Image
sx={{ objectFit: 'cover', width: '100%', height: '450px' }}
sx={{
objectFit: 'cover',
width: '100%',
height: '450px',
}}
src={howto.cover_image.downloadUrl}
alt="how-to cover"
/>
Expand Down
1 change: 0 additions & 1 deletion src/pages/Howto/Content/Howto/Step/ImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const ImageWithPointer = styled(Image)`
width: 100%;
height: 450px;
object-fit: cover;
border-radius: 0px 8px 0px 5px;
`

export default class ImageGallery extends React.PureComponent<IProps, IState> {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Howto/Content/Howto/Step/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class Step extends React.PureComponent<IProps> {
flex={9}
width={1}
flexDirection={['column', 'column', 'row']}
overflow={'hidden'}
>
<Flex width={[1, 1, 4 / 9]} py={4} px={4} flexDirection={'column'}>
<Heading medium mb={0}>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/PageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ const academy = {
),
title: 'Academy',
description: 'Demo external page embed',
customStyles: { position: 'absolute', height: '100%', width: '100%' },
customStyles: {
position: 'absolute',
height: 'calc(100% - 85px)',
width: '100%',
},
fullPageWidth: true,
}
const events = {
Expand Down
Loading