From cfff1dc809e1d4025063b36c7b37123a512d5a42 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Sun, 10 Jul 2022 14:57:03 -0400 Subject: [PATCH 1/2] Update README.md --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e78e4af8..a57cae17 100644 --- a/README.md +++ b/README.md @@ -157,41 +157,52 @@ This project is deployed to AWS CloudFront/S3/Lambda using the [Serverless Frame ### Configuration -There are currently two environments, Preview and Production. They are configured with the following YAML files: +There are currently two environments, Preview and Production. They are configured with the following files: - `serverless-preview.yml` - `serverless-prod.yml` - `.github/workflows/preview.yml` - `.github/workflows/production.yml` +- `next.config.js` -In the former two files, bucket names and distribution IDs are hard coded and must be changed for different AWS deployments. Normally these would not be checked into version control, but since our workflow relies on GitHub automation, it was required. +In the first two files, bucket names and distribution IDs are hard coded and must be changed for different AWS deployments. Normally these would not be checked into version control, but since our workflow relies on GitHub automation, it was required. ### Environment variables In these deployments, environment variables are pulled from [GitHub Environments](https://docs.github.com/en/actions/reference/environments). Note that **any environment variables added to the project** must be manually added to the appropriate steps of `.github/workflows/preview.yml` and `.github/workflows/production.yml`, in addition to the GitHub Environments, to become available to deployments. They will be pulled from the relevant GitHub Environments and made available to the `secrets` object. -For example, a developer might wish to add an environment variable `ADMIN_EMAIL`. +For example, if a developer wishes to add a new environment variable `ADMIN_EMAIL`: -First, the developer should go to the Settings for this GitHub repo and navigate to Environments on the sidebar. Values for this environment variable `ADMIN_EMAIL` should be added to both the "Preview" and "Production" environments. +1. First, the developer should go to the Settings for this GitHub repo and navigate to Environments on the sidebar. Values for this environment variable `ADMIN_EMAIL` should be added to both the "Preview" and "Production" environments. -Then, in code, the developer should add the following line to `.github/workflows/preview.yml` and `.github/workflows/production.yml` in the "Deploy to AWS" step, within the `env` block: +2. Then, in code, the developer should add the following line to `.github/workflows/preview.yml` and `.github/workflows/production.yml` in the "Deploy to AWS" step, within the `env` block: -```yml -ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }} -``` + ```yml + ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }} + ``` -And in both `serverless-preview.yml` and `serverless-prod.yml`, add the following line to `AnnotationStudio.inputs.build`: +3. And in both `serverless-preview.yml` and `serverless-prod.yml`, add the following line to `AnnotationStudio.inputs.build`: -```yml -ADMIN_EMAIL: ${env.ADMIN_EMAIL} -``` + ```yml + ADMIN_EMAIL: ${env.ADMIN_EMAIL} + ``` + +4. Finally, Next.JS needs to be made aware of the new environment variable, so add the following to `next.config.js` in the `env` object: + + ```js + ADMIN_EMAIL: process.env.ADMIN_EMAIL, + ``` That way, the new environment variable will be made available to the deployment in the appropriate steps. +### Logs + +Logs can be inspected from the AWS Cloudfront console. Visit the [Monitoring](https://us-east-1.console.aws.amazon.com/cloudfront/v3/home?region=us-east-1#/monitoring) section of the Cloudfront console, choose Lambda@Edge, and find the two pairs of similarly-named Lambda@Edge functions (should have the same prefix). Each pair represents one deployment, either preview or production. To determine which is which, select one and choose "View metrics", then scroll down to "Associated distributions." If it says "app.annotation.studio" in the alternate domain names, then it is production, otherwise it is preview. To view logs, scroll back up to the top and click "View function logs," and choose us-east-1. + ## To Vercel Since this project is built on Next.js, it can also be deployed directly to Vercel using their automated GitHub integrations. However, the official instance of this project has shifted toward AWS deployments. *** -This README was adapted from [hyperstudio/hidden-perspectives-app](https://github.com/hyperstudio/hidden-perspectives-app/blob/master/README.md). \ No newline at end of file +This README was adapted from [hyperstudio/hidden-perspectives-app](https://github.com/hyperstudio/hidden-perspectives-app/blob/master/README.md). From 0aa5ca06ece6b5e03efc7fa67078645a666e5e48 Mon Sep 17 00:00:00 2001 From: Joshua Mbogo <55801923+mbogo-mit@users.noreply.github.com> Date: Thu, 16 Nov 2023 20:34:25 -0500 Subject: [PATCH 2/2] Revert "Update AnnotationsChannel.js" --- .../DashboardChannels/AnnotationsChannel.js | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/components/DashboardChannels/AnnotationsChannel.js b/src/components/DashboardChannels/AnnotationsChannel.js index 52a51478..2cd181b1 100644 --- a/src/components/DashboardChannels/AnnotationsChannel.js +++ b/src/components/DashboardChannels/AnnotationsChannel.js @@ -189,9 +189,9 @@ export default function AnnotationsChannel({ ); const ASLoadMoreAnnos = ( - (annotations[slug] && annotations[slug]?.countByPermissions + annotations[slug]?.countByPermissions && annotations[slug]?.countByPermissions[selectedPermissions] - > (annotations[slug][selectedPermissions] || []).filter(byWithGroupId).length)) + > annotations[slug][selectedPermissions].length) ? loadComponent : <>; @@ -232,28 +232,7 @@ export default function AnnotationsChannel({ byDateCreated: , }; - const getDocumentFromDocuments = () => { - if (selectedGroupId && selectedDocumentId) { - const obj = documents[selectedGroupId] - // console.log('obj: ', Object.entries(obj)) - for (const [key, arr] of Object.entries(obj)) { - if (Array.isArray(arr)) { - for (let d of arr) { - if (d._id === selectedDocumentId) { - return d - } - } - } - - } - } - - return undefined - } - - const byWithGroupId = (anno) => ( - getDocumentFromDocuments()?.version === 4 ? byGroupFilterMatch(anno?.creator?.withGroupId ? [anno?.creator?.withGroupId] : [], [selectedGroupId]) : true - ); + const byWithGroupId = (anno) => byGroupFilterMatch(anno?.creator?.withGroupId ? [anno?.creator?.withGroupId] : [], [selectedGroupId]); const buttons = [ {