Skip to content

Commit

Permalink
Add note about remaining edit update counts (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored Jan 8, 2025
1 parent b6e069f commit 963b2d8
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/graphql/queries/Config.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
query Config {
getConfig {
edit_update_limit
host_url
require_invite
require_activation
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,7 @@ export enum SortDirectionEnum {

export type StashBoxConfig = {
__typename: "StashBoxConfig";
edit_update_limit: Scalars["Int"]["output"];
guidelines_url: Scalars["String"]["output"];
host_url: Scalars["String"]["output"];
min_destructive_voting_period: Scalars["Int"]["output"];
Expand Down Expand Up @@ -14531,6 +14532,7 @@ export type ConfigQuery = {
__typename: "Query";
getConfig: {
__typename: "StashBoxConfig";
edit_update_limit: number;
host_url: string;
require_invite: boolean;
require_activation: boolean;
Expand Down Expand Up @@ -53360,6 +53362,10 @@ export const ConfigDocument = {
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
name: { kind: "Name", value: "edit_update_limit" },
},
{ kind: "Field", name: { kind: "Name", value: "host_url" } },
{
kind: "Field",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/edits/Edit.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC, useState } from "react";
import { Button } from "react-bootstrap";
import { useParams, Link } from "react-router-dom";
import { UpdateCount } from "./components/UpdateCount";

import {
useEdit,
Expand Down Expand Up @@ -80,6 +81,10 @@ const EditComponent: FC = () => {
const buttons = (isAdmin || isSelf(edit.user?.id)) &&
edit.status === VoteStatusEnum.PENDING && (
<div className="d-flex justify-content-end">
<UpdateCount
updatable={edit.updatable}
updateCount={edit.update_count}
/>
{edit.updatable && (
<Link to={createHref(ROUTE_EDIT_UPDATE, edit)} className="me-2">
<Button variant="primary" disabled={mutating}>
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/pages/edits/components/UpdateCount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { FC } from "react";
import { useConfig } from "src/graphql";

interface Props {
updatable: boolean;
updateCount: number;
}

export const UpdateCount: FC<Props> = ({ updatable, updateCount }) => {
const { data: config } = useConfig();

const updateLimit = config?.getConfig.edit_update_limit;
if (!updatable || !updateLimit) return null;

const updates = updateLimit - updateCount;
return (
<small className="text-muted align-content-center me-3">
Edit can be updated{" "}
{updates === 1 ? "one more time" : `${updates} more times`}
</small>
);
};
1 change: 1 addition & 0 deletions graphql/schema/types/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ type StashBoxConfig {
vote_cron_interval: String!
guidelines_url: String!
require_scene_draft: Boolean!
edit_update_limit: Int!
}
1 change: 1 addition & 0 deletions pkg/api/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ func (r *queryResolver) GetConfig(ctx context.Context) (*models.StashBoxConfig,
VoteCronInterval: config.GetVoteCronInterval(),
GuidelinesURL: config.GetGuidelinesURL(),
RequireSceneDraft: config.GetRequireSceneDraft(),
EditUpdateLimit: config.GetEditUpdateLimit(),
}, nil
}
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.

0 comments on commit 963b2d8

Please sign in to comment.