mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Merge e04bb99c73 into 061d21dede
This commit is contained in:
commit
7eff116261
7 changed files with 65 additions and 0 deletions
|
|
@ -319,6 +319,7 @@ input ConfigDisableDropdownCreateInput {
|
||||||
tag: Boolean
|
tag: Boolean
|
||||||
studio: Boolean
|
studio: Boolean
|
||||||
movie: Boolean
|
movie: Boolean
|
||||||
|
gallery: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ImageLightboxDisplayMode {
|
enum ImageLightboxDisplayMode {
|
||||||
|
|
@ -419,6 +420,7 @@ type ConfigDisableDropdownCreate {
|
||||||
tag: Boolean!
|
tag: Boolean!
|
||||||
studio: Boolean!
|
studio: Boolean!
|
||||||
movie: Boolean!
|
movie: Boolean!
|
||||||
|
gallery: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigInterfaceResult {
|
type ConfigInterfaceResult {
|
||||||
|
|
|
||||||
|
|
@ -521,6 +521,7 @@ func (r *mutationResolver) ConfigureInterface(ctx context.Context, input ConfigI
|
||||||
r.setConfigBool(config.DisableDropdownCreateStudio, ddc.Studio)
|
r.setConfigBool(config.DisableDropdownCreateStudio, ddc.Studio)
|
||||||
r.setConfigBool(config.DisableDropdownCreateTag, ddc.Tag)
|
r.setConfigBool(config.DisableDropdownCreateTag, ddc.Tag)
|
||||||
r.setConfigBool(config.DisableDropdownCreateMovie, ddc.Movie)
|
r.setConfigBool(config.DisableDropdownCreateMovie, ddc.Movie)
|
||||||
|
r.setConfigBool(config.DisableDropdownCreateGallery, ddc.Gallery)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setConfigString(config.HandyKey, input.HandyKey)
|
r.setConfigString(config.HandyKey, input.HandyKey)
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,7 @@ const (
|
||||||
DisableDropdownCreateStudio = "disable_dropdown_create.studio"
|
DisableDropdownCreateStudio = "disable_dropdown_create.studio"
|
||||||
DisableDropdownCreateTag = "disable_dropdown_create.tag"
|
DisableDropdownCreateTag = "disable_dropdown_create.tag"
|
||||||
DisableDropdownCreateMovie = "disable_dropdown_create.movie"
|
DisableDropdownCreateMovie = "disable_dropdown_create.movie"
|
||||||
|
DisableDropdownCreateGallery = "disable_dropdown_create.gallery"
|
||||||
|
|
||||||
HandyKey = "handy_key"
|
HandyKey = "handy_key"
|
||||||
FunscriptOffset = "funscript_offset"
|
FunscriptOffset = "funscript_offset"
|
||||||
|
|
@ -1311,6 +1312,7 @@ func (i *Config) GetDisableDropdownCreate() *ConfigDisableDropdownCreate {
|
||||||
Studio: i.getBool(DisableDropdownCreateStudio),
|
Studio: i.getBool(DisableDropdownCreateStudio),
|
||||||
Tag: i.getBool(DisableDropdownCreateTag),
|
Tag: i.getBool(DisableDropdownCreateTag),
|
||||||
Movie: i.getBool(DisableDropdownCreateMovie),
|
Movie: i.getBool(DisableDropdownCreateMovie),
|
||||||
|
Gallery: i.getBool(DisableDropdownCreateGallery),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,4 +105,5 @@ type ConfigDisableDropdownCreate struct {
|
||||||
Tag bool `json:"tag"`
|
Tag bool `json:"tag"`
|
||||||
Studio bool `json:"studio"`
|
Studio bool `json:"studio"`
|
||||||
Movie bool `json:"movie"`
|
Movie bool `json:"movie"`
|
||||||
|
Gallery bool `json:"gallery"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ fragment ConfigInterfaceData on ConfigInterfaceResult {
|
||||||
tag
|
tag
|
||||||
studio
|
studio
|
||||||
movie
|
movie
|
||||||
|
gallery
|
||||||
}
|
}
|
||||||
handyKey
|
handyKey
|
||||||
funscriptOffset
|
funscriptOffset
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import * as GQL from "src/core/generated-graphql";
|
||||||
import {
|
import {
|
||||||
queryFindGalleriesForSelect,
|
queryFindGalleriesForSelect,
|
||||||
queryFindGalleriesByIDForSelect,
|
queryFindGalleriesByIDForSelect,
|
||||||
|
useGalleryCreate,
|
||||||
} from "src/core/StashService";
|
} from "src/core/StashService";
|
||||||
import { useConfigurationContext } from "src/hooks/Config";
|
import { useConfigurationContext } from "src/hooks/Config";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
@ -70,10 +71,14 @@ const gallerySelectSort = PatchFunction(
|
||||||
const _GallerySelect: React.FC<
|
const _GallerySelect: React.FC<
|
||||||
IFilterProps & IFilterValueProps<Gallery> & ExtraGalleryProps
|
IFilterProps & IFilterValueProps<Gallery> & ExtraGalleryProps
|
||||||
> = (props) => {
|
> = (props) => {
|
||||||
|
const [createGallery] = useGalleryCreate();
|
||||||
|
|
||||||
const { configuration } = useConfigurationContext();
|
const { configuration } = useConfigurationContext();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const maxOptionsShown =
|
const maxOptionsShown =
|
||||||
configuration?.ui.maxOptionsShown ?? defaultMaxOptionsShown;
|
configuration?.ui.maxOptionsShown ?? defaultMaxOptionsShown;
|
||||||
|
const defaultCreatable =
|
||||||
|
!configuration?.interface.disableDropdownCreate.gallery;
|
||||||
|
|
||||||
const exclude = useMemo(() => props.excludeIds ?? [], [props.excludeIds]);
|
const exclude = useMemo(() => props.excludeIds ?? [], [props.excludeIds]);
|
||||||
|
|
||||||
|
|
@ -203,6 +208,42 @@ const _GallerySelect: React.FC<
|
||||||
return <reactSelectComponents.SingleValue {...thisOptionProps} />;
|
return <reactSelectComponents.SingleValue {...thisOptionProps} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onCreate = async (name: string) => {
|
||||||
|
const result = await createGallery({
|
||||||
|
variables: { input: { title: name } },
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
value: result.data!.galleryCreate!.id,
|
||||||
|
item: result.data!.galleryCreate!,
|
||||||
|
message: "Created gallery",
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getNamedObject = (id: string, name: string): Gallery => {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
title: name,
|
||||||
|
files: [],
|
||||||
|
folder: null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const isValidNewOption = (inputValue: string, options: Gallery[]) => {
|
||||||
|
if (!inputValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
options.some((o) => {
|
||||||
|
return galleryTitle(o).toLowerCase() === inputValue.toLowerCase();
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FilterSelectComponent<Gallery, boolean>
|
<FilterSelectComponent<Gallery, boolean>
|
||||||
{...props}
|
{...props}
|
||||||
|
|
@ -214,12 +255,16 @@ const _GallerySelect: React.FC<
|
||||||
props.className
|
props.className
|
||||||
)}
|
)}
|
||||||
loadOptions={loadGalleries}
|
loadOptions={loadGalleries}
|
||||||
|
getNamedObject={getNamedObject}
|
||||||
|
isValidNewOption={isValidNewOption}
|
||||||
components={{
|
components={{
|
||||||
Option: GalleryOption,
|
Option: GalleryOption,
|
||||||
MultiValueLabel: GalleryMultiValueLabel,
|
MultiValueLabel: GalleryMultiValueLabel,
|
||||||
SingleValue: GalleryValueLabel,
|
SingleValue: GalleryValueLabel,
|
||||||
}}
|
}}
|
||||||
isMulti={props.isMulti ?? false}
|
isMulti={props.isMulti ?? false}
|
||||||
|
creatable={props.creatable ?? defaultCreatable}
|
||||||
|
onCreate={onCreate}
|
||||||
placeholder={
|
placeholder={
|
||||||
props.noSelectionString ??
|
props.noSelectionString ??
|
||||||
intl.formatMessage(
|
intl.formatMessage(
|
||||||
|
|
|
||||||
|
|
@ -735,6 +735,19 @@ export const SettingsInterfacePanel: React.FC = PatchComponent(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<BooleanSetting
|
||||||
|
id="disableDropdownCreate_gallery"
|
||||||
|
headingID="gallery"
|
||||||
|
checked={iface.disableDropdownCreate?.gallery ?? undefined}
|
||||||
|
onChange={(v) =>
|
||||||
|
saveInterface({
|
||||||
|
disableDropdownCreate: {
|
||||||
|
...iface.disableDropdownCreate,
|
||||||
|
gallery: v,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<NumberSetting
|
<NumberSetting
|
||||||
id="max_options_shown"
|
id="max_options_shown"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue