Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

feat: Add export dialog to the menu, add shortcuts shift+P and shift+E (#4612)

Oleg Isonen7a1daca08985
diff --git a/apps/builder/app/builder/features/topbar/menu/menu.tsx b/apps/builder/app/builder/features/topbar/menu/menu.tsx
index 6c2b7e069b..44e8ced868 100644
--- a/apps/builder/app/builder/features/topbar/menu/menu.tsx
+++ b/apps/builder/app/builder/features/topbar/menu/menu.tsx
@@ -18,7 +18,7 @@ import {
import {
$isCloneDialogOpen,
$isShareDialogOpen,
- $isPublishDialogOpen,
+ $publishDialog,
} from "~/builder/shared/nano-states";
import { cloneProjectUrl, dashboardUrl } from "~/shared/router-utils";
import {
@@ -174,11 +174,32 @@ export const Menu = () => {
>
<DropdownMenuItem
onSelect={() => {
- $isPublishDialogOpen.set(true);
+ $publishDialog.set("publish");
}}
disabled={isPublishEnabled === false}
>
Publish
+ <DropdownMenuItemRightSlot>
+ <Kbd value={["shift", "P"]} />
+ </DropdownMenuItemRightSlot>
+ </DropdownMenuItem>
+ </Tooltip>
+
+ <Tooltip
+ side="right"
+ sideOffset={10}
+ content={disabledPublishTooltipContent}
+ >
+ <DropdownMenuItem
+ onSelect={() => {
+ $publishDialog.set("export");
+ }}
+ disabled={isPublishEnabled === false}
+ >
+ Export
+ <DropdownMenuItemRightSlot>
+ <Kbd value={["shift", "E"]} />
+ </DropdownMenuItemRightSlot>
</DropdownMenuItem>
</Tooltip>
diff --git a/apps/builder/app/builder/features/topbar/publish.tsx b/apps/builder/app/builder/features/topbar/publish.tsx
index 01242c7079..33e0202eef 100644
--- a/apps/builder/app/builder/features/topbar/publish.tsx
+++ b/apps/builder/app/builder/features/topbar/publish.tsx
@@ -35,7 +35,7 @@ import {
RadioGroup,
} from "@webstudio-is/design-system";
import stripIndent from "strip-indent";
-import { $isPublishDialogOpen } from "../../shared/nano-states";
+import { $publishDialog } from "../../shared/nano-states";
import { validateProjectDomain, type Project } from "@webstudio-is/project";
import {
$authTokenPermissions,
@@ -836,12 +836,8 @@ type PublishProps = {
};
export const PublishButton = ({ projectId }: PublishProps) => {
- const isPublishDialogOpen = useStore($isPublishDialogOpen);
+ const publishDialog = useStore($publishDialog);
const authTokenPermissions = useStore($authTokenPermissions);
- const [dialogContentType, setDialogContentType] = useState<
- "publish" | "export"
- >("publish");
-
const isPublishEnabled = authTokenPermissions.canPublish;
const tooltipContent = isPublishEnabled
@@ -849,20 +845,17 @@ export const PublishButton = ({ projectId }: PublishProps) => {
: "Only the owner, an admin, or content editors with publish permissions can publish projects";
const handleExportClick = () => {
- setDialogContentType("export");
+ $publishDialog.set("export");
};
const handleOpenChange = (isOpen: boolean) => {
- if (isOpen === false) {
- setDialogContentType("publish");
- }
- $isPublishDialogOpen.set(isOpen);
+ $publishDialog.set(isOpen ? "publish" : "none");
};
return (
<FloatingPanelPopover
modal
- open={isPublishDialogOpen}
+ open={publishDialog !== "none"}
onOpenChange={handleOpenChange}
>
<FloatingPanelAnchor>
@@ -891,14 +884,14 @@ export const PublishButton = ({ projectId }: PublishProps) => {
marginRight: theme.spacing[3],
}}
>
- {dialogContentType === "export" && (
+ {publishDialog === "export" && (
<>
<FloatingPanelPopoverTitle>Export</FloatingPanelPopoverTitle>
<ExportContent projectId={projectId} />
</>
)}
- {dialogContentType === "publish" && (
+ {publishDialog === "publish" && (
<>
<FloatingPanelPopoverTitle
actions={
diff --git a/apps/builder/app/builder/shared/commands.ts b/apps/builder/app/builder/shared/commands.ts
index e29ac866b8..747bc30a6d 100644
--- a/apps/builder/app/builder/shared/commands.ts
+++ b/apps/builder/app/builder/shared/commands.ts
@@ -30,6 +30,7 @@ import { serverSyncStore } from "~/shared/sync";
import { $publisher } from "~/shared/pubsub";
import {
$activeInspectorPanel,
+ $publishDialog,
setActiveSidebarPanel,
toggleActiveSidebarPanel,
} from "./nano-states";
@@ -291,6 +292,20 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
$breakpointsMenuView.set("initial");
},
},
+ {
+ name: "openPublishDialog",
+ defaultHotkeys: ["shift+P"],
+ handler: () => {
+ $publishDialog.set("publish");
+ },
+ },
+ {
+ name: "openExportDialog",
+ defaultHotkeys: ["shift+E"],
+ handler: () => {
+ $publishDialog.set("export");
+ },
+ },
{
name: "toggleComponentsPanel",
defaultHotkeys: ["a"],
diff --git a/apps/builder/app/builder/shared/nano-states/index.ts b/apps/builder/app/builder/shared/nano-states/index.ts
index b5b13d28ef..b5986de2d3 100644
--- a/apps/builder/app/builder/shared/nano-states/index.ts
+++ b/apps/builder/app/builder/shared/nano-states/index.ts
@@ -8,7 +8,7 @@ import { $settings, getSetting } from "../client-settings";
export const $isShareDialogOpen = atom<boolean>(false);
-export const $isPublishDialogOpen = atom<boolean>(false);
+export const $publishDialog = atom<"none" | "publish" | "export">("none");
export const $canvasWidth = atom<number | undefined>();