Skip to content

Commit f52c88f

Browse files
committed
app,frontend: Allow to open the plugin folder
From the PluginSettingsDetails.
1 parent feb7ee6 commit f52c88f

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

app/electron/main.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,31 @@ function startElecron() {
14981498

14991499
new PluginManagerEventListeners().setupEventHandlers();
15001500

1501+
// Handle opening plugin folder in file explorer
1502+
ipcMain.on(
1503+
'open-plugin-folder',
1504+
(
1505+
event: IpcMainEvent,
1506+
pluginInfo: { folderName: string; type: 'development' | 'user' | 'shipped' }
1507+
) => {
1508+
let folderPath: string | null = null;
1509+
1510+
if (pluginInfo.type === 'user') {
1511+
folderPath = path.join(defaultUserPluginsDir(), pluginInfo.folderName);
1512+
} else if (pluginInfo.type === 'development') {
1513+
folderPath = path.join(defaultPluginsDir(), pluginInfo.folderName);
1514+
} else if (pluginInfo.type === 'shipped') {
1515+
folderPath = path.join(process.resourcesPath, '.plugins', pluginInfo.folderName);
1516+
}
1517+
1518+
if (folderPath) {
1519+
shell.openPath(folderPath).catch((err: Error) => {
1520+
console.error('Failed to open plugin folder:', err);
1521+
});
1522+
}
1523+
}
1524+
);
1525+
15011526
// Also add bundled plugin bin directories to PATH
15021527
const bundledPlugins = path.join(process.resourcesPath, '.plugins');
15031528
const bundledPluginBinDirs = getPluginBinDirectories(bundledPlugins);

app/electron/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ contextBridge.exposeInMainWorld('desktopApi', {
3030
'plugin-manager',
3131
'request-backend-token',
3232
'request-plugin-permission-secrets',
33+
'open-plugin-folder',
3334
];
3435
if (validChannels.includes(channel)) {
3536
ipcRenderer.send(channel, data);

frontend/src/components/App/PluginSettings/PluginSettingsDetails.tsx

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@ import { ConfirmDialog } from '../../common/Dialog';
3939
import ErrorBoundary from '../../common/ErrorBoundary';
4040
import { SectionBox } from '../../common/SectionBox';
4141

42+
// Helper function to open plugin folder in file explorer (Electron only)
43+
function openPluginFolder(plugin: PluginInfo) {
44+
if (!isElectron()) {
45+
return;
46+
}
47+
48+
const folderName = plugin.folderName || plugin.name.split('/').pop();
49+
if (!folderName || !plugin.type) {
50+
return;
51+
}
52+
53+
const { desktopApi } = window as any;
54+
if (desktopApi?.send) {
55+
desktopApi.send('open-plugin-folder', {
56+
folderName,
57+
type: plugin.type,
58+
});
59+
}
60+
}
61+
62+
// Helper to check if we can open the plugin folder
63+
function canOpenPluginFolder(plugin: PluginInfo): boolean {
64+
if (!isElectron()) {
65+
return false;
66+
}
67+
68+
const folderName = plugin.folderName || plugin.name.split('/').pop();
69+
return !!(folderName && plugin.type);
70+
}
71+
4272
const PluginSettingsDetailsInitializer = (props: { plugin: PluginInfo }) => {
4373
const { plugin } = props;
4474
const { t } = useTranslation(['translation']);
@@ -243,14 +273,27 @@ export function PluginSettingsDetailsPure(props: PluginSettingsDetailsPureProps)
243273
),
244274
]}
245275
actions={
246-
isElectron() && plugin.type !== 'shipped'
276+
isElectron()
247277
? [
248-
<ActionButton
249-
description={t('translation|Delete Plugin')}
250-
icon="mdi:delete"
251-
onClick={handleDelete}
252-
color="error"
253-
/>,
278+
...(canOpenPluginFolder(plugin)
279+
? [
280+
<ActionButton
281+
description={t('translation|Open Plugin Folder')}
282+
icon="mdi:folder-open"
283+
onClick={() => openPluginFolder(plugin)}
284+
/>,
285+
]
286+
: []),
287+
...(plugin.type !== 'shipped'
288+
? [
289+
<ActionButton
290+
description={t('translation|Delete Plugin')}
291+
icon="mdi:delete"
292+
onClick={handleDelete}
293+
color="error"
294+
/>,
295+
]
296+
: []),
254297
]
255298
: []
256299
}

0 commit comments

Comments
 (0)