Implement "secret" toggle for plugin config fields

This commit is contained in:
grimsi
2025-03-28 21:32:41 +01:00
parent 80bb4cefef
commit 3ae4ecb1ac
4 changed files with 8 additions and 6 deletions
@@ -70,8 +70,9 @@ export default function PluginDetailsModal({plugin, isOpen, onOpenChange, update
<h4 className="text-l font-bold mt-6">Configuration</h4>
{(pluginConfigMeta && pluginConfigMeta.length > 0) ?
pluginConfigMeta.map((entry: any) => (
<Input key={entry.key} name={entry.key} label={entry.name} type="text"/>
pluginConfigMeta.map((entry: PluginConfigElement) => (
<Input key={entry.key} name={entry.key} label={entry.name}
type={entry.secret ? "password" : "text"}/>
)) : "This plugin has no configuration options."
}
</ModalBody>
@@ -68,12 +68,12 @@ export function PluginManagementCard({plugin, updatePlugin}: {
<div className="absolute right-0 top-0 flex flex-row">
<Tooltip content={`${isDisabled(plugin.state) ? "Enable" : "Disable"} plugin`} placement="bottom"
color="foreground">
<Button isIconOnly variant="ghost" onPress={() => togglePluginEnabled()}>
<Button isIconOnly variant="light" onPress={() => togglePluginEnabled()}>
<Power/>
</Button>
</Tooltip>
<Tooltip content="Configuration" placement="bottom" color="foreground">
<Button isIconOnly variant="ghost" onPress={pluginDetailsModal.onOpen}>
<Button isIconOnly variant="light" onPress={pluginDetailsModal.onOpen}>
<SlidersHorizontal/>
</Button>
</Tooltip>
@@ -3,5 +3,6 @@ package de.grimsi.gameyfin.pluginapi.core
data class PluginConfigElement(
val key: String,
val name: String,
val description: String
val description: String,
val isSecret: Boolean = false
)
@@ -18,7 +18,7 @@ class IgdbPlugin(wrapper: PluginWrapper) : GameyfinPlugin(wrapper) {
override val configMetadata: List<PluginConfigElement> = listOf(
PluginConfigElement("clientId", "Twitch client ID", "Your Twitch Client ID"),
PluginConfigElement("clientSecret", "Twitch client secret", "Your Twitch Client Secret")
PluginConfigElement("clientSecret", "Twitch client secret", "Your Twitch Client Secret", true)
)
override fun validateConfig(config: Map<String, String?>): Boolean {