Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guidelines link in top menu #601

Merged
merged 6 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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. |
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ 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";
import { Icon } from "src/components/fragments";
import { faBook, faUser } from "@fortawesome/free-solid-svg-icons";
import {
ROUTE_SCENES,
ROUTE_PERFORMERS,
Expand Down Expand Up @@ -33,6 +36,9 @@ const Main: FC<Props> = ({ 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;
Expand Down Expand Up @@ -73,11 +79,11 @@ const Main: FC<Props> = ({ children }) => {
contextValue.authenticated &&
contextValue.user && (
<>
<span>Logged in as</span>
<NavLink
to={userHref(contextValue.user)}
className="nav-link ms-auto me-2"
>
<Icon icon={faUser} className="me-2" />
{contextValue.user.name}
</NavLink>
{isAdmin(user) && (
Expand Down Expand Up @@ -127,6 +133,17 @@ const Main: FC<Props> = ({ children }) => {
Sites
</NavLink>
)}
{guidelinesURL && (
<a
href={guidelinesURL}
target="_blank"
rel="noopener noreferrer"
className="nav-link"
>
<Icon icon={faBook} className="mx-2" />
Guidelines
</a>
)}
</Nav>
<Nav className="align-items-center">
{contextValue.authenticated && renderUserNav()}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/graphql/queries/Config.gql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ query Config {
voting_period
min_destructive_voting_period
vote_cron_interval
guidelines_url
}
}
6 changes: 6 additions & 0 deletions frontend/src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ export enum SortDirectionEnum {

export type StashBoxConfig = {
__typename: "StashBoxConfig";
guidelines_url: Scalars["String"];
host_url: Scalars["String"];
min_destructive_voting_period: Scalars["Int"];
require_activation: Scalars["Boolean"];
Expand Down Expand Up @@ -13900,6 +13901,7 @@ export type ConfigQuery = {
voting_period: number;
min_destructive_voting_period: number;
vote_cron_interval: string;
guidelines_url: string;
};
};

Expand Down Expand Up @@ -39207,6 +39209,10 @@ export const ConfigDocument = {
kind: "Field",
name: { kind: "Name", value: "vote_cron_interval" },
},
{
kind: "Field",
name: { kind: "Name", value: "guidelines_url" },
},
],
},
},
Expand Down
1 change: 1 addition & 0 deletions graphql/schema/types/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type StashBoxConfig {
voting_period: Int!
min_destructive_voting_period: Int!
vote_cron_interval: String!
guidelines_url: String!
}
1 change: 1 addition & 0 deletions pkg/api/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ func (r *queryResolver) GetConfig(ctx context.Context) (*models.StashBoxConfig,
VotingPeriod: config.GetVotingPeriod(),
MinDestructiveVotingPeriod: config.GetMinDestructiveVotingPeriod(),
VoteCronInterval: config.GetVoteCronInterval(),
GuidelinesURL: config.GetGuidelinesURL(),
}, nil
}
6 changes: 6 additions & 0 deletions pkg/manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type config struct {
EmailCooldown int `mapstructure:"email_cooldown"`
DefaultUserRoles []string `mapstructure:"default_user_roles"`

// URL link for contributor guidelines for submitting edits
GuidelinesURL string `mapstructure:"guidelines_url"`
// Number of approved edits before user automatically gets VOTE role
VotePromotionThreshold int `mapstructure:"vote_promotion_threshold"`
// Number of positive votes required for immediate approval
Expand Down Expand Up @@ -220,6 +222,10 @@ func GetHostURL() string {
return C.HostURL
}

func GetGuidelinesURL() string {
return C.GuidelinesURL
}

// GetImageLocation returns the path of where to locally store images.
func GetImageLocation() string {
return C.ImageLocation
Expand Down
60 changes: 60 additions & 0 deletions pkg/models/generated_exec.go

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

1 change: 1 addition & 0 deletions pkg/models/generated_models.go

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

Loading