Skip to content

Commit

Permalink
Merge branch 'master' into jav-search
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Feb 26, 2024
2 parents 15ee0c5 + b739d20 commit 235fa00
Show file tree
Hide file tree
Showing 85 changed files with 7,995 additions and 4,670 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ concurrency:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

services:
postgres:
image: postgres:14.2
image: postgres:16.1
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -41,12 +41,12 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'

- name: Cache node modules
uses: actions/cache@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
golangci:
name: lint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.22.x

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ linters-settings:
enabled: true
- name: increment-decrement
- name: var-naming
arguments:
- ["IDS"] # AllowList
- name: var-declaration
- name: package-comments
- name: range
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ generate-dataloaders:
go run github.com/vektah/dataloaden BodyModificationsLoader github.com/gofrs/uuid.UUID "[]*github.com/stashapp/stash-box/pkg/models.BodyModification"; \
go run github.com/vektah/dataloaden TagCategoryLoader github.com/gofrs/uuid.UUID "*github.com/stashapp/stash-box/pkg/models.TagCategory"; \
go run github.com/vektah/dataloaden SiteLoader github.com/gofrs/uuid.UUID "*github.com/stashapp/stash-box/pkg/models.Site"; \
go run github.com/vektah/dataloaden StudioLoader github.com/gofrs/uuid.UUID "*github.com/stashapp/stash-box/pkg/models.Studio";
go run github.com/vektah/dataloaden StudioLoader github.com/gofrs/uuid.UUID "*github.com/stashapp/stash-box/pkg/models.Studio"; \
go run github.com/vektah/dataloaden BoolsLoader github.com/gofrs/uuid.UUID "bool";

test:
go test ./...
Expand Down
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
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"stylelint-config-standard-scss": "^10.0.0",
"stylelint-scss": "^5.0.1",
"typescript": "~4.9.5",
"vite": "^4.1.5",
"vite": "^4.5.2",
"vite-tsconfig-paths": "^4.0.5"
},
"dependencies": {
Expand All @@ -65,7 +65,7 @@
"bootstrap": "^5.2.3",
"classnames": "^2.3.2",
"date-fns": "^2.29.3",
"graphql": "^16.6.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"i18n-iso-countries": "^7.5.0",
"lodash-es": "^4.17.21",
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
26 changes: 13 additions & 13 deletions frontend/src/components/editCard/ModifyEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ type Details = EditFragment["details"];
type OldDetails = EditFragment["old_details"];
type Options = EditFragment["options"];

type Image = {
height: number;
id: string;
url: string;
width: number;
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
type StartingWith<T, K extends string> = T extends `${K}${infer _}` ? T : never;
type TargetOldDetails<T> = Omit<
Expand Down Expand Up @@ -95,11 +102,6 @@ type BodyMod = {
description?: string | null;
};

type Image = {
id: string;
url: string;
};

export interface PerformerDetails {
name?: string | null;
gender?: GenderEnum | null;
Expand All @@ -123,8 +125,8 @@ export interface PerformerDetails {
removed_piercings?: BodyMod[] | null;
added_aliases?: string[] | null;
removed_aliases?: string[] | null;
added_images?: NullableImage[] | null;
removed_images?: NullableImage[] | null;
added_images?: (Image | null)[] | null;
removed_images?: (Image | null)[] | null;
added_urls?: URL[] | null;
removed_urls?: URL[] | null;
draft_id?: string | null;
Expand Down Expand Up @@ -303,8 +305,6 @@ type ScenePerformance = {
>;
};

type NullableImage = Image | null;

export interface SceneDetails {
title?: string | null;
date?: string | null;
Expand All @@ -318,8 +318,8 @@ export interface SceneDetails {
} | null;
added_performers?: ScenePerformance[] | null;
removed_performers?: ScenePerformance[] | null;
added_images?: NullableImage[] | null;
removed_images?: NullableImage[] | null;
added_images?: (Image | null)[] | null;
removed_images?: (Image | null)[] | null;
added_urls?: URL[] | null;
removed_urls?: URL[] | null;
added_tags?:
Expand Down Expand Up @@ -464,8 +464,8 @@ export interface StudioDetails {
id: string;
name: string;
} | null;
added_images?: NullableImage[] | null;
removed_images?: NullableImage[] | null;
added_images?: (Image | null)[] | null;
removed_images?: (Image | null)[] | null;
added_urls?: URL[] | null;
removed_urls?: URL[] | null;
}
Expand Down
22 changes: 10 additions & 12 deletions frontend/src/components/editCard/VoteBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,16 @@ const VoteBar: FC<Props> = ({ edit }) => {
<div className={CLASSNAME}>
<div className={CLASSNAME_SAVE}>
{currentVote}
{vote &&
vote !== userVote?.vote &&
(userVote || vote !== VoteTypeEnum.ABSTAIN) && (
<Button
variant="secondary"
onClick={handleSave}
disabled={savingVote}
>
<span className="me-2">Save</span>
<Icon icon={faCheck} color="green" />
</Button>
)}
{vote && vote !== userVote?.vote && (
<Button
variant="secondary"
onClick={handleSave}
disabled={savingVote}
>
<span className="me-2">Save</span>
<Icon icon={faCheck} color="green" />
</Button>
)}
</div>
<Form.Group
controlId={`${edit.id}-vote-yes`}
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/components/editImages/editImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Control } from "react-hook-form";
import { faImages } from "@fortawesome/free-solid-svg-icons";
import cx from "classnames";

import { useAddImage } from "src/graphql";
import { ImageFragment as Image, useAddImage } from "src/graphql";
import { Image as ImageInput } from "src/components/form";
import { Icon, LoadingIndicator } from "src/components/fragments";

Expand All @@ -18,11 +18,6 @@ const CLASSNAME_PLACEHOLDER = `${CLASSNAME}-placeholder`;
const CLASSNAME_IMAGE = `${CLASSNAME}-image`;
const CLASSNAME_UPLOADING = `${CLASSNAME_IMAGE}-uploading`;

type Image = {
id: string;
url: string;
};

type ControlType =
| Control<{ images?: Image[] | undefined }, "images">
| undefined;
Expand All @@ -35,7 +30,7 @@ interface EditImagesProps {
maxImages?: number;
/** Whether to allow svg/png image input */
allowLossless?: boolean;
original?: { id: string; url: string }[] | undefined;
original?: Image[] | undefined;
}

const EditImages: FC<EditImagesProps> = ({
Expand Down
42 changes: 12 additions & 30 deletions frontend/src/components/imageChangeRow/ImageChangeRow.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,35 @@
import { FC, useState } from "react";
import { FC } from "react";
import { Col, Row } from "react-bootstrap";

import { ImageFragment as Image } from "src/graphql";
type Image = {
height: number;
id: string;
url: string;
width: number;
};

const CLASSNAME = "ImageChangeRow";
const CLASSNAME_IMAGE = `${CLASSNAME}-image`;

export interface ImageChangeRowProps {
newImages?: (Pick<Image, "id" | "url"> | null)[] | null;
oldImages?: (Pick<Image, "id" | "url"> | null)[] | null;
newImages?: (Image | null)[] | null;
oldImages?: (Image | null)[] | null;
showDiff?: boolean;
}

const Images: FC<{
images: (Pick<Image, "id" | "url"> | null)[] | null | undefined;
images: (Image | null)[] | null | undefined;
}> = ({ images }) => {
const [imgDimensions, setImgDimensions] = useState<{
[key: string]: { height: number; width: number };
}>({});

const onImgLoad = (event: React.SyntheticEvent<HTMLImageElement, Event>) => {
setImgDimensions({
...imgDimensions,
[event.currentTarget.src]: {
height: event.currentTarget.naturalHeight,
width: event.currentTarget.naturalWidth,
},
});
};

return (
<>
{(images ?? []).map((image, i) =>
image === null ? (
<img className={CLASSNAME_IMAGE} alt="Deleted" key={`deleted-${i}`} />
) : (
<div key={image.id}>
<img
src={image.url}
className={CLASSNAME_IMAGE}
alt=""
onLoad={onImgLoad}
/>
<img src={image.url} className={CLASSNAME_IMAGE} alt="" />
<div className={"text-center"}>
{imgDimensions && imgDimensions[image.url]
? `${imgDimensions[image.url].width} x ${
imgDimensions[image.url].height
}`
: ""}
{image.width} x {image.height}
</div>
</div>
)
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/list/EditList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ interface EditsProps {
defaultVoted?: UserVotedFilterEnum;
defaultBot?: "include" | "exclude" | "only";
showVotedFilter?: boolean;
userSubmitted?: boolean;
defaultUserSubmitted?: boolean;
}

const PER_PAGE = 20;
Expand All @@ -44,6 +46,8 @@ const EditListComponent: FC<EditsProps> = ({
defaultVoted,
defaultBot,
showVotedFilter,
userSubmitted,
defaultUserSubmitted,
}) => {
const { page, setPage } = usePagination();
const {
Expand All @@ -56,6 +60,7 @@ const EditListComponent: FC<EditsProps> = ({
selectedStatus,
selectedFavorite,
selectedBot,
selectedUserSubmitted,
} = useEditFilter({
sort,
direction,
Expand All @@ -68,6 +73,8 @@ const EditListComponent: FC<EditsProps> = ({
defaultVoteStatus,
defaultVoted,
defaultBot,
userSubmitted,
defaultUserSubmitted,
});
const { data, loading } = useEdits({
input: {
Expand All @@ -88,6 +95,7 @@ const EditListComponent: FC<EditsProps> = ({
per_page: PER_PAGE,
sort: selectedSort,
direction: selectedDirection,
include_user_submitted: selectedUserSubmitted,
},
});

Expand Down
Loading

0 comments on commit 235fa00

Please sign in to comment.