Skip to content

Commit

Permalink
Merge branch 'feat/dsa-launch-pad' into reject-reason-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushaddon authored Nov 13, 2023
2 parents f565256 + cdd59ca commit fa82a39
Show file tree
Hide file tree
Showing 126 changed files with 6,114 additions and 138 deletions.
14 changes: 14 additions & 0 deletions INDEXES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ 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-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/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
7 changes: 7 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,12 @@ const Navigation: FunctionComponent<Props> = (props) => (
<NavigationLink to="/admin/dashboard">Dashboard</NavigationLink>
</Localized>
)}
{/* TODO: Any other permissions needed? */}
{props.showReports && (
<Localized id="navigation-reports">
<NavigationLink to="/admin/reports">DSA Reports</NavigationLink>
</Localized>
)}
</AppBarNavigation>
);

Expand Down
36 changes: 19 additions & 17 deletions client/src/core/client/admin/App/Navigation/NavigationContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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 { useLocal, withFragmentContainer } from "coral-framework/lib/relay";
import {
SignOutMutation,
withSignOutMutation,
} from "coral-framework/mutations";

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

import Navigation from "./Navigation";

Expand All @@ -17,21 +18,22 @@ interface Props {
viewer: ViewerData | 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 }) => {
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}
/>
);
};

const enhanced = withSignOutMutation(
withFragmentContainer<Props>({
Expand Down
10 changes: 8 additions & 2 deletions client/src/core/client/admin/components/Comment/InReplyTo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Localized } from "@fluent/react/compat";
import cn from "classnames";
import React, { FunctionComponent } from "react";

import { EmailActionReplyIcon, SvgIcon } from "coral-ui/components/icons";
Expand All @@ -7,19 +8,24 @@ import { BaseButton, Flex } from "coral-ui/components/v2";
import styles from "./InReplyTo.css";

interface Props {
className?: string;
children: string;
onUsernameClick: () => void;
}

const InReplyTo: FunctionComponent<Props> = ({ children, onUsernameClick }) => {
const InReplyTo: FunctionComponent<Props> = ({
className,
children,
onUsernameClick,
}) => {
const Username = () => (
<Localized
id="common-username"
attrs={{ "aria-label": true }}
vars={{ username: children }}
>
<BaseButton onClick={onUsernameClick} className={styles.usernameButton}>
<span className={styles.username}>{children}</span>
<span className={cn(styles.username, className)}>{children}</span>
</BaseButton>
</Localized>
);
Expand Down
7 changes: 7 additions & 0 deletions client/src/core/client/admin/routeConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import {
UnmoderatedQueueRoute,
} from "./routes/Moderate/Queue";
import SingleModerateRoute from "./routes/Moderate/SingleModerate";
import ReportsRoute from "./routes/Reports";
import SingleReportRoute from "./routes/Reports/SingleReportRoute";
import StoriesRoute from "./routes/Stories";

interface CoralContainerProps {
Expand Down Expand Up @@ -123,6 +125,11 @@ export default makeRouteConfig(
<Route path="dashboard" {...DashboardRoute.routeConfig} />
<Route path="dashboard/:siteID" {...SiteDashboardRoute.routeConfig} />
<Route path="community" {...CommunityRoute.routeConfig} />
<Route path="reports" {...ReportsRoute.routeConfig} />
<Route
path="reports/report/:reportID"
{...SingleReportRoute.routeConfig}
/>
<Route
{...createAuthCheckRoute({
ability: Ability.CHANGE_CONFIGURATION,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { graphql } from "react-relay";
import { Environment } from "relay-runtime";

import {
commitMutationPromiseNormalized,
createMutation,
MutationInput,
} from "coral-framework/lib/relay";

import { AddReportNoteMutation as MutationTypes } from "coral-admin/__generated__/AddReportNoteMutation.graphql";

let clientMutationId = 0;

const AddReportNoteMutation = createMutation(
"addReportNote",
(environment: Environment, input: MutationInput<MutationTypes>) => {
const result = commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation AddReportNoteMutation($input: AddDSAReportNoteInput!) {
addDSAReportNote(input: $input) {
dsaReport {
id
history {
id
createdBy {
username
}
createdAt
body
type
status
}
}
clientMutationId
}
}
`,
variables: {
input: {
userID: input.userID,
body: input.body,
reportID: input.reportID,
clientMutationId: (clientMutationId++).toString(),
},
},
});
return result;
}
);

export default AddReportNoteMutation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { graphql } from "react-relay";
import { Environment } from "relay-runtime";

import {
commitMutationPromiseNormalized,
createMutation,
MutationInput,
} from "coral-framework/lib/relay";

import { AddReportShareMutation as MutationTypes } from "coral-admin/__generated__/AddReportShareMutation.graphql";

let clientMutationId = 0;

const AddReportShareMutation = createMutation(
"addReportShare",
(environment: Environment, input: MutationInput<MutationTypes>) => {
const result = commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation AddReportShareMutation($input: AddDSAReportShareInput!) {
addDSAReportShare(input: $input) {
dsaReport {
id
history {
id
createdBy {
username
}
createdAt
body
type
status
}
}
clientMutationId
}
}
`,
variables: {
input: {
userID: input.userID,
reportID: input.reportID,
clientMutationId: (clientMutationId++).toString(),
},
},
});
return result;
}
);

export default AddReportShareMutation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { graphql } from "react-relay";
import { Environment } from "relay-runtime";

import {
commitMutationPromiseNormalized,
createMutation,
MutationInput,
} from "coral-framework/lib/relay";

import { ChangeReportStatusMutation as MutationTypes } from "coral-admin/__generated__/ChangeReportStatusMutation.graphql";

let clientMutationId = 0;

const ChangeReportStatusMutation = createMutation(
"changeReportStatus",
(environment: Environment, input: MutationInput<MutationTypes>) => {
const result = commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation ChangeReportStatusMutation(
$input: ChangeDSAReportStatusInput!
) {
changeDSAReportStatus(input: $input) {
dsaReport {
id
status
history {
id
createdBy {
username
}
createdAt
body
type
status
}
}
clientMutationId
}
}
`,
variables: {
input: {
userID: input.userID,
reportID: input.reportID,
status: input.status,
clientMutationId: (clientMutationId++).toString(),
},
},
});
return result;
}
);

export default ChangeReportStatusMutation;
Loading

0 comments on commit fa82a39

Please sign in to comment.