mirror of
https://github.com/stashapp/stash.git
synced 2025-12-11 04:43:03 -06:00
PatchComponentRedo (#5136)
* PatchComponent update specifically for SettingsInterfacePanel * Fix unrelated lint issues --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
parent
49060e6686
commit
7788a6fd07
@ -192,7 +192,7 @@ func (me *contentDirectoryService) Handle(action string, argsXML []byte, r *http
|
||||
|
||||
obj, err := me.objectFromID(browse.ObjectID)
|
||||
if err != nil {
|
||||
return nil, upnp.Errorf(upnpav.NoSuchObjectErrorCode, err.Error())
|
||||
return nil, upnp.Errorf(upnpav.NoSuchObjectErrorCode, "cannot find object with id %q: %v", browse.ObjectID, err.Error())
|
||||
}
|
||||
|
||||
switch browse.BrowseFlag {
|
||||
|
||||
@ -76,7 +76,7 @@ func (t *rawPluginTask) Start() error {
|
||||
if err != nil {
|
||||
logger.Warnf("error marshalling raw command input")
|
||||
}
|
||||
if k, err := io.WriteString(stdin, string(inBytes)); err != nil {
|
||||
if k, err := stdin.Write(inBytes); err != nil {
|
||||
logger.Warnf("error writing input to plugins stdin (wrote %v bytes out of %v): %v", k, len(string(inBytes)), err)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -1338,7 +1338,7 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{
|
||||
return fmt.Errorf("failed to decode data %s: %w", string(responseBytes), err)
|
||||
}
|
||||
|
||||
if respGQL.Errors != nil && len(respGQL.Errors) > 0 {
|
||||
if len(respGQL.Errors) > 0 {
|
||||
// try to parse standard graphql error
|
||||
errors := &client.GqlErrorList{}
|
||||
if e := json.Unmarshal(responseBytes, errors); e != nil {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import React from "react";
|
||||
import { BooleanSetting } from "../Inputs";
|
||||
import { PatchComponent } from "src/patch";
|
||||
|
||||
interface IItem {
|
||||
id: string;
|
||||
@ -13,49 +14,47 @@ interface ICheckboxGroupProps {
|
||||
onChange?: (ids: string[]) => void;
|
||||
}
|
||||
|
||||
export const CheckboxGroup: React.FC<ICheckboxGroupProps> = ({
|
||||
groupId,
|
||||
items,
|
||||
checkedIds = [],
|
||||
onChange,
|
||||
}) => {
|
||||
function generateId(itemId: string) {
|
||||
return `${groupId}-${itemId}`;
|
||||
}
|
||||
export const CheckboxGroup: React.FC<ICheckboxGroupProps> = PatchComponent(
|
||||
"CheckboxGroup",
|
||||
({ groupId, items, checkedIds = [], onChange }) => {
|
||||
function generateId(itemId: string) {
|
||||
return `${groupId}-${itemId}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{items.map(({ id, headingID }) => (
|
||||
<BooleanSetting
|
||||
key={id}
|
||||
id={generateId(id)}
|
||||
headingID={headingID}
|
||||
checked={checkedIds.includes(id)}
|
||||
onChange={(v) => {
|
||||
if (v) {
|
||||
onChange?.(
|
||||
items
|
||||
.map((item) => item.id)
|
||||
.filter(
|
||||
(itemId) =>
|
||||
generateId(itemId) === generateId(id) ||
|
||||
checkedIds.includes(itemId)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
onChange?.(
|
||||
items
|
||||
.map((item) => item.id)
|
||||
.filter(
|
||||
(itemId) =>
|
||||
generateId(itemId) !== generateId(id) &&
|
||||
checkedIds.includes(itemId)
|
||||
)
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
{items.map(({ id, headingID }) => (
|
||||
<BooleanSetting
|
||||
key={id}
|
||||
id={generateId(id)}
|
||||
headingID={headingID}
|
||||
checked={checkedIds.includes(id)}
|
||||
onChange={(v) => {
|
||||
if (v) {
|
||||
onChange?.(
|
||||
items
|
||||
.map((item) => item.id)
|
||||
.filter(
|
||||
(itemId) =>
|
||||
generateId(itemId) === generateId(id) ||
|
||||
checkedIds.includes(itemId)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
onChange?.(
|
||||
items
|
||||
.map((item) => item.id)
|
||||
.filter(
|
||||
(itemId) =>
|
||||
generateId(itemId) !== generateId(id) &&
|
||||
checkedIds.includes(itemId)
|
||||
)
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user