Skip to content

Commit

Permalink
Merge pull request #200 from novaforgood/dev
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
legitmaxwu authored Jun 26, 2024
2 parents 5f85467 + 7865468 commit 2702e8c
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
cache: "npm"

- name: Install Hasura CLI
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
cache: "npm"

- name: Install Hasura CLI
Expand Down
2 changes: 1 addition & 1 deletion hasura/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.env
.env*
/db_data
47 changes: 47 additions & 0 deletions hasura/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.6"
services:
postgres:
image: postgres:12
restart: always
volumes:
- db_data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: postgrespassword
graphql-engine:
image: hasura/graphql-engine:v2.16.0
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
## Hasura JWT Secret
HASURA_GRAPHQL_JWT_SECRET: "${HASURA_GRAPHQL_JWT_SECRET}"
## Unauthorized role
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "public"

## CRON Webhook URL
CANOPY_CRON_WEBHOOK_URL: "${CANOPY_CRON_WEBHOOK_URL}"
## CRON Client Key
CANOPY_CRON_CLIENT_KEY: "${CANOPY_CRON_CLIENT_KEY}"

## Event Webhook URL
CANOPY_EVENT_WEBHOOK_URL: "${CANOPY_EVENT_WEBHOOK_URL}"
## Event Client Key
CANOPY_EVENT_CLIENT_KEY: "${CANOPY_EVENT_CLIENT_KEY}"
volumes:
db_data:
36 changes: 6 additions & 30 deletions hasura/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,20 @@ services:
image: postgres:12
restart: always
volumes:
- db_data:/var/lib/postgresql/data
- canopy_prod_db:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: postgrespassword
env_file:
- .env.prod
graphql-engine:
image: hasura/graphql-engine:v2.16.0
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
## postgres database to store Hasura metadata
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
## Hasura JWT Secret
HASURA_GRAPHQL_JWT_SECRET: "${HASURA_GRAPHQL_JWT_SECRET}"
## Unauthorized role
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "public"
env_file:
- .env.prod

## CRON Webhook URL
CANOPY_CRON_WEBHOOK_URL: "${CANOPY_CRON_WEBHOOK_URL}"
## CRON Client Key
CANOPY_CRON_CLIENT_KEY: "${CANOPY_CRON_CLIENT_KEY}"

## Event Webhook URL
CANOPY_EVENT_WEBHOOK_URL: "${CANOPY_EVENT_WEBHOOK_URL}"
## Event Client Key
CANOPY_EVENT_CLIENT_KEY: "${CANOPY_EVENT_CLIENT_KEY}"
volumes:
db_data:
canopy_prod_db:
48 changes: 47 additions & 1 deletion web/components/EditProfileListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import { EditResponse } from "./edit-profile/EditResponse";
import { ProfileSocialsDisplay } from "./edit-socials-info/ProfileSocialsDisplay";
import { ProfileSocialsModal } from "./edit-socials-info/ProfileSocialsModal";
import PublishedToggleSwitch from "./PublishedToggleSwitch";
import { useSpaceAttributes } from "../hooks/useSpaceAttributes";
import { CheckBox } from "./atomic/CheckBox";
import { handleError } from "../lib/error";
import toast from "react-hot-toast";

function EditProfileImage() {
const { currentProfile } = useCurrentProfile();
Expand Down Expand Up @@ -53,9 +57,15 @@ interface EditProfileListingProps {
export function EditProfileListing(props: EditProfileListingProps) {
const { showPublishedToggle = true } = props;

const { currentProfile, currentProfileHasRole } = useCurrentProfile();
const {
currentProfile,
currentProfileHasRole,
profileAttributes,
updateProfileAttributes,
} = useCurrentProfile();
const { currentSpace } = useCurrentSpace();
const { userData } = useUserData();
const { attributes } = useSpaceAttributes();

const [socialsOpened, socialsHandlers] = useDisclosure(false);

Expand All @@ -78,7 +88,43 @@ export function EditProfileListing(props: EditProfileListingProps) {
profileListingId={currentProfile.profile_listing?.id ?? ""}
/>
)}

<div className="h-4"></div>
{attributes?.communityGuidelinesUrl && (
<>
<CheckBox
label={
<span>
I agree to the{" "}
<a
href={attributes.communityGuidelinesUrl}
target="_blank"
rel="noreferrer"
className="text-lime-700 underline"
>
community guidelines
</a>
</span>
}
checked={profileAttributes.agreedToCommunityGuidelines}
onChange={(e) => {
const newVal = e.target?.checked ?? false;

toast.promise(
updateProfileAttributes({
agreedToCommunityGuidelines: newVal,
}),
{
loading: "Loading",
success: `${newVal ? "Agreed" : "Disagreed"} to guidelines`,
error: (err) => err.message,
}
);
}}
/>
<div className="h-4"></div>
</>
)}
<div className="flex w-full max-w-3xl flex-col rounded-lg border border-black bg-white pb-12">
<div className="h-20 rounded-t-lg bg-gray-100"></div>
<div className="-mt-4 px-4 sm:px-12">
Expand Down
8 changes: 5 additions & 3 deletions web/components/account-settings/ProfileSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { useCurrentSpace } from "../../hooks/useCurrentSpace";
import { usePrevious } from "../../hooks/usePrevious";
import { useSaveChangesState } from "../../hooks/useSaveChangesState";
import { useUserData } from "../../hooks/useUserData";
import { ProfileAttributes } from "../../lib/profileAttributes";
import {
DEFAULT_PROFILE_ATTRIBUTES,
ProfileAttributes,
} from "../../lib/profileAttributes";
import { Button, Text } from "../atomic";
import { CheckBox } from "../atomic/CheckBox";

Expand Down Expand Up @@ -57,8 +60,6 @@ export function ProfileSettings() {
return true;
}, [client, currentProfile?.profile_listing]);

console.log(settings);

return (
<>
<Text variant="heading3">Settings for {currentSpace?.name}</Text>
Expand Down Expand Up @@ -88,6 +89,7 @@ export function ProfileSettings() {
}

setSettings((prev) => ({
...DEFAULT_PROFILE_ATTRIBUTES,
...prev,
enableChatIntros: newVal,
}));
Expand Down
72 changes: 52 additions & 20 deletions web/components/admin/SetPrivacySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@ import { useEffect, useMemo, useState } from "react";

import toast from "react-hot-toast";

import { Button, Text } from "../../components/atomic";
import { Button, Input, Text } from "../../components/atomic";
import {
useUpdateSpaceAttributesMutation,
useUpdateSpaceMutation,
} from "../../generated/graphql";
import { useCurrentSpace } from "../../hooks/useCurrentSpace";
import {
PrivacySettings,
usePrivacySettings,
} from "../../hooks/usePrivacySettings";
import { useSpaceAttributes } from "../../hooks/useSpaceAttributes";
import { useSaveChangesState } from "../../hooks/useSaveChangesState";
import { CheckBox } from "../atomic/CheckBox";
import { TextInput } from "../inputs/TextInput";
import { SpaceAttributes } from "../../lib/spaceAttributes";

export function SetPrivacySettings() {
const { currentSpace } = useCurrentSpace();

const { privacySettings } = usePrivacySettings();
const { attributes } = useSpaceAttributes();

const [settings, setSettings] = useState<PrivacySettings>();
const [attributesState, setAttributesState] = useState<SpaceAttributes>();
const { mustSave, setMustSave } = useSaveChangesState();

useEffect(() => {
if (privacySettings) {
setSettings(privacySettings);
if (attributes) {
setAttributesState(attributes);
}
}, [privacySettings]);
}, [attributes]);

const [loading, setLoading] = useState(false);
const [_, updateSpaceAttributes] = useUpdateSpaceAttributesMutation();

if (!settings) {
if (!attributesState) {
return null;
}

Expand All @@ -48,24 +47,24 @@ export function SetPrivacySettings() {
<div className="h-4"></div>
<CheckBox
label={`Public (visible to anyone who visits ${window.location.origin}/space/${currentSpace?.slug}, not just members in your space)`}
checked={settings.public}
checked={attributesState.public}
onChange={(e) => {
const newVal = e.target?.checked ?? false;

setMustSave(true);
setSettings({ ...settings, public: newVal });
setAttributesState({ ...attributesState, public: newVal });
}}
/>
<div className="h-4"></div>

<CheckBox
label={`Only allow members with published profiles to view other profiles. (Admins will still be able to view all published profiles)`}
checked={settings.allowOnlyPublicMembersToViewProfiles}
checked={attributesState.allowOnlyPublicMembersToViewProfiles}
onChange={(e) => {
const newVal = e.target?.checked ?? false;
setMustSave(true);
setSettings({
...settings,
setAttributesState({
...attributesState,
allowOnlyPublicMembersToViewProfiles: newVal,
});
}}
Expand All @@ -74,19 +73,52 @@ export function SetPrivacySettings() {
<div className="h-4"></div>
<CheckBox
label={`Opt new users in to matches by default (when they join the space)`}
checked={settings.optUsersInToMatchesByDefault}
checked={attributesState.optUsersInToMatchesByDefault}
onChange={(e) => {
const newVal = e.target?.checked ?? false;

setMustSave(true);
setSettings({
...settings,
setAttributesState({
...attributesState,
optUsersInToMatchesByDefault: newVal,
});
}}
/>

<div className="h-12"></div>
<TextInput
label="Comma-separated allowed domains to join space. Empty = allow all domains"
placeholder="example.com,example.org"
value={attributesState.domainWhitelists?.join(",") ?? ""}
onChange={(e) => {
const newVal = e.target.value;

setMustSave(true);
setAttributesState({
...attributesState,
domainWhitelists: newVal
? newVal.split(",").map((x) => x.trim())
: null,
});
}}
/>

<div className="h-4"></div>
<TextInput
label="Community guidelines URL (users must agree to guidelines before publishing profile)"
value={attributesState.communityGuidelinesUrl || ""}
onChange={(e) => {
const newVal = e.target.value;
setMustSave(true);
setAttributesState({
...attributesState,
communityGuidelinesUrl: newVal || null,
});
}}
/>

<div className="h-8"></div>
{/* <pre>{JSON.stringify(settings, null, 2)}</pre> */}
<Button
disabled={!mustSave}
rounded
Expand All @@ -97,7 +129,7 @@ export function SetPrivacySettings() {
}
setLoading(true);
updateSpaceAttributes({
changes: settings,
changes: attributesState,
space_id: currentSpace.id,
})
.then((res) => {
Expand Down
3 changes: 2 additions & 1 deletion web/components/atomic/CheckBox.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ReactNode } from "react";
import { Text } from ".";

export function CheckBox(
props: {
label?: string;
label?: ReactNode;
} & React.InputHTMLAttributes<HTMLInputElement>
) {
const { label, ...rest } = props;
Expand Down
Loading

0 comments on commit 2702e8c

Please sign in to comment.