Skip to content

Commit

Permalink
fix: support command panel only in design mode (#4624)
Browse files Browse the repository at this point in the history
We do not want users to mess with command panel in content or design
mode.
  • Loading branch information
TrySound authored Dec 23, 2024
1 parent fb67334 commit e3baeec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 10 additions & 6 deletions apps/builder/app/builder/features/topbar/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
$authPermit,
$authToken,
$authTokenPermissions,
$isDesignMode,
$userPlanFeatures,
} from "~/shared/nano-states";
import { emitCommand } from "~/builder/shared/commands";
Expand Down Expand Up @@ -60,6 +61,7 @@ export const Menu = () => {
const authPermit = useStore($authPermit);
const authTokenPermission = useStore($authTokenPermissions);
const authToken = useStore($authToken);
const isDesignMode = useStore($isDesignMode);

const isPublishEnabled = authPermit === "own" || authPermit === "admin";

Expand Down Expand Up @@ -240,12 +242,14 @@ export const Menu = () => {

<DropdownMenuSeparator />

<DropdownMenuItem onSelect={() => emitCommand("openCommandPanel")}>
Search & Commands
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "k"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>
{isDesignMode && (
<DropdownMenuItem onSelect={() => emitCommand("openCommandPanel")}>
Search & Commands
<DropdownMenuItemRightSlot>
<Kbd value={["cmd", "k"]} />
</DropdownMenuItemRightSlot>
</DropdownMenuItem>
)}

<DropdownMenuItem
onSelect={() => {
Expand Down
4 changes: 3 additions & 1 deletion apps/builder/app/builder/shared/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
hidden: true,
defaultHotkeys: ["meta+k", "ctrl+k"],
handler: () => {
openCommandPanel();
if ($isDesignMode.get()) {
openCommandPanel();
}
},
},
],
Expand Down

0 comments on commit e3baeec

Please sign in to comment.