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

Plugin api improvements #4935

Merged

Conversation

WithoutPants
Copy link
Collaborator

@WithoutPants WithoutPants commented Jun 6, 2024

Related #4510
Resolves #4880
Obsoletes #4928 with a plugin.

Makes the App container component patchable.
Makes the settings components patchable and usable in plugins.
Makes the PerformerDetailsPanel, CompressedPerformerDetailsPanel components patchable, and adds a new patchable component PerformerDetailsPanel.DetailGroup.

Adds a PluginSettings component that can be hooked with patch.after to replace with a custom set of settings:

(function() {
    const PluginApi = window.PluginApi;
    const React = PluginApi.React;
    const { useSettings } = PluginApi.hooks;

    function pluginSettingsHook (props, _, result) {
        const { StringListSetting } = PluginApi.components;
        const { pluginID } = props;
        const { plugins, savePluginSettings } = useSettings();
        const pluginSettings = plugins[pluginID] ?? {};

        if (props.pluginID === "settingTest") {
            return React.createElement("div", null, [
                React.createElement(StringListSetting, {
                    heading: "String List Example",
                    value: pluginSettings.testSetting ?? [],
                    onChange: (value) => savePluginSettings(pluginID, { ...pluginSettings, testSetting: value }),
                }),
            ]);
        }
        
        return result;
    }
    PluginApi.patch.after('PluginSettings', pluginSettingsHook);
})();

@WithoutPants WithoutPants added the improvement Something needed tweaking. label Jun 6, 2024
@WithoutPants WithoutPants added this to the Version 0.27.0 milestone Jun 6, 2024
@WithoutPants WithoutPants force-pushed the plugin-api-improvements-20240606 branch from 8019b9f to b1121dd Compare June 6, 2024 04:41
@WithoutPants WithoutPants merged commit 845d718 into stashapp:develop Jun 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something needed tweaking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add PerformerDetailsPanel to PluginAPI.components
1 participant