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

Remove scene create button from webUI on config #789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -99,6 +99,7 @@ There are two ways to authenticate a user in Stash-box: a session or an API key.
| `postgres.max_open_conns` | (0) | Maximum number of concurrent open connections to the database. |
| `postgres.max_idle_conns` | (0) | Maximum number of concurrent idle database connections. |
| `postgres.conn_max_lifetime` | (0) | Maximum lifetime in minutes before a connection is released. |
| `allow_webui_scene_create` | true | Whether to allow scene creation via web UI. |

## SSL (HTTPS)

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 @@ -9,5 +9,6 @@ query Config {
min_destructive_voting_period
vote_cron_interval
guidelines_url
allow_webui_scene_create
}
}
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";
allow_webui_scene_create: Scalars["Boolean"];
guidelines_url: Scalars["String"];
host_url: Scalars["String"];
min_destructive_voting_period: Scalars["Int"];
Expand Down Expand Up @@ -13902,6 +13903,7 @@ export type ConfigQuery = {
min_destructive_voting_period: number;
vote_cron_interval: string;
guidelines_url: string;
allow_webui_scene_create: boolean;
};
};

Expand Down Expand Up @@ -39213,6 +39215,10 @@ export const ConfigDocument = {
kind: "Field",
name: { kind: "Name", value: "guidelines_url" },
},
{
kind: "Field",
name: { kind: "Name", value: "allow_webui_scene_create" },
},
],
},
},
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/pages/scenes/Scenes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC, useContext } from "react";
import { Button } from "react-bootstrap";
import { Link } from "react-router-dom";

import { CriterionModifier } from "src/graphql";
import { CriterionModifier, useConfig } from "src/graphql";
import { canEdit, createHref } from "src/utils";
import AuthContext from "src/AuthContext";
import { SceneList } from "src/components/list";
Expand All @@ -11,6 +11,7 @@ import { ROUTE_SCENE_ADD } from "src/constants/route";

const Scenes: FC = () => {
const auth = useContext(AuthContext);
const { data: configData } = useConfig();
const [{ fingerprint }] = useQueryParams({
fingerprint: { name: "fingerprint", type: "string" },
});
Expand All @@ -27,11 +28,12 @@ const Scenes: FC = () => {
<>
<div className="d-flex">
<h3 className="me-4">Scenes</h3>
{canEdit(auth.user) && (
<Link to={createHref(ROUTE_SCENE_ADD)} className="ms-auto">
<Button>Create</Button>
</Link>
)}
{canEdit(auth.user) &&
configData?.getConfig.allow_webui_scene_create && (
<Link to={createHref(ROUTE_SCENE_ADD)} className="ms-auto">
<Button>Create</Button>
</Link>
)}
</div>
<SceneList filter={filter} favoriteFilter="all" />
</>
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 @@ -8,4 +8,5 @@ type StashBoxConfig {
min_destructive_voting_period: Int!
vote_cron_interval: String!
guidelines_url: String!
allow_webui_scene_create: Boolean!
}
1 change: 1 addition & 0 deletions pkg/api/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ func (r *queryResolver) GetConfig(ctx context.Context) (*models.StashBoxConfig,
MinDestructiveVotingPeriod: config.GetMinDestructiveVotingPeriod(),
VoteCronInterval: config.GetVoteCronInterval(),
GuidelinesURL: config.GetGuidelinesURL(),
AllowWebuiSceneCreate: config.GetAllowWebuiSceneCreate(),
}, nil
}
7 changes: 7 additions & 0 deletions pkg/manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type config struct {
MinDestructiveVotingPeriod int `mapstructure:"min_destructive_voting_period"`
// Interval between checks for completed voting periods
VoteCronInterval string `mapstructure:"vote_cron_interval"`
// Allow scene creation in web UI
AllowWebuiSceneCreate bool `mapstructure:"allow_webui_scene_create"`

// Email settings
EmailHost string `mapstructure:"email_host"`
Expand Down Expand Up @@ -120,6 +122,7 @@ var C = &config{
VotingPeriod: 345600,
MinDestructiveVotingPeriod: 172800,
DraftTimeLimit: 86400,
AllowWebuiSceneCreate: true,
}

func GetDatabasePath() string {
Expand Down Expand Up @@ -360,6 +363,10 @@ func GetVoteCronInterval() string {
return C.VoteCronInterval
}

func GetAllowWebuiSceneCreate() bool {
return C.AllowWebuiSceneCreate
}

func GetTitle() string {
if C.Title == "" {
return "Stash-Box"
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