From 35e34b36f981ac71523cdb75f33fef45529eb067 Mon Sep 17 00:00:00 2001
From: Alexander Medvedev
Date: Mon, 31 Aug 2026 21:23:46 +0200
Subject: [PATCH] fix: commands sidebar
---
package.json | 1 -
src/pages/PluginDetail.tsx | 315 ++++++++++----------
src/pages/dashboard/plugin/AddPlugin.tsx | 11 +-
src/pages/dashboard/plugin/StoreListing.tsx | 13 +-
4 files changed, 174 insertions(+), 166 deletions(-)
diff --git a/package.json b/package.json
index b9a25e4..d449b0f 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,6 @@
"i18next": "^26.4.0",
"i18next-browser-languagedetector": "^8.2.1",
"lucide-react": "^1.37.0",
- "or": "^0.2.0",
"qrcode.react": "^4.2.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
diff --git a/src/pages/PluginDetail.tsx b/src/pages/PluginDetail.tsx
index f052a71..b94d0e2 100644
--- a/src/pages/PluginDetail.tsx
+++ b/src/pages/PluginDetail.tsx
@@ -202,173 +202,176 @@ const PluginCommandsSidebarWidget = ({ commands }: { commands?: PluginCommand[]
const visibleCommands = expanded ? commands : commands.slice(0, 4);
return (
-
-
-
-
- {t('plugin.commands.title', 'Commands & Permissions')}
-
-
- {commands.length}
-
-
+ <>
+
+
+
+
+
+ {t('plugin.commands.title', 'Commands & Permissions')}
+
+
+ {commands.length}
+
+
-
- {visibleCommands.map((cmd: any, index: number) => {
- const desc = getLocalizedCommandDescription(cmd.description, activeLang);
- const cmdCopyKey = `cmd-${cmd.id || index}`;
- const permCopyKey = `perm-${cmd.id || index}`;
- const formattedName = cmd.name?.startsWith('/') ? cmd.name : `/${cmd.name}`;
+
+ {visibleCommands.map((cmd: any, index: number) => {
+ const desc = getLocalizedCommandDescription(cmd.description, activeLang);
+ const cmdCopyKey = `cmd-${cmd.id || index}`;
+ const permCopyKey = `perm-${cmd.id || index}`;
+ const formattedName = cmd.name?.startsWith('/') ? cmd.name : `/${cmd.name}`;
- return (
-
- {/* Command row */}
-
-
- {formattedName}
-
-
-
-
- {/* Permission row */}
- {cmd.permission ? (
+ return (
+
+ {/* Command row */}
-
-
-
- {cmd.permission}
-
-
+
+ {formattedName}
+
- ) : null}
- {/* Description */}
- {desc ? (
-
- {desc}
-
- ) : null}
-
- );
- })}
+ {/* Permission row */}
+ {cmd.permission ? (
+
+
+
+
+ {cmd.permission}
+
+
+
+
+ ) : null}
+
+ {/* Description */}
+ {desc ? (
+
+ {desc}
+
+ ) : null}
+
+ );
+ })}
+
+
+ {commands.length > 4 && (
+
+ )}
-
- {commands.length > 4 && (
-
- )}
-
+ >
);
};
@@ -1503,8 +1506,11 @@ const PluginDetail = () => {
)}
)}
+
-
+
+
+ {(user || reportDone) && }
{user && !reportDone && (
<>
{!reportOpen ? (
@@ -1562,9 +1568,6 @@ const PluginDetail = () => {
)}
-
-
-
diff --git a/src/pages/dashboard/plugin/AddPlugin.tsx b/src/pages/dashboard/plugin/AddPlugin.tsx
index 421665d..a557dc0 100644
--- a/src/pages/dashboard/plugin/AddPlugin.tsx
+++ b/src/pages/dashboard/plugin/AddPlugin.tsx
@@ -252,9 +252,10 @@ const AddPlugin = () => {
};
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
+ const cleanValue = field === 'name' ? value.replace(/^\/+/, '') : value;
setCommands(prev => {
const next = [...prev];
- next[index] = { ...next[index], [field]: value };
+ next[index] = { ...next[index], [field]: cleanValue };
return next;
});
};
@@ -460,9 +461,9 @@ const AddPlugin = () => {
setSubmitting(true);
try {
const validCommands = commands
- .filter(c => c.name.trim().length > 0)
+ .filter(c => c.name.trim().replace(/^\/+/, '').length > 0)
.map((c, idx) => ({
- name: c.name.trim(),
+ name: c.name.trim().replace(/^\/+/, ''),
permission: c.permission.trim() || undefined,
description: c.descriptions,
display_order: idx,
@@ -864,8 +865,9 @@ const AddPlugin = () => {
updateCommandField(idx, 'name', e.target.value)}
required
/>
@@ -879,6 +881,7 @@ const AddPlugin = () => {
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
placeholder="pumpkin.command.spawn"
value={cmd.permission}
+ maxLength={128}
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
/>
diff --git a/src/pages/dashboard/plugin/StoreListing.tsx b/src/pages/dashboard/plugin/StoreListing.tsx
index 2094314..0e44693 100644
--- a/src/pages/dashboard/plugin/StoreListing.tsx
+++ b/src/pages/dashboard/plugin/StoreListing.tsx
@@ -234,7 +234,7 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
}
return {
id: cmd.id,
- name: cmd.name || '',
+ name: (cmd.name || '').replace(/^\/+/, ''),
permission: cmd.permission || '',
descriptions: descMap,
};
@@ -253,9 +253,10 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
};
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
+ const cleanValue = field === 'name' ? value.replace(/^\/+/, '') : value;
setCommands(prev => {
const next = [...prev];
- next[index] = { ...next[index], [field]: value };
+ next[index] = { ...next[index], [field]: cleanValue };
return next;
});
};
@@ -311,10 +312,10 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
setSaveError(null);
setSaveSuccess(false);
const validCommands = commands
- .filter(c => c.name.trim().length > 0)
+ .filter(c => c.name.trim().replace(/^\/+/, '').length > 0)
.map((c, idx) => ({
id: c.id,
- name: c.name.trim(),
+ name: c.name.trim().replace(/^\/+/, ''),
permission: c.permission.trim() || undefined,
description: c.descriptions,
display_order: idx,
@@ -685,8 +686,9 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
updateCommandField(idx, 'name', e.target.value)}
required
/>
@@ -700,6 +702,7 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
placeholder="pumpkin.command.spawn"
value={cmd.permission}
+ maxLength={128}
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
/>