fix: commands sidebar
This commit is contained in:
parent
21f54d9274
commit
35e34b36f9
@ -26,7 +26,6 @@
|
|||||||
"i18next": "^26.4.0",
|
"i18next": "^26.4.0",
|
||||||
"i18next-browser-languagedetector": "^8.2.1",
|
"i18next-browser-languagedetector": "^8.2.1",
|
||||||
"lucide-react": "^1.37.0",
|
"lucide-react": "^1.37.0",
|
||||||
"or": "^0.2.0",
|
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
"react": "^19.2.8",
|
"react": "^19.2.8",
|
||||||
"react-dom": "^19.2.8",
|
"react-dom": "^19.2.8",
|
||||||
|
|||||||
@ -202,7 +202,9 @@ const PluginCommandsSidebarWidget = ({ commands }: { commands?: PluginCommand[]
|
|||||||
const visibleCommands = expanded ? commands : commands.slice(0, 4);
|
const visibleCommands = expanded ? commands : commands.slice(0, 4);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sidebar-widget commands-widget" style={{ marginTop: '1.25rem', position: 'static' }}>
|
<>
|
||||||
|
<div className="divider-sm" />
|
||||||
|
<div className="commands-widget-section">
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '0.85rem' }}>
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '0.85rem' }}>
|
||||||
<h3 style={{ margin: 0, display: 'flex', alignItems: 'center', gap: '0.45rem', fontSize: '0.82rem' }}>
|
<h3 style={{ margin: 0, display: 'flex', alignItems: 'center', gap: '0.45rem', fontSize: '0.82rem' }}>
|
||||||
<Terminal size={14} color="var(--primary)" />
|
<Terminal size={14} color="var(--primary)" />
|
||||||
@ -369,6 +371,7 @@ const PluginCommandsSidebarWidget = ({ commands }: { commands?: PluginCommand[]
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1503,8 +1506,11 @@ const PluginDetail = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="divider-sm" />
|
<PluginCommandsSidebarWidget commands={plugin.commands} />
|
||||||
|
|
||||||
|
{(user || reportDone) && <div className="divider-sm" />}
|
||||||
{user && !reportDone && (
|
{user && !reportDone && (
|
||||||
<>
|
<>
|
||||||
{!reportOpen ? (
|
{!reportOpen ? (
|
||||||
@ -1562,9 +1568,6 @@ const PluginDetail = () => {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<PluginCommandsSidebarWidget commands={plugin.commands} />
|
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -252,9 +252,10 @@ const AddPlugin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
|
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
|
||||||
|
const cleanValue = field === 'name' ? value.replace(/^\/+/, '') : value;
|
||||||
setCommands(prev => {
|
setCommands(prev => {
|
||||||
const next = [...prev];
|
const next = [...prev];
|
||||||
next[index] = { ...next[index], [field]: value };
|
next[index] = { ...next[index], [field]: cleanValue };
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -460,9 +461,9 @@ const AddPlugin = () => {
|
|||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const validCommands = commands
|
const validCommands = commands
|
||||||
.filter(c => c.name.trim().length > 0)
|
.filter(c => c.name.trim().replace(/^\/+/, '').length > 0)
|
||||||
.map((c, idx) => ({
|
.map((c, idx) => ({
|
||||||
name: c.name.trim(),
|
name: c.name.trim().replace(/^\/+/, ''),
|
||||||
permission: c.permission.trim() || undefined,
|
permission: c.permission.trim() || undefined,
|
||||||
description: c.descriptions,
|
description: c.descriptions,
|
||||||
display_order: idx,
|
display_order: idx,
|
||||||
@ -864,8 +865,9 @@ const AddPlugin = () => {
|
|||||||
<input
|
<input
|
||||||
className="mp-input"
|
className="mp-input"
|
||||||
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
||||||
placeholder="/spawn [player]"
|
placeholder="spawn [player]"
|
||||||
value={cmd.name}
|
value={cmd.name}
|
||||||
|
maxLength={64}
|
||||||
onChange={e => updateCommandField(idx, 'name', e.target.value)}
|
onChange={e => updateCommandField(idx, 'name', e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
@ -879,6 +881,7 @@ const AddPlugin = () => {
|
|||||||
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
||||||
placeholder="pumpkin.command.spawn"
|
placeholder="pumpkin.command.spawn"
|
||||||
value={cmd.permission}
|
value={cmd.permission}
|
||||||
|
maxLength={128}
|
||||||
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
|
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -234,7 +234,7 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: cmd.id,
|
id: cmd.id,
|
||||||
name: cmd.name || '',
|
name: (cmd.name || '').replace(/^\/+/, ''),
|
||||||
permission: cmd.permission || '',
|
permission: cmd.permission || '',
|
||||||
descriptions: descMap,
|
descriptions: descMap,
|
||||||
};
|
};
|
||||||
@ -253,9 +253,10 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
|
const updateCommandField = (index: number, field: 'name' | 'permission', value: string) => {
|
||||||
|
const cleanValue = field === 'name' ? value.replace(/^\/+/, '') : value;
|
||||||
setCommands(prev => {
|
setCommands(prev => {
|
||||||
const next = [...prev];
|
const next = [...prev];
|
||||||
next[index] = { ...next[index], [field]: value };
|
next[index] = { ...next[index], [field]: cleanValue };
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -311,10 +312,10 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
setSaveError(null);
|
setSaveError(null);
|
||||||
setSaveSuccess(false);
|
setSaveSuccess(false);
|
||||||
const validCommands = commands
|
const validCommands = commands
|
||||||
.filter(c => c.name.trim().length > 0)
|
.filter(c => c.name.trim().replace(/^\/+/, '').length > 0)
|
||||||
.map((c, idx) => ({
|
.map((c, idx) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name.trim(),
|
name: c.name.trim().replace(/^\/+/, ''),
|
||||||
permission: c.permission.trim() || undefined,
|
permission: c.permission.trim() || undefined,
|
||||||
description: c.descriptions,
|
description: c.descriptions,
|
||||||
display_order: idx,
|
display_order: idx,
|
||||||
@ -685,8 +686,9 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
<input
|
<input
|
||||||
className="mp-input"
|
className="mp-input"
|
||||||
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
||||||
placeholder="/spawn [player]"
|
placeholder="spawn [player]"
|
||||||
value={cmd.name}
|
value={cmd.name}
|
||||||
|
maxLength={64}
|
||||||
onChange={e => updateCommandField(idx, 'name', e.target.value)}
|
onChange={e => updateCommandField(idx, 'name', e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
@ -700,6 +702,7 @@ const StoreListing = ({ plugin, onSaved }: Props) => {
|
|||||||
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
style={{ fontFamily: 'var(--font-mono)', fontSize: '0.82rem', padding: '0.45rem 0.65rem' }}
|
||||||
placeholder="pumpkin.command.spawn"
|
placeholder="pumpkin.command.spawn"
|
||||||
value={cmd.permission}
|
value={cmd.permission}
|
||||||
|
maxLength={128}
|
||||||
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
|
onChange={e => updateCommandField(idx, 'permission', e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user