Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -1,8 +1,27 @@
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { Avatar, Badge, Box, Button, color, config, Header, IconButton, Input, Menu, MenuItem, PopOut, RectCords, Scroll, Spinner, Switch, Text, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Spinner,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { HexColorPicker } from 'react-colorful';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { PluginTab, PluginMetadata, InstalledPlugin } from './types';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
@@ -22,7 +41,9 @@ function PluginSettingsRenderer({ pluginId }: { pluginId: string }) {
|
||||
if (!schema || Object.keys(schema).length === 0) {
|
||||
return (
|
||||
<Box padding="300">
|
||||
<Text size="T300" priority="300">No settings available for this plugin.</Text>
|
||||
<Text size="T300" priority="300">
|
||||
No settings available for this plugin.
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -65,7 +86,7 @@ function SettingRenderer({
|
||||
const [selectMenuCords, setSelectMenuCords] = useState<RectCords>();
|
||||
|
||||
const label = definition.label || settingKey;
|
||||
const description = definition.description;
|
||||
const { description } = definition;
|
||||
|
||||
// Boolean - Switch
|
||||
if (definition.type === 'boolean') {
|
||||
@@ -111,7 +132,7 @@ function SettingRenderer({
|
||||
// Select - Dropdown
|
||||
if (definition.type === 'select' && definition.options) {
|
||||
const currentValue = value ?? definition.default ?? definition.options[0]?.value;
|
||||
const selectedOption = definition.options.find(opt => opt.value === currentValue);
|
||||
const selectedOption = definition.options.find((opt) => opt.value === currentValue);
|
||||
|
||||
return (
|
||||
<SettingTile title={label} description={description}>
|
||||
@@ -145,7 +166,11 @@ function SettingRenderer({
|
||||
<MenuItem
|
||||
key={option.value}
|
||||
size="300"
|
||||
after={currentValue === option.value ? <Icon size="100" src={Icons.Check} /> : undefined}
|
||||
after={
|
||||
currentValue === option.value ? (
|
||||
<Icon size="100" src={Icons.Check} />
|
||||
) : undefined
|
||||
}
|
||||
radii="300"
|
||||
onClick={() => {
|
||||
onChange(option.value);
|
||||
@@ -277,7 +302,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[refreshInstalledPlugins]
|
||||
[refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const handleUninstall = useCallback(
|
||||
@@ -291,7 +316,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to uninstall plugin');
|
||||
}
|
||||
},
|
||||
[refreshInstalledPlugins]
|
||||
[refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const handleToggleEnabled = useCallback(
|
||||
@@ -313,15 +338,15 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to update plugin state');
|
||||
}
|
||||
},
|
||||
[installedPlugins, refreshInstalledPlugins]
|
||||
[installedPlugins, refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const isPluginInstalled = useCallback(
|
||||
(pluginId: string) => installedPlugins.some((p) => p.id === pluginId),
|
||||
[installedPlugins]
|
||||
[installedPlugins],
|
||||
);
|
||||
|
||||
const PluginAvatar = ({ thumbnail, name }: { thumbnail: string; name: string }) => {
|
||||
function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) {
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -356,7 +381,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
)}
|
||||
</Avatar>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const filteredMarketplacePlugins = useMemo(() => {
|
||||
if (!searchQuery.trim()) return marketplacePlugins;
|
||||
@@ -468,7 +493,9 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
{!loading && !error && filteredMarketplacePlugins.length === 0 && (
|
||||
<Box justifyContent="Center" style={{ padding: toRem(32) }}>
|
||||
<Text size="T400" priority="300">
|
||||
{searchQuery ? 'No plugins found matching your search' : 'No plugins available'}
|
||||
{searchQuery
|
||||
? 'No plugins found matching your search'
|
||||
: 'No plugins available'}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
@@ -504,7 +531,9 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">•</Text>
|
||||
<Text size="T200" priority="400">
|
||||
•
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
@@ -545,112 +574,127 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
{filteredInstalledPlugins.length === 0 && (
|
||||
<Box justifyContent="Center" style={{ padding: toRem(32) }}>
|
||||
<Text size="T400" priority="300">
|
||||
{searchQuery ? 'No installed plugins found matching your search' : 'No plugins installed'}
|
||||
{searchQuery
|
||||
? 'No installed plugins found matching your search'
|
||||
: 'No plugins installed'}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{filteredInstalledPlugins.map((plugin) => {
|
||||
const hasSettings = pluginRegistry.getPluginSettingsSchema(plugin.id) &&
|
||||
const hasSettings =
|
||||
pluginRegistry.getPluginSettingsSchema(plugin.id) &&
|
||||
Object.keys(pluginRegistry.getPluginSettingsSchema(plugin.id)!).length > 0;
|
||||
const settingsExpanded = expandedSettings === plugin.id;
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={plugin.id}
|
||||
direction="Column"
|
||||
style={{
|
||||
background: color.Surface.Container,
|
||||
borderRadius: config.radii.R400,
|
||||
border: `1px solid ${color.Surface.ContainerLine}`,
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
key={plugin.id}
|
||||
direction="Column"
|
||||
style={{
|
||||
padding: config.space.S500,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(-2px)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = '0 4px 12px rgba(0,0,0,0.1)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(0)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = 'none';
|
||||
background: color.Surface.Container,
|
||||
borderRadius: config.radii.R400,
|
||||
border: `1px solid ${color.Surface.ContainerLine}`,
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<Box gap="500" alignItems="Start">
|
||||
<Box shrink="No">
|
||||
<PluginAvatar thumbnail={plugin.thumbnail} name={plugin.name} />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="200">
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="H5">{plugin.name}</Text>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">•</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Text size="T300" priority="300">
|
||||
{plugin.description}
|
||||
</Text>
|
||||
<Box gap="100" wrap="Wrap">
|
||||
<Badge
|
||||
size="300"
|
||||
variant={plugin.enabled ? 'Success' : 'Secondary'}
|
||||
fill="Soft"
|
||||
>
|
||||
<Text size="L400">{plugin.enabled ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Badge>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="200">
|
||||
{hasSettings && (
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="400"
|
||||
before={<Icon size="200" src={Icons.Setting} />}
|
||||
after={<Icon size="200" src={settingsExpanded ? Icons.ChevronTop : Icons.ChevronBottom} />}
|
||||
onClick={() => setExpandedSettings(settingsExpanded ? null : plugin.id)}
|
||||
>
|
||||
<Text size="B400">Settings</Text>
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="Secondary"
|
||||
size="400"
|
||||
onClick={() => handleToggleEnabled(plugin.id)}
|
||||
>
|
||||
<Text size="B400">{plugin.enabled ? 'Disable' : 'Enable'}</Text>
|
||||
</Button>
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
size="400"
|
||||
onClick={() => handleUninstall(plugin.id)}
|
||||
>
|
||||
<Text size="B400">Uninstall</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
{hasSettings && settingsExpanded && (
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{
|
||||
borderTop: `1px solid ${color.Surface.ContainerLine}`,
|
||||
background: color.Surface.ContainerLowest,
|
||||
padding: config.space.S500,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(-2px)';
|
||||
e.currentTarget.parentElement!.style.boxShadow =
|
||||
'0 4px 12px rgba(0,0,0,0.1)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(0)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = 'none';
|
||||
}}
|
||||
>
|
||||
<PluginSettingsRenderer pluginId={plugin.id} />
|
||||
<Box gap="500" alignItems="Start">
|
||||
<Box shrink="No">
|
||||
<PluginAvatar thumbnail={plugin.thumbnail} name={plugin.name} />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="200">
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="H5">{plugin.name}</Text>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
•
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Text size="T300" priority="300">
|
||||
{plugin.description}
|
||||
</Text>
|
||||
<Box gap="100" wrap="Wrap">
|
||||
<Badge
|
||||
size="300"
|
||||
variant={plugin.enabled ? 'Success' : 'Secondary'}
|
||||
fill="Soft"
|
||||
>
|
||||
<Text size="L400">{plugin.enabled ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Badge>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="200">
|
||||
{hasSettings && (
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="400"
|
||||
before={<Icon size="200" src={Icons.Setting} />}
|
||||
after={
|
||||
<Icon
|
||||
size="200"
|
||||
src={
|
||||
settingsExpanded ? Icons.ChevronTop : Icons.ChevronBottom
|
||||
}
|
||||
/>
|
||||
}
|
||||
onClick={() =>
|
||||
setExpandedSettings(settingsExpanded ? null : plugin.id)
|
||||
}
|
||||
>
|
||||
<Text size="B400">Settings</Text>
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="Secondary"
|
||||
size="400"
|
||||
onClick={() => handleToggleEnabled(plugin.id)}
|
||||
>
|
||||
<Text size="B400">{plugin.enabled ? 'Disable' : 'Enable'}</Text>
|
||||
</Button>
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
size="400"
|
||||
onClick={() => handleUninstall(plugin.id)}
|
||||
>
|
||||
<Text size="B400">Uninstall</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
{hasSettings && settingsExpanded && (
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{
|
||||
borderTop: `1px solid ${color.Surface.ContainerLine}`,
|
||||
background: color.Surface.ContainerLowest,
|
||||
}}
|
||||
>
|
||||
<PluginSettingsRenderer pluginId={plugin.id} />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user