Skip to content

Commit

Permalink
Merge branch 'master' into feat/questions-supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojsnunes committed Jan 9, 2025
2 parents d73ce48 + 5ffb3a0 commit 758b146
Show file tree
Hide file tree
Showing 159 changed files with 1,197 additions and 2,084 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ jobs:
--build-secret VITE_DONATIONS_IMAGE_URL="$VITE_DONATIONS_IMAGE_URL" \
--build-secret VITE_HOWTOS_HEADING="$VITE_HOWTOS_HEADING" \
--build-secret VITE_COMMUNITY_PROGRAM_URL="$VITE_COMMUNITY_PROGRAM_URL" \
--build-secret VITE_QUESTIONS_GUIDELINES_URL="$VITE_QUESTIONS_GUIDELINES_URL"
--build-secret VITE_QUESTIONS_GUIDELINES_URL="$VITE_QUESTIONS_GUIDELINES_URL" \
--build-secret VITE_HIDE_MEMBER_PINS_BY_DEFAULT="$VITE_HIDE_MEMBER_PINS_BY_DEFAULT"
- run:
name: Set Supabase Secrets
command: flyctl -a << parameters.FLY_APP_NAME >> secrets set SUPABASE_API_URL=$SUPABASE_API_URL SUPABASE_KEY=$SUPABASE_KEY FIREBASE_PROJECT_ID=$FIREBASE_PROJECT_ID FIREBASE_PRIVATE_KEY="$FIREBASE_PRIVATE_KEY" FIREBASE_CLIENT_EMAIL=$FIREBASE_CLIENT_EMAIL
Expand Down
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ VITE_COMMUNITY_PROGRAM_URL=https://community.preciousplastic.com/academy/guides/
VITE_PROFILE_GUIDELINES_URL=https://community.preciousplastic.com/academy/guides/platform
VITE_QUESTIONS_GUIDELINES_URL=https://community.preciousplastic.com/academy/guides/guidelines-questions

# Optional variable for limiting the display of member map pins by default on load
VITE_HIDE_MEMBER_PINS_BY_DEFAULT=false

# For testing, VITE_PLATFORM_PROFILES in localStorage is prioritised over this value
# All valid options for VITE_PLATFORM_PROFILES: "member,workspace,community-builder,space,collection-point,machine-builder"
VITE_PLATFORM_PROFILES="member,workspace,community-builder,collection-point,machine-builder"
Expand Down
4 changes: 2 additions & 2 deletions .github/pr-labeler.config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configuration for pr-labeller actions
"Mod: HowTo 📰":
- src/pages/Howto/**/*
"Mod: Library 📰":
- src/pages/Library/**/*
"Mod: Maps 🗺":
- src/pages/Maps/**/*
"Mod: Research 🔬":
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ARG VITE_DONATIONS_IMAGE_URL
ARG VITE_HOWTOS_HEADING
ARG VITE_COMMUNITY_PROGRAM_URL
ARG VITE_QUESTIONS_GUIDELINES_URL
ARG VITE_HIDE_MEMBER_PINS_BY_DEFAULT

# Throw-away build stage to reduce size of final image
FROM base AS build
Expand Down Expand Up @@ -80,6 +81,7 @@ RUN --mount=type=secret,id=VITE_BRANCH \
--mount=type=secret,id=VITE_HOWTOS_HEADING \
--mount=type=secret,id=VITE_COMMUNITY_PROGRAM_URL \
--mount=type=secret,id=VITE_QUESTIONS_GUIDELINES_URL \
--mount=type=secret,id=VITE_HIDE_MEMBER_PINS_BY_DEFAULT \
VITE_CDN_URL="$(cat /run/secrets/VITE_CDN_URL)" && \
VITE_BRANCH="$(cat /run/secrets/VITE_BRANCH)" && \
VITE_FIREBASE_API_KEY="$(cat /run/secrets/VITE_FIREBASE_API_KEY)" && \
Expand All @@ -105,6 +107,7 @@ RUN --mount=type=secret,id=VITE_BRANCH \
VITE_HOWTOS_HEADING="$(cat /run/secrets/VITE_HOWTOS_HEADING)" && \
VITE_COMMUNITY_PROGRAM_URL="$(cat /run/secrets/VITE_COMMUNITY_PROGRAM_URL)" && \
VITE_QUESTIONS_GUIDELINES_URL="$(cat /run/secrets/VITE_QUESTIONS_GUIDELINES_URL)" && \
VITE_HIDE_MEMBER_PINS_BY_DEFAULT="$(cat /run/secrets/VITE_HIDE_MEMBER_PINS_BY_DEFAULT)" && \
echo "VITE_CDN_URL=\"${VITE_CDN_URL}\"" >> .env && \
echo "VITE_BRANCH=\"${VITE_BRANCH}\"" >> .env && \
echo "VITE_FIREBASE_API_KEY=\"${VITE_FIREBASE_API_KEY}\"" >> .env && \
Expand All @@ -129,7 +132,8 @@ RUN --mount=type=secret,id=VITE_BRANCH \
echo "VITE_DONATIONS_IMAGE_URL=\"${VITE_DONATIONS_IMAGE_URL}\"" >> .env && \
echo "VITE_HOWTOS_HEADING=\"${VITE_HOWTOS_HEADING}\"" >> .env && \
echo "VITE_COMMUNITY_PROGRAM_URL=\"${VITE_COMMUNITY_PROGRAM_URL}\"" >> .env && \
echo "VITE_QUESTIONS_GUIDELINES_URL=\"${VITE_QUESTIONS_GUIDELINES_URL}\"" >> .env
echo "VITE_QUESTIONS_GUIDELINES_URL=\"${VITE_QUESTIONS_GUIDELINES_URL}\"" >> .env && \
echo "VITE_HIDE_MEMBER_PINS_BY_DEFAULT=\"${VITE_HIDE_MEMBER_PINS_BY_DEFAULT}\"" >> .env

# Build application
RUN yarn run build
Expand Down
5 changes: 2 additions & 3 deletions functions/src/emailNotifications/createModerationEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { getUserAndEmail } from './utils'

import type { QueryDocumentSnapshot } from 'firebase-admin/firestore'
import type { Change } from 'firebase-functions/v1'
import type { IModerable } from 'oa-shared'
import type { IHowtoDB } from 'oa-shared/models/howto'
import type { ILibrary, IModerable } from 'oa-shared'
import type { IMapPin } from 'oa-shared/models/maps'

export async function handleModerationUpdate<T extends IModerable>(
Expand All @@ -27,7 +26,7 @@ export async function handleModerationUpdate<T extends IModerable>(
}
}

export async function createHowtoModerationEmail(howto: IHowtoDB) {
export async function createHowtoModerationEmail(howto: ILibrary.DB) {
const { toUser, toUserEmail } = await getUserAndEmail(howto._createdBy)

if (howto.moderation === IModerationStatus.ACCEPTED) {
Expand Down
7 changes: 3 additions & 4 deletions functions/src/emailNotifications/createSubmissionEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
getSenderMessageEmail,
} from './templateHelpers'
import { getUserAndEmail, isValidMessageRequest } from './utils'
import { IMessageDB } from 'oa-shared/models/messages'
import { IHowtoDB } from 'oa-shared/models/howto'
import { IMapPin } from 'oa-shared/models/maps'

import type { ILibrary, IMapPin, IMessageDB } from 'oa-shared'

export async function createMessageEmails(message: IMessageDB) {
const isValid = await isValidMessageRequest(message)
Expand All @@ -38,7 +37,7 @@ export async function createMessageEmails(message: IMessageDB) {
}
}

export async function createHowtoSubmissionEmail(howto: IHowtoDB) {
export async function createHowtoSubmissionEmail(howto: ILibrary.DB) {
const { toUser, toUserEmail } = await getUserAndEmail(howto._createdBy)

if (howto.moderation === IModerationStatus.AWAITING_MODERATION) {
Expand Down
27 changes: 15 additions & 12 deletions functions/src/emailNotifications/templateHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { getEmailHtml } from './templates/index'
import { NOTIFICATION_LIST_IMAGE } from './constants'
import {
getNotificationListItem,
getProjectImageSrc,
SITE_URL,
getProjectName,
getNotificationListItem,
getProjectSignoff,
SITE_URL,
} from './utils'
import { getEmailHtml } from './templates/index'
import { IUserDB } from 'oa-shared/models/user'
import { INotification } from 'oa-shared/models/notifications'
import { IHowtoDB } from 'oa-shared/models/howto'
import { IMapPin } from 'oa-shared/models/maps'
import { IMessageDB } from 'oa-shared/models/messages'

import type {
ILibrary,
IMapPin,
IMessageDB,
INotification,
IUserDB,
} from 'oa-shared'

export interface Email {
html: string
Expand Down Expand Up @@ -137,7 +140,7 @@ export const getNotificationEmail = (
export const HOW_TO_APPROVAL_SUBJECT = 'Your project has been approved!'
export const getHowToApprovalEmail = (
user: IUserDB,
howto: IHowtoDB,
howto: ILibrary.DB,
): Email => {
return {
html: getEmailHtml('how-to-approval', {
Expand Down Expand Up @@ -186,7 +189,7 @@ export const getSenderMessageEmail = ({
export const HOW_TO_SUBMISSION_SUBJECT = 'Your project has been submitted'
export const getHowToSubmissionEmail = (
user: IUserDB,
howto: IHowtoDB,
howto: ILibrary.DB,
): Email => {
return {
html: getEmailHtml('how-to-submission', {
Expand Down Expand Up @@ -237,7 +240,7 @@ export const getUserVerifiedBadgeAddedEmail = (user: IUserDB): Email => ({
export const HOW_TO_REJECTED_SUBJECT = 'Your project has been rejected'
export const getHowToRejectedEmail = (
user: IUserDB,
howto: IHowtoDB,
howto: ILibrary.DB,
): Email => ({
subject: HOW_TO_REJECTED_SUBJECT,
html: getEmailHtml('how-to-rejected', {
Expand All @@ -260,7 +263,7 @@ export const HOW_TO_NEEDS_IMPROVEMENTS_SUBJECT =
'Your project needs improvements'
export const getHowToNeedsImprovementsEmail = (
user: IUserDB,
howto: IHowtoDB,
howto: ILibrary.DB,
): Email => ({
subject: HOW_TO_NEEDS_IMPROVEMENTS_SUBJECT,
html: getEmailHtml('how-to-needs-improvements', {
Expand Down
9 changes: 4 additions & 5 deletions functions/src/emulator/seed/content-generate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DifficultyLevel, IModerationStatus } from 'oa-shared'
import { MOCK_AUTH_USERS } from 'oa-shared/mocks/auth'

import { setDoc, updateDoc } from '../../Firebase/firestoreDB'

import type { ILibrary, IUserDB } from 'oa-shared'
import type { IMockAuthUser } from 'oa-shared/mocks/auth'
import { DifficultyLevel, IHowtoDB } from 'oa-shared/models/howto'
import { IModerationStatus } from 'oa-shared'
import { IUserDB } from 'oa-shared/models/user'

/**
* Populate additional mock howtos alongside production data for ease of testing
Expand All @@ -22,11 +21,11 @@ export async function seedContentGenerate() {

export function getMockHowto(
uid: string,
moderation: IHowtoDB['moderation'] = IModerationStatus.ACCEPTED,
moderation: ILibrary.DB['moderation'] = IModerationStatus.ACCEPTED,
) {
const _id = `00_${uid}_howto`
const loginInfo = `username : ${uid}@example.com\npassword : ${uid}`
const howto: IHowtoDB = {
const howto: ILibrary.DB = {
_id,
_created: new Date().toISOString(),
_modified: new Date().toISOString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/components/assets/icons/other.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 4 additions & 24 deletions packages/components/src/CardList/CardList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
component: CardList,
} as Meta<typeof CardList>

const allItems = [
const list = [
{
_deleted: false,
_id: 'first-one',
Expand Down Expand Up @@ -43,44 +43,24 @@ const allItems = [
},
]

const onBlur = () => undefined
const onPinClick = () => undefined

export const Default: StoryFn<typeof CardList> = () => {
return (
<CardList
list={allItems}
onBlur={onBlur}
list={list}
onPinClick={onPinClick}
filteredList={null}
selectedPin={undefined}
viewport="stories"
/>
)
}

export const FiltedDisplay: StoryFn<typeof CardList> = () => {
const filteredList = [allItems[0], allItems[2]]

return (
<CardList
list={allItems}
onBlur={onBlur}
onPinClick={onPinClick}
filteredList={filteredList}
selectedPin={undefined}
viewport="stories"
/>
)
}

export const WhenFiltedDisplayIsZero: StoryFn<typeof CardList> = () => {
export const WhenDisplayIsZero: StoryFn<typeof CardList> = () => {
return (
<CardList
list={allItems}
onBlur={onBlur}
list={[]}
onPinClick={onPinClick}
filteredList={[]}
selectedPin={undefined}
viewport="stories"
/>
Expand Down
18 changes: 3 additions & 15 deletions packages/components/src/CardList/CardList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { describe, expect, it } from 'vitest'

import { render } from '../test/utils'
import { EMPTY_LIST, type IProps } from './CardList'
import {
Default,
FiltedDisplay,
WhenFiltedDisplayIsZero,
} from './CardList.stories'
import { Default, WhenDisplayIsZero } from './CardList.stories'

describe('CardList', () => {
it('Shows all items when no filtering is done', () => {
Expand All @@ -17,17 +13,9 @@ describe('CardList', () => {
expect(getAllByTestId('CardListItem').length).toBe(4)
})

it('Shows only filted items when provided', () => {
const { getAllByTestId } = render(
<FiltedDisplay {...(FiltedDisplay.args as IProps)} />,
)

expect(getAllByTestId('CardListItem').length).toBe(2)
})

it('Shows the no items label when filted items is empty', () => {
it('Shows the no item label when filted items is empty', () => {
const { getByText } = render(
<WhenFiltedDisplayIsZero {...(WhenFiltedDisplayIsZero.args as IProps)} />,
<WhenDisplayIsZero {...(WhenDisplayIsZero.args as IProps)} />,
)

expect(getByText(EMPTY_LIST)).toBeInTheDocument()
Expand Down
Loading

0 comments on commit 758b146

Please sign in to comment.