Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0125a58
chore(ci): track coverage
thisislawatts Mar 23, 2023
f6fda6d
chore(components): add coverage to unit tests
thisislawatts Apr 26, 2023
1a9f5a2
Merge pull request #2156 from ONEARMY/chore/track-coverage
thisislawatts Apr 26, 2023
3e55db8
feat(platform): add color toggle to follow button on research page
NoHara42 Apr 5, 2023
12d1bf2
feat(platform): add tests for 'Follow'/'Following' states of Research…
NoHara42 Apr 25, 2023
b1304d9
refactor(theme): extract common colors from themes to an exportable var
NoHara42 Apr 26, 2023
cfed652
refactor(Icons in ResearchDescription): adapt thunderbolt button to u…
NoHara42 Apr 26, 2023
3d39ad2
style(formatting): format fix
NoHara42 Apr 26, 2023
bda55ab
refactor: refactor variable names and remove unnecessary theme usage
AlfonsoGhislieri Apr 26, 2023
d6d301d
fix: update userstatisticx snapshot
AlfonsoGhislieri Apr 26, 2023
136dea0
test: check iconcolor of following button
AlfonsoGhislieri Apr 26, 2023
a2787aa
fix: reupdate userstatistic snapshot
AlfonsoGhislieri Apr 26, 2023
9c98986
feat(email-notifs): send emails from admin panel for testing
evakill Apr 27, 2023
4ecaa57
Merge pull request #2253 from evakill/evakill/notifications-button
thisislawatts Apr 27, 2023
86951bf
Merge pull request #2251 from AlfonsoGhislieri/noHara
thisislawatts Apr 27, 2023
f49c4ce
fix: packages/components/package.json to reduce vulnerabilities
snyk-bot Apr 26, 2023
e564886
docs: update README.md
allcontributors[bot] Apr 27, 2023
985e221
docs: update .all-contributorsrc
allcontributors[bot] Apr 27, 2023
f1adf1f
Merge pull request #2254 from ONEARMY/all-contributors/add-NoHara42
thisislawatts Apr 27, 2023
30d2003
Merge pull request #2246 from ONEARMY/snyk-fix-8a135a9e1f2faae30b1b8e…
thisislawatts Apr 27, 2023
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
12 changes: 11 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,20 @@
"contributions": [
"code"
]
},
{
"login": "NoHara42",
"name": "Ned O'Hara",
"avatar_url": "https://avatars.githubusercontent.com/u/43496778?v=4",
"profile": "https://github.com/NoHara42",
"contributions": [
"code"
]
}
],
"projectName": "community-platform",
"projectOwner": "ONEARMY",
"repoType": "github",
"repoHost": "https://github.com"
"repoHost": "https://github.com",
"commitConvention": "angular"
}
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ orbs:
browser-tools: circleci/browser-tools@1.1.3
# used to enable slack integration (required api key set in environment)
slack: circleci/slack@4.4.2
# used to track coverage
codecov: codecov/codecov@3.2.4

######################################################################################################
# Aliases - code snippets that can be included inline in any other markup
Expand Down Expand Up @@ -284,6 +286,12 @@ jobs:
- run:
# NOTE - run-in-band to try reduce memory leaks (https://github.com/facebook/jest/issues/7874)
command: yarn run test:unit:ci && yarn run test:components
- store_artifacts:
path: coverage
- store_artifacts:
path: packages/components/coverage
- codecov/upload

test_circular_dependency:
docker: *docker
steps:
Expand All @@ -295,6 +303,7 @@ jobs:
command: yarn workspaces focus one-army-community-platform
- run:
command: yarn run test:madge

build:
<<: *docker_matrix
environment:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Thanks go to these wonderful people ([emoji key](https://allcontributors.org/doc
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://devtato.com"><img src="https://avatars.githubusercontent.com/u/4504330?v=4?s=60" width="60px;" alt="Devtato"/><br /><sub><b>Devtato</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=cerkiewny" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/NoHara42"><img src="https://avatars.githubusercontent.com/u/43496778?v=4?s=60" width="60px;" alt="Ned O'Hara"/><br /><sub><b>Ned O'Hara</b></sub></a><br /><a href="https://github.com/ONEARMY/community-platform/commits?author=NoHara42" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions functions/src/emailNotifications/createEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const getResourceLabelFromNotificationType = (type: NotificationType) => {
return 'research'
case 'howto_useful':
case 'howto_mention':
case 'new_comment':
return 'how-to'
}
}
Expand Down
33 changes: 33 additions & 0 deletions functions/src/emailNotifications/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
import * as functions from 'firebase-functions'
import { createNotificationEmails } from './createEmail'
import { db } from '../Firebase/firestoreDB'
import { DB_ENDPOINTS, IUserDB } from '../models'

/** Trigger daily process to send any pending email notifications */
exports.sendDaily = functions.pubsub
// Trigger daily at 5pm (https://crontab.guru/#0_17_*_*_*)
.schedule('0 17 * * *')
.onRun(async () => createNotificationEmails())

exports.sendOnce = functions.https.onCall(async (_, context) => {
if (!context.auth) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called while authenticated.',
)
}
// Validate user exists and has admin status before triggering function.
const { uid } = context.auth
const user = await db.collection(DB_ENDPOINTS.users).doc(uid).get()
if (user.exists) {
const { userRoles } = user.data() as IUserDB
if (userRoles?.some((role) => ['admin', 'super-admin'].includes(role))) {
try {
await createNotificationEmails()
return 'OK'
} catch (error) {
console.error(error)
throw new functions.https.HttpsError(
'internal',
'There was an error creating emails.',
)
}
}
}
throw new functions.https.HttpsError(
'permission-denied',
'Emails can be triggered by admins only.',
)
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"test": "yarn workspace oa-cypress start",
"test:components": "yarn workspace oa-components test",
"test:unit": "env-cmd -e cra craco test --env=jsdom",
"test:unit:ci": "yarn build:themes && yarn build:components && env-cmd -e cra craco test --env=jsdom --runInBand --logHeapUsage",
"test:unit:ci": "yarn build:themes && yarn build:components && env-cmd -e cra craco test --env=jsdom --runInBand --logHeapUsage --coverage",
"test:madge": "npx madge --circular --extensions ts,tsx ./ --exclude src/stores",
"storybook": "yarn workspace oa-components start",
"storybook:build": "yarn build:themes && yarn workspace oa-components build:sb",
Expand Down
3 changes: 2 additions & 1 deletion packages/components/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
storybook-static
dist
dist
coverage
7 changes: 4 additions & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev": "tsc --watch",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx src --color",
"new-component": "ts-node scripts/newComponent.ts",
"test": "vitest"
"test": "vitest --coverage"
},
"dependencies": {
"@emotion/react": "^11.10.6",
Expand All @@ -36,7 +36,7 @@
"storybook": "^7.0.4",
"theme-ui": "^0.15.7",
"use-debounce": "^8.0.4",
"webpack": "^5.75.0",
"webpack": "5.76.0",
"yup": "^1.1.1"
},
"peerDependencies": {
Expand All @@ -56,6 +56,7 @@
"@types/react-flag-icon-css": "^1.0.5",
"@types/react-portal": "^4.0.4",
"@vitejs/plugin-react": "^3.1.0",
"@vitest/coverage-c8": "^0.30.1",
"babel-loader": "8.1.0",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.4",
Expand All @@ -67,6 +68,6 @@
"react-dom": "^17.0.2",
"ts-node": "^10.7.0",
"typescript": "^4.5.5",
"vitest": "^0.29.5"
"vitest": "^0.30.1"
}
}
3 changes: 2 additions & 1 deletion packages/components/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IBtnProps extends React.ButtonHTMLAttributes<HTMLElement> {
small?: boolean
large?: boolean
showIconOnly?: boolean
iconColor?: string
}

type ToArray<Type> = [Type] extends [any] ? Type[] : never
Expand Down Expand Up @@ -112,7 +113,7 @@ export const Button = (props: BtnProps) => {
pointerEvents: 'none',
}}
>
<Icon glyph={props.icon} />
<Icon glyph={props.icon} color={props.iconColor} />
</Flex>
)}
<Text
Expand Down
10 changes: 4 additions & 6 deletions packages/components/src/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ const IconWrapper = styled.div<Props>`
min-width: ${(props) => (props.size ? `${props.size}px` : '32px')};
min-height: ${(props) => (props.size ? `${props.size}px` : '32px')};
position: relative;
color: ${(props) => (props.color ? `${props.color}` : 'inherit')};
${verticalAlign}
${space}

${(props) =>
color: ${(props) => props.color || 'inherit'};
${verticalAlign} ${space}
${(props) =>
props.onClick &&
`
cursor: pointer;
`}
`};
`

const sizeMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`UserStatistics > renders correctly 1`] = `
class="css-i1ihic-Box"
>
<div
class="css-sqxgz6"
class="css-gz1tr0"
size="22"
>
<img
Expand All @@ -35,7 +35,7 @@ exports[`UserStatistics > renders correctly 1`] = `
class="css-i1ihic-Box"
>
<div
class="css-sqxgz6"
class="css-gz1tr0"
size="22"
>
<svg
Expand Down Expand Up @@ -64,7 +64,7 @@ exports[`UserStatistics > renders correctly 1`] = `
class="css-i1ihic-Box"
>
<div
class="css-sqxgz6"
class="css-gz1tr0"
size="22"
>
<img
Expand Down
4 changes: 4 additions & 0 deletions packages/components/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ export default defineConfig({
environment: 'jsdom',
globals: true,
setupFiles: './src/tests/setup.ts',
coverage: {
provider: 'c8',
reporter: ['text', 'json', 'html'],
},
},
})
21 changes: 21 additions & 0 deletions packages/themes/src/common/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const commonColors = {
white: 'white',
offwhite: '#ececec',
black: '#1b1b1b',
softyellow: '#f5ede2',
blue: '#83ceeb',
red: '#eb1b1f',
red2: '#f58d8e',
softblue: '#e2edf7',
bluetag: '#5683b0',
grey: '#61646b',
green: '#00c3a9',
error: 'red',
background: '#f4f6f7',
silver: '#c0c0c0',
softgrey: '#c2d4e4',
lightgrey: '#ababac',
darkGrey: '#686868',
subscribed: 'orange',
notSubscribed: '#1b1b1b',
}
19 changes: 2 additions & 17 deletions packages/themes/src/fixing-fashion/styles.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { commonColors } from './../common/colors'
import type { ThemeWithName } from '../types'
import spaceBadge from '../../assets/images/themes/fixing-fashion/avatar_space_lg.svg'
import memberBadgeLowDetail from '../../assets/images/themes/fixing-fashion/avatar_member_sm.svg'
Expand All @@ -12,25 +13,9 @@ const fonts = {

// use enum to specify list of possible colors for typing
export const colors = {
white: 'white',
offwhite: '#ececec',
black: '#1b1b1b',
...commonColors,
primary: 'green',
softyellow: '#f5ede2',
yellow: { base: '#E95628', hover: 'hsl(14, 81%, 43%)' },
blue: '#83ceeb',
red: '#eb1b1f',
red2: '#f58d8e',
softblue: '#e2edf7',
bluetag: '#5683b0',
grey: '#61646b',
green: '#00c3a9',
error: 'red',
background: '#f4f6f7',
silver: '#c0c0c0',
softgrey: '#c2d4e4',
lightgrey: '#ababac',
darkGrey: '#686868',
}

export const zIndex = {
Expand Down
19 changes: 2 additions & 17 deletions packages/themes/src/precious-plastic/styles.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { commonColors } from './../common/colors'
import memberBadgeLowDetail from '../../assets/images/themes/precious-plastic/avatar_member_sm.svg'
import memberBadgeHighDetail from '../../assets/images/themes/precious-plastic/avatar_member_lg.svg'
import CollectionBadge from '../../assets/images/badges/pt-collection-point.svg'
Expand All @@ -20,25 +21,9 @@ const fonts = {

// use enum to specify list of possible colors for typing
export const colors = {
white: 'white',
offwhite: '#ececec',
black: '#1b1b1b',
...commonColors,
primary: 'red',
softyellow: '#f5ede2',
yellow: { base: '#fee77b', hover: '#ffde45' },
blue: '#83ceeb',
red: '#eb1b1f',
red2: '#f58d8e',
softblue: '#e2edf7',
bluetag: '#5683b0',
grey: '#61646b',
green: '#00c3a9',
error: 'red',
background: '#f4f6f7',
silver: '#c0c0c0',
softgrey: '#c2d4e4',
lightgrey: '#ababac',
darkGrey: '#686868',
}

export const zIndex = {
Expand Down
19 changes: 2 additions & 17 deletions packages/themes/src/project-kamp/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,14 @@ import memberBadgeHighDetail from '../../assets/images/themes/project-kamp/avata
import logo from '../../assets/images/themes/project-kamp/project-kamp-header.png'
import type { ThemeWithName } from '../types'
import { getButtons } from '../common/button'
import { commonColors } from '../common/colors'
export type { ButtonVariants } from '../common/button'

// use enum to specify list of possible colors for typing
export const colors = {
white: 'white',
offwhite: '#ececec',
black: '#1b1b1b',
...commonColors,
primary: 'green',
softyellow: '#f5ede2',
yellow: { base: '#8ab57f', hover: 'hsl(108, 25%, 68%)' },
blue: '#83ceeb',
red: '#eb1b1f',
red2: '#f58d8e',
softblue: '#e2edf7',
bluetag: '#5683b0',
grey: '#61646b',
green: '#00c3a9',
error: 'red',
background: '#f4f6f7',
silver: '#c0c0c0',
softgrey: '#c2d4e4',
lightgrey: '#ababac',
darkGrey: '#686868',
}

export const zIndex = {
Expand Down
2 changes: 2 additions & 0 deletions packages/themes/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface ThemeWithName {
offwhite: string
lightgrey: string
darkGrey: string
subscribed: string
notSubscribed: string
}

fontSizes: number[]
Expand Down
Loading