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

Fix Promise Tracker UI Breaking imports #1033

Merged
merged 10 commits into from
Jan 31, 2025
76 changes: 76 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,79 @@ USER nextjs
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "apps/vpnmanager/server.js"]

# ============================================================================
# Promise Tracker
# ============================================================================

#
# promisetracker-desp: image with all pesayetu dependencies
# -----------------------------------------------------

FROM base-deps AS promisetracker-deps

COPY apps/promisetracker/package.json ./apps/promisetracker/package.json

# Use virtual store: https://pnpm.io/cli/fetch#usage-scenario
RUN pnpm --filter "./apps/promisetracker" install --offline --frozen-lockfile

#
# promisetracker-builder: image that uses deps to build shippable output
# ------------------------------------------------------------------

FROM base-builder AS promisetracker-builder

ARG NEXT_TELEMETRY_DISABLED \
# Next.js / Payload (build time)
PORT \
# Next.js (runtime)
NEXT_PUBLIC_APP_NAME="Promise Tracker" \
NEXT_PUBLIC_APP_URL \
NEXT_PUBLIC_SENTRY_DSN \
NEXT_PUBLIC_SEO_DISABLED \
NEXT_PUBLIC_GOOGLE_ANALYTICS \
# Sentry (build time)
SENTRY_AUTH_TOKEN \
SENTRY_ENVIRONMENT \
SENTRY_ORG \
SENTRY_PROJECT

# This is in app-builder instead of base-builder just incase app-deps adds deps
COPY --from=promisetracker-deps /workspace/node_modules ./node_modules

COPY --from=promisetracker-deps /workspace/apps/promisetracker/node_modules ./apps/promisetracker/node_modules

COPY apps/promisetracker ./apps/promisetracker

RUN --mount=type=secret,id=sentry_auth_token,env=SENTRY_AUTH_TOKEN \
pnpm --filter "./apps/promisetracker" build

#
# promisetracker-runner: final deployable image
# -----------------------------------------

FROM base-runner AS promisetracker-runner

ARG API_SECRET_KEY
RUN set -ex \
# Create nextjs cache dir w/ correct permissions
&& mkdir -p ./apps/promisetracker/.next \
&& chown nextjs:nodejs ./apps/promisetracker/.next

# PNPM
# symlink some dependencies
COPY --from=promisetracker-builder --chown=nextjs:nodejs /workspace/node_modules ./node_modules

# Next.js
# Public assets
COPY --from=promisetracker-builder --chown=nextjs:nodejs /workspace/apps/promisetracker/public ./apps/promisetracker/public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=promisetracker-builder --chown=nextjs:nodejs /workspace/apps/promisetracker/.next/standalone ./apps/promisetracker
COPY --from=promisetracker-builder --chown=nextjs:nodejs /workspace/apps/promisetracker/.next/static ./apps/promisetracker/.next/static
USER nextjs

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "apps/promisetracker/server.js"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ techlabblog:
vpnmanager:
$(COMPOSE_BUILD_ENV) $(COMPOSE) --env-file apps/vpnmanager/.env.local up vpnmanager --build

promisetracker:
$(COMPOSE_BUILD_ENV) $(COMPOSE) --env-file apps/promisetracker/.env.local up promisetracker --build

7 changes: 7 additions & 0 deletions apps/promisetracker/instrumentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Next.js requires this to be exported as register https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation
// eslint-disable-next-line import/prefer-default-export
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./sentry.server.config");
}
}
18 changes: 5 additions & 13 deletions apps/promisetracker/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const outputFileTracingRoot = PROJECT_ROOT
: undefined;

const moduleExports = {
experimental: {
experimental: outputFileTracingRoot && {
outputFileTracingRoot,
},
i18n: {
Expand Down Expand Up @@ -55,18 +55,6 @@ const moduleExports = {
},
];
},

// Optional build-time configuration options
sentry: {
// See the 'Configure Source Maps' and 'Configure Legacy Browser Support'
// sections below for information on the following options:
// - disableServerWebpackPlugin
// - disableClientWebpackPlugin
// - hideSourceMaps
// - widenClientFileUpload
// - transpileClientSDK
hideSourceMaps: false,
},
};

const sentryWebpackPluginOptions = {
Expand All @@ -79,6 +67,10 @@ const sentryWebpackPluginOptions = {
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
hideSourceMaps: true,
org: process.env.SENTRY_ORG,
authToken: process.env.SENTRY_AUTH_TOKEN,
project: process.env.SENTRY_PROJECT,
};

// Make sure adding Sentry options is the last code to run before exporting, to
Expand Down
1 change: 1 addition & 0 deletions apps/promisetracker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@mui/material": "catalog:mui-styles",
"@mui/styles": "catalog:mui-styles",
"@mui/utils": "catalog:mui-styles",
"@mui/private-theming": "catalog:mui-styles",
"@sentry/nextjs": "catalog:",
"clsx": "catalog:",
"date-fns": "catalog:",
Expand Down
4 changes: 0 additions & 4 deletions apps/promisetracker/src/components/AboutPage/Partners.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,4 @@ Partners.propTypes = {
items: PropTypes.arrayOf(PropTypes.shape({})),
};

Partners.defaultProps = {
items: undefined,
};

export default Partners;
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ PromiseCriteria.propTypes = {
items: PropTypes.arrayOf(PropTypes.shape({})),
};

PromiseCriteria.defaultProps = {
items: undefined,
title: undefined,
};

export default PromiseCriteria;
13 changes: 0 additions & 13 deletions apps/promisetracker/src/components/AboutPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,4 @@ AboutPage.propTypes = {
title: PropTypes.string,
};

AboutPage.defaultProps = {
actNow: undefined,
actNowEnabled: undefined,
content: undefined,
criteria: undefined,
description: undefined,
featuredImage: undefined,
footer: undefined,
navigation: undefined,
partners: undefined,
title: undefined,
};

export default AboutPage;
6 changes: 0 additions & 6 deletions apps/promisetracker/src/components/ActNow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,4 @@ ActNow.propTypes = {
title: PropTypes.string,
};

ActNow.defaultProps = {
actionLabel: undefined,
description: undefined,
title: undefined,
};

export default ActNow;
6 changes: 0 additions & 6 deletions apps/promisetracker/src/components/ActNowCard/BaseContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,4 @@ BaseCard.propTypes = {
children: PropTypes.node,
};

BaseCard.defaultProps = {
onCloseCard: undefined,
description: undefined,
children: undefined,
};

export default BaseCard;
12 changes: 1 addition & 11 deletions apps/promisetracker/src/components/ActNowCard/ConnectCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useStyles from "./useStyles";

import CtAButton from "@/promisetracker/components/CtAButton";

function ConnectCard({ closeCard, promiseActNow }) {
function ConnectCard({ closeCard, promiseActNow = { connect: {} } }) {
const {
connect: {
connect_title: connectTitle,
Expand Down Expand Up @@ -49,14 +49,4 @@ ConnectCard.propTypes = {
}),
};

ConnectCard.defaultProps = {
promiseActNow: PropTypes.shape({
connect: {
connectTitle: null,
connectDescription: null,
connectButton: null,
},
}),
};

export default ConnectCard;
12 changes: 1 addition & 11 deletions apps/promisetracker/src/components/ActNowCard/FollowCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useStyles from "./useStyles";

import CtAButton from "@/promisetracker/components/CtAButton";

function FollowCard({ closeCard, promiseActNow }) {
function FollowCard({ closeCard, promiseActNow = { follow: {} } }) {
const classes = useStyles();

const {
Expand Down Expand Up @@ -58,14 +58,4 @@ FollowCard.propTypes = {
}),
};

FollowCard.defaultProps = {
promiseActNow: PropTypes.shape({
follow: {
followTitle: null,
followDescription: null,
followButton: null,
},
}),
};

export default FollowCard;
20 changes: 6 additions & 14 deletions apps/promisetracker/src/components/ActNowCard/PetitionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Grid, Snackbar } from "@mui/material";
import Alert from "@mui/material/Alert";
import Router from "next/router";
import { useSession } from "next-auth/react";
import PropTypes, { string } from "prop-types";
import PropTypes from "prop-types";
import React, { useState } from "react";

import BaseContent from "./BaseContent";
Expand All @@ -11,7 +11,11 @@ import useStyles from "./useStyles";
import CtAButton from "@/promisetracker/components/CtAButton";
import FormDialog from "@/promisetracker/components/FormDialog";

function PetitionCard({ closeCard, promiseActNow, ...props }) {
function PetitionCard({
closeCard,
promiseActNow = { petition: { petitionTitle: "", petitionDescription: "" } },
...props
}) {
const {
petition: {
petition_title: petitionTitle,
Expand Down Expand Up @@ -104,16 +108,4 @@ PetitionCard.propTypes = {
}),
};

PetitionCard.defaultProps = {
petitionJoin: null,
petitionStart: null,
petitionTitle: string,
promiseActNow: PropTypes.shape({
petition: {
petitionTitle: null,
petitionDescription: null,
},
}),
};

export default PetitionCard;
11 changes: 1 addition & 10 deletions apps/promisetracker/src/components/ActNowCard/ShareCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from "react";
import BaseContent from "./BaseContent";
import useStyles from "./useStyles";

function ShareCard({ closeCard, promiseActNow }) {
function ShareCard({ closeCard, promiseActNow = { share: {} } }) {
const classes = useStyles();

const {
Expand Down Expand Up @@ -58,13 +58,4 @@ ShareCard.propTypes = {
}),
};

ShareCard.defaultProps = {
promiseActNow: PropTypes.shape({
share: {
shareTitle: null,
shareDescription: null,
},
}),
};

export default ShareCard;
18 changes: 4 additions & 14 deletions apps/promisetracker/src/components/ActNowCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import useStyles from "./useStyles";

import UpdateFormDialog from "@/promisetracker/components/FormDialog/UpdateDialog";

function ActNowButtonCard({ promise_act_now: promiseActNow, ...props }) {
function ActNowButtonCard({
promise_act_now: promiseActNow = { act_now: {} },
...props
}) {
const {
act_now: {
act_now_title: actNowTitle,
Expand Down Expand Up @@ -162,17 +165,4 @@ ActNowButtonCard.propTypes = {
}),
};

ActNowButtonCard.defaultProps = {
promise_act_now: PropTypes.shape({
act_now: {
act_now_title: null,
connect_label: null,
petition_label: null,
follow_label: null,
update_label: null,
share_label: null,
},
}),
};

export default ActNowButtonCard;
8 changes: 0 additions & 8 deletions apps/promisetracker/src/components/ActNowPage/LoggedIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,4 @@ ActNowLoggedInPage.propTypes = {
title: PropTypes.string,
};

ActNowLoggedInPage.defaultProps = {
footer: undefined,
navigation: undefined,
ownedPetitions: undefined,
signedPetitions: undefined,
title: undefined,
};

export default ActNowLoggedInPage;
9 changes: 0 additions & 9 deletions apps/promisetracker/src/components/ActNowPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,4 @@ ActNow.propTypes = {
title: PropTypes.string,
};

ActNow.defaultProps = {
actNow: null,
description: null,
footer: null,
navigation: null,
petitions: null,
title: null,
};

export default ActNow;
5 changes: 0 additions & 5 deletions apps/promisetracker/src/components/ActNowSummary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,4 @@ ActNowSummary.propTypes = {
}),
};

ActNowSummary.defaultProps = {
summary: undefined,
titles: undefined,
};

export default ActNowSummary;
9 changes: 0 additions & 9 deletions apps/promisetracker/src/components/ActionDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,4 @@ ActionDialog.propTypes = {
title: PropTypes.string,
};

ActionDialog.defaultProps = {
children: undefined,
description: undefined,
name: undefined,
onClose: undefined,
open: undefined,
title: undefined,
};

export default ActionDialog;
Loading
Loading