Rewrite the restricted iterators and reorder the forward references. [skip build]
This commit is contained in:
@@ -31,43 +31,6 @@ import { pluginMarketplaceManager, pluginRegistry, SettingDefinition } from './P
|
||||
import { stopPropagation } from '../../../utils/keyboard';
|
||||
import { fuzzyFilter } from '../../../utils/fuzzy';
|
||||
|
||||
/**
|
||||
* Renders settings UI for a plugin based on its settings schema
|
||||
*/
|
||||
function PluginSettingsRenderer({ pluginId }: { pluginId: string }) {
|
||||
const schema = pluginRegistry.getPluginSettingsSchema(pluginId);
|
||||
const [, forceUpdate] = useState({});
|
||||
|
||||
if (!schema || Object.keys(schema).length === 0) {
|
||||
return (
|
||||
<Box padding="300">
|
||||
<Text size="T300" priority="300">
|
||||
No settings available for this plugin.
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const handleChange = (key: string, value: any) => {
|
||||
pluginRegistry.setPluginSetting(pluginId, key, value);
|
||||
forceUpdate({});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="300" style={{ padding: config.space.S400 }}>
|
||||
{Object.entries(schema).map(([key, def]) => (
|
||||
<SettingRenderer
|
||||
key={key}
|
||||
settingKey={key}
|
||||
definition={def}
|
||||
value={pluginRegistry.getPluginSetting(pluginId, key)}
|
||||
onChange={(value) => handleChange(key, value)}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a single setting based on its type
|
||||
*/
|
||||
@@ -242,6 +205,43 @@ function SettingRenderer({
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders settings UI for a plugin based on its settings schema
|
||||
*/
|
||||
function PluginSettingsRenderer({ pluginId }: { pluginId: string }) {
|
||||
const schema = pluginRegistry.getPluginSettingsSchema(pluginId);
|
||||
const [, forceUpdate] = useState({});
|
||||
|
||||
if (!schema || Object.keys(schema).length === 0) {
|
||||
return (
|
||||
<Box padding="300">
|
||||
<Text size="T300" priority="300">
|
||||
No settings available for this plugin.
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const handleChange = (key: string, value: any) => {
|
||||
pluginRegistry.setPluginSetting(pluginId, key, value);
|
||||
forceUpdate({});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="300" style={{ padding: config.space.S400 }}>
|
||||
{Object.entries(schema).map(([key, def]) => (
|
||||
<SettingRenderer
|
||||
key={key}
|
||||
settingKey={key}
|
||||
definition={def}
|
||||
value={pluginRegistry.getPluginSetting(pluginId, key)}
|
||||
onChange={(value) => handleChange(key, value)}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) {
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user