mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Merge branch 'master' into delete_scene
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
FileInput,
|
||||
Menu,
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
Popover,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { NavigationUtils } from "../../utils/navigation";
|
||||
@@ -20,6 +21,7 @@ interface IProps {
|
||||
isEditing: boolean;
|
||||
onToggleEdit: () => void;
|
||||
onSave: () => void;
|
||||
onDelete: () => void;
|
||||
onImageChange: (event: React.FormEvent<HTMLInputElement>) => void;
|
||||
|
||||
// TODO: only for performers. make generic
|
||||
@@ -27,6 +29,8 @@ interface IProps {
|
||||
}
|
||||
|
||||
export const DetailsEditNavbar: FunctionComponent<IProps> = (props: IProps) => {
|
||||
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState<boolean>(false);
|
||||
|
||||
function renderEditButton() {
|
||||
if (props.isNew) { return; }
|
||||
return (
|
||||
@@ -43,6 +47,11 @@ export const DetailsEditNavbar: FunctionComponent<IProps> = (props: IProps) => {
|
||||
return <Button intent="success" text="Save" onClick={() => props.onSave()} />;
|
||||
}
|
||||
|
||||
function renderDeleteButton() {
|
||||
if (props.isNew || props.isEditing) { return; }
|
||||
return <Button intent="danger" text="Delete" onClick={() => setIsDeleteAlertOpen(true)} />;
|
||||
}
|
||||
|
||||
function renderImageInput() {
|
||||
if (!props.isEditing) { return; }
|
||||
return <FileInput text="Choose image..." onInputChange={props.onImageChange} inputProps={{accept: ".jpg,.jpeg"}} />;
|
||||
@@ -81,7 +90,37 @@ export const DetailsEditNavbar: FunctionComponent<IProps> = (props: IProps) => {
|
||||
);
|
||||
}
|
||||
|
||||
function renderDeleteAlert() {
|
||||
var name;
|
||||
|
||||
if (props.performer) {
|
||||
name = props.performer.name;
|
||||
}
|
||||
if (props.studio) {
|
||||
name = props.studio.name;
|
||||
}
|
||||
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText="Cancel"
|
||||
confirmButtonText="Delete"
|
||||
icon="trash"
|
||||
intent="danger"
|
||||
isOpen={isDeleteAlertOpen}
|
||||
onCancel={() => setIsDeleteAlertOpen(false)}
|
||||
onConfirm={() => props.onDelete()}
|
||||
>
|
||||
<p>
|
||||
Are you sure you want to delete {name}?
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{renderDeleteAlert()}
|
||||
<Navbar>
|
||||
<Navbar.Group>
|
||||
{renderEditButton()}
|
||||
@@ -91,7 +130,9 @@ export const DetailsEditNavbar: FunctionComponent<IProps> = (props: IProps) => {
|
||||
{renderSaveButton()}
|
||||
|
||||
{renderScenesButton()}
|
||||
{renderDeleteButton()}
|
||||
</Navbar.Group>
|
||||
</Navbar>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -39,6 +39,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
const { data, error, loading } = StashService.useFindStudio(props.match.params.id);
|
||||
const updateStudio = StashService.useStudioUpdate(getStudioInput() as GQL.StudioUpdateInput);
|
||||
const createStudio = StashService.useStudioCreate(getStudioInput() as GQL.StudioCreateInput);
|
||||
const deleteStudio = StashService.useStudioDestroy(getStudioInput() as GQL.StudioDestroyInput);
|
||||
|
||||
function updateStudioEditState(state: Partial<GQL.StudioDataFragment>) {
|
||||
setName(state.name);
|
||||
@@ -95,6 +96,19 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const result = await deleteStudio();
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
}
|
||||
setIsLoading(false);
|
||||
|
||||
// redirect to studios page
|
||||
props.history.push(`/studios`);
|
||||
}
|
||||
|
||||
function onImageChange(event: React.FormEvent<HTMLInputElement>) {
|
||||
const file: File = (event.target as any).files[0];
|
||||
const reader: FileReader = new FileReader();
|
||||
@@ -120,6 +134,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
isEditing={isEditing}
|
||||
onToggleEdit={() => { setIsEditing(!isEditing); updateStudioEditState(studio); }}
|
||||
onSave={onSave}
|
||||
onDelete={onDelete}
|
||||
onImageChange={onImageChange}
|
||||
/>
|
||||
<h1 className="bp3-heading">
|
||||
|
||||
@@ -55,6 +55,7 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
const { data, error, loading } = StashService.useFindPerformer(props.match.params.id);
|
||||
const updatePerformer = StashService.usePerformerUpdate(getPerformerInput() as GQL.PerformerUpdateInput);
|
||||
const createPerformer = StashService.usePerformerCreate(getPerformerInput() as GQL.PerformerCreateInput);
|
||||
const deletePerformer = StashService.usePerformerDestroy(getPerformerInput() as GQL.PerformerDestroyInput);
|
||||
|
||||
function updatePerformerEditState(state: Partial<GQL.PerformerDataFragment | GQL.ScrapeFreeonesScrapeFreeones>) {
|
||||
if ((state as GQL.PerformerDataFragment).favorite !== undefined) {
|
||||
@@ -141,6 +142,19 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
async function onDelete() {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const result = await deletePerformer();
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
}
|
||||
setIsLoading(false);
|
||||
|
||||
// redirect to performers page
|
||||
props.history.push(`/performers`);
|
||||
}
|
||||
|
||||
function onImageChange(event: React.FormEvent<HTMLInputElement>) {
|
||||
const file: File = (event.target as any).files[0];
|
||||
const reader: FileReader = new FileReader();
|
||||
@@ -218,6 +232,7 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
isEditing={isEditing}
|
||||
onToggleEdit={() => { setIsEditing(!isEditing); updatePerformerEditState(performer); }}
|
||||
onSave={onSave}
|
||||
onDelete={onDelete}
|
||||
onImageChange={onImageChange}
|
||||
onDisplayFreeOnesDialog={onDisplayFreeOnesDialog}
|
||||
/>
|
||||
|
||||
@@ -133,6 +133,9 @@ export class StashService {
|
||||
public static usePerformerUpdate(input: GQL.PerformerUpdateInput) {
|
||||
return GQL.usePerformerUpdate({ variables: input });
|
||||
}
|
||||
public static usePerformerDestroy(input: GQL.PerformerDestroyInput) {
|
||||
return GQL.usePerformerDestroy({ variables: input });
|
||||
}
|
||||
|
||||
public static useSceneUpdate(input: GQL.SceneUpdateInput) {
|
||||
return GQL.useSceneUpdate({ variables: input });
|
||||
@@ -148,6 +151,9 @@ export class StashService {
|
||||
public static useStudioUpdate(input: GQL.StudioUpdateInput) {
|
||||
return GQL.useStudioUpdate({ variables: input });
|
||||
}
|
||||
public static useStudioDestroy(input: GQL.StudioDestroyInput) {
|
||||
return GQL.useStudioDestroy({ variables: input });
|
||||
}
|
||||
|
||||
public static useTagCreate(input: GQL.TagCreateInput) {
|
||||
return GQL.useTagCreate({ variables: input, refetchQueries: ["AllTags"] });
|
||||
|
||||
@@ -196,6 +196,10 @@ export interface PerformerUpdateInput {
|
||||
image?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface PerformerDestroyInput {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface StudioCreateInput {
|
||||
name: string;
|
||||
|
||||
@@ -214,6 +218,10 @@ export interface StudioUpdateInput {
|
||||
image?: Maybe<string>;
|
||||
}
|
||||
|
||||
export interface StudioDestroyInput {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface TagCreateInput {
|
||||
name: string;
|
||||
}
|
||||
@@ -334,6 +342,16 @@ export type PerformerUpdateMutation = {
|
||||
|
||||
export type PerformerUpdatePerformerUpdate = PerformerDataFragment;
|
||||
|
||||
export type PerformerDestroyVariables = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type PerformerDestroyMutation = {
|
||||
__typename?: "Mutation";
|
||||
|
||||
performerDestroy: boolean;
|
||||
};
|
||||
|
||||
export type SceneMarkerCreateVariables = {
|
||||
title: string;
|
||||
seconds: number;
|
||||
@@ -439,6 +457,16 @@ export type StudioUpdateMutation = {
|
||||
|
||||
export type StudioUpdateStudioUpdate = StudioDataFragment;
|
||||
|
||||
export type StudioDestroyVariables = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type StudioDestroyMutation = {
|
||||
__typename?: "Mutation";
|
||||
|
||||
studioDestroy: boolean;
|
||||
};
|
||||
|
||||
export type TagCreateVariables = {
|
||||
name: string;
|
||||
};
|
||||
@@ -1664,6 +1692,22 @@ export function usePerformerUpdate(
|
||||
PerformerUpdateVariables
|
||||
>(PerformerUpdateDocument, baseOptions);
|
||||
}
|
||||
export const PerformerDestroyDocument = gql`
|
||||
mutation PerformerDestroy($id: ID!) {
|
||||
performerDestroy(input: { id: $id })
|
||||
}
|
||||
`;
|
||||
export function usePerformerDestroy(
|
||||
baseOptions?: ReactApolloHooks.MutationHookOptions<
|
||||
PerformerDestroyMutation,
|
||||
PerformerDestroyVariables
|
||||
>
|
||||
) {
|
||||
return ReactApolloHooks.useMutation<
|
||||
PerformerDestroyMutation,
|
||||
PerformerDestroyVariables
|
||||
>(PerformerDestroyDocument, baseOptions);
|
||||
}
|
||||
export const SceneMarkerCreateDocument = gql`
|
||||
mutation SceneMarkerCreate(
|
||||
$title: String!
|
||||
@@ -1860,6 +1904,22 @@ export function useStudioUpdate(
|
||||
StudioUpdateVariables
|
||||
>(StudioUpdateDocument, baseOptions);
|
||||
}
|
||||
export const StudioDestroyDocument = gql`
|
||||
mutation StudioDestroy($id: ID!) {
|
||||
studioDestroy(input: { id: $id })
|
||||
}
|
||||
`;
|
||||
export function useStudioDestroy(
|
||||
baseOptions?: ReactApolloHooks.MutationHookOptions<
|
||||
StudioDestroyMutation,
|
||||
StudioDestroyVariables
|
||||
>
|
||||
) {
|
||||
return ReactApolloHooks.useMutation<
|
||||
StudioDestroyMutation,
|
||||
StudioDestroyVariables
|
||||
>(StudioDestroyDocument, baseOptions);
|
||||
}
|
||||
export const TagCreateDocument = gql`
|
||||
mutation TagCreate($name: String!) {
|
||||
tagCreate(input: { name: $name }) {
|
||||
|
||||
@@ -186,10 +186,14 @@ span.block {
|
||||
|
||||
& .tag-list-row {
|
||||
margin: 10px;
|
||||
cursor: pointer;
|
||||
|
||||
& .bp3-button {
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
& .tag-list-row:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user