Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

ux: remove unneeded options in notebook menu (#7480)

Akshay Agrawala108ae9e7cc0
diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsx
index 748ea3de4f..a5c5d15dda 100644
--- a/frontend/src/components/editor/actions/useNotebookActions.tsx
+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx
@@ -39,7 +39,6 @@ import {
XCircleIcon,
YoutubeIcon,
ZapIcon,
- ZapOffIcon,
} from "lucide-react";
import { settingDialogAtom } from "@/components/app-config/state";
import { MarkdownIcon } from "@/components/editor/cell/code/icons";
@@ -51,10 +50,9 @@ import {
canUndoDeletesAtom,
getNotebook,
hasDisabledCellsAtom,
- hasEnabledCellsAtom,
useCellActions,
} from "@/core/cells/cells";
-import { disabledCellIds, enabledCellIds } from "@/core/cells/utils";
+import { disabledCellIds } from "@/core/cells/utils";
import { useResolvedMarimoConfig } from "@/core/config/config";
import { Constants } from "@/core/constants";
import { useLayoutActions, useLayoutState } from "@/core/layout/layout";
@@ -115,7 +113,6 @@ export function useNotebookActions() {
const { exportAsMarkdown, readCode, saveCellConfig } = useRequestClient();
const hasDisabledCells = useAtomValue(hasDisabledCellsAtom);
- const hasEnabledCells = useAtomValue(hasEnabledCellsAtom);
const canUndoDeletes = useAtomValue(canUndoDeletesAtom);
const { selectedLayout } = useLayoutState();
const { setLayoutView } = useLayoutActions();
@@ -132,36 +129,6 @@ export function useNotebookActions() {
);
const actions: ActionButton[] = [
- {
- icon: <Share2Icon size={14} strokeWidth={1.5} />,
- label: "Share",
- handle: NOOP_HANDLER,
- hidden: !sharingHtmlEnabled && !sharingWasmEnabled,
- dropdown: [
- {
- icon: <GlobeIcon size={14} strokeWidth={1.5} />,
- label: "Publish HTML to web",
- hidden: !sharingHtmlEnabled,
- handle: async () => {
- openModal(<ShareStaticNotebookModal onClose={closeModal} />);
- },
- },
- {
- icon: <LinkIcon size={14} strokeWidth={1.5} />,
- label: "Create WebAssembly link",
- hidden: !sharingWasmEnabled,
- handle: async () => {
- const code = await readCode();
- const url = createShareableLink({ code: code.contents });
- await copyToClipboard(url);
- toast({
- title: "Copied",
- description: "Link copied to clipboard.",
- });
- },
- },
- ],
- },
{
icon: <DownloadIcon size={14} strokeWidth={1.5} />,
label: "Download",
@@ -267,9 +234,40 @@ export function useNotebookActions() {
},
{
- divider: true,
+ icon: <Share2Icon size={14} strokeWidth={1.5} />,
+ label: "Share",
+ handle: NOOP_HANDLER,
+ hidden: !sharingHtmlEnabled && !sharingWasmEnabled,
+ dropdown: [
+ {
+ icon: <GlobeIcon size={14} strokeWidth={1.5} />,
+ label: "Publish HTML to web",
+ hidden: !sharingHtmlEnabled,
+ handle: async () => {
+ openModal(<ShareStaticNotebookModal onClose={closeModal} />);
+ },
+ },
+ {
+ icon: <LinkIcon size={14} strokeWidth={1.5} />,
+ label: "Create WebAssembly link",
+ hidden: !sharingWasmEnabled,
+ handle: async () => {
+ const code = await readCode();
+ const url = createShareableLink({ code: code.contents });
+ await copyToClipboard(url);
+ toast({
+ title: "Copied",
+ description: "Link copied to clipboard.",
+ });
+ },
+ },
+ ],
+ },
+
+ {
icon: <PanelLeftIcon size={14} strokeWidth={1.5} />,
label: "Helper panel",
+ redundant: true,
handle: NOOP_HANDLER,
dropdown: PANELS.flatMap(({ type, Icon, hidden }) => {
if (hidden) {
@@ -324,10 +322,9 @@ export function useNotebookActions() {
}),
],
},
-
{
icon: <Files size={14} strokeWidth={1.5} />,
- label: "Create notebook copy",
+ label: "Duplicate notebook",
hidden: !filename || isWasm(),
handle: copyNotebook,
},
@@ -362,42 +359,9 @@ export function useNotebookActions() {
}
},
},
+
{
- icon: <ZapOffIcon size={14} strokeWidth={1.5} />,
- label: "Disable all cells",
- hidden: !hasEnabledCells || kioskMode,
- handle: async () => {
- const notebook = getNotebook();
- const ids = enabledCellIds(notebook);
- const newConfigs = Objects.fromEntries(
- ids.map((cellId) => [cellId, { disabled: true }]),
- );
- // send to BE
- await saveCellConfig({ configs: newConfigs });
- // update on FE
- for (const cellId of ids) {
- updateCellConfig({ cellId, config: { disabled: true } });
- }
- },
- },
- {
- icon: <EyeOffIcon size={14} strokeWidth={1.5} />,
- label: "Hide all markdown code",
- handle: hideAllMarkdownCode,
- },
- {
- icon: <ChevronRightCircleIcon size={14} strokeWidth={1.5} />,
- label: "Collapse all sections",
- hotkey: "global.collapseAllSections",
- handle: collapseAllCells,
- },
- {
- icon: <ChevronDownCircleIcon size={14} strokeWidth={1.5} />,
- label: "Expand all sections",
- hotkey: "global.expandAllSections",
- handle: expandAllCells,
- },
- {
+ divider: true,
icon: <DiamondPlusIcon size={14} strokeWidth={1.5} />,
label: "Add setup cell",
handle: () => {
@@ -405,36 +369,63 @@ export function useNotebookActions() {
},
},
{
- icon: <XCircleIcon size={14} strokeWidth={1.5} />,
- label: "Clear all outputs",
+ icon: <DatabaseIcon size={14} strokeWidth={1.5} />,
+ label: "Add database connection",
handle: () => {
- clearAllCellOutputs();
+ openModal(<AddDatabaseDialogContent onClose={closeModal} />);
},
},
+ {
+ icon: <Undo2Icon size={14} strokeWidth={1.5} />,
+ label: "Undo cell deletion",
+ hidden: !canUndoDeletes || kioskMode,
+ handle: () => {
+ undoDeleteCell();
+ },
+ },
+ {
+ icon: <PowerSquareIcon size={14} strokeWidth={1.5} />,
+ label: "Restart kernel",
+ variant: "danger",
+ handle: restartKernel,
+ },
{
icon: <FastForwardIcon size={14} strokeWidth={1.5} />,
label: "Re-run all cells",
+ redundant: true,
hotkey: "global.runAll",
handle: async () => {
runAllCells();
},
},
{
- icon: <Undo2Icon size={14} strokeWidth={1.5} />,
- label: "Undo cell deletion",
- hidden: !canUndoDeletes || kioskMode,
+ icon: <XCircleIcon size={14} strokeWidth={1.5} />,
+ label: "Clear all outputs",
+ redundant: true,
handle: () => {
- undoDeleteCell();
+ clearAllCellOutputs();
},
},
{
- icon: <DatabaseIcon size={14} strokeWidth={1.5} />,
- label: "Add database connection",
- handle: () => {
- openModal(<AddDatabaseDialogContent onClose={closeModal} />);
- },
+ icon: <EyeOffIcon size={14} strokeWidth={1.5} />,
+ label: "Hide all markdown code",
+ handle: hideAllMarkdownCode,
+ redundant: true, // hidden by default
+ },
+ {
+ icon: <ChevronRightCircleIcon size={14} strokeWidth={1.5} />,
+ label: "Collapse all sections",
+ hotkey: "global.collapseAllSections",
+ handle: collapseAllCells,
+ redundant: true,
+ },
+ {
+ icon: <ChevronDownCircleIcon size={14} strokeWidth={1.5} />,
+ label: "Expand all sections",
+ hotkey: "global.expandAllSections",
+ handle: expandAllCells,
+ redundant: true,
},
-
{
divider: true,
icon: <CommandIcon size={14} strokeWidth={1.5} />,
@@ -443,27 +434,18 @@ export function useNotebookActions() {
handle: () => setCommandPaletteOpen((open) => !open),
},
- {
- icon: <SettingsIcon size={14} strokeWidth={1.5} />,
- label: "User settings",
- handle: () => setSettingsDialogOpen((open) => !open),
- },
-
{
icon: <KeyboardIcon size={14} strokeWidth={1.5} />,
label: "Keyboard shortcuts",
hotkey: "global.showHelp",
handle: () => setKeyboardShortcutsOpen((open) => !open),
},
-
{
- icon: <BookMarkedIcon size={14} strokeWidth={1.5} />,
- label: "Open documentation",
- handle: () => {
- window.open(Constants.docsPage, "_blank");
- },
+ icon: <SettingsIcon size={14} strokeWidth={1.5} />,
+ label: "User settings",
+ handle: () => setSettingsDialogOpen((open) => !open),
+ redundant: true,
},
-
{
icon: <ExternalLinkIcon size={14} strokeWidth={1.5} />,
label: "Resources",
@@ -531,13 +513,6 @@ export function useNotebookActions() {
window.open(url, "_blank");
},
},
-
- {
- icon: <PowerSquareIcon size={14} strokeWidth={1.5} />,
- label: "Restart kernel",
- variant: "danger",
- handle: restartKernel,
- },
];
return actions
diff --git a/frontend/src/components/editor/controls/notebook-menu-dropdown.tsx b/frontend/src/components/editor/controls/notebook-menu-dropdown.tsx
index fec9d11a62..1c4c129ef1 100644
--- a/frontend/src/components/editor/controls/notebook-menu-dropdown.tsx
+++ b/frontend/src/components/editor/controls/notebook-menu-dropdown.tsx
@@ -113,7 +113,7 @@ export const NotebookMenuDropdown: React.FC<Props> = ({
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="no-print w-[240px]">
{actions.map((action) => {
- if (action.hidden) {
+ if (action.hidden || action.redundant) {
return null;
}