Skip to content

Commit

Permalink
Merge branch 'develop' into fix/docs-env-file-server
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-funk committed Dec 7, 2023
2 parents 968a8b5 + 378fa70 commit 6e0f91f
Show file tree
Hide file tree
Showing 317 changed files with 13,248 additions and 823 deletions.
23 changes: 22 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
# tests are not run in the docker container.
__tests__
**/__tests__
**/coverage
coverage

# we won't use the .git folder in production.
.git
.github

# don't include the dependancies
node_modules
**/node_modules

# don't include any logs
npm-debug.log*
**/npm-debug.log*

# don't include any yarn files
yarn-error.log
yarn.lock

# don't include any OS/editor files
.env
**/.env
.idea/
.vs
.vscode

.docz
**/.docz

*.swp
**/*.swp

*.DS_STORE
*.DS_Store
**/*.DS_STORE
**/*.DS_Store

# don't include any generated files
dist
**/dist

*.css.d.ts
**/*.css.d.ts

__generated__
docs/.next
**/__generated__

**/.next
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Any related Github issue should be linked by adding its URL to this section.
<!--
In this section, you should describe any changes to be made to the GraphQL
schema file (located https://github.com/coralproject/talk/blob/main/src/core/server/graph/schema/schema.graphql) or any
database model (located as types in the https://github.com/coralproject/talk/blob/main/src/core/server/models directory).
schema file (located https://github.com/coralproject/talk/blob/main/server/src/core/server/graph/schema/schema.graphql) or any
database model (located as types in the https://github.com/coralproject/talk/tree/main/server/src/core/server/models directory).
If no changes were added to the GraphQL/Database Schema as a part of this PR,
simply write "None".
Expand Down Expand Up @@ -70,7 +70,7 @@ verify features introduced or bugs fixed in this PR.
-->

## Where any tests migrated to React Testing Library?
## Were any tests migrated to React Testing Library?

<!--
In this section, you should list the paths to and test names of any tests that were migrated to RTL.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ jobs:
name: Deploy Static Assets to GCS Bucket
run: |
CONTAINER_ID=$(docker create "coralproject/talk:${PATCH_TAG}")
docker cp "${CONTAINER_ID}:/usr/src/app/dist/static" static/
docker cp "${CONTAINER_ID}:/usr/src/app/client/dist/static" static/
docker rm "${CONTAINER_ID}"
find ./static -type f -name "*.gz" -print -delete
gsutil -m -h "Cache-Control: public, max-age=86400, immutable" cp -r -z "js,css,map,txt,json" ./static/** "gs://${GOOGLE_CLOUD_BUCKET}/${PATCH_TAG}/"
-
name: Upload to Sentry
run: |
CONTAINER_ID=$(docker create "coralproject/talk:${PATCH_TAG}")
docker cp "${CONTAINER_ID}:/usr/src/app/dist" dist/
docker cp "${CONTAINER_ID}:/usr/src/app/client/dist" dist/
docker rm "${CONTAINER_ID}"
npx @sentry/cli -V
npx @sentry/cli releases files "coral@${PATCH_TAG}" upload-sourcemaps ./dist --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ This can ensure that code reviews contain more meaningful feedback tied to the
contribution rather than nit-picking on stylistic choices.

Reviewers must ensure that linting and tests pass in CI and locally prior to a
review taking place. You can do this by running `npm run generate` followed by
`npm run lint` and `npm run test`.
review taking place. You can do this by running `sh scripts/generate.sh` followed by
`sh scripts/lint.sh`. You can run `npm run test` in `/server` and `/client`.

### Review the feature/fixes

Expand Down Expand Up @@ -186,7 +186,7 @@ the API and the runtime on the server that powers resolving data from data
sources. This heavily influences a lot of the decisions around how we create and
consume it's API internally and how we expose it to others to interact with.

There are many GraphQL types in our [`schema.graphql`](https://github.com/coralproject/talk/blob/main/src/core/server/graph/schema/schema.graphql)
There are many GraphQL types in our [`schema.graphql`](https://github.com/coralproject/talk/blob/main/server/src/core/server/graph/schema/schema.graphql)
that define the way we handle data in our API. We'll try to outline a few of
them here with examples to help you understand their uses.

Expand Down Expand Up @@ -433,7 +433,7 @@ fragment on Comment {
```

Here we see the `@auth` directive. It has documentation describing the various
parameters allowed located in the [`schema.graphql`](https://github.com/coralproject/talk/blob/main/src/core/server/graph/schema/schema.graphql)
parameters allowed located in the [`schema.graphql`](https://github.com/coralproject/talk/blob/main/server/src/core/server/graph/schema/schema.graphql)
file, we'll discuss below what this particular set of parameters can be read as:

- The roles that are allowed to access this information are `MODERATOR` and
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ RUN cd server && \
npm prune --production && \
cd ..

# Set working directory within server folder
WORKDIR /usr/src/app/server

# Setup the environment
ENV NODE_ENV production
ENV PORT 5000
EXPOSE 5000

# Run the node process directly instead of using `npm run start`:
# SEE: https://github.com/nodejs/docker-node/blob/a2eb9f80b0fd224503ee2678867096c9e19a51c2/docs/BestPractices.md#cmd
CMD ["node", "server/dist/index.js"]
CMD ["node", "dist/index.js"]
30 changes: 30 additions & 0 deletions INDEXES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ The goal of this document is to date-mark the indexes you add to support the cha

If you are releasing, you can use this readme to check all the indexes prior to the release you are deploying and have a good idea of what indexes you might need to deploy to Mongo along with your release of a new Coral Docker image to kubernetes.

## 2023-11-24

```
db.dsaReports.createIndex({ tenantID: 1, id: 1 }, { unique: true });
```

- This index creates the uniqueness constraint for the `tenantID` and `id` fields on the `dsaReports`

```
db.dsaReports.createIndex({ status: 1, createdAt: 1, tenantID: 1 });
db.dsaReports.createIndex({ referenceID: 1, tenantID: 1 });
db.dsaReports.createIndex({ submissionID: 1, tenantID: 1 });
```

- These indices are used to optimize pagination of `dsaReports` and allow them to be retrieved by their `referenceID`, `submissionID` efficiently.

## 2023-10-18

```
db.notifications.createIndex({ tenantID: 1, id: 1 }, { unique: true });
```

- This index creates the uniqueness constraint for the `tenantID` and `id` fields on the notifications collection

```
db.notifications.createIndex({ tenantID: 1, ownerID: 1, createdAt: 1 });
```

- This index speeds up the retrieval of notifications by `tenantID`, `ownerID`, and `createdAt` which is the most common way of retrieving notifications for pagination in the notifications tab on the stream.

## 2023-03-28

```
Expand Down
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coralproject/talk",
"version": "8.5.0",
"version": "8.6.2",
"author": "The Coral Project",
"homepage": "https://coralproject.net/",
"sideEffects": [
Expand Down
4 changes: 2 additions & 2 deletions client/scripts/precommitLint.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ sgf((err, results) => {

const eslintFiles = [];
for (const item of results) {
const { filename } = item;
const { filename, status } = item;

// only include valid, filtered extensions
// this is primarily to keep eslint rampaging
// over non-source files
if (!matchesExtension(extensions, filename)) {
if (!matchesExtension(extensions, filename) || status === "Deleted") {
continue;
}

Expand Down
5 changes: 3 additions & 2 deletions client/src/core/client/admin/App/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ import styles from "./Main.css";
interface Props {
viewer: PropTypesOf<typeof UserMenuContainer>["viewer"] &
PropTypesOf<typeof NavigationContainer>["viewer"];
settings: PropTypesOf<typeof NavigationContainer>["settings"];
children: React.ReactNode;
}

const Main: FunctionComponent<Props> = ({ children, viewer }) => (
const Main: FunctionComponent<Props> = ({ children, viewer, settings }) => (
<div className={styles.root}>
<AppBar gutterBegin gutterEnd>
<Begin itemGutter="double">
<div className={styles.logoContainer}>
<LogoHorizontal />
</div>
<NavigationContainer viewer={viewer} />
<NavigationContainer viewer={viewer} settings={settings} />
</Begin>
<End>
<DecisionHistoryButton />
Expand Down
10 changes: 9 additions & 1 deletion client/src/core/client/admin/App/MainRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const MainRoute: React.FunctionComponent<Props> = (props) => {
return (
<>
{ErrorReporterSetUser}
<Main viewer={props.data && props.data.viewer}>{props.children}</Main>
<Main
viewer={props.data && props.data.viewer}
settings={props.data && props.data.settings}
>
{props.children}
</Main>
</>
);
};
Expand All @@ -33,6 +38,9 @@ const enhanced = withRouteConfig<Props>({
...UserMenuContainer_viewer
...NavigationContainer_viewer
}
settings {
...NavigationContainer_settings
}
}
`,
})(MainRoute);
Expand Down
6 changes: 6 additions & 0 deletions client/src/core/client/admin/App/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import NavigationLink from "./NavigationLink";
interface Props {
showConfigure: boolean;
showDashboard: boolean;
showReports: boolean;
}

const Navigation: FunctionComponent<Props> = (props) => (
Expand All @@ -31,6 +32,11 @@ const Navigation: FunctionComponent<Props> = (props) => (
<NavigationLink to="/admin/dashboard">Dashboard</NavigationLink>
</Localized>
)}
{props.showReports && (
<Localized id="navigation-reports">
<NavigationLink to="/admin/reports">DSA Reports</NavigationLink>
</Localized>
)}
</AppBarNavigation>
);

Expand Down
64 changes: 47 additions & 17 deletions client/src/core/client/admin/App/Navigation/NavigationContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,73 @@
import React from "react";
import React, { FunctionComponent } from "react";
import { graphql } from "react-relay";

import { Ability, can } from "coral-admin/permissions/tenant";
import { withFragmentContainer } from "coral-framework/lib/relay";
import { GQLUSER_ROLE } from "coral-common/client/src/core/client/framework/schema/__generated__/types";
import { useLocal, withFragmentContainer } from "coral-framework/lib/relay";
import {
SignOutMutation,
withSignOutMutation,
} from "coral-framework/mutations";

import { NavigationContainer_settings as SettingsData } from "coral-admin/__generated__/NavigationContainer_settings.graphql";
import { NavigationContainer_viewer as ViewerData } from "coral-admin/__generated__/NavigationContainer_viewer.graphql";
import { NavigationContainerLocal } from "coral-admin/__generated__/NavigationContainerLocal.graphql";

import Navigation from "./Navigation";

interface Props {
signOut: SignOutMutation;
viewer: ViewerData | null;
settings: SettingsData | null;
}

class NavigationContainer extends React.Component<Props> {
public render() {
return (
<Navigation
showDashboard={
!!this.props.viewer && can(this.props.viewer, Ability.VIEW_STATISTICS)
}
showConfigure={
!!this.props.viewer &&
can(this.props.viewer, Ability.CHANGE_CONFIGURATION)
}
/>
);
}
}
const NavigationContainer: FunctionComponent<Props> = ({
viewer,
settings,
}) => {
const [{ dsaFeaturesEnabled }] = useLocal<NavigationContainerLocal>(
graphql`
fragment NavigationContainerLocal on Local {
dsaFeaturesEnabled
}
`
);
return (
<Navigation
showDashboard={!!viewer && can(viewer, Ability.VIEW_STATISTICS)}
showConfigure={!!viewer && can(viewer, Ability.CHANGE_CONFIGURATION)}
showReports={
!!dsaFeaturesEnabled &&
!!viewer &&
can(viewer, Ability.MODERATE_DSA_REPORTS) &&
// Exclude single-site moderators
!(
settings?.multisite &&
viewer.role === GQLUSER_ROLE.MODERATOR &&
viewer.moderationScopes &&
viewer.moderationScopes.sites &&
viewer.moderationScopes.sites.length === 1
)
}
/>
);
};

const enhanced = withSignOutMutation(
withFragmentContainer<Props>({
viewer: graphql`
fragment NavigationContainer_viewer on User {
role
moderationScopes {
sites {
id
}
}
}
`,
settings: graphql`
fragment NavigationContainer_settings on Settings {
multisite
}
`,
})(NavigationContainer)
Expand Down
Loading

0 comments on commit 6e0f91f

Please sign in to comment.