Skip to content

Commit 963b2d8

Browse files
authoredJan 8, 2025
Add note about remaining edit update counts (#895)
1 parent b6e069f commit 963b2d8

File tree

8 files changed

+97
-0
lines changed

8 files changed

+97
-0
lines changed
 

‎frontend/src/graphql/queries/Config.gql

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
query Config {
22
getConfig {
3+
edit_update_limit
34
host_url
45
require_invite
56
require_activation

‎frontend/src/graphql/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,7 @@ export enum SortDirectionEnum {
17281728

17291729
export type StashBoxConfig = {
17301730
__typename: "StashBoxConfig";
1731+
edit_update_limit: Scalars["Int"]["output"];
17311732
guidelines_url: Scalars["String"]["output"];
17321733
host_url: Scalars["String"]["output"];
17331734
min_destructive_voting_period: Scalars["Int"]["output"];
@@ -14531,6 +14532,7 @@ export type ConfigQuery = {
1453114532
__typename: "Query";
1453214533
getConfig: {
1453314534
__typename: "StashBoxConfig";
14535+
edit_update_limit: number;
1453414536
host_url: string;
1453514537
require_invite: boolean;
1453614538
require_activation: boolean;
@@ -53360,6 +53362,10 @@ export const ConfigDocument = {
5336053362
selectionSet: {
5336153363
kind: "SelectionSet",
5336253364
selections: [
53365+
{
53366+
kind: "Field",
53367+
name: { kind: "Name", value: "edit_update_limit" },
53368+
},
5336353369
{ kind: "Field", name: { kind: "Name", value: "host_url" } },
5336453370
{
5336553371
kind: "Field",

‎frontend/src/pages/edits/Edit.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC, useState } from "react";
22
import { Button } from "react-bootstrap";
33
import { useParams, Link } from "react-router-dom";
4+
import { UpdateCount } from "./components/UpdateCount";
45

56
import {
67
useEdit,
@@ -80,6 +81,10 @@ const EditComponent: FC = () => {
8081
const buttons = (isAdmin || isSelf(edit.user?.id)) &&
8182
edit.status === VoteStatusEnum.PENDING && (
8283
<div className="d-flex justify-content-end">
84+
<UpdateCount
85+
updatable={edit.updatable}
86+
updateCount={edit.update_count}
87+
/>
8388
{edit.updatable && (
8489
<Link to={createHref(ROUTE_EDIT_UPDATE, edit)} className="me-2">
8590
<Button variant="primary" disabled={mutating}>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { FC } from "react";
2+
import { useConfig } from "src/graphql";
3+
4+
interface Props {
5+
updatable: boolean;
6+
updateCount: number;
7+
}
8+
9+
export const UpdateCount: FC<Props> = ({ updatable, updateCount }) => {
10+
const { data: config } = useConfig();
11+
12+
const updateLimit = config?.getConfig.edit_update_limit;
13+
if (!updatable || !updateLimit) return null;
14+
15+
const updates = updateLimit - updateCount;
16+
return (
17+
<small className="text-muted align-content-center me-3">
18+
Edit can be updated{" "}
19+
{updates === 1 ? "one more time" : `${updates} more times`}
20+
</small>
21+
);
22+
};

‎graphql/schema/types/config.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ type StashBoxConfig {
99
vote_cron_interval: String!
1010
guidelines_url: String!
1111
require_scene_draft: Boolean!
12+
edit_update_limit: Int!
1213
}

‎pkg/api/resolver.go

+1
Original file line numberDiff line numberDiff line change
@@ -129,5 +129,6 @@ func (r *queryResolver) GetConfig(ctx context.Context) (*models.StashBoxConfig,
129129
VoteCronInterval: config.GetVoteCronInterval(),
130130
GuidelinesURL: config.GetGuidelinesURL(),
131131
RequireSceneDraft: config.GetRequireSceneDraft(),
132+
EditUpdateLimit: config.GetEditUpdateLimit(),
132133
}, nil
133134
}

‎pkg/models/generated_exec.go

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pkg/models/generated_models.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)