From 4df72fb21cdda543117fd69e55b6df496579cd82 Mon Sep 17 00:00:00 2001 From: Flashy78 <90150289+Flashy78@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:28:31 -0800 Subject: [PATCH 1/5] Add config option for contributor guidelines url --- README.md | 1 + frontend/src/Main.tsx | 9 ++++ frontend/src/graphql/queries/Config.gql | 1 + frontend/src/graphql/types.ts | 2 + graphql/schema/types/config.graphql | 1 + pkg/api/resolver.go | 1 + pkg/manager/config/config.go | 6 +++ pkg/models/generated_exec.go | 62 +++++++++++++++++++++++++ pkg/models/generated_models.go | 1 + 9 files changed, 84 insertions(+) diff --git a/README.md b/README.md index ee4f47b9a..656adbb22 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ There are two ways to authenticate a user in Stash-box: a session or an API key. | `activation_expiry` | `7200` (2 hours) | The time - in seconds - after which an activation key (emailed to the user for email verification or password reset purposes) expires. | | `email_cooldown` | `300` (5 minutes) | The time - in seconds - that a user must wait before submitting an activation or reset password request for a specific email address. | | `default_user_roles` | `READ`, `VOTE`, `EDIT` | The roles assigned to new users when registering. This field must be expressed as a yaml array. | +| `guidelines_url` | (none) | URL to link to a set of guidelines for users contributing edits. Should be in the form of `https://hostname.com`. | | `vote_promotion_threshold` | (none) | Number of approved edits before a user automatically has the `VOTE` role assigned. Leave empty to disable. | | `vote_application_threshold` | `3` | Number of same votes required for immediate application of an edit. Set to zero to disable automatic application. | | `voting_period` | `345600` | Time, in seconds, before a voting period is closed. | diff --git a/frontend/src/Main.tsx b/frontend/src/Main.tsx index 6b49ab922..ae3d87bd4 100644 --- a/frontend/src/Main.tsx +++ b/frontend/src/Main.tsx @@ -3,6 +3,7 @@ import { Navbar, Nav } from "react-bootstrap"; import { NavLink, useLocation, useNavigate } from "react-router-dom"; import SearchField, { SearchType } from "src/components/searchField"; +import { useConfig } from "src/graphql"; import { getPlatformURL, getCredentialsSetting } from "src/utils/createClient"; import { isAdmin, canEdit, userHref, setCachedUser } from "src/utils"; import { useAuth } from "src/hooks"; @@ -33,6 +34,9 @@ const Main: FC = ({ children }) => { const location = useLocation(); const navigate = useNavigate(); const { loading, user } = useAuth(); + const { data: configData } = useConfig(); + + const guidelinesURL = configData?.getConfig.guidelines_url; useEffect(() => { if (loading || user) return; @@ -127,6 +131,11 @@ const Main: FC = ({ children }) => { Sites )} + {guidelinesURL && ( + + Guidelines + + )}